:root {
  color-scheme: dark light;
  --bg: #efe4d4;
  --bg-deep: #12181e;
  --paper: rgba(255, 248, 238, 0.9);
  --paper-strong: rgba(255, 251, 245, 0.97);
  --ink: #17232d;
  --muted: #586873;
  --line: rgba(23, 35, 45, 0.12);
  --shadow: 0 24px 60px rgba(23, 35, 45, 0.14);
  --trust: #2f9d7e;
  --budget: #d38b1d;
  --pressure: #d2594d;
  --accent: #274c77;
  --accent-soft: #cad7e6;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #10161d;
    --paper: rgba(24, 31, 40, 0.88);
    --paper-strong: rgba(26, 34, 44, 0.98);
    --ink: #eff5fb;
    --muted: #a6b3bf;
    --line: rgba(239, 245, 251, 0.12);
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
    --accent-soft: rgba(85, 115, 150, 0.35);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  font-family: "Quicksand", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(211, 139, 29, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(39, 76, 119, 0.18), transparent 32%),
    linear-gradient(180deg, var(--bg) 0%, color-mix(in srgb, var(--bg) 88%, black 12%) 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.28;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(circle at center, black 35%, transparent 82%);
}

.app-shell {
  width: min(1180px, calc(100vw - 24px));
  height: 100svh;
  max-height: 100svh;
  margin: 0 auto;
  padding: clamp(10px, 2.2vh, 24px) 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: clamp(10px, 1.6vh, 18px);
}

.hero,
.meters-panel,
.stack-panel,
.controls-card,
.top-card,
.back-card,
.overlay-panel {
  backdrop-filter: blur(14px);
}

.hero,
.meters-panel,
.stack-panel,
.controls-card {
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  background: var(--paper);
}

.hero {
  padding: 22px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
}

.hero-copy {
  max-width: 620px;
}

.eyebrow,
.meter-topline span,
.meta-pill span,
.option-key,
.legend-row span,
.notes-list,
.option-effect,
.overlay-caption {
  font-family: "Baloo 2", "Quicksand", sans-serif;
  letter-spacing: 0.04em;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1,
h2 {
  font-family: "Baloo 2", "Quicksand", sans-serif;
  line-height: 0.95;
}

h1 {
  font-size: clamp(2.4rem, 5vw, 4.6rem);
}

h2 {
  font-size: clamp(1.4rem, 2vw, 2rem);
}

.hero-text {
  margin-top: 12px;
  font-size: clamp(1rem, 1vw + 0.8rem, 1.2rem);
  color: var(--muted);
  line-height: 1.45;
}

.hero-text span {
  display: inline-grid;
  place-items: center;
  min-width: 1.7rem;
  padding: 0.18rem 0.42rem;
  margin: 0 0.1rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.hero-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(110px, 1fr));
  gap: 10px;
  width: min(100%, 390px);
}

.meta-pill {
  padding: 12px 14px;
  border-radius: 18px;
  background: var(--paper-strong);
  border: 1px solid var(--line);
}

.meta-pill span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
}

.meta-pill strong {
  display: block;
  margin-top: 5px;
  font-size: 1.25rem;
}

.status-pill strong[data-state="paused"] {
  color: var(--accent);
}

.status-pill strong[data-state="won"] {
  color: var(--trust);
}

.status-pill strong[data-state="lost"] {
  color: var(--pressure);
}

.meters-panel {
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.meter-card {
  padding: 10px 12px;
  border-radius: 20px;
  background: var(--paper-strong);
  border: 1px solid var(--line);
}

.meter-topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.meter-topline span {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
}

.meter-topline strong {
  font-size: 1.25rem;
}

.meter-track {
  height: 10px;
  margin-top: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(127, 143, 156, 0.22);
}

.meter-fill {
  height: 100%;
  width: 50%;
  border-radius: inherit;
  transition: width 180ms ease;
}

.meter-trust .meter-fill {
  background: linear-gradient(90deg, var(--trust), #9ce5d1);
}

.meter-budget .meter-fill {
  background: linear-gradient(90deg, var(--budget), #efc67d);
}

.meter-pressure .meter-fill {
  background: linear-gradient(90deg, #f2b4ad, var(--pressure));
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(290px, 0.8fr);
  gap: 18px;
  align-items: stretch;
  min-height: 0;
}

.stack-panel {
  position: relative;
  min-height: 0;
  padding: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.stack-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 14px;
  margin-bottom: 10px;
}

.round-message {
  max-width: 290px;
  font-size: 0.95rem;
  line-height: 1.4;
  color: var(--muted);
  text-align: right;
}

.deck-stage {
  position: relative;
  min-height: 0;
  flex: 1;
  padding: 14px;
  border-radius: 28px;
  background:
    linear-gradient(145deg, rgba(39, 76, 119, 0.1), transparent 45%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0.08));
  border: 1px solid var(--line);
  overflow: hidden;
}

.backing-stack {
  position: absolute;
  inset: 22px;
}

.back-card,
.top-card {
  position: absolute;
  inset: 0;
  border-radius: 28px;
  border: 1px solid var(--line);
  background: var(--paper-strong);
}

.back-card {
  background:
    linear-gradient(145deg, rgba(39, 76, 119, 0.14), rgba(255, 255, 255, 0.6)),
    var(--paper-strong);
  box-shadow: 0 18px 40px rgba(23, 35, 45, 0.12);
}

.back-card::after {
  content: "";
  position: absolute;
  inset: 16px;
  border-radius: 20px;
  border: 2px dashed rgba(39, 76, 119, 0.2);
}

.top-card {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 12px;
  padding: 20px;
  box-shadow: 0 24px 60px rgba(23, 35, 45, 0.18);
  z-index: 5;
  transition: transform 420ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 320ms ease, filter 320ms ease;
}

.top-card.is-transitioning {
  transform: translateY(-22px) rotate(-3.5deg) scale(0.98);
  opacity: 0;
  filter: blur(1px);
}

.top-card.is-paused {
  filter: grayscale(0.18);
}

.top-card-topline {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.card-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
}

.card-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.36rem 0.7rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.card-body {
  font-size: clamp(1rem, 1vw + 0.85rem, 1.45rem);
  line-height: 1.45;
  color: var(--muted);
  max-width: 44ch;
}

.options-list {
  display: grid;
  gap: 12px;
  align-content: start;
}

.option-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  padding: 14px 16px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(127, 143, 156, 0.08);
}

.option-key {
  width: 2.35rem;
  height: 2.35rem;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
}

.option-copy strong {
  display: block;
  font-size: 1.02rem;
}

.option-effect {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.top-card-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.footer-hint strong {
  color: var(--accent);
}

.controls-card {
  padding: 14px;
}

.control-panel {
  display: grid;
  gap: 14px;
  min-height: 0;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.legend-grid,
.mobile-actions {
  display: grid;
  gap: 10px;
}

.legend-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 0.8rem 0.95rem;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--paper-strong);
}

.legend-row strong {
  font-size: 0.95rem;
}

.mobile-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mobile-button {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 0.95rem 0.6rem;
  background: linear-gradient(180deg, var(--paper-strong), rgba(127, 143, 156, 0.12));
  color: var(--ink);
  font: inherit;
  text-align: left;
  display: grid;
  gap: 4px;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.mobile-button:hover:not(:disabled),
.mobile-button:focus-visible:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(39, 76, 119, 0.45);
}

.mobile-button:disabled {
  opacity: 0.48;
  cursor: default;
}

.mobile-button span {
  font-size: 0.78rem;
  color: var(--muted);
}

.mobile-button strong {
  font-size: 1rem;
}

.notes-list {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--muted);
  line-height: 1.45;
}

.control-panel .controls-card:last-child {
  min-height: 0;
  overflow: hidden;
}

.overlay-panel {
  position: absolute;
  inset: 18px;
  z-index: 20;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 28px;
  border-radius: 28px;
  border: 1px solid var(--line);
  background: rgba(17, 24, 31, 0.76);
  color: #f5f7fb;
}

.overlay-panel.hidden {
  display: none;
}

.overlay-card {
  max-width: 420px;
}

.overlay-card h3 {
  margin: 0;
  font-family: "Baloo 2", "Quicksand", sans-serif;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 0.95;
}

.overlay-caption {
  margin-top: 8px;
  text-transform: uppercase;
  color: rgba(245, 247, 251, 0.76);
  font-size: 0.82rem;
}

.overlay-card p {
  margin-top: 14px;
  font-size: 1rem;
  line-height: 1.5;
  color: rgba(245, 247, 251, 0.9);
}

.overlay-meters {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.overlay-meters span {
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.overlay-button {
  margin-top: 18px;
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 0.9rem 1.3rem;
  background: #f0c36d;
  color: #131920;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

@media (max-width: 900px) {
  .hero {
    flex-direction: column;
    align-items: stretch;
  }

  .hero-meta {
    width: 100%;
  }

  .game-layout {
    grid-template-columns: 1fr;
  }

  .round-message {
    text-align: left;
    max-width: none;
  }

  .deck-stage {
    min-height: 560px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100vw - 14px, 100%);
    padding-top: 14px;
  }

  .hero,
  .meters-panel,
  .stack-panel,
  .controls-card {
    border-radius: 22px;
  }

  .hero-meta,
  .meters-panel {
    grid-template-columns: 1fr;
  }

  .stack-header {
    flex-direction: column;
    align-items: start;
  }

  .deck-stage {
    min-height: 600px;
    padding: 12px;
  }

  .backing-stack {
    inset: 20px;
  }

  .top-card {
    padding: 20px;
  }

  .mobile-actions {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 901px) {
  .hero {
    padding: 14px 18px;
  }

  h1 {
    font-size: clamp(2.6rem, 4vw, 3.8rem);
  }

  .hero-text {
    margin-top: 6px;
    font-size: 1rem;
    line-height: 1.3;
  }

  .hero-meta {
    gap: 8px;
  }

  .meta-pill {
    padding: 9px 11px;
  }

  .meters-panel {
    padding: 8px;
    gap: 8px;
  }

  .meter-card {
    padding: 8px 10px;
  }

  .meter-track {
    height: 8px;
    margin-top: 6px;
  }

  .game-layout {
    gap: 12px;
  }

  .stack-panel {
    padding: 12px;
  }

  .stack-header {
    margin-bottom: 6px;
  }

  .deck-stage {
    padding: 10px;
    border-radius: 24px;
  }

  .backing-stack {
    inset: 16px;
  }

  .top-card {
    gap: 8px;
    padding: 16px;
    border-radius: 24px;
  }

  .card-body {
    font-size: 1.08rem;
    line-height: 1.3;
  }

  .options-list {
    gap: 7px;
  }

  .option-card {
    gap: 10px;
    padding: 9px 11px;
    border-radius: 16px;
  }

  .option-key {
    width: 2rem;
    height: 2rem;
    border-radius: 12px;
  }

  .option-copy strong {
    font-size: 0.95rem;
  }

  .option-effect {
    margin-top: 2px;
    font-size: 0.74rem;
  }

  .controls-card {
    padding: 10px;
  }

  .control-panel {
    gap: 10px;
  }

  .legend-grid,
  .mobile-actions {
    gap: 6px;
  }

  .legend-row {
    padding: 0.55rem 0.7rem;
    border-radius: 14px;
  }

  .mobile-button {
    padding: 0.65rem 0.5rem;
    border-radius: 14px;
  }

  .control-panel .controls-card:last-child {
    display: none;
  }
}
