:root {
  --navy: #132A52;
  --navy-2: #1d3a6b;
  --gold: #A8741A;
  --gold-l: #E0B45A;
  --cream: #F5EFE2;
  --paper: #FBF8F1;
  --ink: #1d1d1d;
  --muted: #5a5f6b;
  --line: #e2d9c4;
  --good: #2E7D32;
  --bad: #B23B3B;
  --radius: 14px;
  --serif: Garamond, "EB Garamond", "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: env(safe-area-inset-bottom);
}
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }

/* top bar */
.bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--navy); color: #fff;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
}
.bar-home { display: flex; align-items: center; gap: 10px; background: none; border: 0; color: #fff; padding: 4px 0; }
.bar-home img { border-radius: 50%; }
.bar-home span { font-family: var(--serif); font-size: 22px; }
.bar-home i { color: var(--gold-l); }
.bar-btn { width: 38px; height: 38px; border-radius: 50%; border: 2px solid rgba(255,255,255,.7); background: none; color: #fff; font-weight: 700; font-size: 18px; }

main { max-width: 1200px; margin: 0 auto; }
.screen { padding: 16px; }
.screen.text { max-width: 720px; margin: 0 auto; }
h1 { font-family: var(--serif); font-weight: 500; color: var(--navy); font-size: 30px; margin: 8px 0 8px; }
h2 { font-family: var(--serif); color: var(--navy); font-size: 22px; margin: 22px 0 6px; }
.lead { color: var(--muted); margin-top: 0; }
.small { font-size: 13.5px; color: var(--muted); }
.center { text-align: center; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 18px;
  border-radius: 999px; border: 2px solid var(--navy);
  background: #fff; color: var(--navy); font-weight: 600;
}
.btn:active { transform: translateY(1px); }
.btn.big { min-height: 56px; font-size: 18px; background: var(--navy); color: #fff; }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn.ghost { border-style: dashed; }
.btn.good { background: var(--good); border-color: var(--good); color: #fff; }
.btn.bad { background: #fff; border-color: var(--bad); color: var(--bad); }
.btn:disabled { opacity: .45; cursor: default; }
.btn:focus-visible, .bar-btn:focus-visible, .bar-home:focus-visible { outline: 3px solid var(--gold-l); outline-offset: 2px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 14px; }

/* home */
.hero {
  background: var(--navy); border-radius: var(--radius);
  padding: 34px 20px 26px; text-align: center; margin-bottom: 18px;
}
.hero-logo { width: min(520px, 100%); height: auto; }
.hero-tag { color: #E9E2D0; font-family: var(--serif); font-style: italic; font-size: 19px; margin: 14px 0 0; }
.menu { display: grid; gap: 12px; max-width: 420px; margin: 0 auto; }
.menu .btn { width: 100%; }
.facts { text-align: center; color: var(--muted); font-size: 14px; margin-top: 20px; }

/* setup */
.players { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.player-row {
  display: grid; grid-template-columns: 34px 1fr auto auto; gap: 8px; align-items: center;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px;
}
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px #0003; }
.player-row input {
  width: 100%; min-width: 0; font: inherit; padding: 10px; border: 1px solid #cfc5ad; border-radius: 10px;
}
.seg { display: inline-flex; border: 2px solid var(--navy); border-radius: 999px; overflow: hidden; }
.seg button { border: 0; background: #fff; color: var(--navy); padding: 8px 10px; font-size: 14px; font-weight: 600; min-height: 40px; }
.seg button[aria-pressed="true"] { background: var(--navy); color: #fff; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid #cfc5ad; background: #fff; color: var(--bad); font-size: 20px; line-height: 1; }
.err { color: var(--bad); min-height: 1.4em; }

/* game */
.game { display: grid; gap: 14px; }
.board-wrap { background: #fff; border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; }
#board { display: block; width: 100%; height: auto; }
.side { display: grid; gap: 12px; align-content: start; }
.scores { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.score {
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px;
  display: grid; grid-template-columns: 14px 1fr; gap: 2px 8px; align-items: center; font-size: 14px;
}
.score.now { border: 2px solid var(--gold); box-shadow: 0 2px 10px #a8741a33; }
.score .dot { width: 14px; height: 14px; border-radius: 50%; }
.score b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score .meta { grid-column: 2; color: var(--muted); font-size: 13px; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.panel h2 { margin: 0 0 6px; }
.who { display: flex; align-items: center; gap: 10px; }
.who .dot { width: 22px; height: 22px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px #0003; }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.choice .btn { min-height: 92px; flex-direction: column; border-radius: 18px; font-size: 20px; }
.choice .btn small { font-weight: 400; font-size: 13px; opacity: .85; }
.btn.stretch { background: var(--navy); color: #fff; }
.btn.settle { background: var(--cream); border-color: #cdbd97; color: var(--ink); }
.note { background: var(--cream); border-left: 4px solid var(--gold); padding: 8px 12px; border-radius: 8px; margin: 10px 0 0; font-size: 15px; }
.log { color: var(--muted); font-size: 14px; margin: 0; min-height: 1.4em; }

/* die */
.die { width: 84px; height: 84px; margin: 6px auto 0; display: block; }
.die.rolling { animation: wobble .12s linear infinite; }
@keyframes wobble { 0% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } 100% { transform: rotate(-8deg); } }

/* challenge card */
.ccard { border-radius: 18px; overflow: hidden; border: 1px solid var(--line); margin-top: 10px; background: #fff; }
.ccard-head { color: #fff; padding: 12px 14px; display: flex; align-items: center; gap: 12px; }
.ccard-head .die-s { width: 44px; height: 44px; flex: none; }
.ccard-cat { font-family: var(--serif); font-size: 26px; line-height: 1; }
.ccard-task { font-size: 14px; font-style: italic; opacity: .95; }
.ccard-body { padding: 14px; }
.ccard-text { font-family: var(--serif); font-size: 24px; line-height: 1.25; margin: 4px 0 10px; }
.level-toggle { font-size: 13px; }
.timer { height: 10px; background: #eee; border-radius: 99px; overflow: hidden; margin: 10px 0 4px; }
.timer > div { height: 100%; width: 100%; background: var(--gold); transition: width .25s linear; }
.timer-label { font-variant-numeric: tabular-nums; font-size: 14px; color: var(--muted); }
.results { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.results .btn { min-height: 64px; flex-direction: column; border-radius: 14px; padding: 6px; font-size: 16px; }
.results .btn small { font-weight: 400; font-size: 12px; }

/* stretch or settle 2.0: big stretch, life squares, hot timer */
.choice.three { grid-template-columns: 1fr 1fr 1fr; }
.choice.three .btn { font-size: 18px; min-height: 96px; padding: 8px; }
.btn.bigstretch { background: linear-gradient(135deg, #B23B3B, #E06A2C); border-color: #B23B3B; color: #fff; }
.bigtag { color: #B23B3B; letter-spacing: 1px; }
.bigbanner { background: linear-gradient(135deg, #B23B3B, #E06A2C); color: #fff; font-weight: 700; border-radius: 12px; padding: 8px 12px; margin: 8px 0; animation: pulse 1s ease-in-out infinite; }
.ccard.big { box-shadow: 0 0 0 3px #E06A2C; }
.note.ahead { font-size: 14px; }
.note.ahead .gold { color: #7A5210; font-weight: 700; }
.note.ahead .red { color: #B23B3B; font-weight: 700; }
.gold-text { color: #8A5E0E; }
.red-text { color: #B23B3B; }
.timerbox.hot .timer > div { background: #D7263D; }
.timerbox.hot .timer-label { color: #D7263D; font-weight: 700; animation: pulse .5s ease-in-out infinite; }
.small-btn { min-height: 40px; padding: 6px 12px; font-size: 14px; }
.life { border-radius: 18px; padding: 22px 18px; text-align: center; }
.life.gold { background: radial-gradient(circle at 50% 0%, #FFF3C4, #F6D77B); border: 3px solid #B07A12; }
.life.red { background: radial-gradient(circle at 50% 0%, #FFE1DD, #F2B4AE); border: 3px solid #B23B3B; }
.life.hit { animation: shake .5s ease-in-out 1, glow 1.6s ease-in-out infinite; }
.life-kicker { font-weight: 800; letter-spacing: 2px; font-size: 14px; color: #5a3b06; }
.life.red .life-kicker { color: #7A1F1F; }
.life-label { font-family: var(--serif); font-size: 40px; line-height: 1.05; color: var(--navy); margin: 6px 0; }
.life-title { font-style: italic; color: #4a3b2a; }
.life-text { font-size: 18px; margin: 12px 0 16px; }
.shake { animation: shake .6s ease-in-out 1; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-10px) rotate(-1deg); } 40% { transform: translateX(10px) rotate(1deg); } 60% { transform: translateX(-6px); } 80% { transform: translateX(6px); } }
@keyframes glow { 0%, 100% { box-shadow: 0 0 0 0 rgba(0,0,0,0); } 50% { box-shadow: 0 0 22px 2px rgba(224,180,90,.65); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
@media (max-width: 420px) { .choice.three .btn { font-size: 16px; min-height: 90px; } .choice.three .btn small { font-size: 11.5px; } .life-label { font-size: 32px; } }
@media (prefers-reduced-motion: reduce) { .life.hit, .shake, .bigbanner, .timerbox.hot .timer-label { animation: none; } }

/* storm + end tables */
table.t { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 15px; }
table.t th, table.t td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
table.t td.n, table.t th.n { text-align: right; font-variant-numeric: tabular-nums; }
.storm-head { background: #3f4b5e; color: #fff; border-radius: 12px; padding: 14px; display: flex; gap: 12px; align-items: center; }
.storm-head svg { width: 56px; height: 56px; flex: none; }
.win-head { background: var(--navy); color: #fff; border-radius: var(--radius); padding: 22px; text-align: center; }
.win-head h1 { color: #fff; margin: 4px 0; }
.win-head p { color: #E9E2D0; margin: 4px 0; }
.questions { padding-left: 20px; }
.questions li { margin-bottom: 8px; }

/* custom cards */
.card-form { display: grid; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card-form label { display: grid; gap: 4px; font-weight: 600; font-size: 14px; color: var(--navy); }
.card-form select, .card-form textarea { font: inherit; font-weight: 400; color: var(--ink); padding: 10px; border: 1px solid #cfc5ad; border-radius: 10px; background: #fff; }
.custom-list { list-style: none; padding: 0; display: grid; gap: 8px; }
.custom-list li { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; grid-template-columns: 1fr auto; gap: 6px; font-size: 14px; }
.custom-list .tag { display: inline-block; color: #fff; border-radius: 99px; padding: 1px 8px; font-size: 12px; font-weight: 600; margin-right: 6px; }

/* shop */
.shop { display: grid; gap: 12px; }
.shop-item { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.shop-item h2 { margin: 0 0 2px; }
.shop-item .line { color: var(--gold); font-style: italic; font-family: var(--serif); font-size: 17px; margin: 0 0 6px; }
.shop-item p { margin: 0 0 10px; }
.shop-item .soon { display: inline-block; background: var(--cream); color: #7A5210; border-radius: 99px; padding: 2px 10px; font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.shop-item .row, .shop-contact .row { margin-top: 6px; }
.shop-contact { background: var(--navy); color: #fff; border-radius: var(--radius); padding: 16px; margin: 16px 0; }
.shop-contact h2 { color: #fff; margin: 0 0 4px; }
.shop-contact p { color: #E9E2D0; margin: 0 0 8px; }
.shop-contact .btn { background: #fff; }
a.btn { text-decoration: none; }
.cta { background: var(--cream); border-radius: var(--radius); padding: 14px 16px; margin: 16px 0; text-align: center; }
.cta p { margin: 0 0 10px; font-family: var(--serif); font-size: 19px; color: var(--navy); }

/* card packs */
.code-form { background: var(--navy); color: #fff; border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
.code-form label { font-weight: 700; display: block; }
.code-form input { flex: 1; min-width: 0; font: inherit; font-family: ui-monospace, Consolas, monospace; letter-spacing: 1px; text-transform: uppercase;
  padding: 12px; border-radius: 10px; border: 0; }
.code-form .row { flex-wrap: nowrap; }
.code-msg { min-height: 1.3em; margin: 8px 0 0; font-weight: 600; }
.code-msg.ok { color: #9BE59B; }
.code-msg.bad { color: #FFB4AE; }
.shop-item .have { display: inline-block; vertical-align: middle; background: #2E7D32; color: #fff; font-family: var(--sans); font-size: 12px; border-radius: 99px; padding: 2px 10px; margin-left: 6px; }
.shop-item .price { font-family: var(--serif); font-size: 26px; color: var(--navy); margin: 0 0 6px; }
.shop-item.all { border: 2px solid var(--gold); }
.switch { display: flex; gap: 10px; align-items: center; font-weight: 600; }
.switch input { width: 22px; height: 22px; accent-color: var(--navy); }

/* modal */
.modal { position: fixed; inset: 0; background: #0008; z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal-box { background: #fff; border-radius: var(--radius); padding: 18px; width: min(460px, 100%); max-height: 90vh; overflow: auto; }
.modal-box h2 { margin-top: 0; }
.pick { display: grid; gap: 8px; margin: 10px 0; }

@media (min-width: 900px) {
  .game { grid-template-columns: minmax(0, 1.6fr) minmax(320px, 1fr); align-items: start; }
  .screen { padding: 22px; }
}
@media (max-width: 899px) {
  .side .panel { order: 1; }
  .side .log { order: 2; }
  .side .scores { order: 3; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .score { font-size: 13px; padding: 6px 8px; }
  .score .meta { font-size: 12px; }
}
@media (max-width: 420px) {
  .player-row { grid-template-columns: 30px 1fr auto; }
  .player-row .seg { grid-column: 2 / span 2; justify-self: start; }
  .player-row .icon-btn { grid-row: 1; grid-column: 3; }
  .choice .btn { min-height: 84px; }
  .ccard-text { font-size: 21px; }
}
@media (prefers-reduced-motion: reduce) {
  .die.rolling { animation: none; }
  .timer > div { transition: none; }
}
