/* Twin Snap — the approved "Game Night" mockup: deep plum stage, cream round cards with a thick rim
   and a drop shadow, gold accents, Unbounded headings over Nunito. The cards themselves are styled
   inline by twin-icons.mjs cardHtml (so Game Night can reuse them); this file is the page around them. */
.tsn-page {
  --ink: #fff4ea; --ink-2: #f1d9e4; --muted: #d9b8c8; --gold: #ffcf5a; --orange: #ff8a00; --cyan: #5cf4ff; --pink: #ff8fb3;
  --panel: rgba(13, 2, 11, .55); --line: rgba(255, 244, 234, .14);
  --head: 'Unbounded', system-ui, sans-serif;
  --cbx-display: 'Unbounded', system-ui, sans-serif;
  --mine: 340px; --deck: 270px;
  color: var(--ink);
}
body.cbx.tsn-page { color: var(--ink); background: radial-gradient(120% 900px at 50% -120px, #4a0f37, #2c0822 55%, #150410) top center / 100% 1400px no-repeat, #150410; }
.tsn-page [hidden] { display: none !important; }

.tsn-wrap { width: 100%; max-width: 980px; margin: 0 auto; padding: 8px 16px 24px; display: flex; flex-direction: column; gap: 12px; min-width: 0; box-sizing: border-box; scroll-margin-top: 0; }
.tsn-wrap button { font-family: 'Nunito', system-ui, sans-serif; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.tsn-wrap :focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }

/* ---- top row + head ---- */
.tsn-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 40px; }
.tsn-back { display: flex; align-items: center; min-height: 40px; font-weight: 800; font-size: 14px; text-decoration: none; color: var(--muted) !important; white-space: nowrap; }
.tsn-back:hover { color: #fff !important; }
.tsn-meta { font-size: 13px; font-weight: 800; color: var(--muted); text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tsn-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.tsn-titles { min-width: 0; }
.tsn-kicker { margin: 0; font-size: 12px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; color: var(--cyan); }
.tsn-title { margin: 2px 0 0; font: 900 28px/1.05 var(--head); letter-spacing: -.01em; color: #fff; white-space: nowrap; }
@media (max-width: 420px) { .tsn-title { font-size: 24px; } .tsn-page.is-playing .tsn-kicker { display: none; } }
.tsn-hud { flex: none; display: flex; align-items: center; gap: 8px; }
.tsn-count { font: 800 16px var(--head); color: var(--gold); font-variant-numeric: tabular-nums; }
.tsn-clock { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font: 800 16px var(--head); font-variant-numeric: tabular-nums; color: #fff; min-width: 98px; justify-content: center; }
.tsn-page.is-practice .tsn-count { color: var(--cyan); }

/* ---- race panel ---- */
.tsn-race { padding: 12px 14px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.tsn-race-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.tsn-race-name { font: 800 16px var(--head); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tsn-race-beat { font-size: 13px; font-weight: 800; color: var(--muted); white-space: nowrap; }
.tsn-race-beat b { font-family: var(--head); color: var(--gold); }
.tsn-race-row { display: flex; align-items: center; gap: 8px; }
.tsn-race-row .who { width: 48px; font-size: 12px; font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tsn-race-row.them .who, .tsn-race-row.them .num { color: var(--muted); }
.tsn-race-row .bar { flex: 1; height: 10px; border-radius: 5px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.tsn-race-row .bar i { display: block; height: 100%; width: 0; background: var(--gold); transition: width .3s ease; }
.tsn-race-row.them .bar i { background: repeating-linear-gradient(45deg, #ff8fb3 0 5px, #e46a93 5px 10px); }
.tsn-race-row .num { width: 44px; text-align: right; font: 800 13px var(--head); font-variant-numeric: tabular-nums; }
.tsn-race-pace { margin: 0; font-size: 13px; font-weight: 800; color: var(--ink-2); }

.tsn-banner { margin: 0; padding: 10px 13px; border-radius: 12px; background: rgba(255, 207, 90, .14); border: 1.5px solid rgba(255, 207, 90, .45); font-size: 14px; font-weight: 800; line-height: 1.4; color: var(--ink); }

/* ---- intro ---- */
.tsn-intro { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; padding: 8px 0 4px; }
.tsn-intro-cards { position: relative; width: 300px; height: 210px; max-width: 100%; }
.tsn-intro-cards > div { position: absolute; }
.tsn-intro-cards > div:first-child { left: 0; top: 0; transform: rotate(-8deg); }
.tsn-intro-cards > div:last-child { right: 0; bottom: 0; transform: rotate(7deg); }
.tsn-intro-title { margin: 6px 0 0; font: 900 26px/1.15 var(--head); color: #fff; }
.tsn-intro-text { margin: 0; max-width: 460px; font-size: 16px; font-weight: 800; line-height: 1.45; color: var(--ink-2); }

/* ---- buttons ---- */
.tsn-actions { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 420px; align-self: center; }
.tsn-primary { min-height: 54px; border: 0; border-radius: 16px; background: linear-gradient(90deg, #ffcf5a, #ff9a1f); color: #2a1404; font: 900 17px 'Nunito', sans-serif; box-shadow: 0 4px 0 #b4600a, 0 12px 24px -10px rgba(0, 0, 0, .6); }
.tsn-primary:active { transform: translateY(2px); box-shadow: 0 2px 0 #b4600a; }
.tsn-ghost { min-height: 48px; border-radius: 14px; border: 2px solid rgba(255, 244, 234, .28); background: rgba(255, 244, 234, .06); color: var(--ink); font: 800 15px 'Nunito', sans-serif; padding: 0 12px; }
.tsn-ghost:hover { background: rgba(255, 244, 234, .12); }
.tsn-small { min-height: 40px; font-size: 14px; }
.tsn-two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tsn-two .tsn-ghost { font-size: 14px; padding: 0 8px; }

/* ---- the stage: two cards ---- */
.tsn-stage { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.tsn-col { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; }
.tsn-lab { margin: 0; font-size: 12px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.tsn-minecol .tsn-lab { color: var(--gold); margin-top: 4px; }
.tsn-slot { position: relative; display: grid; place-items: center; }
#deck .ts-card, #mine .ts-card { touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.tsn-stage .ts-sym { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.tsn-stage .ts-sym:focus { outline: none; }
.tsn-stage .ts-sym:focus-visible { box-shadow: 0 0 0 3px #2c0822, 0 0 0 6px var(--cyan); }
.tsn-stage .ts-sym.ts-hl { animation: tsnGlow .45s ease-out; }
@keyframes tsnGlow { 0% { transform: translate(-50%, -50%) scale(1); } 40% { transform: translate(-50%, -50%) scale(1.2); } 100% { transform: translate(-50%, -50%) scale(1.06); } }
.tsn-slot .ts-card.enter { animation: tsnEnter .24s ease-out; }
@keyframes tsnEnter { from { transform: translateY(46px) scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }
.tsn-slot .ts-card.shake { animation: tsnShake .42s ease; }
@keyframes tsnShake { 15% { transform: translateX(-12px) rotate(-3deg); } 35% { transform: translateX(10px) rotate(2deg); } 55% { transform: translateX(-7px); } 75% { transform: translateX(4px); } }

/* frozen: an icy disc over your card with a draining bar */
.tsn-freeze { position: absolute; inset: 0; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; pointer-events: auto;
  background: radial-gradient(circle, rgba(170, 225, 255, .55), rgba(92, 170, 230, .72)); box-shadow: inset 0 0 0 6px rgba(220, 245, 255, .9), 0 0 30px rgba(120, 200, 255, .55); }
.tsn-freeze-txt { font: 900 26px var(--head); color: #0b2a4a; letter-spacing: .06em; text-transform: uppercase; text-shadow: 0 1px 0 rgba(255, 255, 255, .7); }
.tsn-freeze-bar { width: 46%; height: 10px; border-radius: 5px; background: rgba(11, 42, 74, .25); overflow: hidden; }
.tsn-freeze-bar i { display: block; height: 100%; width: 100%; background: #0b2a4a; transform-origin: left; }
.tsn-freeze.on .tsn-freeze-bar i { animation: tsnDrain 1s linear forwards; }
@keyframes tsnDrain { to { transform: scaleX(0); } }
.tsn-page.is-frozen .tsn-minecol .tsn-lab { color: #8fd3ff; }

.tsn-pbar { display: flex; align-items: center; justify-content: center; gap: 14px; font-weight: 800; color: var(--ink-2); }

/* ---- finish ---- */
.tsn-done { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 18px 16px; border-radius: 22px; background: var(--panel); border: 1px solid var(--line); }
.tsn-done-kicker { margin: 0; font-size: 12px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; color: var(--cyan); }
.tsn-done-time { margin: 0; font: 900 46px/1 var(--head); color: var(--gold); font-variant-numeric: tabular-nums; }
.tsn-done-sub { margin: 0; font-size: 15px; font-weight: 800; color: var(--ink-2); }
.tsn-result { width: 100%; max-width: 420px; padding: 12px 14px; border-radius: 16px; background: rgba(255, 207, 90, .14); border: 2px solid var(--gold); }
.tsn-result.lose { background: rgba(255, 143, 179, .12); border-color: var(--pink); }
.tsn-result .big { margin: 0; font: 900 19px/1.3 var(--head); color: #fff; }
.tsn-result .sub { margin: 4px 0 0; font-size: 14px; font-weight: 800; color: var(--ink-2); }
.tsn-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; max-width: 420px; }
.tsn-stats div { padding: 10px 6px; border-radius: 14px; background: rgba(255, 244, 234, .07); display: flex; flex-direction: column; gap: 2px; }
.tsn-stats b { font: 800 18px var(--head); color: #fff; font-variant-numeric: tabular-nums; }
.tsn-stats small { font-size: 12px; font-weight: 800; color: var(--muted); }
.tsn-name { display: flex; flex-direction: column; gap: 6px; text-align: left; font-size: 13px; font-weight: 800; color: var(--muted); }
.tsn-name input { min-height: 46px; border-radius: 12px; border: 2px solid rgba(255, 244, 234, .28); background: rgba(255, 244, 234, .08); color: #fff; font: 800 16px 'Nunito', sans-serif; padding: 0 12px; }
.tsn-name input::placeholder { color: rgba(255, 244, 234, .5); }
.tsn-note { margin: 2px 0 0; font-size: 13px; font-weight: 800; color: var(--muted); }

.tsn-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- the how-to card, dark to match ---- */
.tsn-read-wrap { max-width: 760px; }
.tsn-page .tsn-read { background: rgba(13, 2, 11, .5); color: var(--ink-2); box-shadow: none; border: 1px solid var(--line); }
.tsn-page .tsn-read h2, .tsn-page .tsn-read h3 { font-family: var(--head); font-weight: 800; color: #fff; }
.tsn-page .tsn-read h2 { font-size: 22px; }
.tsn-page .tsn-read h3 { font-size: 17px; }
.tsn-page .tsn-read p, .tsn-page .tsn-read li { color: var(--ink-2); }
.tsn-page .tsn-read b { color: #fff; }
.tsn-page .tsn-read a { color: var(--cyan); }
.tsn-page .tsn-read .cbx-note { color: var(--muted); }
.tsn-page #postGameLinks { width: 100%; max-width: 760px; margin: 0 auto; padding: 0 16px; box-sizing: border-box; }
.tsn-page #postGameLinks h3 { color: #fff; font-family: var(--head); }

/* ---- big screens: cards side by side ---- */
@media (min-width: 820px) {
  .tsn-title { font-size: 34px; }
  .tsn-stage { flex-direction: row; align-items: center; justify-content: center; gap: 40px; }
  .tsn-minecol .tsn-lab { margin-top: 0; }
  .tsn-intro-cards { width: 380px; height: 250px; }
}

@media (prefers-reduced-motion: reduce) {
  .tsn-stage .ts-sym.ts-hl, .tsn-slot .ts-card.enter, .tsn-slot .ts-card.shake { animation: none; }
  .tsn-freeze.on .tsn-freeze-bar i { animation: none; transform: scaleX(.5); }
  .tsn-race-row .bar i { transition: none; }
}

/* narrow phones: title, count and clock share one row */
@media (max-width: 360px) {
  .tsn-head { gap: 4px 8px; flex-wrap: wrap; }
  .tsn-titles { min-width: auto; }   /* if it still can't fit, the clock wraps under the title instead of overlapping it */
  .tsn-title { font-size: 17px; }
  .tsn-hud { gap: 6px; margin-left: auto; }
  .tsn-count { font-size: 14px; }
  .tsn-clock { min-width: 0; padding: 6px 10px; font-size: 15px; }
  .tsn-clock svg { display: none; }
}
/* a phone on its side: the two cards side by side, as on big screens (twin-snap.js sizes them to fit) */
@media (max-width: 819px) and (orientation: landscape) and (min-aspect-ratio: 6/5) {
  .tsn-stage { flex-direction: row; align-items: center; justify-content: center; gap: 24px; }
  .tsn-minecol .tsn-lab { margin-top: 0; }
  .tsn-page.is-playing .tsn-kicker { display: none; }
  .tsn-wrap { gap: 8px; }
}
/* short screens: a slimmer race panel so both cards still fit below it */
@media (max-height: 700px) and (max-width: 819px) {
  .tsn-race { padding: 8px 12px; gap: 5px; border-radius: 14px; }
  .tsn-race-name { font-size: 14px; }
  .tsn-race-pace { font-size: 12px; }
  .tsn-page.is-playing .tsn-top { min-height: 32px; }
  .tsn-page.is-playing .tsn-back { min-height: 32px; }
}
