:root {
  color-scheme: dark;
  --navy: #0e1a2b; --plate: rgba(10, 20, 36, .82); --gold: #ffd21f; --red: #e0261b; /* (white on it: 4.7:1) */ --paper: #fbf8f1; --ink: #13161c;
  --me: #ff5a4e;
  --nav: var(--random-nav-h, env(safe-area-inset-bottom, 0px));
  --top: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--navy); color: #fff; font: 17px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
canvas#yard { position: fixed; inset: 0; width: 100vw; height: 100dvh; display: block; }
.logo, h2, .pill, #banner, #act, #final-list, .big { font-family: "League Gothic", Impact, "Arial Narrow", sans-serif; letter-spacing: .04em; text-transform: uppercase; }

/* the join and face screens: a card over the yard */
.screen { position: fixed; inset: 0; overflow: auto; padding: calc(20px + var(--top)) 16px calc(20px + var(--nav)); display: flex; flex-direction: column; align-items: center; gap: 12px; background: var(--navy); }
#join, #face { justify-content: safe center; }
#join > *, #face > * { width: min(100%, 380px); }
.logo { margin: 0; font-weight: 400; font-size: 76px; line-height: .9; text-align: center; color: #fff; text-shadow: 4px 4px 0 var(--red); }
h2 { margin: 0; font-weight: 400; font-size: 46px; line-height: 1; }
.sub { margin: 0; color: #d6e2f0; text-align: center; }
form { display: grid; gap: 12px; background: var(--paper); color: var(--ink); padding: 18px; box-shadow: 8px 8px 0 var(--gold); }
label { display: grid; gap: 4px; font-weight: 600; font-size: 15px; }
input { font: 22px system-ui, sans-serif; padding: 10px 12px; border: 2px solid var(--ink); border-radius: 0; background: #fff; color: var(--ink); width: 100%; }
#code { text-transform: uppercase; letter-spacing: .2em; font-weight: 700; }
.big { font-size: 28px; padding: 10px 18px; background: var(--gold); color: var(--ink); border: 2px solid var(--ink); cursor: pointer; width: 100%; box-shadow: 4px 4px 0 var(--ink); }
.big:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
.btn { font: 600 17px system-ui, sans-serif; padding: 10px 16px; background: var(--plate); color: #fff; border: 2px solid #fff; cursor: pointer; text-align: center; flex: 1; }
.link { background: none; border: 0; color: #d6e2f0; text-decoration: underline; font: inherit; cursor: pointer; }
.row { display: flex; gap: 8px; }
.err { margin: 0; color: #b42318; font-size: 15px; min-height: 1em; }
.err:empty { display: none; }
.host { text-align: center; margin: 4px 0 0; }
.host a { color: #d6e2f0; }
#face-c { width: 200px !important; height: 200px; border-radius: 50%; background: var(--paper); box-shadow: 0 0 0 6px var(--me); touch-action: none; align-self: center; }

/* the lobby and the final: a sheet at the bottom, the yard (and your figure) above */
.sheet { top: auto; justify-content: safe flex-end; background: linear-gradient(transparent, var(--navy) 34%); padding-top: 60px; max-height: 70dvh; }
@media (orientation: landscape) and (max-height: 500px) {
  .sheet { max-height: 100dvh; padding-top: calc(10px + var(--top)); background: rgba(14, 26, 43, .86); }
  #final-list { font-size: 22px; columns: 2; column-gap: 18px; }
  #final-list li { break-inside: avoid; }
  h2 { font-size: 34px; }
}
.sheet > * { width: min(100%, 460px); }
#vip { display: grid; gap: 10px; }
.chips { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.chips span { font-weight: 600; min-width: 4.5em; }
.chips button { font: 600 15px system-ui, sans-serif; padding: 7px 12px; min-height: 44px; border: 2px solid #fff; background: transparent; color: #fff; border-radius: 999px; cursor: pointer; }
.chips button[aria-checked="true"], .chips button[aria-pressed="true"] { background: #fff; color: var(--ink); }
#final-list { margin: 0; padding: 0; list-style: none; font-size: 30px; }
#final-list li { display: grid; grid-template-columns: 2.2em .4em 1fr auto; gap: .4em; align-items: center; border-bottom: 1px solid rgba(255,255,255,.2); }
#final-list li i { align-self: stretch; }
#final-list li small { font-size: .55em; color: #d6e2f0; }
#final-list li.me { color: var(--gold); }
#final-list li em { display: block; font-style: normal; font: 600 13px system-ui, sans-serif; letter-spacing: 0; text-transform: none; color: var(--ink); background: var(--gold); padding: 1px 6px; width: max-content; }
#final-mine { margin: 4px 0 0; }
#fake-hint.on { color: var(--gold); font-weight: 600; }
/* after a few throws the pad stops explaining itself (a fake's hint still shows) */
#swipe.pro p:not(:has(.on)) { display: none; }

/* in the game */
#pad { position: fixed; inset: 0; touch-action: none; user-select: none; -webkit-user-select: none; }
#hud { z-index: 2; position: absolute; top: calc(8px + var(--top)); left: 8px; right: 8px; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; pointer-events: none; }
.pill { background: var(--plate); padding: 2px 12px; font-size: 22px; border-left: 4px solid var(--me); white-space: nowrap; }
@media (max-width: 360px) { .pill { font-size: 18px; padding: 2px 8px; } #swipe .throws { gap: 6px; } #swipe .throws svg { width: 32px; height: 44px; } }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#role.it { background: var(--gold); color: var(--ink); }
#role.frozen { background: #1f6fe0; } /* (white on it: 4.8:1) */
#clock { font-variant-numeric: tabular-nums; }
#banner { position: absolute; top: 22%; left: 0; right: 0; text-align: center; font-size: clamp(56px, 16vw, 120px); color: #fff; -webkit-text-stroke: .025em var(--ink); text-shadow: .05em .05em 0 var(--red); pointer-events: none; opacity: 0; }
#banner.on { animation: pop 1.6s cubic-bezier(.2,1.4,.3,1) both; }
@keyframes pop { 0% { opacity: 0; transform: scale(1.8); } 15% { opacity: 1; transform: scale(1); } 75% { opacity: 1; } 100% { opacity: 0; } }
/* the stick: anywhere on the screen that isn't a button or the throw pad, starting where the thumb comes down; nothing
   drawn until then */
#stick-zone { position: absolute; left: 0; right: 0; top: calc(56px + var(--top)); bottom: var(--nav); }
#stick { position: absolute; width: 132px; height: 132px; margin: -66px 0 0 -66px; border-radius: 50%; background: rgba(255,255,255,.12); border: 2px solid rgba(255,255,255,.45); left: 90px; top: calc(100% - 110px); pointer-events: none; transition: opacity .15s; opacity: 0; }
#stick.on { opacity: 1; }
#stick i { position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px 0 0 -29px; border-radius: 50%; background: rgba(255,255,255,.85); box-shadow: 0 0 0 4px var(--me); }
#swipe { position: absolute; right: 0; top: 30%; bottom: var(--nav); width: 46%; display: grid; place-items: center; background: linear-gradient(90deg, transparent, rgba(255, 210, 31, .12)); border-left: 2px dashed rgba(255, 210, 31, .5); }
#swipe { align-content: center; gap: 10px; }
#swipe p { margin: 0; text-align: center; font-weight: 700; color: var(--gold); text-shadow: 0 1px 3px #000; font-size: 14px; background: var(--plate); padding: 4px 10px; justify-self: center; }
#swipe .throws { list-style: none; margin: 0; padding: 0; display: flex; gap: 14px; justify-content: center; }
#swipe .throws li { display: grid; justify-items: center; font: 600 16px system-ui, sans-serif; color: #fff; text-shadow: 0 1px 3px #000; }
#swipe .throws svg { width: 44px; height: 60px; fill: none; stroke: #fff; stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 1px 2px #000); }
#charge { justify-self: center; width: min(70%, 220px); height: 12px; border-radius: 6px; background: rgba(0,0,0,.45); border: 2px solid rgba(255,255,255,.7); overflow: hidden; }
#charge i { display: block; height: 100%; width: calc(var(--c, 0) * 100%); background: linear-gradient(90deg, var(--gold), #ff6a1f); }
#charge.full { border-color: #ff6a1f; box-shadow: 0 0 12px #ff6a1f; }
#swipe small { font-weight: 500; color: #fff; }
/* the swipe's trail, over everything, never in the way of a finger */
#trail { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }
/* the throw the swipe reads as so far: its icon lights up in the trail's colour */
#swipe .throws li { transition: transform .12s; }
#swipe .throws li.on { transform: scale(1.18); }
#swipe .throws li.on:nth-child(1) svg { stroke: #fff; filter: drop-shadow(0 0 6px #fff); }
#swipe .throws li.on:nth-child(2) { color: #ffd21f; } #swipe .throws li.on:nth-child(2) svg { stroke: #ffd21f; filter: drop-shadow(0 0 6px #ffd21f); }
#swipe .throws li.on:nth-child(3) { color: #7fd3ff; } #swipe .throws li.on:nth-child(3) svg { stroke: #7fd3ff; filter: drop-shadow(0 0 6px #7fd3ff); }
#acts { position: absolute; right: calc(16px + env(safe-area-inset-right, 0px)); bottom: calc(18px + var(--nav)); display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
#act { width: 132px; height: 132px; border-radius: 50%; font-size: 40px; border: 4px solid var(--ink); background: var(--gold); color: var(--ink); box-shadow: 0 6px 0 var(--ink); cursor: pointer; }
#act:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
#act.stop { background: var(--red); color: #fff; font-size: 48px; }
#act.plant { background: #1f6fe0; color: #fff; }
#act:disabled { opacity: .5; }
#duck { width: 96px; height: 96px; border-radius: 50%; font: 400 30px "League Gothic", Impact, sans-serif; letter-spacing: .04em; text-transform: uppercase; border: 4px solid var(--ink); background: var(--paper); color: var(--ink); box-shadow: 0 5px 0 var(--ink); cursor: pointer; touch-action: none; }
#duck.on { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); background: var(--gold); }
/* a mouse and keys: each button says its key */
.keys-only { display: none; }
body.keys .keys-only { display: block; }
body.keys #act, body.keys #duck { position: relative; }
body.keys #act::after, body.keys #duck::after { content: attr(data-key); position: absolute; left: 50%; bottom: -10px; transform: translateX(-50%); padding: 1px 7px; border-radius: 4px; background: var(--ink); color: #fff; font: 700 12px system-ui, sans-serif; letter-spacing: 0; text-transform: none; }
.chip { font: 600 15px system-ui, sans-serif; padding: 8px 14px; border-radius: 999px; border: 2px solid #fff; background: var(--plate); color: #fff; }
.chip[aria-pressed="true"] { background: #fff; color: var(--ink); }
#arrow { position: absolute; width: 0; height: 0; border-left: 14px solid transparent; border-right: 14px solid transparent; border-bottom: 26px solid var(--gold); filter: drop-shadow(0 2px 2px #000); pointer-events: none; }
#arrow.it { border-bottom-color: var(--red); }
#tip { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(14px + var(--nav)); margin: 0; max-width: 46%; text-align: center; font-size: 15px; background: var(--plate); padding: 6px 12px; pointer-events: none; }
#tip:empty { display: none; }
/* solo: the broadcast's captions, small, top left under the header */
#cap { position: absolute; left: calc(12px + env(safe-area-inset-left, 0px)); top: calc(56px + var(--top)); display: grid; pointer-events: none; opacity: 0; transform: translateX(-12px); transition: opacity .25s, transform .25s; max-width: 70%; }
#cap.on { opacity: 1; transform: none; }
#cap b { justify-self: start; background: var(--gold); color: var(--ink); font: 400 15px "League Gothic", Impact, sans-serif; letter-spacing: .05em; text-transform: uppercase; padding: 0 8px; }
#cap span { background: var(--navy); color: #fff; font: 400 24px "League Gothic", Impact, sans-serif; letter-spacing: .04em; text-transform: uppercase; padding: 0 10px 2px; }
/* solo: the replay (letterboxed, a tap skips it) */
#replay { position: absolute; inset: 0; display: none; }
body.replay #replay { display: block; }
#replay .bar { position: absolute; left: 0; right: 0; height: 9vh; background: #0b1220; }
#replay .top { top: 0; } #replay .bot { bottom: 0; }
#replay b { position: absolute; right: 16px; bottom: calc(9vh + 10px); font: 400 30px "League Gothic", Impact, sans-serif; letter-spacing: .08em; text-transform: uppercase; color: var(--ink); background: var(--gold); padding: 0 .5em; box-shadow: 4px 4px 0 var(--red); }
#replay small { position: absolute; left: 16px; bottom: calc(9vh + 12px); color: #fff; font-size: 13px; text-shadow: 0 1px 2px #000; }
body.replay #hud, body.replay #acts, body.replay #stick-zone, body.replay #swipe, body.replay #tip, body.replay #arrow { visibility: hidden; }
body.calm #cap { transition: none; }
#solo { margin-top: 10px; flex: none; min-height: 48px; } /* (a .btn grows to fill a row; in the join screen's column it would fill the screen) */
/* upright: the yard on top, the controls in a deck along the bottom (the stick left, the button or the pad right) */
@media (orientation: portrait) {
  #pad::before { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 40%; background: linear-gradient(transparent, rgba(10, 20, 36, .5) 35%); pointer-events: none; }
  #swipe { top: 60%; width: 54%; background: rgba(255, 210, 31, .08); border-left: 0; border-top: 2px dashed rgba(255, 210, 31, .5); }
  #tip { bottom: auto; top: calc(56px + var(--top)); max-width: 90%; }
  #act { width: 112px; height: 112px; font-size: 34px; }
  #duck { width: 84px; height: 84px; }
}
@media (prefers-reduced-motion: reduce) { #banner.on { animation: calm-pop 1.6s linear both; } }
body.calm #banner.on { animation: calm-pop 1.6s linear both; }
@keyframes calm-pop { 0% { opacity: 0; } 12%, 75% { opacity: 1; } 100% { opacity: 0; } }
.chips .note { flex-basis: 100%; color: #d6e2f0; font-size: 13px; }

/* the shout toggle (in the header, away from the STOP button) */
#hud .chip { pointer-events: auto; padding: 2px 12px; min-height: 44px; }
/* the shot clock: only its last ten seconds show */
#shotpill { background: var(--gold); color: var(--ink); border-left-color: #fff; }
#shotpill.hot { background: var(--red); color: #fff; }
/* how to play */
#howto { justify-content: safe center; }
#howto > * { width: min(100%, 560px); }
.howto { margin: 0; padding-left: 1.2em; display: grid; gap: 8px; text-align: left; }
.howto .throws-row { display: flex; flex-wrap: wrap; gap: 10px 16px; margin: 6px 0; }
.howto .throws-row span { display: flex; align-items: center; gap: 6px; font-size: 15px; }
.howto svg { width: 26px; height: 38px; fill: none; stroke: var(--gold); stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }
#lobby .row .btn { min-height: 44px; }
/* turn sideways */
#final-wait { margin-top: 4px; }
