:root {
  color-scheme: dark;
  --bg: #0f1117;
  --panel: #171b24;
  --border: #2a3142;
  --text: #f3f5f9;
  --muted: #9aa3b2;
  --accent: #1b9cfc;
  --accent-hover: #0d8ae6;
  --danger: #ef4444;
  --success: #22c55e;
  --radius: 12px;
  font-family: Segoe UI, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, #102536 0%, var(--bg) 45%);
  color: var(--text);
}

#app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}

.hidden {
  display: none !important;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

h1,
h2 {
  margin: 0 0 8px;
}

.subtitle,
.muted {
  color: var(--muted);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.add-form {
  flex-direction: row;
}

input {
  flex: 1;
  background: #0d1018;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 12px 14px;
  font-size: 15px;
}

button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

button:hover {
  background: var(--accent-hover);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

button.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

button.secondary:hover {
  border-color: var(--accent);
}

button.danger {
  background: transparent;
  border: 1px solid var(--danger);
  color: #fecaca;
}

.games-list {
  display: grid;
  gap: 12px;
}

.game-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #11151d;
}

.game-card img {
  width: 120px;
  height: 56px;
  object-fit: cover;
  border-radius: 6px;
  background: #0d1018;
}

.game-meta {
  flex: 1;
  min-width: 0;
}

.game-meta h3 {
  margin: 0 0 4px;
  font-size: 18px;
}

.game-meta p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.game-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.lookup-result {
  margin-top: 16px;
  padding: 16px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.lookup-result img {
  width: 120px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
}

.results-list {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.result-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0d1018;
  cursor: pointer;
  color: inherit;
  text-align: left;
  width: 100%;
}

.result-option img {
  width: 84px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
}

.error {
  color: #fecaca;
  margin-top: 12px;
}

.status {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #11151d;
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.status.success {
  border-color: var(--success);
}

.status.error {
  border-color: var(--danger);
}

.game-title-btn {
  background: none;
  border: none;
  color: var(--text);
  padding: 0;
  font-size: 18px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.game-title-btn:hover {
  color: var(--accent);
  background: none;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-header {
  margin-bottom: 16px;
}

.detail-title-row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.detail-title-row img,
.detail-art-fallback {
  width: 184px;
  height: 86px;
  object-fit: cover;
  border-radius: 8px;
  background: #0d1018;
  flex-shrink: 0;
}

.detail-title-row a {
  color: var(--accent);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.stat {
  background: #11151d;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.stat strong {
  font-size: 20px;
}

.range-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.range-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.range-btn.active {
  border-color: var(--accent);
  color: var(--accent);
}

.chart-wrap {
  position: relative;
  height: 280px;
  background: #11151d;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.price-summary {
  margin-bottom: 10px;
  font-size: 14px;
}

.detail-links code {
  display: inline-block;
  margin: 2px 0;
  font-size: 13px;
}

.ok {
  color: #86efac;
}

.warn {
  color: #fcd34d;
}

@media (max-width: 640px) {
  .topbar,
  .add-form,
  .game-card,
  .detail-title-row,
  .panel-header,
  .range-row {
    flex-direction: column;
    align-items: stretch;
  }

  .game-actions,
  .detail-actions {
    justify-content: flex-end;
  }

  .detail-title-row img,
  .detail-art-fallback {
    width: 100%;
    height: auto;
    aspect-ratio: 460 / 215;
  }

  .chart-wrap {
    height: 220px;
  }
}
