/* Grove Grid. Black and white: black field, grey rivals, you in white. Colour only where it means something: Attack is pink.
   body.colour (?tweaks Look switch) is the green field and a hundred colours. */
@font-face { font-family: "SG"; src: url("/fonts/space-grotesk-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "SG"; src: url("/fonts/space-grotesk-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root { --field: #000000; --deep: #262626; --ink: #ffffff; --soft: rgba(255, 255, 255, 0.62); --d: #ffffff; --a: #ff3f8e; --btn-ink: #000000; }
body.colour { --field: #2c8c3c; --deep: #237531; --ink: #f6fff2; --soft: rgba(246, 255, 242, 0.7); --btn-ink: #17521f; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--field); color: var(--ink); font-family: "SG", system-ui, sans-serif; font-weight: 700; overscroll-behavior: none; touch-action: none; -webkit-user-select: none; user-select: none; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
[hidden] { display: none !important; }
#app { position: fixed; inset: 0; height: var(--h, 100dvh); }
.screen { position: absolute; inset: 0; padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(16px, env(safe-area-inset-left)); }

.big { display: block; width: 100%; height: 58px; border-radius: 12px; background: var(--ink); color: var(--btn-ink); font-size: 24px; transition: transform 0.08s, opacity 0.2s; }
.big:active { transform: scale(0.98); }
.big.alt { background: var(--deep); color: var(--ink); }
.big.off { background: var(--deep); color: var(--soft); }
.big kbd { font: inherit; font-size: 14px; padding: 1px 7px; margin-left: 10px; border-radius: 5px; border: 2px solid currentColor; vertical-align: 3px; opacity: 0.55; }
.link { font-size: 17px; color: var(--soft); padding: 8px 4px; }
.pair { display: flex; gap: 8px; }
.seg { display: flex; gap: 6px; }
.seg button { flex: 1; height: 44px; border-radius: 10px; font-size: 18px; color: var(--soft); background: var(--deep); }
.seg button.on { background: var(--ink); color: var(--btn-ink); }
.ic { display: inline-block; width: 1em; height: 1em; background: currentColor; -webkit-mask: var(--m) center / contain no-repeat; mask: var(--m) center / contain no-repeat; }
.ic.d { --m: url("/art/shield.svg"); } .ic.a { --m: url("/art/arrow.svg"); }
.sheet { position: absolute; inset: 0; z-index: 10; background: var(--field); display: flex; flex-direction: column; justify-content: flex-end; gap: 12px; padding: 24px max(16px, env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.sheet p { margin: 0; font-size: clamp(24px, 7vw, 36px); line-height: 1.1; letter-spacing: -0.02em; }
.sheet input { height: 58px; border-radius: 12px; border: 0; padding: 0 16px; font: inherit; font-size: 24px; background: var(--deep); color: var(--ink); outline: none; }
.sheet input::placeholder { color: var(--soft); }
#inviteUrl { font-size: 20px; color: var(--soft); word-break: break-all; -webkit-user-select: all; user-select: all; }
.sheet .link { align-self: center; }
#rulesSheet { z-index: 20; justify-content: center; }
.rules { margin: 0 auto; padding: 0 0 0 1.3em; max-width: 560px; display: flex; flex-direction: column; gap: 14px; font-size: clamp(18px, 5vw, 23px); line-height: 1.25; font-weight: 500; }
.rules b { font-weight: 700; padding: 0 6px; border-radius: 5px; }
.rules b.d { background: var(--d); color: var(--btn-ink); } .rules b.a { background: var(--a); color: #fff; }
@media (max-height: 640px) { .rules { gap: 9px; font-size: 17px; } }
#rulesSheet .big { max-width: 560px; width: 100%; align-self: center; margin-top: 14px; }
.doorLinks { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 18px; }
.doorLinks .link { padding: 2px 8px; }

/* ---- door: bots playing a whole game full bleed, the name over it ---- */
#door { display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; }
#doorBoard { position: absolute; inset: 0; width: 100%; height: 100%; }
.doorTop, .doorFoot { position: relative; width: 100%; max-width: 520px; align-self: center; }
.doorTop { padding-top: 7vh; }
.title { margin: 0; font-size: clamp(76px, 25vw, 150px); line-height: 0.86; letter-spacing: -0.05em; }
.rule { margin: 16px 0 0; font-size: 21px; line-height: 1.25; }
.doorFoot { display: flex; flex-direction: column; gap: 10px; padding-bottom: 20px; }

/* ---- game: fixed rows; the board takes what is left and never changes size during a game ---- */
#game { display: grid; grid-template-columns: 1fr; grid-template-rows: 44px 36px 1fr 44px 56px 74px; grid-template-areas: "top" "race" "board" "say" "jobs" "foot"; }
#top { grid-area: top; display: flex; align-items: center; justify-content: space-between; font-size: 18px; }
#top .chips { display: flex; gap: 10px; }
#race { grid-area: race; display: flex; justify-content: space-between; gap: 10px; align-items: center; font-size: 15px; overflow: hidden; white-space: nowrap; }
#race .who { display: flex; align-items: center; gap: 6px; flex: none; }
#race .who i { width: 12px; height: 12px; border-radius: 3px; flex: none; }
#race .who.done::after { content: "✓"; color: var(--soft); font-weight: 500; }
#race .who.out { opacity: 0.45; }
#race .goal { margin-left: auto; color: var(--soft); font-weight: 500; flex: none; }
#boardBox { grid-area: board; min-height: 0; display: flex; align-items: center; justify-content: center; }
#board { touch-action: none; display: block; }
#say { grid-area: say; margin: 0; font-size: clamp(13px, 3.9vw, 16px); line-height: 20px; text-align: center; color: var(--soft); font-weight: 500; display: flex; align-items: center; justify-content: center; overflow: hidden; }
#say.warn { color: var(--ink); font-weight: 700; }
#jobsBar { grid-area: jobs; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding-top: 2px; }
/* readouts, not buttons: shield pips that empty as you place them, and your arrow count in pink */
.job { display: flex; justify-content: center; align-items: center; gap: 10px; font-size: 30px; }
.job.d { color: var(--ink); gap: 6px; } .job.a { color: var(--a); }
.job .ic.used { opacity: 0.2; }
#foot { grid-area: foot; padding: 8px 0 8px; }
#foot .pair .big { flex: 1; }
#endSheet { grid-area: 4 / 1 / 7 / 2; display: flex; flex-direction: column; justify-content: space-between; gap: 6px; padding: 2px 0 6px; background: var(--field); z-index: 2; }
#endLine { margin: 0; font-size: clamp(24px, 7vw, 38px); line-height: 1.05; letter-spacing: -0.02em; text-align: center; }
#endSheet .pair .big { flex: 1; }
#home { align-self: center; padding: 4px; }
body.ended #say, body.ended #jobsBar, body.ended #foot { visibility: hidden; }

/* short landscape phones: board on the left, everything else beside it */
@media (orientation: landscape) and (max-height: 540px) {
  #game { grid-template-columns: auto 1fr; grid-template-rows: 44px 36px 1fr 56px 74px; grid-template-areas: "board top" "board race" "board say" "board jobs" "board foot"; column-gap: 16px; }
  #boardBox { padding: 8px 0; }
  #race { flex-wrap: wrap; align-content: center; justify-content: flex-start; font-size: 14px; line-height: 16px; row-gap: 2px; column-gap: 14px; }
  #endSheet { grid-area: 3 / 2 / 6 / 3; }
  .doorTop { padding-top: 12px; }
  .title { font-size: 64px; }
  .rule { margin-top: 6px; font-size: 17px; }
  .doorFoot { gap: 6px; padding-bottom: 10px; }
  .doorFoot .big { height: 48px; font-size: 20px; }
  .doorFoot .seg button { height: 38px; }
}
/* desktop: one centred column */
@media (min-width: 900px) and (min-height: 600px) {
  #game { grid-template-columns: minmax(0, 760px); justify-content: center; grid-template-rows: 56px 44px 1fr 48px 60px 80px; }
  #top { font-size: 22px; } #top .link { font-size: 20px; }
  #race { font-size: 19px; } #race .who i { width: 15px; height: 15px; }
  #say { font-size: 18px; }
  .doorTop, .doorFoot { max-width: 620px; }
  .rules { font-size: 24px; max-width: 680px; } #rulesSheet .big { max-width: 680px; }
}
