/* Ink Cannons.
   Built phone-first: every measure is fluid, every control is thumb-sized, and the game is the
   window — two bars pinned to the edges, nothing floating in a card. The four ink colours are the
   only colour on the board; green means one thing, "you can act here". */

@font-face { font-family: "Space Grotesk"; src: url("/fonts/space-grotesk-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Space Grotesk"; src: url("/fonts/space-grotesk-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Space Grotesk"; src: url("/fonts/space-grotesk-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --bg: #121110;
  --bg-lift: #1b1a18;
  --panel: rgba(27, 26, 24, 0.88);
  --ink: #f4f1ea;
  --dim: #a09a90;
  --faint: #6f6a63;
  --edge: rgba(255, 255, 255, 0.09);
  --edge-strong: rgba(255, 255, 255, 0.16);
  --go: #8ec54f;
  --go-deep: #6fa33a;
  --go-text: #101a06;
  --warn: #e8b13f;
  --s0: #ff6b4a;
  --s1: #4fb8f5;
  --s2: #f5c53d;
  --s3: #b98cff;

  --gap: 12px;
  --radius: 18px;
  --bar-top: 54px;
  --bar-bottom: 60px;
  --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);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overscroll-behavior: none; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.45 "Space Grotesk", system-ui, -apple-system, sans-serif;
  letter-spacing: -0.01em;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
[hidden] { display: none !important; }

/* a film of grain over everything, so flat fills read as paper rather than plastic */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.035;
  z-index: 6;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

/* ---- controls ------------------------------------------------------------------------------- */
button {
  font: inherit;
  letter-spacing: inherit;
  color: var(--ink);
  background: none;
  border: 0;
  cursor: pointer;
  border-radius: 12px;
  transition: transform 0.12s var(--ease), background 0.15s, box-shadow 0.15s, opacity 0.15s;
}
button:active { transform: scale(0.97); }
button:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

.go {
  background: linear-gradient(180deg, var(--go), var(--go-deep));
  color: var(--go-text);
  font-weight: 700;
  font-size: clamp(17px, 4.4vw, 19px);
  padding: 16px 34px;
  min-height: 56px;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.ghost {
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 1px var(--edge);
  padding: 13px 22px;
  min-height: 48px;
  font-weight: 500;
}
.ghost:hover { background: rgba(255, 255, 255, 0.08); }
.link { color: var(--dim); padding: 10px 4px; font-size: 15px; text-decoration: underline; text-underline-offset: 4px; }
.link:hover { color: var(--ink); }
.icon {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  box-shadow: inset 0 0 0 1px var(--edge);
}
.icon svg { width: 19px; height: 19px; fill: none; stroke: var(--ink); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.key, kbd {
  font: 500 13px/1 "Space Grotesk", system-ui, sans-serif;
  display: inline-block;
  padding: 5px 8px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.07);
  box-shadow: inset 0 0 0 1px var(--edge);
  color: var(--ink);
  white-space: nowrap;
}

/* ---- screens -------------------------------------------------------------------------------- */
.screen {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: flex-end;             /* phone: sheets rise from the bottom */
  justify-content: center;
  padding: calc(var(--safe-t) + 12px) 0 var(--safe-b);
  background: var(--scrim, radial-gradient(120% 80% at 50% 40%, rgba(18, 17, 16, 0.55), rgba(10, 10, 9, 0.88)));
  /* Shown and hidden with the hidden attribute, never with opacity alone: a transition that gets
     throttled (a background tab, a frame off screen) leaves a half-faded menu sitting on the board
     for ever. The entrance is animated; the exit is immediate. */
  animation: fadeIn 0.24s var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } }
.screen.bare { background: none; pointer-events: none; align-items: center; }

.sheet {
  width: min(560px, 100%);
  max-height: calc(100dvh - var(--safe-t) - 24px);
  overflow: auto;
  background: var(--panel);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -1px 0 var(--edge-strong), 0 -30px 70px rgba(0, 0, 0, 0.55);
  padding: 22px 20px calc(22px + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.screen .sheet { transform: none; animation: rise 0.32s var(--ease); }
@keyframes rise { from { transform: translateY(16px); opacity: 0; } }
.sheet::before {
  content: "";
  width: 38px; height: 4px;
  border-radius: 99px;
  background: var(--edge-strong);
  margin: -8px auto 2px;
}
.sheet-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.eyebrow { margin: 0 0 2px; font-size: 12px; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); }
.sheet h2 { margin: 0; font-size: clamp(26px, 7vw, 32px); font-weight: 700; letter-spacing: -0.03em; line-height: 1.05; }

/* home: the landing page. The board behind it is a real table of four bots, playing. */
#home { align-items: center; }
.hero {
  display: flex; flex-direction: column; align-items: center; gap: 22px;
  text-align: center; padding: 28px 22px; max-width: 760px;
}
.wordmark {
  margin: 0;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  text-transform: uppercase;
}
.wordmark .w1 {
  font-weight: 700;
  font-size: clamp(46px, 13.5vw, 118px);
  line-height: 0.86;
  letter-spacing: -0.045em;
  background: linear-gradient(100deg, var(--s0), var(--s2) 38%, var(--s1) 68%, var(--s3));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.wordmark .w2 {
  font-weight: 500;
  font-size: clamp(15px, 4.2vw, 30px);
  letter-spacing: 0.34em;
  text-indent: 0.34em;             /* tracking pushes the last letter out; put it back */
  color: var(--ink);
  opacity: 0.86;
}
.lede { margin: 0; font-size: clamp(16px, 4.2vw, 20px); color: var(--dim); max-width: 30em; line-height: 1.45; }
.lede em { color: var(--ink); font-style: normal; font-weight: 500; }
.cta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; }

.facts {
  list-style: none; margin: 4px 0 0; padding: 0;
  display: grid; gap: 10px; width: 100%;
  grid-template-columns: 1fr;
  text-align: left;
}
.facts li {
  display: flex; flex-direction: column; gap: 3px;
  padding: 13px 15px;
  border-radius: 12px;
  background: rgba(233, 228, 216, 0.035);
  box-shadow: inset 0 0 0 1px var(--edge);
  font-size: 14px; color: var(--dim); line-height: 1.4;
}
.facts b { font-weight: 700; color: var(--ink); font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; }
.strap { margin: 0; font-size: 12.5px; letter-spacing: 0.13em; text-transform: uppercase; color: var(--faint); }

/* lobby */
.seats { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seats li {
  display: flex; align-items: center; gap: 9px;
  padding: 12px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.045);
  font-weight: 500;
  min-height: 52px;
}
.seats li .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; box-shadow: 0 0 12px currentColor; }
.seats li .who { color: var(--faint); font-weight: 400; margin-left: auto; font-size: 13px; }
.seats li.you { box-shadow: inset 0 0 0 1.5px var(--edge-strong); background: rgba(255, 255, 255, 0.08); }

.field { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.field .eyebrow { margin: 0; }
.seg { display: inline-flex; border-radius: 12px; padding: 3px; background: rgba(255, 255, 255, 0.05); box-shadow: inset 0 0 0 1px var(--edge); }
.seg button { border-radius: 10px; padding: 9px 15px; font-size: 15px; font-weight: 500; color: var(--dim); min-height: 42px; }
.seg button.on { background: var(--ink); color: var(--bg); font-weight: 700; }
.seg button:disabled { cursor: default; opacity: 0.55; }

.how { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.how li { color: var(--dim); font-size: 15px; line-height: 1.5; }

.tally { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.tally li { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.tally .dot { width: 12px; height: 12px; border-radius: 50%; box-shadow: 0 0 12px currentColor; }
.tally .pips { margin-left: auto; letter-spacing: 4px; color: var(--dim); }

#creditList { display: flex; flex-direction: column; gap: 10px; max-height: 46dvh; overflow: auto; }
#creditList p { margin: 0; color: var(--dim); font-size: 15px; }
#creditList b { color: var(--ink); font-weight: 500; }
#creditList a { color: var(--ink); }

/* ---- the in-game bars ----------------------------------------------------------------------- */
.hud { position: fixed; inset: 0; z-index: 3; pointer-events: none; }
.bar {
  position: fixed;
  left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 calc(12px + var(--safe-l)) 0 calc(12px + var(--safe-r));
  background: linear-gradient(180deg, rgba(14, 13, 12, 0.92), rgba(14, 13, 12, 0.72));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  pointer-events: auto;
}
.bar.top {
  top: 0;
  height: calc(var(--bar-top) + var(--safe-t));
  padding-top: var(--safe-t);
  box-shadow: 0 1px 0 var(--edge);
}
.bar.bottom {
  bottom: 0;
  min-height: calc(var(--bar-bottom) + var(--safe-b));
  padding-bottom: var(--safe-b);
  box-shadow: 0 -1px 0 var(--edge);
  justify-content: center;
}
.round { font-weight: 700; font-size: 14px; white-space: nowrap; letter-spacing: -0.02em; }
.scores { list-style: none; margin: 0; padding: 0; display: flex; gap: 12px; flex: 1; justify-content: center; }
.scores li { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; font-size: 14px; white-space: nowrap; transition: opacity 0.3s; }
.scores li.out { opacity: 0.32; }
.scores li.out .name { text-decoration: line-through; }
.scores .dot { width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 10px currentColor; }
.scores .pips { color: var(--faint); letter-spacing: 2px; font-size: 12px; }
.clock { font-variant-numeric: tabular-nums; font-size: 14px; color: var(--dim); white-space: nowrap; }
.clock.warn { color: var(--warn); font-weight: 700; }

.prompts { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; color: var(--dim); font-size: 13.5px; }
.prompts span { display: inline-flex; align-items: center; gap: 7px; }

/* Touch: the bottom of a phone is the only part a thumb reaches, so it carries the whole control
   deck — which of the two things you are doing, and how much ink is left to do it with. */
body[data-input="touch"] { --bar-bottom: 152px; }
.bar.bottom { flex-direction: column; justify-content: center; gap: 2px; }
.deck { width: 100%; max-width: 560px; padding-top: 10px; }
.ink-bar {
  position: relative;
  display: flex;
  height: 10px;
  border-radius: 99px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 1px var(--edge);
}
.ink-bar i { display: block; height: 100%; transition: width 0.12s linear; }
.ink-bar .pool { background: var(--me, var(--ink)); }
.ink-bar .wall { background: var(--me, var(--ink)); opacity: 0.42; }
.ink-bar .out { background: var(--me, var(--ink)); opacity: 0.16; }
.ink-bar .cap { position: absolute; top: -2px; bottom: -2px; width: 2px; background: rgba(255, 255, 255, 0.45); border-radius: 2px; }
.ink-legend { display: flex; gap: 14px; justify-content: center; margin-top: 6px; font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--faint); }
.ink-legend span::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 2px; margin-right: 5px; background: var(--me, var(--ink)); }
.ink-legend .wall::before { opacity: 0.42; }
.ink-legend .out::before { opacity: 0.16; }
.thumbs { display: flex; align-items: stretch; justify-content: space-between; gap: 12px; width: 100%; max-width: 560px; padding: 10px 0; }
.thumb {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  padding: 10px 6px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--dim);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 0 0 1px var(--edge);
  border-radius: 16px;
  min-height: 84px;
}
.thumb svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.thumb.on { color: var(--bg); background: var(--ink); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45); }
.thumb.on svg { stroke-width: 2; }
.ink-read { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; line-height: 1; color: var(--dim); min-width: 82px; }
.ink-read b { font-size: 34px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: -0.03em; }
.ink-read i { font-style: normal; font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; margin-top: 4px; }

.banner {
  font-weight: 700;
  font-size: clamp(34px, 11vw, 78px);
  letter-spacing: -0.04em;
  text-align: center;
  line-height: 1;
  text-shadow: 0 6px 40px rgba(0, 0, 0, 0.9);
  animation: pop 0.35s var(--ease);
}
.banner small { display: block; font-size: clamp(14px, 3.6vw, 20px); font-weight: 500; letter-spacing: -0.01em; color: var(--dim); margin-top: 10px; }
@keyframes pop { from { opacity: 0; transform: scale(0.94) translateY(8px); } }

/* the line look keeps its buttons as flat bone rectangles, the way Spin Defense does */
html[data-look="line"] .go { background: var(--go); box-shadow: none; border-radius: 8px; }
html[data-look="line"] .ghost, html[data-look="line"] .seg, html[data-look="line"] .icon { border-radius: 8px; }
html[data-look="line"] .sheet { border-radius: 12px 12px 0 0; }
html[data-look="line"] .thumb { border-radius: 10px; }

/* ---- the television ------------------------------------------------------------------------- */
#tv { position: fixed; left: 0; right: 0; bottom: 0; z-index: 2; display: flex; justify-content: center; padding: 0 0 18px; pointer-events: none; }
.tv-card { display: flex; align-items: baseline; gap: 18px; padding: 10px 22px; border-radius: 14px; background: rgba(11, 13, 18, 0.72); box-shadow: inset 0 0 0 1px var(--edge); backdrop-filter: blur(10px); }
.tv-card .eyebrow { margin: 0; }
.tv-host { margin: 0; color: var(--dim); font-size: 18px; }
.tv-code { margin: 0; font-size: 34px; font-weight: 700; letter-spacing: 0.22em; line-height: 1; }
body[data-tv] .bar.top { height: calc(70px + var(--safe-t)); }
body[data-tv] .round { font-size: 19px; }
body[data-tv] .scores li { font-size: 19px; gap: 8px; }
body[data-tv] .scores .dot { width: 14px; height: 14px; }
body[data-tv] .scores .pips { font-size: 16px; }
body[data-tv] .clock { font-size: 19px; }
body[data-tv] .bar.bottom, body[data-tv] #leave { display: none; }
body[data-tv] .banner { font-size: clamp(48px, 9vw, 110px); }

.head-buttons { display: flex; gap: 8px; }
.code-input {
  font: 700 34px/1 "Space Grotesk", system-ui; letter-spacing: 0.3em; text-align: center;
  padding: 16px; border-radius: 14px; border: 0; width: 100%;
  background: rgba(255, 255, 255, 0.06); color: var(--ink); box-shadow: inset 0 0 0 1px var(--edge);
}
.code-input:focus { outline: 2px solid var(--ink); outline-offset: 2px; }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bar-bottom) + var(--safe-b) + 16px);
  transform: translateX(-50%) translateY(8px);
  background: var(--ink);
  color: var(--bg);
  font-weight: 600;
  font-size: 14px;
  padding: 11px 16px;
  border-radius: 12px;
  z-index: 7;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s var(--ease);
}
#toast.on { opacity: 1; transform: translateX(-50%); }

/* ---- bigger screens ------------------------------------------------------------------------- */
@media (min-width: 720px) {
  :root { --bar-top: 56px; --bar-bottom: 48px; }
  body[data-input="touch"] { --bar-bottom: 152px; }
  .screen { align-items: center; padding: 24px; }
  .sheet {
    border-radius: 22px;
    padding: 26px 28px;
    box-shadow: 0 0 0 1px var(--edge), 0 40px 90px rgba(0, 0, 0, 0.55);
  }
  .sheet::before { display: none; }
  .bar { padding-left: 18px; padding-right: 18px; }
  .prompts { font-size: 14px; }
}

@media (max-width: 460px) {
  .scores li .name { display: none; }
  .scores { gap: 14px; }
  .round { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
