.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#snow { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; transition: opacity 800ms ease-out; }
#snow.dim { opacity: 0.45; }

/* ---------- Cover ---------- */
.cover {
  position: fixed; inset: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px;
  padding: calc(24px + var(--safe-top)) 20px calc(24px + var(--safe-bottom));
  transition: opacity 500ms ease-out;
}
.cover.gone { opacity: 0; pointer-events: none; }
.stage { perspective: 1600px; width: min(78vw, 360px, 52vh); }
.card3d {
  position: relative; width: 100%; aspect-ratio: 5 / 7; transform-origin: left center;
  transform-style: preserve-3d;
  transition: transform 900ms cubic-bezier(.5,0,.2,1);
}
.card3d.opening { transform: translateX(50%) scale(var(--open-scale, 0.6)); }
.page-right, .flap, .face { position: absolute; inset: 0; border-radius: 6px; }
.page-right {
  background: #111; box-shadow: inset 0 0 0 1px #262626;
  display: flex; flex-direction: column; justify-content: flex-end; padding: 22px;
}
.pr-mark { width: 30%; height: auto; margin-bottom: auto; }
.pr-text { font-family: var(--heading); font-weight: 700; text-transform: uppercase; font-size: clamp(22px, 7vw, 32px); line-height: 1; margin: 0; }
.flap {
  transform-style: preserve-3d; transform-origin: left center;
  transition: transform 1100ms cubic-bezier(.6,0,.2,1);
}
.card3d.opening .flap { transform: rotateY(-178deg); }
.face { backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: hidden; }
.cover-face {
  background: #050505;
  box-shadow: inset 0 0 0 1px #262626, 0 30px 80px rgba(0,0,0,.6);
  display: flex; flex-direction: column;
}
.back-face {
  background: var(--lime); color: var(--black); transform: rotateY(180deg);
  display: flex; align-items: flex-end; padding: 22px;
}
.back-face .hand { color: var(--black); font-size: clamp(26px, 8vw, 36px); transform: rotate(-4deg); margin: 0; }
#tree { width: 100%; flex: 1; display: block; }
.front-text { padding: 0 22px 24px; }
.front-text .for { margin: 0 0 6px; font-size: 14px; color: var(--grey); }
.front-text h1 { font-size: clamp(30px, 10vw, 46px); color: var(--white); overflow-wrap: anywhere; }
.front-text .company { margin: 8px 0 0; font-size: 15px; color: #D0D0D0; }
.open { position: relative; z-index: 2; }
.cover-error { max-width: 30ch; text-align: center; color: #D0D0D0; margin: 0; }

/* ---------- Inside ---------- */
main {
  position: relative; z-index: 2;
  max-width: 640px; margin: 0 auto;
  padding: calc(20px + var(--safe-top)) 22px calc(40px + var(--safe-bottom));
}
main.reveal > * { animation: rise 600ms ease-out both; }
main.reveal > *:nth-child(2) { animation-delay: 60ms; }
main.reveal > *:nth-child(3) { animation-delay: 160ms; }
main.reveal > *:nth-child(4) { animation-delay: 260ms; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

.preview-banner {
  background: var(--panel); color: #D0D0D0; font-size: 14px;
  padding: 10px 14px; border-left: 3px solid var(--lime); margin-bottom: 18px;
}
.top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 44px; }
.logo { height: 26px; width: auto; }

.hello h1 { font-size: clamp(34px, 9.5vw, 58px); color: var(--lime); margin-bottom: 22px; overflow-wrap: anywhere; }
.hello .message { margin: 0 0 14px; font-size: 18px; max-width: 34em; white-space: pre-line; }
.hello .from { margin: 0 0 56px; color: #CFCFCF; }

.play {
  background: var(--panel); border-radius: var(--r);
  overflow: hidden; margin-bottom: 56px;
}
.play-art { background: #0A0A0A; }
#lorryArt { display: block; width: 100%; height: 170px; }
.play-copy { padding: 22px 22px 26px; }
.play-copy h2 { font-size: clamp(24px, 7vw, 34px); margin-bottom: 12px; }
.play-copy p { margin: 0 0 20px; color: #E2E2E2; }
.play-copy .btn { width: 100%; font-size: 17px; min-height: 58px; }
.per-play { font-size: 24px; margin: 16px 0 0 !important; transform: rotate(-2deg); color: var(--lime) !important; }

.give { margin-bottom: 60px; }
.stat-wrap { position: relative; display: inline-block; padding: 18px 26px 10px 8px; margin-bottom: 8px; }
.stat {
  position: relative; z-index: 1;
  font-family: var(--body); font-weight: 900; font-size: clamp(64px, 20vw, 110px);
  line-height: 1; color: var(--white); letter-spacing: -0.02em;
}
.stat-ring {
  position: absolute; left: -6%; top: -6%; width: 116%; height: 120%;
  transform: rotate(-4deg); pointer-events: none;
  filter: brightness(0) saturate(100%) invert(84%) sepia(37%) saturate(731%) hue-rotate(41deg) brightness(101%) contrast(87%);
  opacity: 0; transition: opacity 400ms ease-out;
}
.stat-ring.on { opacity: 1; }
.give-line { margin: 6px 0 14px; max-width: 32em; }
.bar { height: 6px; background: #262626; border-radius: 3px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--lime); transition: width 900ms ease-out; }

.board { margin-bottom: 60px; }
.board h2 { font-size: 22px; margin-bottom: 8px; }
.board-note { margin: 0 0 16px; font-size: 15px; }
.board-list { list-style: none; margin: 0; padding: 0; counter-reset: none; }
.board-list li {
  display: grid; grid-template-columns: 2.2em 1fr auto; align-items: baseline;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.board-list li .rk { color: var(--grey); font-variant-numeric: tabular-nums; }
.board-list li .nm { font-weight: 500; }
.board-list li .sc { font-weight: 600; font-variant-numeric: tabular-nums; }
.board-list li.me .nm::after { content: "you"; margin-left: 8px; font-size: 12px; color: var(--black); background: var(--lime); padding: 2px 7px; border-radius: 3px; vertical-align: 2px; font-weight: 600; }
.board-list li.gap { border: 0; color: var(--grey); padding: 4px 0; display: block; text-align: center; }
.crew-line { margin: 16px 0 0; color: #D0D0D0; font-size: 15px; }
.crew-line strong { color: var(--white); font-variant-numeric: tabular-nums; }

.invite { margin-bottom: 64px; }
.invite h2 { font-size: 22px; margin-bottom: 8px; }
.invite > p { margin: 0 0 18px; font-size: 15px; }
.invite form > div, .row2 > div { margin-bottom: 14px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row2 > div { margin-bottom: 0; }
.row2 { margin-bottom: 14px; }
.invite .btn { width: 100%; }
.invite-done p { margin: 0 0 12px; }
.link-box input { font-size: 14px; color: #CFCFCF; }
.invite-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.invite-actions .btn { flex: 1 1 140px; width: auto; }

.signed h2 { font-size: 22px; margin-bottom: 18px; }
.sig-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.sig { background: var(--panel); border-radius: var(--r); padding: 12px 14px 14px; }
.sig svg { width: 100%; height: auto; display: block; margin-bottom: 4px; }
.sig svg path { fill: none; stroke: var(--white); stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; }
.sig .who { font-weight: 600; font-size: 14px; }
.sig .msg { font-size: 14px; color: #CFCFCF; margin-top: 4px; }
.sig-empty { color: var(--grey); }

.foot { margin-top: 72px; display: flex; gap: 16px; align-items: center; color: var(--grey); font-size: 14px; }
.foot p { margin: 0; }
.foot-mark { width: 40px; height: auto; }

/* ---------- Game ---------- */
.game, .reward, .results {
  position: fixed; inset: 0; z-index: 20; background: var(--black);
}
.game {
  display: flex; flex-direction: column;
  padding: calc(8px + var(--safe-top)) 12px calc(10px + var(--safe-bottom));
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.game { align-items: center; }
.game > * { width: 100%; max-width: 560px; }
.game[hidden], .reward[hidden], .results[hidden] { display: none; }
.hud { display: flex; align-items: stretch; gap: 8px; margin-bottom: 8px; }
.hud-cell { background: var(--panel); border-radius: var(--r); padding: 6px 10px; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.hud-cell:first-child { flex: 1; }
.hud-cell:nth-child(2) { flex: 1; }
.hud-label { font-size: 11px; color: var(--grey); white-space: nowrap; }
.hud-val { font-family: var(--body); font-weight: 900; font-size: 24px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.hud-val.urgent { color: var(--red); }
.hud-cell.next { flex: 1.5; }
.next-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.hud-cell.next canvas { width: 34px; height: 20px; flex: none; }
.next-name { font-size: 13px; font-weight: 600; line-height: 1.25; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quit {
  background: var(--panel); color: var(--white); border: 0; border-radius: var(--r);
  width: 44px; font-size: 26px; cursor: pointer;
}
.well-wrap { flex: 1; min-height: 0; position: relative; display: flex; justify-content: center; align-items: center; }
#well { display: block; touch-action: none; }
.banner {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%) rotate(-3deg);
  font-family: var(--hand); color: var(--lime); font-size: clamp(36px, 11vw, 64px);
  text-shadow: 0 4px 20px #000, 0 0 2px #000; white-space: nowrap; pointer-events: none;
}
.banner.big { font-family: var(--body); font-weight: 900; color: var(--white); font-size: clamp(70px, 26vw, 140px); transform: translate(-50%, -50%); }
.pad { display: grid; grid-template-columns: repeat(4, 1fr) 1.4fr; gap: 8px; margin-top: 10px; }
.pad button {
  height: 60px; border: 0; border-radius: var(--r); background: var(--panel); color: var(--white);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  -webkit-tap-highlight-color: transparent; touch-action: none;
}
.pad button.on { background: #333; }
.pad svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.pad .drop { background: var(--lime); color: var(--black); font-family: var(--heading); font-weight: 700; text-transform: uppercase; font-size: 14px; letter-spacing: .04em; }
.pad .drop.on { background: #a5f57a; }
.pad-hint { text-align: center; font-size: 12px; margin: 8px 0 0; }
@media (hover: hover) and (pointer: fine) { .pad-hint::after { content: " On a keyboard: arrows to move, up to turn, space to drop."; } }

/* ---------- Reward + results ---------- */
#rewardCanvas { display: block; width: 100%; height: 100%; }
.skip {
  position: absolute; right: 14px; bottom: calc(14px + var(--safe-bottom));
  background: rgba(26,26,26,.85); color: var(--white); border: 0; border-radius: var(--r);
  font: 500 14px var(--body); padding: 10px 16px; cursor: pointer;
}
.results { display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 21; }
.results-inner { width: 100%; max-width: 420px; }
.results .hand { font-size: clamp(30px, 9vw, 42px); margin: 0 0 6px; transform: rotate(-3deg); }
.results-score { font-weight: 900; font-size: clamp(76px, 24vw, 120px); line-height: 1; margin: 0 0 8px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.results-sub { margin: 0 0 22px; font-size: 18px; }
.results-give { margin: 0 0 28px; color: #D0D0D0; padding-left: 14px; border-left: 3px solid var(--lime); }
.results-actions { display: grid; gap: 10px; }
.results-actions .btn { width: 100%; }

@media (min-width: 720px) {
  .play { display: grid; grid-template-columns: 1fr 1fr; }
  #lorryArt { height: 100%; min-height: 240px; }
}
