:root {
  --ink: #141b2d;
  --paper: #fffaf0;
  --cream: #f2e7cb;
  --gold: #f7b733;
  --red: #ee5148;
  --blue: #50c6db;
  --green: #67c587;
  --muted: #667085;
  --shadow: 0 24px 70px rgba(20, 27, 45, .24);
  --accent: var(--red);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--ink); }
body {
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  background:
    radial-gradient(circle at 14% 10%, rgba(80,198,219,.34), transparent 30%),
    radial-gradient(circle at 86% 85%, rgba(238,81,72,.28), transparent 31%),
    linear-gradient(145deg, #141b2d 0%, #222c46 54%, #172438 100%);
  display: grid;
  place-items: center;
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
.shell { width: min(920px, 100%); }
.card {
  position: relative;
  overflow: hidden;
  min-height: min(760px, calc(100svh - 36px));
  background: var(--paper);
  border: 2px solid rgba(255,255,255,.72);
  border-radius: 28px;
  box-shadow: var(--shadow);
}
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .22;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.75' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.08'/%3E%3C/svg%3E");
}
.screen { position: relative; z-index: 1; min-height: inherit; }
.loading-screen, .fatal {
  padding: clamp(28px, 7vw, 72px);
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
}
.intro {
  padding: clamp(28px, 7vw, 64px);
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  min-height: inherit;
}
.eyebrow, .category, .difficulty, .count, .kicker, .tiny, .deck-summary, .card-mode, .sync-title {
  font-family: "Trebuchet MS", "Gill Sans", sans-serif;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-weight: 800;
}
.eyebrow { color: var(--red); font-size: clamp(.78rem, 2vw, .96rem); margin: 0 0 14px; }
h1 {
  max-width: 720px;
  margin: 0;
  font-size: clamp(3.2rem, 11vw, 7.4rem);
  line-height: .84;
  letter-spacing: -.065em;
  text-wrap: balance;
}
h1 em { display: block; color: var(--red); font-weight: 400; }
.tagline { max-width: 570px; margin: 24px 0 10px; color: #4c5260; font-size: clamp(1.1rem, 2.6vw, 1.4rem); line-height: 1.5; }
.deck-summary { margin: 0 0 28px; color: var(--muted); font-size: .72rem; letter-spacing: .08em; }
.primary, .secondary {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  min-height: 62px;
  padding: 16px 28px;
  font-family: "Trebuchet MS", "Gill Sans", sans-serif;
  font-weight: 900;
  font-size: 1.05rem;
  letter-spacing: .02em;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}
.primary { color: var(--paper); background: var(--ink); box-shadow: 0 9px 0 #080c16; }
.secondary { color: var(--ink); background: var(--gold); box-shadow: 0 9px 0 #bb7412; }
.primary:active, .secondary:active { transform: translateY(6px); box-shadow: 0 3px 0 #080c16; }
.intro-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; }
.tiny { margin: 28px 0 0; color: var(--muted); font-size: .88rem; letter-spacing: .08em; }
.sync-card {
  width: min(600px, 100%);
  margin-top: 28px;
  padding: 16px 18px;
  border: 1px solid #d9d0bc;
  border-radius: 18px;
  background: rgba(242,231,203,.58);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  text-align: left;
}
.sync-title { margin: 0 0 5px; font-size: .7rem; color: var(--ink); }
.sync-status { margin: 0; color: var(--muted); font: 700 .82rem/1.35 "Trebuchet MS", "Gill Sans", sans-serif; }
details.tools { margin-top: 18px; color: var(--muted); font-family: "Trebuchet MS", "Gill Sans", sans-serif; }
details.tools summary { cursor: pointer; font-weight: 800; }
.credit { margin: 18px 0 0; color: var(--muted); font: 700 .7rem/1.4 "Trebuchet MS", "Gill Sans", sans-serif; }
.credit a { color: inherit; }
.tool-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; padding-top: 14px; }
.tool-button, .home-button {
  color: var(--ink);
  background: transparent;
  border: 1px solid #b7b09f;
  border-radius: 999px;
  padding: 10px 14px;
  cursor: pointer;
  font-family: "Trebuchet MS", "Gill Sans", sans-serif;
  font-weight: 800;
}
.game { min-height: inherit; display: grid; grid-template-rows: auto 1fr auto; }
.topbar { padding: clamp(20px, 4vw, 34px) clamp(22px, 5vw, 48px) 0; }
.meter { height: 7px; overflow: hidden; border-radius: 99px; background: var(--cream); }
.meter span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width .35s ease; }
.meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; }
.category { display: inline-flex; align-items: center; gap: 9px; font-size: clamp(.78rem, 2vw, .98rem); }
.category::before { content: ""; width: 13px; height: 13px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 22%, transparent); }
.count { color: var(--muted); font-size: .76rem; white-space: nowrap; }
.scoreboard {
  width: fit-content;
  margin: 14px auto 0;
  padding: 7px 12px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  background: rgba(242,231,203,.72);
  border: 1px solid #d9d0bc;
  border-radius: 999px;
  font: 900 .84rem/1 "Trebuchet MS", "Gill Sans", sans-serif;
  letter-spacing: .04em;
}
.score-title { color: var(--muted); font-size: .64rem; letter-spacing: .11em; text-transform: uppercase; }
.score-token { display: inline-flex; align-items: baseline; gap: 5px; }
.score-token strong { min-width: 1.2ch; font-size: 1.15rem; }
.score-token-y strong { color: #17657a; }
.score-token-d strong { color: #b23a35; }
.score-divider { color: #b7b09f; }
.question-wrap { display: grid; align-content: center; padding: clamp(26px, 6vw, 64px) clamp(24px, 7vw, 72px); }
.question-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.difficulty, .card-mode { width: fit-content; margin: 0 0 22px; color: var(--muted); font-size: .75rem; }
.card-mode { color: #9a4b12; }
.question {
  max-width: 760px;
  margin: 0;
  font-size: clamp(2.15rem, 6.3vw, 5.15rem);
  line-height: 1.03;
  letter-spacing: -.045em;
  text-wrap: balance;
}
.choices {
  margin: 26px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  list-style-position: inside;
}
.choices li { padding: 14px 16px; border: 1px solid #d9d0bc; border-radius: 15px; background: rgba(242,231,203,.48); font-size: clamp(1rem, 2.5vw, 1.2rem); font-weight: 700; }
.answer-panel { margin-top: clamp(26px, 5vw, 46px); padding: 22px 24px; border-left: 8px solid var(--accent); border-radius: 8px 20px 20px 8px; background: var(--cream); animation: answer-in .25s ease both; }
@keyframes answer-in { from { opacity: 0; transform: translateY(8px); } }
.kicker { margin: 0 0 7px; color: var(--muted); font-size: .7rem; }
.answer { margin: 0; font-size: clamp(1.65rem, 4.2vw, 3rem); line-height: 1.08; font-weight: 700; }
.controls { padding: 0 clamp(22px, 5vw, 48px) clamp(24px, 5vw, 42px); display: grid; gap: 15px; }
.controls .primary, .controls .secondary { width: 100%; font-size: clamp(1rem, 2.5vw, 1.2rem); }
.score-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.score-button {
  min-height: 52px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 2px solid transparent;
  border-radius: 16px;
  cursor: pointer;
  color: var(--ink);
  font: 900 .98rem/1 "Trebuchet MS", "Gill Sans", sans-serif;
  transition: transform .15s ease, filter .15s ease, opacity .15s ease;
}
.score-button-y { background: color-mix(in srgb, var(--blue) 42%, var(--paper)); border-color: #42aabe; }
.score-button-d { background: color-mix(in srgb, var(--red) 34%, var(--paper)); border-color: #d94e47; }
.score-button:active:not(:disabled) { transform: scale(.97); }
.score-button:disabled { cursor: default; opacity: .58; filter: grayscale(.35); }
.score-button:disabled strong { display: none; }
.score-button:disabled span::after { content: " ✓"; }
.under-controls { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.home-button { min-height: 44px; padding: 9px 15px; color: var(--ink); background: var(--cream); border-color: #c7bda6; font-size: .86rem; }
.hint { color: var(--muted); font: 700 .76rem/1.3 "Trebuchet MS", "Gill Sans", sans-serif; text-align: right; }
.fatal h2 { margin: 0; font-size: clamp(2.2rem, 7vw, 4rem); letter-spacing: -.04em; }
.fatal p:not(.eyebrow) { max-width: 500px; color: var(--muted); font-size: 1.1rem; line-height: 1.5; }

@media (max-width: 620px) {
  body { padding: 0; background: var(--paper); }
  .card { min-height: 100svh; border: 0; border-radius: 0; box-shadow: none; }
  .intro { padding: 32px 24px; }
  .sync-card { align-items: stretch; flex-direction: column; text-align: center; }
  .question-wrap { align-content: start; padding-top: 42px; }
  .choices { grid-template-columns: 1fr; }
  .score-actions { gap: 9px; }
  .score-button { padding-inline: 10px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; animation: none !important; transition: none !important; } }
