* { box-sizing: border-box; }

:root {
  --bg: #0e0f12;
  --panel: #17191f;
  --panel-2: #1e2129;
  --text: #f5f3ee;
  --muted: #a9adba;
  --line: #2b2f39;
  --accent: #f3a712;
  --accent-2: #ffcf56;
  --good: #61d095;
  --bad: #ff6b6b;
  --shadow: 0 16px 40px rgba(0,0,0,.26);
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgba(243,167,18,.09), transparent 30%),
    linear-gradient(180deg, #101116 0%, #0c0d10 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell {
  width: min(1440px, calc(100% - 24px));
  height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: 72px minmax(0, 1fr);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.main-stage {
  min-height: 0;
  padding-bottom: 12px;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.5rem, 2vw, 2.2rem); }
h2, h3 { margin-bottom: 0; }

.eyebrow {
  color: var(--accent);
  font-size: .68rem;
  letter-spacing: .18em;
  font-weight: 800;
}

.panel {
  background: rgba(23,25,31,.96);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.hidden { display: none !important; }

.start-panel, .end-panel {
  width: min(760px, 100%);
  max-height: calc(100vh - 96px);
  margin: 3vh auto 0;
  padding: clamp(24px, 4vw, 46px);
  text-align: center;
}

.hero-copy h2 {
  font-size: clamp(2rem, 4.6vw, 3.8rem);
  line-height: 1.02;
  margin: 14px 0;
}

.hero-copy p, .end-panel p {
  color: var(--muted);
  max-width: 620px;
  margin: 0 auto;
  line-height: 1.55;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid rgba(243,167,18,.35);
  border-radius: 999px;
  color: var(--accent-2);
  background: rgba(243,167,18,.08);
  font-size: .68rem;
  letter-spacing: .08em;
  font-weight: 800;
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 14px;
  margin: 28px 0 22px;
  text-align: left;
}

label {
  color: var(--muted);
  font-size: .82rem;
  font-weight: 700;
}

input, select {
  width: 100%;
  margin-top: 7px;
  padding: 13px 14px;
  color: var(--text);
  background: #111318;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
}

input:focus, select:focus { border-color: var(--accent); }

.primary-btn, .ghost-btn, .choice-btn {
  border: 0;
  border-radius: 11px;
  font-weight: 800;
}

.primary-btn {
  color: #17120a;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  padding: 12px 18px;
}

.primary-btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.primary-btn.big { padding: 15px 24px; }

.ghost-btn {
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line);
  padding: 10px 14px;
}

.game-screen, .dashboard-grid { height: 100%; min-height: 0; }

.dashboard-grid {
  display: grid;
  grid-template-columns: 330px minmax(0,1fr);
  gap: 14px;
}

.sidebar, .main-column {
  min-height: 0;
  display: grid;
  gap: 12px;
}

.sidebar {
  grid-template-rows: auto auto minmax(0,1fr) auto;
}

.main-column {
  grid-template-rows: auto minmax(0,1fr) auto 132px;
}

.identity-card {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 15px;
}

.identity-card h2 { margin: 3px 0; font-size: 1.18rem; }
.identity-card p { margin: 0; color: var(--muted); font-size: .78rem; }

.shop-icon {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  background: rgba(243,167,18,.12);
  border-radius: 14px;
  font-size: 1.75rem;
}

.price-panel, .stats-panel, .upgrades-panel, .history-panel, .timeline-panel {
  padding: 14px 15px;
}

.section-head, .timeline-panel, .price-scale {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.section-head span, .price-scale, .timeline-panel {
  color: var(--muted);
  font-size: .72rem;
}

.price-panel h3, .stats-panel h3, .upgrades-panel h3, .history-panel h3 {
  font-size: .95rem;
}

#priceDisplay { color: var(--accent-2); font-size: 1.15rem; }

input[type="range"] {
  margin: 10px 0 5px;
  padding: 0;
  accent-color: var(--accent);
}

.stats-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 11px;
}

.stat-row {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  gap: 8px;
}

.stat-label { color: var(--muted); font-size: .76rem; }
.stat-value { font-size: .82rem; font-weight: 800; }

.stat-bar {
  grid-column: 2 / 4;
  height: 6px;
  overflow: hidden;
  background: #0d0f13;
  border-radius: 999px;
}

.stat-bar > div {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: inherit;
  transition: width .65s cubic-bezier(.22,1,.36,1);
}

.progress-track {
  flex: 1;
  height: 8px;
  margin: 0 18px;
  overflow: hidden;
  background: #0d0f13;
  border-radius: 999px;
}

.progress-fill {
  height: 100%;
  width: 8%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .65s cubic-bezier(.22,1,.36,1);
}

.upgrade-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 8px;
  margin-top: 10px;
}

.upgrade-card {
  padding: 9px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 11px;
}

.upgrade-card strong { display: block; margin-bottom: 2px; font-size: .76rem; }
.upgrade-card p { margin-bottom: 7px; color: var(--muted); font-size: .67rem; line-height: 1.3; }
.upgrade-card button {
  width: 100%;
  padding: 7px 6px;
  color: var(--text);
  background: #121419;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: .68rem;
  font-weight: 800;
}
.upgrade-card button:disabled { cursor: not-allowed; opacity: .45; }

.event-card {
  min-height: 0;
  padding: clamp(18px, 2.5vw, 30px);
  text-align: center;
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0,1fr);
  align-content: center;
}

.event-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: .75rem;
}

.event-emoji {
  width: 72px;
  height: 72px;
  margin: 12px auto 12px;
  display: grid;
  place-items: center;
  background: rgba(243,167,18,.1);
  border: 1px solid rgba(243,167,18,.22);
  border-radius: 21px;
  font-size: 2.8rem;
}

.event-card h2 {
  font-size: clamp(1.45rem, 2.6vw, 2.2rem);
  margin-bottom: 8px;
}

.event-card > p {
  max-width: 650px;
  margin: 0 auto 14px;
  color: var(--muted);
  line-height: 1.45;
  font-size: .92rem;
}

.choices {
  width: min(760px, 100%);
  display: grid;
  gap: 8px;
  align-self: center;
  margin: 0 auto;
}

.choice-btn {
  padding: 12px 14px;
  color: var(--text);
  text-align: left;
  background: var(--panel-2);
  border: 1px solid var(--line);
  transition: .18s ease;
  font-size: .88rem;
}

.choice-btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.choice-btn small {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 3px;
  color: var(--muted);
  font-size: .7rem;
  font-weight: 500;
}

.choice-cost {
  color: var(--accent-2);
  font-weight: 800;
  white-space: nowrap;
}

.result-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
}

.result-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: #0c2217;
  background: var(--good);
  border-radius: 50%;
  font-weight: 900;
}

.result-card h3 { margin-bottom: 3px; font-size: .95rem; }
.result-card p { margin-bottom: 0; color: var(--muted); font-size: .8rem; }

.effect-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
}

.effect-chip {
  padding: 5px 8px;
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 800;
}
.effect-chip.positive { color: var(--good); background: rgba(97,208,149,.1); }
.effect-chip.negative { color: var(--bad); background: rgba(255,107,107,.1); }

.history-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 8px;
  margin-top: 9px;
}

.history-entry {
  min-width: 0;
  padding: 9px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.history-entry strong {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: .72rem;
}

.history-entry span { color: var(--muted); font-size: .65rem; }

.text-btn {
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 0;
  font-size: .7rem;
}

.final-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 10px;
  margin: 24px 0;
}

.final-stat {
  padding: 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.final-stat strong { display: block; font-size: 1.18rem; }
.final-stat span { color: var(--muted); font-size: .72rem; }

.ending-icon {
  width: 84px;
  height: 84px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  background: rgba(243,167,18,.1);
  border-radius: 24px;
  font-size: 3.5rem;
}

@media (max-width: 980px) {
  html, body { overflow: auto; }
  .app-shell { height: auto; min-height: 100vh; display: block; }
  .main-stage { padding-bottom: 16px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .sidebar { grid-template-columns: repeat(2, minmax(0,1fr)); grid-template-rows: auto; }
  .stats-panel, .upgrades-panel { grid-column: 1 / -1; }
  .main-column { grid-template-rows: auto; }
}

@media (max-width: 620px) {
  .app-shell { width: min(100% - 16px, 1440px); }
  .topbar { height: 64px; }
  .setup-grid, .sidebar, .final-stats { grid-template-columns: 1fr; }
  .stats-panel, .upgrades-panel { grid-column: auto; }
  .upgrade-list { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .history-list { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .event-meta { gap: 8px; flex-direction: column; }
  .result-card { grid-template-columns: 1fr; text-align: center; }
  .result-icon { margin: 0 auto; }
}
