*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --gold: #f59e0b;
  --gold-light: #fbbf24;
  --gold-dark: #d97706;
  --red: #ef4444;
  --green: #10b981;
  --bg: #0b1220;
  --surface: #131c2f;
  --surface-2: #1f2a44;
  --border: #2f3c5c;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #6366f1;
  --primary-light: #818cf8;
  --buy: #16a34a;
  --buy-light: #22c55e;
  --sell: #dc2626;
  --sell-light: #ef4444;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Top bar ── */
.top-bar {
  padding: 0.6rem 1.5rem;
  background: #0a0f1c;
  border-bottom: 1px solid var(--border);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}
.back-link:hover { color: var(--text); }

/* ── Header ── */
.game-header {
  background: linear-gradient(135deg, #131c2f 0%, #0b1220 100%);
  border-bottom: 1px solid var(--border);
  padding: 0.9rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.mystery-ticker {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.mystery-emoji {
  font-size: 2.2rem;
  line-height: 1;
}

.mystery-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gold-light);
}

.mystery-sector {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.stats-strip {
  display: flex;
  gap: 1rem;
  flex: 1;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 90px;
}

.stat-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.stat.highlight .stat-value {
  color: var(--gold-light);
  font-size: 1.15rem;
}

@media (max-width: 768px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  .stats-strip {
    justify-content: flex-start;
    gap: 0.75rem 1.25rem;
  }
  .stat { align-items: flex-start; min-width: 80px; }
}

/* ── Main layout ── */
.game-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2rem;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 900px) {
  .game-main { grid-template-columns: 1fr; }
}

/* ── Chart ── */
.chart-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chart-wrap {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 0.75rem;
  overflow: hidden;
}

#chart {
  display: block;
  width: 100%;
  height: auto;
  max-height: 60vh;
}

.chart-overlay {
  position: absolute;
  inset: 0;
  background: rgba(11, 18, 32, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  z-index: 5;
  transition: opacity 0.3s ease;
}

.chart-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay-card {
  text-align: center;
  max-width: 460px;
  padding: 1.5rem;
}

.overlay-card h2 {
  font-size: 1.8rem;
  font-weight: 800;
  background: linear-gradient(135deg, #f8fafc 0%, var(--gold-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.75rem;
}

.overlay-card p {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 1.25rem;
}

.overlay-card strong { color: var(--gold-light); }

/* ── Controls ── */
.controls {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.control-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.qty-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: 0.2rem;
}

.qty-input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  width: 110px;
  font-variant-numeric: tabular-nums;
}

.qty-input:focus {
  outline: none;
  border-color: var(--primary-light);
}

.ghost-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.5rem 0.9rem;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  transition: all 0.15s;
}

.ghost-btn:hover:not(:disabled) {
  background: var(--surface);
  color: var(--text);
  border-color: var(--primary-light);
}

.ghost-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.action-btn {
  border: none;
  color: white;
  padding: 0.65rem 1.5rem;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 700;
  transition: all 0.15s;
  flex: 1;
  min-width: 110px;
}

.action-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.buy-btn { background: var(--buy); }
.buy-btn:hover:not(:disabled) { background: var(--buy-light); transform: translateY(-1px); }

.sell-btn { background: var(--sell); }
.sell-btn:hover:not(:disabled) { background: var(--sell-light); transform: translateY(-1px); }

.speed-control {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
}

.speed-control label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.speed-control select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.6rem;
  border-radius: 0.4rem;
  font-size: 0.82rem;
  cursor: pointer;
}

/* ── Side panel ── */
.side-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 130px;
}

.side-panel h2 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.log-empty {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
  padding: 1rem 0;
  border: 1px dashed var(--border);
  border-radius: 0.5rem;
}

.trade-log {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 320px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.trade-log li {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  padding: 0.45rem 0.6rem;
  font-size: 0.78rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
  animation: slideIn 0.18s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}

.trade-action { font-weight: 700; }
.trade-action.buy { color: var(--buy-light); }
.trade-action.sell { color: var(--sell-light); }

.trade-meta { color: var(--text-muted); font-size: 0.7rem; }
.trade-price { font-variant-numeric: tabular-nums; font-weight: 600; }

.benchmark-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  padding: 0.75rem 0.85rem;
}

.benchmark-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  padding: 0.25rem 0;
  color: var(--text-muted);
}

.benchmark-row span:last-child {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.benchmark-row.total {
  border-top: 1px solid var(--border);
  margin-top: 0.4rem;
  padding-top: 0.5rem;
  font-weight: 700;
}

.benchmark-row.total span:last-child { color: var(--gold-light); }

/* ── Reveal banner ── */
.reveal-banner {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  z-index: 200;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  padding: 1rem;
}

.reveal-banner.active { display: flex; }

.reveal-card {
  background: var(--surface);
  border: 1px solid var(--gold);
  border-radius: 1.25rem;
  padding: 2rem 1.75rem;
  max-width: 480px;
  width: 100%;
  text-align: center;
  animation: popIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  max-height: 90vh;
  overflow-y: auto;
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}

.reveal-emoji {
  font-size: 3.5rem;
  margin-bottom: 0.5rem;
}

.reveal-ticker {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--gold-light);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.reveal-name {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0.2rem 0 0.4rem;
}

.reveal-sector {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.reveal-desc, .reveal-next {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 0.6rem;
}

.reveal-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin: 1.2rem 0;
  background: rgba(245, 158, 11, 0.08);
  border-radius: 0.625rem;
  padding: 0.75rem 0.5rem;
}

.reveal-stat-label {
  font-size: 0.66rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}

.reveal-stat-value {
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.reveal-verdict {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  padding: 0.6rem;
  border-radius: 0.5rem;
  background: var(--surface-2);
}

.reveal-verdict.win { color: var(--green); border: 1px solid rgba(16, 185, 129, 0.4); }
.reveal-verdict.lose { color: var(--red); border: 1px solid rgba(239, 68, 68, 0.4); }
.reveal-verdict.tie { color: var(--text-muted); border: 1px solid var(--border); }

/* ── Primary button ── */
.primary-btn {
  background: linear-gradient(135deg, var(--gold-dark), var(--gold-light));
  border: none;
  color: #1a1306;
  padding: 0.75rem 2rem;
  border-radius: 0.625rem;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 800;
  transition: all 0.2s;
  width: 100%;
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(245, 158, 11, 0.45);
}

/* ── Float label ── */
.float-label {
  position: fixed;
  font-size: 1rem;
  font-weight: 800;
  pointer-events: none;
  z-index: 150;
  animation: floatUp 0.9s ease forwards;
  padding: 0.25rem 0.6rem;
  border-radius: 0.4rem;
  color: white;
}

.float-label.buy { background: var(--buy); }
.float-label.sell { background: var(--sell); }

@keyframes floatUp {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-70px) scale(1.2); }
}
