/* Fourth & Dice — a board game on a walnut table. */
:root {
  --wood: #4a2e1c;
  --wood-dk: #2b190e;
  --wood-lt: #6b4529;
  --card: #f7f1e3;
  --card-edge: #e6dcc4;
  --ink: #1d1b18;
  --ink-soft: #5b544a;
  --turf: #2f7d3b;
  --turf2: #2a7135;
  --chalk: rgba(255, 255, 255, .78);
  --ltg: #ffd21f;
  --led: #ffb627;
  --stamp-stop: #b3121b;
  --stamp-open: #17803a;
  --run: #1d1b18;
  --pass: #f7f1e3;
  --display: "Avenir Next Condensed", "Roboto Condensed", "Arial Narrow", "Nimbus Sans Narrow", "Helvetica Neue", "DejaVu Sans Condensed", sans-serif-condensed, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, "Liberation Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", "Roboto Mono", "DejaVu Sans Mono", monospace;
  --spd: 1;
  --r: 10px;
  --shadow: 0 2px 0 rgba(0,0,0,.25), 0 8px 18px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--body);
  color: var(--card);
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(255,210,150,.10), transparent 60%),
    radial-gradient(140% 120% at 50% 120%, rgba(0,0,0,.55), transparent 60%),
    repeating-linear-gradient(92deg, rgba(0,0,0,.07) 0 2px, transparent 2px 9px, rgba(255,255,255,.025) 9px 10px, transparent 10px 23px),
    repeating-linear-gradient(88deg, transparent 0 41px, rgba(0,0,0,.08) 41px 43px, transparent 43px 97px),
    linear-gradient(180deg, var(--wood-lt), var(--wood) 40%, var(--wood-dk));
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--ltg); outline-offset: 2px; }
.hidden { display: none !important; }
#app { min-height: 100%; }
.screen { min-height: 100dvh; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  border: 2px solid var(--ink); border-radius: 999px; padding: .7em 1.2em;
  background: var(--card); color: var(--ink);
  font-family: var(--display); font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
  box-shadow: 0 3px 0 var(--ink);
  transition: transform .08s, box-shadow .08s, opacity .2s;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; box-shadow: 0 3px 0 var(--ink); }
.btn.go { background: var(--ltg); }
.btn.big { font-size: 1.35rem; padding: .7em 1.4em; width: 100%; }
.btn.ghost { background: transparent; color: var(--card); border-color: rgba(247,241,227,.5); box-shadow: none; }
.btn.team { background: var(--tc); color: var(--tci); }
.btn small { font-family: var(--body); font-weight: 600; text-transform: none; letter-spacing: 0; font-size: .78em; opacity: .85; }

/* ---------- START ---------- */
#start { display: grid; place-items: center; padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); }
.start-inner { width: min(440px, 100%); display: grid; gap: 22px; }
.logo { text-align: center; }
.logo h1 {
  margin: 6px 0 0; font-family: var(--display); font-weight: 900; font-style: italic; text-transform: uppercase;
  font-size: clamp(3.2rem, 17vw, 5rem); line-height: .82; letter-spacing: -.01em;
  display: flex; flex-direction: column; align-items: center;
  color: var(--card); text-shadow: 0 3px 0 var(--ink), 0 6px 0 rgba(0,0,0,.25);
}
.logo h1 .amp { font-size: .55em; color: var(--ltg); line-height: .9; font-style: normal; }
.logo .tag { margin: 12px auto 0; max-width: 28ch; color: rgba(247,241,227,.8); font-size: .95rem; }
.logo-dice { display: flex; justify-content: center; gap: 10px; }
.logo-dice .die { transform: rotate(-12deg); }
.logo-dice .die + .die { transform: rotate(9deg) translateY(4px); }
.panel {
  background: var(--card); color: var(--ink); border-radius: 18px; padding: 18px;
  border: 2px solid var(--ink); box-shadow: var(--shadow); display: grid; gap: 14px;
}
.seg { display: grid; grid-template-columns: 1fr 1fr; border: 2px solid var(--ink); border-radius: 999px; overflow: hidden; }
.seg-b { border: 0; background: transparent; padding: .7em .5em; font-family: var(--display); font-weight: 800; text-transform: uppercase; letter-spacing: .04em; font-size: 1.05rem; }
.seg-b.on { background: var(--ink); color: var(--card); }
.seg.small .seg-b { font-size: .9rem; }
.seg-b i { display: block; font-style: normal; font-family: var(--body); font-weight: 500; text-transform: none; letter-spacing: 0; font-size: .75rem; opacity: .75; }
.pick-row { display: grid; grid-template-columns: 1fr; gap: 6px; }
.pick-label { font-family: var(--display); font-weight: 800; text-transform: uppercase; font-size: 1.05rem; }
.swatches { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.sw {
  border: 2px solid var(--ink); border-radius: 10px; height: 46px; background: var(--tc); color: var(--tci);
  font-family: var(--display); font-weight: 800; font-size: .74rem; letter-spacing: .01em; text-transform: uppercase; padding: 0 2px; overflow: hidden; text-overflow: ellipsis;
  position: relative; box-shadow: 0 2px 0 var(--ink);
}
.sw.on { outline: 3px solid var(--ink); outline-offset: 2px; }
.sw.on::after { content: "✓"; position: absolute; top: -9px; right: -7px; width: 20px; height: 20px; border-radius: 50%; background: var(--ink); color: var(--card); font-size: 12px; line-height: 20px; }
.sw[disabled] { opacity: .25; cursor: not-allowed; }

/* ---------- SCOREBOARD ---------- */
#game { display: flex; flex-direction: column; max-width: 1180px; margin: 0 auto; padding: max(8px, env(safe-area-inset-top)) 8px calc(8px + env(safe-area-inset-bottom)); gap: 8px; }
.scoreboard {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch;
  background: linear-gradient(#1b1a18, #0e0d0c); border: 3px solid #050505; border-radius: 14px;
  box-shadow: inset 0 0 0 2px #2b2924, var(--shadow); overflow: hidden;
}
.sb-team { display: flex; align-items: center; padding: 6px 8px; gap: 8px; position: relative; min-width: 0; }
.sb-team.p1 { flex-direction: row-reverse; }
.sb-info { min-width: 0; display: grid; gap: 4px; justify-items: start; }
.sb-team.p1 .sb-info { justify-items: end; }
.sb-team.p1 .sb-meta { flex-direction: row-reverse; }
.sb-name {
  font-family: var(--display); font-weight: 900; font-style: italic; text-transform: uppercase; font-size: 1.05rem; line-height: 1;
  color: var(--tci); background: var(--tc); padding: 4px 8px; border-radius: 6px; justify-self: start; letter-spacing: .03em;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sb-score {
  font-family: var(--mono); font-weight: 800; font-size: 2.4rem; line-height: 1;
  color: var(--led); text-shadow: 0 0 10px rgba(255,182,39,.55); font-variant-numeric: tabular-nums;
  min-width: 2ch; text-align: center;
}
.sb-score.bump { animation: bump calc(.6s * var(--spd)) ease-out; }
@keyframes bump { 0% { transform: scale(1); } 30% { transform: scale(1.45); color: #fff; } 100% { transform: scale(1); } }
.sb-meta { display: flex; gap: 6px; align-items: center; font-size: .8rem; color: rgba(247,241,227,.75); font-weight: 700; }
.hype .hl { display: none; }
.ball-dot { width: 14px; height: 9px; border-radius: 50%; background: #8a4b22; border: 1.5px solid #fff; display: inline-block; visibility: hidden; }
.sb-team.has-ball .ball-dot { visibility: visible; }
.hype { color: var(--ltg); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sb-mid { display: grid; place-items: center; padding: 6px 10px; border-left: 2px solid #2b2924; border-right: 2px solid #2b2924; min-width: 92px; text-align: center; }
.sb-q { font-family: var(--display); font-weight: 900; font-size: 1.15rem; color: var(--card); letter-spacing: .05em; }
.sb-snaps { font-family: var(--mono); color: var(--led); font-size: 1.25rem; font-weight: 800; line-height: 1; text-shadow: 0 0 8px rgba(255,182,39,.5); }
.sb-snaps-l { font-size: .62rem; text-transform: uppercase; letter-spacing: .08em; color: rgba(247,241,227,.6); }
.sb-down {
  grid-column: 1 / -1; display: flex; justify-content: center; gap: 12px; align-items: center;
  background: #0a0a09; border-top: 2px solid #2b2924; padding: 4px 8px;
  font-family: var(--display); font-weight: 800; text-transform: uppercase; letter-spacing: .05em; font-size: 1rem;
}
.sb-down .dd { color: var(--ltg); }
.sb-down .spot { color: var(--card); }
.sb-down .sep { width: 4px; height: 4px; border-radius: 50%; background: rgba(247,241,227,.4); }

/* ---------- FIELD ---------- */
#fieldWrap { padding: 4px 0; }
.field {
  position: relative; height: 92px; border-radius: 8px; overflow: hidden;
  border: 3px solid #f2efe6; box-shadow: 0 0 0 2px #1a3d1f, var(--shadow);
  background: var(--turf);
}
.field .turf { position: absolute; inset: 0 8.333%; background: repeating-linear-gradient(90deg, var(--turf) 0 10%, var(--turf2) 10% 20%); }
.field .ez {
  position: absolute; top: 0; bottom: 0; width: 8.333%; background: var(--tc);
  display: grid; place-items: center; overflow: hidden;
  background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.12) 0 6px, transparent 6px 14px);
}
.field .ez span {
  writing-mode: vertical-rl; transform: rotate(180deg); font-family: var(--display); font-weight: 900; font-style: italic;
  text-transform: uppercase; color: var(--tci); font-size: .95rem; letter-spacing: .12em; white-space: nowrap;
}
.field .ez.r span { transform: none; }
.field .ez.long span { font-size: .66rem; letter-spacing: .03em; }
.field .ez.l { left: 0; border-right: 2px solid #fff; }
.field .ez.r { right: 0; border-left: 2px solid #fff; }
.yl { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--chalk); }
.yl.five { width: 1px; background: rgba(255,255,255,.35); }
.yn { position: absolute; font-family: var(--display); font-weight: 800; color: rgba(255,255,255,.82); font-size: .72rem; transform: translateX(-50%); letter-spacing: .02em; }
.yn.t { top: 6px; } .yn.b { bottom: 6px; transform: translateX(-50%) rotate(180deg); }
.hash { position: absolute; width: 1px; height: 5px; background: rgba(255,255,255,.5); }
.marker { position: absolute; top: 0; bottom: 0; transition: left calc(.65s * var(--spd)) cubic-bezier(.3,.7,.2,1); will-change: left; }
.los { width: 3px; margin-left: -1.5px; background: rgba(120, 190, 255, .95); }
.ltg { width: 4px; margin-left: -2px; background: var(--ltg); box-shadow: 0 0 6px rgba(255,210,31,.8); }
.ltg::after { content: "1ST"; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: var(--ltg); color: var(--ink); font: 800 .6rem var(--display); padding: 2px 3px; border-radius: 3px; }
.ltg.goal::after { content: "GOAL"; }
.ball {
  width: 0; z-index: 3;
}
.ball .fb {
  position: absolute; top: 50%; left: 0; width: 26px; height: 16px; transform: translate(-50%, -50%);
  background: radial-gradient(ellipse at 40% 35%, #b56a33, #7a3d17 70%); border-radius: 50%;
  border: 2px solid var(--tc); box-shadow: 0 2px 4px rgba(0,0,0,.5);
}
.ball .fb::before { content: ""; position: absolute; left: 6px; right: 6px; top: 50%; height: 2px; margin-top: -1px; background: #fff; border-radius: 1px; }
.ball .fb::after { content: ""; position: absolute; left: 50%; top: 3px; bottom: 3px; width: 6px; margin-left: -3px; background: repeating-linear-gradient(90deg, transparent 0 1px, #fff 1px 2px); opacity: .9; }
.ball .dir {
  position: absolute; top: calc(50% - 22px); left: 0; transform: translateX(-50%);
  font: 900 .7rem var(--display); color: var(--tci); background: var(--tc); padding: 1px 5px; border-radius: 4px; white-space: nowrap;
  border: 1.5px solid rgba(0,0,0,.35);
}
.field.flash-td { animation: fieldflash calc(1.2s * var(--spd)) ease-out; }
@keyframes fieldflash { 0%, 100% { filter: none; } 30% { filter: brightness(1.5) saturate(1.3); } }

/* ---------- BOARD ---------- */
.board { position: relative; display: grid; gap: 8px; grid-template-columns: 1fr; flex: 1; align-content: start; }
.left, .right { display: grid; gap: 8px; align-content: start; }
.left, .right { display: contents; }
#prompt { order: 1; } #hand { order: 2; } #actions { order: 3; } #log { order: 4; }

.prompt {
  border-radius: var(--r); padding: 10px 12px; background: rgba(0,0,0,.28); border: 1.5px solid rgba(255,255,255,.08);
  display: grid; gap: 2px;
}
.prompt .role { display: flex; align-items: center; gap: 8px; font-family: var(--display); font-weight: 900; text-transform: uppercase; letter-spacing: .04em; font-size: 1.25rem; line-height: 1.05; }
.prompt .chip { background: var(--tc); color: var(--tci); padding: 2px 8px; border-radius: 6px; font-style: italic; }
.prompt .say { color: rgba(247,241,227,.88); font-size: .92rem; line-height: 1.3; }
.prompt .say b { color: var(--ltg); font-weight: 700; }

.log { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; font-size: .8rem; max-height: 4.6em; overflow: hidden; color: rgba(247,241,227,.75); cursor: pointer; position: relative; }
.log.open { max-height: 40vh; overflow: auto; }
.log li { display: flex; gap: 6px; align-items: baseline; line-height: 1.35; }
.log li::before { content: ""; flex: 0 0 8px; height: 8px; border-radius: 2px; background: var(--tc, #888); transform: translateY(1px); }
.log li.sys::before { background: transparent; border: 1.5px solid rgba(247,241,227,.4); }
.log li:first-child { color: var(--card); font-weight: 600; }
.log-more { font-size: .7rem; color: rgba(247,241,227,.5); text-align: right; margin-top: -4px; }

/* ---------- HAND + CARDS ---------- */
.hand { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.hand.backs .card { pointer-events: none; }
.card {
  position: relative; color: var(--ink); background: var(--card); border-radius: 10px; padding: 7px 8px 8px;
  border: 2px solid var(--ink); box-shadow: 0 2px 0 var(--card-edge), 0 3px 0 var(--ink), 0 8px 14px rgba(0,0,0,.35);
  display: flex; flex-direction: column; gap: 4px; text-align: left; min-height: 128px;
  background-image: radial-gradient(rgba(29,27,24,.05) 1px, transparent 1.2px); background-size: 4px 4px;
  transition: transform calc(.16s * var(--spd)) ease-out, box-shadow .16s;
  user-select: none;
}
.card::before { /* team trim */
  content: ""; position: absolute; inset: 3px; border-radius: 7px; border: 2px solid var(--tc); pointer-events: none; opacity: .9;
}
button.card { font: inherit; }
.hand .card:hover { transform: translateY(-2px); }
.card.sel { transform: translateY(-6px) rotate(-1deg); box-shadow: 0 0 0 3px var(--ltg), 0 3px 0 var(--ink), 0 14px 22px rgba(0,0,0,.45); }
.card .c-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.badge {
  font-family: var(--display); font-weight: 900; font-size: .7rem; letter-spacing: .06em; text-transform: uppercase;
  padding: 2px 6px; border-radius: 4px; border: 1.5px solid var(--ink); white-space: nowrap; display: inline-flex; gap: 4px; align-items: center;
}
.badge.run { background: var(--ink); color: var(--card); }
.badge.pass { background: var(--card); color: var(--ink); }
.badge.def { background: var(--tc); color: var(--tci); border-color: var(--ink); }
.badge svg { width: 11px; height: 11px; }
.cost { font-family: var(--display); font-weight: 900; font-size: .85rem; background: var(--ltg); border: 1.5px solid var(--ink); border-radius: 999px; padding: 0 7px; }
.oneshot { font-family: var(--display); font-weight: 800; font-size: .6rem; text-transform: uppercase; letter-spacing: .08em; color: var(--stamp-stop); border: 1.5px solid var(--stamp-stop); border-radius: 4px; padding: 0 4px; }
.c-name { font-family: var(--display); font-weight: 900; font-style: italic; text-transform: uppercase; font-size: 1.2rem; line-height: .95; letter-spacing: .01em; }
.c-blurb { font-size: .68rem; color: var(--ink-soft); line-height: 1.2; min-height: 1.2em; }
.c-rows { display: grid; gap: 3px; margin-top: auto; }
.c-row { display: grid; grid-template-columns: 52px 1fr; align-items: center; border: 1.5px solid var(--ink); border-radius: 5px; overflow: hidden; min-height: 26px; transition: box-shadow .2s, transform .2s; }
.c-row .rl { align-self: stretch; display: grid; place-items: center; font-family: var(--display); font-weight: 900; font-size: .6rem; letter-spacing: .05em; color: #fff; line-height: 1; text-align: center; padding: 0 2px; }
.c-row.stopped .rl { background: var(--stamp-stop); }
.c-row.open .rl { background: var(--stamp-open); }
.c-row .rv { padding: 2px 5px; font-family: var(--mono); font-weight: 700; font-size: .78rem; line-height: 1.15; display: flex; flex-wrap: wrap; gap: 2px 5px; align-items: center; }
.rv .f { font-size: .95rem; }
.rv .x { font-family: var(--body); font-size: .62rem; font-weight: 600; color: var(--ink-soft); }
.rv .dn { font-family: var(--display); font-size: .65rem; font-weight: 900; background: var(--ink); color: var(--card); padding: 0 3px; border-radius: 3px; }
.rv .ch { white-space: nowrap; font-size: .66rem; }
.rv .ch i { font-style: normal; display: inline-block; min-width: 1.4em; text-align: center; background: rgba(29,27,24,.1); border-radius: 3px; padding: 0 2px; margin-right: 2px; }
.rv .ch.bad { color: var(--stamp-stop); }
.rv .ch.good { color: #0e6a2d; }
.rv .ch.hit { background: var(--ltg); border-radius: 3px; outline: 1.5px solid var(--ink); }
.c-note { font-size: .62rem; font-weight: 700; color: var(--ink); background: rgba(255,210,31,.5); border-radius: 4px; padding: 1px 5px; }
.c-row.hl { box-shadow: 0 0 0 3px var(--ltg), 0 0 18px 4px rgba(255,210,31,.75); transform: scale(1.03); }
.c-row.dim { opacity: .35; }

/* defense card */
.card.defc .guess { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-top: auto; }
.g-cell { border: 1.5px solid var(--ink); border-radius: 5px; overflow: hidden; text-align: center; }
.g-cell .gt { font-family: var(--display); font-weight: 900; font-size: .7rem; letter-spacing: .05em; padding: 2px 0; background: rgba(29,27,24,.08); border-bottom: 1.5px solid var(--ink); }
.g-cell .gr { font-family: var(--display); font-weight: 900; font-size: .78rem; padding: 4px 2px; color: #fff; line-height: 1; }
.g-cell .gr small { display: block; font-size: .62rem; font-weight: 800; opacity: .9; margin-top: 2px; }
.g-cell.stop .gr { background: var(--stamp-stop); }
.g-cell.open .gr { background: var(--stamp-open); }
.g-cell.hl { box-shadow: 0 0 0 3px var(--ltg), 0 0 18px 4px rgba(255,210,31,.75); }

/* card back */
.cardback {
  border-radius: 10px; border: 2px solid var(--ink); background: var(--tc); position: relative; overflow: hidden;
  box-shadow: 0 3px 0 var(--ink), 0 8px 14px rgba(0,0,0,.35);
  background-image:
    repeating-linear-gradient(45deg, rgba(255,255,255,.14) 0 5px, transparent 5px 12px),
    repeating-linear-gradient(-45deg, rgba(0,0,0,.08) 0 5px, transparent 5px 12px);
  display: grid; place-items: center; min-height: 128px;
}
.cardback::before { content: ""; position: absolute; inset: 6px; border: 2px solid rgba(255,255,255,.65); border-radius: 7px; }
.cardback .mark { font-family: var(--display); font-weight: 900; font-style: italic; font-size: 1.6rem; color: var(--tci); background: rgba(0,0,0,.18); width: 3.2em; height: 3.2em; border-radius: 50%; display: grid; place-items: center; border: 2px solid rgba(255,255,255,.7); letter-spacing: -.02em; position: relative; }
.cardback.tc-light .mark { background: rgba(255,255,255,.35); }

/* ---------- ACTIONS ---------- */
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions .btn { flex: 1 1 0; min-width: 0; padding: .65em .6em; font-size: .95rem; flex-direction: column; gap: 0; line-height: 1.05; }
.actions .btn.primary { flex: 1.6 1 0; background: var(--ltg); font-size: 1.1rem; }
.actions .wait { flex: 1; text-align: center; font-family: var(--display); font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: rgba(247,241,227,.7); padding: 12px; }
.dots::after { content: ""; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

/* ---------- REVEAL ---------- */
.reveal {
  position: absolute; inset: -4px -4px auto -4px; min-height: calc(100% + 8px); z-index: 20; border-radius: 14px; overflow: hidden;
  background:
    radial-gradient(90% 70% at 50% 40%, rgba(46, 125, 59, .96), rgba(23, 70, 32, .98) 70%),
    #1d4a25;
  border: 3px solid #0f2a14; box-shadow: inset 0 0 40px rgba(0,0,0,.5), var(--shadow);
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 10px 10px; gap: 10px; min-height: 470px; cursor: pointer;
}
.reveal > * { flex-shrink: 0; }
.reveal::before { /* felt texture */
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .25;
  background-image: radial-gradient(rgba(0,0,0,.35) 1px, transparent 1.3px); background-size: 3px 3px;
}
.rv-sit { font-family: var(--display); font-weight: 800; text-transform: uppercase; letter-spacing: .08em; font-size: .8rem; color: rgba(255,255,255,.75); z-index: 1; }
.rv-cards { position: relative; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 6px; width: 100%; max-width: 560px; z-index: 1; }
.rv-vs { font-family: var(--display); font-weight: 900; font-style: italic; font-size: 1.1rem; color: rgba(255,255,255,.7); }
.slot { perspective: 900px; position: relative; }
.slot .who { text-align: center; font-family: var(--display); font-weight: 800; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 4px; }
.slot .who b { background: var(--tc); color: var(--tci); padding: 1px 6px; border-radius: 4px; }
.flip { position: relative; transform-style: preserve-3d; transition: transform calc(.5s * var(--spd)) cubic-bezier(.3,.6,.25,1.2); min-height: 168px; }
.flip .face { backface-visibility: hidden; -webkit-backface-visibility: hidden; position: absolute; inset: 0; }
.flip .face.front { transform: rotateY(180deg); position: relative; }
.flip .face.front .card { min-height: 168px; height: 100%; }
.flip .face.back .cardback { height: 100%; }
.flip.flipped { transform: rotateY(180deg); }
.slot.slam { animation: slam calc(.32s * var(--spd)) cubic-bezier(.2,.8,.3,1.2) both; }
.slot.d.slam { animation-delay: calc(.12s * var(--spd)); }
@keyframes slam {
  0% { transform: translateY(-60px) scale(1.5) rotate(-6deg); opacity: 0; }
  70% { transform: translateY(4px) scale(.97) rotate(1deg); opacity: 1; }
  100% { transform: none; opacity: 1; }
}
.slot.d.slam { animation-name: slam2; }
@keyframes slam2 {
  0% { transform: translateY(-60px) scale(1.5) rotate(6deg); opacity: 0; }
  70% { transform: translateY(4px) scale(.97) rotate(-1deg); opacity: 1; }
  100% { transform: none; opacity: 1; }
}
.stamp {
  z-index: 4; font-family: var(--display); font-weight: 900; text-transform: uppercase; letter-spacing: .06em;
  font-size: 2.1rem; line-height: 1; padding: 6px 16px 4px; border: 5px solid currentColor; border-radius: 8px;
  white-space: nowrap; margin: 2px 0 4px;
  transform: rotate(-6deg); box-shadow: 0 6px 18px rgba(0,0,0,.35); background: rgba(247,241,227,.92);
  -webkit-mask-image: radial-gradient(circle at 30% 40%, #000 60%, rgba(0,0,0,.75) 61%, #000 75%);
  mask-image: radial-gradient(circle at 30% 40%, #000 60%, rgba(0,0,0,.75) 61%, #000 75%);
  opacity: 0; visibility: hidden;
}
.stamp.stopped { color: var(--stamp-stop); }
.stamp.open { color: var(--stamp-open); }
.stamp.special { color: var(--ink); }
.stamp.show { visibility: visible; animation: stamp calc(.34s * var(--spd)) cubic-bezier(.2,.9,.3,1.3) both; }
@keyframes stamp { 0% { transform: scale(2.4) rotate(-14deg); opacity: 0; } 60% { transform: scale(.94) rotate(-5deg); opacity: 1; } 100% { transform: scale(1) rotate(-6deg); opacity: 1; } }
.rv-note { min-height: 1em; z-index: 1; font-size: .78rem; font-weight: 700; color: var(--ltg); text-align: center; }
.rv-dice { display: flex; gap: 14px; justify-content: center; align-items: flex-end; flex-wrap: wrap; z-index: 1; min-height: 64px; }
.dgroup { display: grid; justify-items: center; gap: 4px; }
.dgroup .dl { font-family: var(--display); font-weight: 800; font-size: .65rem; text-transform: uppercase; letter-spacing: .08em; color: rgba(255,255,255,.75); }
.dgroup .dd { display: flex; gap: 8px; }
.dgroup .dsum { font-family: var(--mono); font-weight: 800; font-size: .8rem; color: #fff; min-height: 1em; }
.rv-call { z-index: 2; text-align: center; display: grid; gap: 2px; align-content: start; }
.rv-call .big { font-family: var(--display); font-weight: 900; font-style: italic; text-transform: uppercase; font-size: 2.7rem; line-height: .9; color: #fff; text-shadow: 0 3px 0 var(--ink), 0 0 20px rgba(0,0,0,.4); }
.rv-call .sub { font-family: var(--display); font-weight: 900; text-transform: uppercase; letter-spacing: .06em; font-size: 1.15rem; color: var(--ltg); text-shadow: 0 2px 0 var(--ink); }
.rv-call .txt { font-size: .8rem; color: rgba(255,255,255,.85); margin-top: 4px; max-width: 34ch; }
.rv-call.pop { animation: pop calc(.4s * var(--spd)) cubic-bezier(.2,.9,.3,1.4) both; }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.rv-tap { margin-top: auto; z-index: 1; font-size: .7rem; color: rgba(255,255,255,.5); text-transform: uppercase; letter-spacing: .1em; font-weight: 700; }
.reveal.done .rv-tap { color: var(--ltg); }
.reveal.shake { animation: shake calc(.45s * var(--spd)) both; }
@keyframes shake { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); } 30%, 50%, 70% { transform: translateX(-7px) rotate(-.5deg); } 40%, 60% { transform: translateX(7px) rotate(.5deg); } }

/* special teams card */
.stcard { background: var(--ink); color: var(--card); border-radius: 10px; border: 2px solid var(--ink); padding: 10px; min-height: 168px; display: grid; align-content: center; justify-items: center; gap: 6px; text-align: center; box-shadow: 0 3px 0 #000, 0 8px 14px rgba(0,0,0,.35); position: relative; }
.stcard::before { content: ""; position: absolute; inset: 4px; border: 2px solid var(--tc); border-radius: 7px; }
.stcard .stn { font-family: var(--display); font-weight: 900; font-style: italic; font-size: 1.6rem; text-transform: uppercase; line-height: .9; }
.stcard .sts { font-size: .75rem; color: rgba(247,241,227,.75); }
.stcard .stbig { font-family: var(--mono); font-size: 1.1rem; color: var(--ltg); font-weight: 800; }

/* ---------- DICE ---------- */
.die {
  width: 46px; height: 46px; border-radius: 10px; background: #fbf8f0; border: 2px solid var(--ink);
  box-shadow: inset -3px -4px 0 rgba(0,0,0,.12), 0 3px 0 var(--ink), 0 6px 10px rgba(0,0,0,.35);
  display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 6px; position: relative;
}
.die.mini { width: 40px; height: 40px; padding: 5px; }
.die.red { background: #e03131; }
.die.red .pip { background: #fff; }
.die .pip { width: 8px; height: 8px; border-radius: 50%; background: var(--ink); place-self: center; visibility: hidden; }
.die.mini .pip { width: 7px; height: 7px; }
.die[data-face="1"] .p5,
.die[data-face="2"] .p1, .die[data-face="2"] .p9,
.die[data-face="3"] .p1, .die[data-face="3"] .p5, .die[data-face="3"] .p9,
.die[data-face="4"] .p1, .die[data-face="4"] .p3, .die[data-face="4"] .p7, .die[data-face="4"] .p9,
.die[data-face="5"] .p1, .die[data-face="5"] .p3, .die[data-face="5"] .p5, .die[data-face="5"] .p7, .die[data-face="5"] .p9,
.die[data-face="6"] .p1, .die[data-face="6"] .p3, .die[data-face="6"] .p4, .die[data-face="6"] .p6, .die[data-face="6"] .p7, .die[data-face="6"] .p9 { visibility: visible; }
.die.tumble { animation: tumble calc(.18s * var(--spd)) linear infinite; }
@keyframes tumble { 0% { transform: rotate(0) translateY(0); } 25% { transform: rotate(80deg) translateY(-10px); } 50% { transform: rotate(180deg) translateY(-4px); } 75% { transform: rotate(270deg) translateY(-10px); } 100% { transform: rotate(360deg) translateY(0); } }
.die.land { animation: land calc(.3s * var(--spd)) cubic-bezier(.2,.9,.3,1.4) both; }
@keyframes land { 0% { transform: scale(1.3) rotate(-20deg); } 100% { transform: scale(1) rotate(var(--rot, 0deg)); } }

/* ---------- OVERLAYS ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; align-items: center; padding: 16px; background: rgba(20, 12, 6, .82); backdrop-filter: blur(3px); overflow: auto; }
.sheet { width: min(520px, 100%); background: var(--card); color: var(--ink); border: 2px solid var(--ink); border-radius: 16px; padding: 18px; box-shadow: var(--shadow); }
.sheet h2 { margin: 0 0 8px; font-family: var(--display); font-weight: 900; font-style: italic; text-transform: uppercase; font-size: 1.9rem; line-height: 1; }
.how-list { margin: 0; padding: 0 0 0 1.1em; display: grid; gap: 7px; font-size: .9rem; line-height: 1.35; }
.how-list li::marker { font-family: var(--display); font-weight: 900; }
.how-tip { font-size: .85rem; font-weight: 700; margin: 10px 0 12px; }
.k { font-family: var(--display); font-weight: 900; font-size: .8rem; padding: 0 5px; border-radius: 3px; border: 1.5px solid var(--ink); }
.k.run { background: var(--ink); color: var(--card); }
.k.pass { background: var(--card); }
.how .btn { width: 100%; }

/* handoff */
#handoff { background: var(--tc); background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.1) 0 14px, transparent 14px 30px); cursor: pointer; }
.handoff-in { text-align: center; color: var(--tci); display: grid; gap: 12px; justify-items: center; }
.handoff-in .ph { font-size: 4rem; line-height: 1; }
.handoff-in h2 { margin: 0; font-family: var(--display); font-weight: 900; font-style: italic; text-transform: uppercase; font-size: clamp(2.4rem, 12vw, 4rem); line-height: .9; }
.handoff-in p { margin: 0; font-weight: 600; max-width: 26ch; }
.handoff-in .btn { margin-top: 10px; }

/* draft */
#draft { align-items: start; }
.draft { width: min(760px, 100%); background: var(--card); color: var(--ink); border: 2px solid var(--ink); border-radius: 16px; padding: 14px; box-shadow: var(--shadow); display: grid; gap: 12px; position: relative; }
.draft::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 8px; background: var(--tc); border-radius: 14px 14px 0 0; }
.d-head { display: flex; justify-content: space-between; align-items: end; gap: 10px; flex-wrap: wrap; padding-top: 4px; }
.d-head h2 { margin: 0; font-family: var(--display); font-weight: 900; font-style: italic; text-transform: uppercase; font-size: 1.7rem; line-height: .95; }
.d-head h2 small { display: block; font-size: .8rem; font-style: normal; letter-spacing: .1em; color: var(--ink-soft); }
.d-hype { font-family: var(--display); font-weight: 900; font-size: 1.6rem; background: var(--ink); color: var(--ltg); padding: 4px 12px; border-radius: 999px; white-space: nowrap; }
.d-hype small { font-size: .7rem; color: var(--card); letter-spacing: .08em; margin-left: 4px; }
.d-help { font-size: .82rem; color: var(--ink-soft); margin: -4px 0 0; line-height: 1.35; }
.d-sec h3 { margin: 0 0 6px; font-family: var(--display); font-weight: 900; text-transform: uppercase; letter-spacing: .06em; font-size: .95rem; display: flex; gap: 8px; align-items: center; }
.d-sec h3 span { font-family: var(--body); text-transform: none; letter-spacing: 0; font-weight: 500; font-size: .75rem; color: var(--ink-soft); }
.market { display: grid; grid-template-columns: repeat(3, minmax(176px, 1fr)); gap: 8px; overflow-x: auto; padding: 4px 2px 8px; scroll-snap-type: x mandatory; }
.mk { scroll-snap-align: start; }
.draft { min-width: 0; }
.draft > * { min-width: 0; }
.mk { display: grid; gap: 6px; }
.mk .card { min-height: 150px; }
.mk .btn { padding: .45em .5em; font-size: .85rem; }
.mk.bought .card::after { content: "SIGNED"; position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%) rotate(-12deg); font: 900 1.4rem var(--display); color: var(--stamp-open); border: 3px solid var(--stamp-open); padding: 0 6px; border-radius: 6px; background: rgba(247,241,227,.85); letter-spacing: .05em; }
.playbook { display: flex; flex-wrap: wrap; gap: 6px; }
.pb { border: 1.5px solid var(--ink); border-radius: 999px; background: var(--card); padding: 4px 10px; font-size: .78rem; font-weight: 700; display: inline-flex; gap: 6px; align-items: center; }
.pb b { font-family: var(--mono); }
.pb .tdot { width: 8px; height: 8px; border-radius: 2px; border: 1.5px solid var(--ink); }
.pb .tdot.run { background: var(--ink); }
.pb.cuttable { cursor: pointer; }
.pb.cuttable:hover { background: #ffe1e1; border-color: var(--stamp-stop); }
.pb.cuttable::after { content: "✂"; color: var(--stamp-stop); }
.d-foot { display: flex; gap: 8px; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.d-foot .btn.go { min-width: 46%; }
.d-cpu { font-size: .82rem; background: rgba(29,27,24,.06); border-radius: 8px; padding: 8px 10px; }

/* final */
.final { text-align: center; display: grid; gap: 12px; justify-items: center; }
.final h2 { font-size: clamp(2.2rem, 11vw, 3.4rem); }
.final .fs { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; width: 100%; }
.final .ft { display: grid; gap: 4px; justify-items: center; }
.final .ft .sb-name { font-size: 1.1rem; }
.final .ft .n { font-family: var(--mono); font-size: 3.2rem; font-weight: 800; line-height: 1; }
.final .ft.win .n { color: var(--tcd); }
.final table { border-collapse: collapse; width: 100%; font-size: .85rem; }
.final td, .final th { padding: 4px 6px; border-bottom: 1px solid var(--card-edge); }
.final th { font-family: var(--display); text-transform: uppercase; letter-spacing: .06em; font-size: .75rem; color: var(--ink-soft); }
.final td:first-child, .final td:last-child { font-family: var(--mono); font-weight: 800; }
.final .btns { display: flex; gap: 8px; width: 100%; }
.final .btns .btn { flex: 1; }

/* big moment flash */
.flash { position: fixed; inset: 0; z-index: 40; pointer-events: none; display: grid; place-items: center; overflow: hidden; }
.flash .burst { position: absolute; inset: -20%; background: repeating-conic-gradient(from 0deg, var(--tc) 0 8deg, transparent 8deg 18deg); opacity: 0; mix-blend-mode: screen; }
.flash.on .burst { animation: burst calc(1.6s * var(--spd)) ease-out both; }
@keyframes burst { 0% { opacity: 0; transform: scale(.3) rotate(0); } 20% { opacity: .55; } 100% { opacity: 0; transform: scale(1.4) rotate(40deg); } }
.flash .word {
  font-family: var(--display); font-weight: 900; font-style: italic; text-transform: uppercase; color: var(--tc);
  font-size: clamp(3rem, 16vw, 8rem); line-height: .85; text-align: center; letter-spacing: -.01em;
  -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill;
  text-shadow: 0 6px 0 var(--ink), 0 0 40px rgba(0,0,0,.5); opacity: 0; position: relative;
}
.flash .word span { display: inline-block; }
.flash.on .word { animation: word calc(1.6s * var(--spd)) cubic-bezier(.2,.9,.3,1.2) both; }
@keyframes word { 0% { opacity: 0; transform: scale(2.4) rotate(-8deg); } 15% { opacity: 1; transform: scale(.95) rotate(-4deg); } 22% { transform: scale(1) rotate(-4deg); } 80% { opacity: 1; transform: scale(1.04) rotate(-4deg); } 100% { opacity: 0; transform: scale(1.1) rotate(-4deg); } }
.confetti { position: absolute; top: -20px; width: 10px; height: 16px; background: var(--c); opacity: 0; border-radius: 2px; }
.flash.on .confetti { animation: fall calc(var(--t) * var(--spd)) cubic-bezier(.3,.4,.6,1) var(--d) both; }
@keyframes fall { 0% { opacity: 1; transform: translate(0, 0) rotate(0); } 100% { opacity: 1; transform: translate(var(--x), 110vh) rotate(var(--r)); } }

.corner-btn { position: fixed; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 30; width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--ink); background: var(--card); color: var(--ink); font: 900 1rem var(--display); box-shadow: 0 2px 0 var(--ink); opacity: .85; }
.toast { position: fixed; left: 50%; top: 150px; transform: translateX(-50%); z-index: 60; background: var(--ink); color: var(--card); border: 2px solid var(--card); border-radius: 999px; padding: 8px 16px; font-weight: 700; font-size: .85rem; box-shadow: var(--shadow); animation: toast 2.6s ease both; pointer-events: none; text-align: center; max-width: 92vw; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, -12px); } 10%, 85% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }

/* skipping animations: snap everything to the end */
body.skipping *, body.skipping *::before, body.skipping *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }

/* ---------- small phones ---------- */
@media (max-width: 360px) {
  .c-name { font-size: 1.05rem; }
  .rv-call .big { font-size: 2.2rem; }
  .sb-score { font-size: 2rem; }
}
@media (max-height: 740px) and (max-width: 600px) {
  .card { min-height: 116px; }
  .c-blurb { display: none; }
  .field { height: 78px; }
}

/* ---------- desktop ---------- */
@media (min-width: 900px) {
  #game { padding: 14px 18px; gap: 12px; }
  .sb-score { font-size: 3rem; }
  .sb-name { font-size: 1.35rem; }
  .sb-mid { min-width: 140px; }
  .sb-q { font-size: 1.4rem; }
  .sb-down { font-size: 1.2rem; }
  .field { height: 140px; }
  .field .ez span { font-size: 1.5rem; }
  .field .ez.long span { font-size: 1.05rem; }
  .yn { font-size: 1rem; }
  .yn.t { top: 10px; } .yn.b { bottom: 10px; }
  .ball .fb { width: 34px; height: 21px; }
  .board { grid-template-columns: 330px 1fr; gap: 14px; }
  .left, .right { display: grid; }
  .hype .hl { display: inline; }
  .toast { top: 250px; }
  .hand { grid-template-columns: repeat(4, 1fr); gap: 12px; }
  .card { min-height: 210px; padding: 10px 10px 10px; gap: 6px; }
  .c-name { font-size: 1.5rem; }
  .c-blurb { font-size: .78rem; }
  .c-row { grid-template-columns: 60px 1fr; min-height: 34px; }
  .c-row .rl { font-size: .68rem; }
  .c-row .rv { font-size: .9rem; }
  .rv .ch { font-size: .76rem; }
  .prompt { padding: 14px 16px; }
  .prompt .role { font-size: 1.6rem; }
  .prompt .say { font-size: 1rem; }
  .log { max-height: none; font-size: .85rem; }
  .actions .btn { font-size: 1.05rem; padding: .8em; }
  .actions .btn.primary { font-size: 1.3rem; }
  .reveal { min-height: 520px; }
  .flip, .flip .face.front .card, .stcard { min-height: 172px; }
  .rv-sit { display: none; }
  .rv-call .big { font-size: 3rem !important; }
  .die { width: 50px !important; height: 50px !important; }
  .reveal { gap: 8px; padding-top: 10px; }
  .rv-cards { max-width: 620px; gap: 18px; }
  .rv-call .big { font-size: 3.6rem; }
  .stamp { font-size: 2.3rem; }
  .die { width: 56px; height: 56px; }
  .die .pip { width: 10px; height: 10px; }
  .corner-btn { bottom: 16px; right: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .flip { transition: none; }
  .reveal.shake { animation: none; }
  .flash .burst, .confetti { display: none; }
  .die.tumble { animation: none; }
}
