/* Arena Push. The house ground (warm dark, Space Grotesk, one green that means "you can act
   here"), and two team colours that carry everything else: orange and blue, which stay apart for
   every common kind of colour blindness. The game is the window; chrome is bars on its edges. */

@font-face { font-family: "Space Grotesk"; src: url("/fonts/SpaceGrotesk.ttf") format("truetype"); font-weight: 300 700; font-display: swap; }

:root {
  --bg: #262421; --panel: #21201d; --ink: #e4e1dd; --dim: #98948e; --edge: #3a3733;
  --go: #81b64c; --amber: #d9a13b;
  --t0: #f2812f; --t1: #4fb3e8;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--ink); overflow: hidden;
  font-family: "Space Grotesk", system-ui, sans-serif; -webkit-font-smoothing: antialiased;
  user-select: none; -webkit-user-select: none; touch-action: none;
}
#stage { position: fixed; inset: 0; }
#stage canvas { display: block; width: 100%; height: 100%; }

button {
  font: inherit; font-weight: 600; font-size: 16px; color: var(--ink); background: #34312d;
  border: 0; border-radius: 6px; padding: 12px 18px; cursor: pointer; min-height: 44px;
}
button:hover { background: #403c37; }
button:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
button.go { background: var(--go); color: #16210b; }
button.go:hover { background: #8fc45a; }
button.quiet { background: none; color: var(--dim); font-weight: 400; }
button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

/* ---- home ------------------------------------------------------------------------------- */
.screen {
  position: fixed; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: calc(24px + var(--safe-t)) 20px calc(24px + var(--safe-b));
  background: radial-gradient(ellipse at center, #262421e0 0 30%, #26242180 75%);
}
.screen.on { display: flex; }
h1 { font-size: clamp(44px, 11vw, 96px); letter-spacing: .04em; margin: 0; line-height: 1; font-weight: 700; }
h1 img { display: block; width: min(560px, 88vw); height: auto; filter: drop-shadow(0 12px 30px #000b); }
.lede { color: var(--ink); font-size: 26px; font-weight: 700; margin: 0; text-align: center; text-shadow: 0 3px 14px #000c; }
.actions { display: flex; flex-direction: column; gap: 10px; width: min(360px, 100%); }
.actions .go { font-size: 22px; padding: 16px; }
.row { display: flex; gap: 8px; }
.row > button { flex: 1; }
.level .lvl { color: var(--dim); align-self: center; padding: 0 6px; font-size: 14px; }
.howto { color: var(--dim); font-size: 14px; text-align: center; line-height: 1.9; }
.howto b { color: var(--ink); font-weight: 600; }
body.has-pad .howto div:first-child, body:not(.has-pad) .howto div:last-child { display: none; }
#credits-list { max-width: 560px; color: var(--dim); line-height: 1.6; font-size: 15px; }
#credits-list b { color: var(--ink); }
#credits-list p { margin: 0 0 10px; }

/* ---- the bar across the top ------------------------------------------------------------- */
#bar {
  position: fixed; left: 0; right: 0; top: 0; display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center; padding: calc(6px + var(--safe-t)) calc(14px + var(--safe-r)) 6px calc(14px + var(--safe-l));
  background: #21201dd9; border-bottom: 1px solid var(--edge); pointer-events: none;
}
#bar .team { display: flex; align-items: center; gap: 12px; }
#bar .t1 { justify-content: flex-end; }
#bar .team b { font-size: 34px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
#bar .t0 b { color: var(--t0); } #bar .t1 b { color: var(--t1); }
#bar .tag { font-size: 13px; letter-spacing: .12em; color: var(--dim); font-weight: 600; }
#bar .team.mine .tag { color: var(--ink); }
#bar .team.mine .tag::after { content: " · YOU"; }
#bar .mid { text-align: center; }
#clock { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
#clock.sudden { color: var(--amber); }
#target { font-size: 12px; color: var(--dim); letter-spacing: .08em; }
#bar .bar-fill { height: 3px; }

#next {
  position: fixed; top: calc(58px + var(--safe-t)); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; padding: 4px 12px 4px 6px; border-radius: 6px;
  background: #21201dcc; font-size: 14px; color: var(--dim); pointer-events: none; white-space: nowrap;
}
#next svg { width: 30px; height: 30px; }
#next b { color: var(--ink); font-weight: 600; }
#next.landing { background: #3a3326e6; color: var(--ink); }
#next.landing b { color: var(--amber); }

/* ---- lobby -------------------------------------------------------------------------------- */
.panel {
  z-index: 5;
  position: fixed; left: 50%; bottom: calc(18px + var(--safe-b)); transform: translateX(-50%);
  width: min(460px, calc(100% - 24px)); background: #21201df2; border-top: 3px solid var(--edge);
  padding: 14px; display: flex; flex-direction: column; gap: 10px; border-radius: 6px;
}
#lobby-title { font-size: 18px; font-weight: 600; }
#lobby-title .code { color: var(--go); letter-spacing: .12em; }
#seats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
#seats .seat { display: flex; gap: 8px; align-items: center; font-size: 15px; min-height: 26px; }
#seats .seat i { width: 10px; height: 10px; border-radius: 50%; flex: none; }
#seats .seat.empty { color: var(--dim); }
#seats .seat .you { color: var(--go); font-weight: 600; }
#lobby-note { color: var(--dim); font-size: 14px; }

/* ---- cooldowns ---------------------------------------------------------------------------- */
#cooldowns { position: fixed; left: calc(14px + var(--safe-l)); bottom: calc(14px + var(--safe-b)); display: flex; gap: 14px; pointer-events: none; }
.cd { position: relative; width: 56px; text-align: center; }
.cd svg { width: 56px; height: 56px; transform: rotate(-90deg); }
.cd circle { fill: #21201dcc; stroke: #4b4741; stroke-width: 4; }
.cd circle.fill { fill: none; stroke: var(--go); stroke-dasharray: 106.8; stroke-dashoffset: 0; }
.cd.cooling circle.fill { stroke: var(--dim); }
.cd .key { position: absolute; left: 0; right: 0; top: 18px; font-size: 12px; font-weight: 600; }
.cd .name { display: block; font-size: 12px; color: var(--dim); }
body.has-pad .k-kb, body:not(.has-pad) .k-pad { display: none; }
body.touch #cooldowns { display: none; }

/* ---- floating things ---------------------------------------------------------------------- */
#arrows, #labels { position: fixed; inset: 0; pointer-events: none; }
.arrow { position: absolute; width: 0; height: 0; border-left: 12px solid transparent; border-right: 12px solid transparent; border-bottom: 22px solid; filter: drop-shadow(0 2px 4px #0008); }
.label { position: absolute; transform: translate(-50%, -100%); font-size: 11px; font-weight: 700; letter-spacing: .1em;
  padding: 1px 5px; border-radius: 4px; background: #21201dcc; color: var(--dim); white-space: nowrap; }
.label.you { color: var(--go); }
.pop { position: absolute; transform: translate(-50%, -50%); font-size: 40px; font-weight: 700; text-shadow: 0 3px 0 #0009;
  animation: pop 1.3s ease-out forwards; white-space: nowrap; }
@keyframes pop { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.6); } 15% { opacity: 1; transform: translate(-50%, -60%) scale(1.15); }
  70% { opacity: 1; transform: translate(-50%, -110%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -140%) scale(1); } }

#banner { position: fixed; left: 0; right: 0; top: 38%; text-align: center; font-size: clamp(48px, 13vw, 120px); font-weight: 700;
  pointer-events: none; opacity: 0; text-shadow: 0 6px 30px #000a; transition: opacity .2s; }
#banner.on { opacity: 1; }
#banner small { display: block; font-size: 22px; font-weight: 500; color: var(--ink); }
#callout { position: fixed; left: 0; right: 0; top: calc(96px + var(--safe-t)); text-align: center; pointer-events: none; opacity: 0; transition: opacity .25s; }
#callout.on { opacity: 1; }
#callout span { display: inline-block; background: var(--amber); color: #231a08; font-size: 26px; font-weight: 700; padding: 6px 16px; border-radius: 6px; letter-spacing: .06em; }
#toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%); background: #21201df2; padding: 10px 16px;
  border-radius: 6px; opacity: 0; transition: opacity .25s; pointer-events: none; font-size: 15px; }
#toast.on { opacity: 1; }
#leave { position: fixed; right: calc(10px + var(--safe-r)); top: calc(62px + var(--safe-t)); width: 40px; min-height: 40px; padding: 0; background: #21201dcc; color: var(--dim); }
#cam { position: fixed; right: calc(58px + var(--safe-r)); top: calc(62px + var(--safe-t)); min-height: 40px; padding: 0 12px; font-size: 14px; background: #21201dcc; color: var(--dim); }
#net { position: fixed; right: calc(10px + var(--safe-r)); bottom: calc(8px + var(--safe-b)); font-size: 11px; color: var(--dim); pointer-events: none; font-variant-numeric: tabular-nums; }

/* ---- touch -------------------------------------------------------------------------------- */
#touch { position: fixed; inset: auto 0 0 0; height: 42%; pointer-events: none; }
#stick { position: absolute; left: calc(26px + var(--safe-l)); bottom: calc(26px + var(--safe-b)); width: 130px; height: 130px; border-radius: 50%;
  background: #ffffff14; border: 2px solid #ffffff22; pointer-events: auto; }
#nub { position: absolute; left: 40px; top: 40px; width: 50px; height: 50px; border-radius: 50%; background: #e4e1dd66; }
#t-shove, #t-dash { position: absolute; pointer-events: auto; border-radius: 50%; width: 84px; height: 84px; background: #34312dcc; font-size: 14px; }
#t-shove { right: calc(24px + var(--safe-r)); bottom: calc(30px + var(--safe-b)); }
#t-dash { right: calc(120px + var(--safe-r)); bottom: calc(14px + var(--safe-b)); width: 70px; height: 70px; }

@media (max-width: 560px) {
  #bar .team b { font-size: 26px; }
  #bar .tag { display: none; }
  #bar .team.mine b { text-decoration: underline; text-underline-offset: 5px; }
}

/* ---- sharing and phones ------------------------------------------------------------------- */
.actions .friends { font-size: 18px; padding: 14px; }
.join input { flex: 1; min-width: 0; font: inherit; font-size: 20px; font-weight: 700; letter-spacing: .3em; text-transform: uppercase;
  text-align: center; color: var(--ink); background: #1b1a18; border: 2px solid var(--edge); border-radius: 6px; padding: 8px; }
.join input:focus { outline: none; border-color: var(--go); }
.join button { flex: 0 0 auto; }
.h-touch { display: none; }
body.touch .h-kb, body.touch .howto div:last-child:not(.h-touch) { display: none; }
body.touch .h-touch { display: block; }
body.has-pad .h-kb { display: none; }

.lobby-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
#lobby-title .code { font-size: 26px; letter-spacing: .18em; }
#lobby-count { color: var(--dim); font-size: 14px; white-space: nowrap; }
.me { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--dim); }
.me input { flex: 1; min-width: 0; font: inherit; font-size: 16px; font-weight: 600; color: var(--ink); background: #1b1a18;
  border: 1px solid var(--edge); border-radius: 6px; padding: 8px 10px; }
.me input:focus { outline: none; border-color: var(--go); }
.invite-row { display: flex; gap: 12px; align-items: center; }
.invite-row #invite { flex: 1; font-size: 20px; padding: 14px; }
#qr { flex: none; width: 96px; height: 96px; background: #fff; border-radius: 6px; padding: 4px; }
#qr svg { width: 100%; height: 100%; display: block; }
#start.go { font-size: 18px; }
#seats .seat .joined { color: var(--ink); font-weight: 600; }

#share-btn { position: fixed; right: calc(162px + var(--safe-r)); top: calc(62px + var(--safe-t)); min-height: 40px; padding: 0 12px; font-size: 14px;
  background: var(--go); color: #16210b; }
#result { bottom: calc(18px + var(--safe-b)); text-align: center; }
#result-line { font-size: 20px; font-weight: 700; }
#result-note { color: var(--dim); font-size: 14px; }

/* phones: the lobby and the result are a sheet across the bottom, and the tray's tag on the left
   edge gets room so it never sits on a button */
@media (max-width: 700px), (max-height: 500px) {
  .panel { left: 0; right: 0; transform: none; width: auto; border-radius: 12px 12px 0 0; bottom: 0;
    padding: 14px calc(14px + var(--safe-r)) calc(14px + var(--safe-b)) calc(40px + var(--safe-l)); max-height: 78vh; overflow-y: auto; }
  body.touch .screen { padding-left: 44px; }
  #leave, #cam { top: calc(54px + var(--safe-t)); }
  #share-btn { top: calc(100px + var(--safe-t)); right: calc(10px + var(--safe-r)); }
  #next { left: calc(12px + var(--safe-l)); transform: none; top: calc(54px + var(--safe-t)); }
  #qr { display: none; }
}
@media (max-height: 500px) {
  /* a phone on its side: the lobby goes two columns so Start is never below the fold */
  .panel { left: 8%; right: 8%; max-height: 92vh; }
  #lobby { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; padding-top: 10px; padding-bottom: calc(10px + var(--safe-b)); }
  #lobby .lobby-head, #lobby #lobby-note { grid-column: 1 / -1; }
  #lobby #seats, #lobby .me { grid-column: 1; }
  #lobby #lobby-target, #lobby .invite-row, #lobby .row:not(#lobby-target) { grid-column: 2; }
  #lobby #seats { grid-row: 2 / span 2; }
  #lobby .invite-row #invite { font-size: 16px; padding: 10px; }
  #lobby #lobby-note { font-size: 12px; }
  #bar .team b { font-size: 24px; }
  #bar { padding-top: calc(2px + var(--safe-t)); padding-bottom: 2px; }
  #clock { font-size: 17px; }
}
