/* Everything is uppercase monospace with hard offset shadows and no curves, which is the whole
   look: a cabinet in a dark room. Two accent colours, one per pond, and nothing else. */

:root {
  --night: #0b1410;
  --bog: #101c15;
  --line: #24382a;
  --ink: #07100b;
  --pale: #e8ffd8;
  --bone: #a8c08e;
  --green: #79e04a;
  --purple: #c86bff;
  --fly: #ffe14d;
  --warn: #ff6a5e;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--night);
  color: var(--pale);
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  -webkit-text-size-adjust: 100%;
}

body { min-height: 100vh; min-height: 100dvh; }

/* scanlines and a vignette over the whole page */
.crt {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9;
  background:
    repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.14) 0 1px, rgba(0, 0, 0, 0) 1px 4px),
    radial-gradient(130% 110% at 50% 45%, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.65) 100%);
}

a { color: var(--green); }

/* ---- logo ---- */

.logo {
  margin: 0 0 0.4em;
  line-height: 0.86;
  font-size: clamp(2.6rem, 9vw, 5.6rem);
  letter-spacing: 0.04em;
}
.logo span { display: block; }
.logo .l1 { color: var(--pale); text-shadow: 4px 4px 0 var(--ink), 8px 8px 0 #1c2b1f; }
.logo .l2 { color: var(--green); text-shadow: 4px 4px 0 var(--ink), 8px 8px 0 #2b4a1d; }

/* ---- shared page shell ---- */

.shell { display: grid; place-items: center; padding: 6vmin 5vw; }
.hero { width: min(760px, 100%); }
.hero.narrow { width: min(460px, 100%); text-align: center; }
.tag { color: var(--bone); font-size: 0.95rem; margin: 0 0 2.2em; }

button, .big {
  font: inherit;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink);
  background: var(--green);
  border: 3px solid var(--ink);
  box-shadow: 5px 5px 0 var(--ink);
  padding: 0.8em 1.2em;
  cursor: pointer;
  display: inline-block;
  text-decoration: none;
}
button:active, .big:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--ink); }

.host-form { margin: 0 0 2.4em; }
.host-form .big { font-size: clamp(1.1rem, 3.4vw, 1.5rem); }
.host-form .sub { display: block; margin-top: 0.9em; color: var(--bone); font-size: 0.72rem; letter-spacing: 0.14em; }

.joiner label { display: block; color: var(--bone); font-size: 0.72rem; margin-bottom: 0.6em; letter-spacing: 0.2em; }
.joiner .row { display: flex; gap: 0.6rem; align-items: stretch; }
.joiner input {
  font: inherit;
  font-size: 1.6rem;
  letter-spacing: 0.4em;
  width: 6.5em;
  text-align: center;
  text-transform: uppercase;
  color: var(--fly);
  background: #0a140d;
  border: 3px solid var(--line);
  padding: 0.3em 0 0.3em 0.4em;
}
.joiner input:focus { outline: none; border-color: var(--fly); }
.joiner button { background: var(--fly); }
.big-joiner { margin-top: 2em; }
.big-joiner .row { justify-content: center; }

.rules { margin-top: 3.4em; border-top: 2px solid var(--line); padding-top: 1.6em; }
.rules h2 { font-size: 0.78rem; letter-spacing: 0.26em; color: var(--bone); margin: 0 0 1.2em; }
.rules ol { margin: 0 0 1.4em; padding-left: 1.4em; line-height: 1.75; font-size: 0.84rem; }
.rules li { margin-bottom: 0.5em; color: var(--pale); }
.rules b { color: var(--green); }
.fine { color: var(--bone); font-size: 0.72rem; line-height: 1.8; text-transform: none; letter-spacing: 0.04em; }
.fine b { color: var(--pale); }
.fine code { color: var(--fly); }
.warn { color: var(--warn); font-size: 0.8rem; }

/* ---- host screen ---- */

body.host { overflow: hidden; }
.hidden { display: none !important; }

.lobby {
  height: 100vh;
  height: 100dvh;
  padding: 3.4vmin 4vmin;
  display: flex;
  flex-direction: column;
  gap: 2vmin;
  overflow: hidden;
}
.lobby-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 4vmin; flex: 0 1 auto; min-height: 0; }
.lobby-left { min-width: 0; }
.lobby .logo { font-size: clamp(2.2rem, 6.4vw, 4.4rem); margin-bottom: 0.5em; }
.lobby-left .fine { margin: 0.5em 0 0; max-width: 36ch; }

.codeblock { text-align: right; }
.goto { margin: 0 0 0.9em; font-size: clamp(0.8rem, 1.8vw, 1.1rem); color: var(--bone); }
.goto b { color: var(--pale); }
.codelabel { margin: 0; font-size: 0.7rem; letter-spacing: 0.3em; color: var(--bone); }
.code {
  margin: 0.1em 0 0.4em;
  font-size: clamp(3rem, 11vw, 7rem);
  line-height: 1;
  color: var(--fly);
  letter-spacing: 0.14em;
  text-shadow: 5px 5px 0 var(--ink);
}
#qr { width: clamp(96px, 12vw, 150px); height: auto; border: 4px solid var(--pale); image-rendering: pixelated; }

.ponds { display: grid; grid-template-columns: 1fr 1fr; gap: 2.4vmin; flex: 1 1 0; min-height: 0; }
.pond { border: 3px solid var(--line); padding: 2vmin; }
.pond h2 { margin: 0 0 1.2vmin; font-size: clamp(0.9rem, 2.4vw, 1.5rem); }
.pond.p0 { border-color: #2d5a1c; }
.pond.p0 h2 { color: var(--green); }
.pond.p1 { border-color: #4b1f73; }
.pond.p1 h2 { color: var(--purple); }
.pond ul { list-style: none; margin: 0; padding: 0; }
.pond li {
  display: flex;
  align-items: center;
  gap: 0.8em;
  padding: 0.38em 0.2em;
  border-bottom: 1px solid #16241a;
  font-size: clamp(0.78rem, 1.8vw, 1.1rem);
}
.pond li.empty { color: #35482f; }
.pond li.gone { opacity: 0.4; }
.pond li .nm { flex: 1; }
.pond li .st { font-size: 0.7em; color: var(--bone); }
.pond li.ready .st { color: var(--green); }
.pond li .crown { font-size: 0.62em; color: var(--ink); background: var(--fly); padding: 0.25em 0.5em; }
.pond li .vip { font-size: 0.62em; color: var(--ink); background: var(--pale); padding: 0.25em 0.5em; }

.why { margin: 0; font-size: clamp(0.85rem, 2.2vw, 1.25rem); color: var(--warn); }
.why.go { color: var(--green); }
.lobby .fine { margin: 0; }

.arena { height: 100vh; height: 100dvh; display: grid; place-items: center; position: relative; }
#stage {
  width: min(100vw, calc(100dvh * 16 / 9));
  height: auto;
  image-rendering: pixelated;
  display: block;
}
.floating-code {
  position: fixed;
  bottom: 0.6rem;
  right: 0.9rem;
  margin: 0;
  font-size: 0.7rem;
  color: #567048;
  z-index: 10;
}

.result {
  position: absolute;
  inset: 8% 12%;
  background: rgba(7, 16, 11, 0.94);
  border: 4px solid var(--pale);
  padding: 3vmin;
  display: grid;
  place-content: center;
  text-align: center;
  z-index: 8;
}
.result h2 { margin: 0; font-size: clamp(1.6rem, 6vw, 4rem); }
.result h2.t0 { color: var(--green); }
.result h2.t1 { color: var(--purple); }
.result .kind { margin: 0.3em 0 1.6em; color: var(--fly); font-size: clamp(0.8rem, 2.4vw, 1.4rem); letter-spacing: 0.3em; }
.result table { border-collapse: collapse; margin: 0 auto; font-size: clamp(0.65rem, 1.6vw, 1rem); }
.result th { color: var(--bone); font-weight: normal; padding: 0.4em 1em; font-size: 0.8em; letter-spacing: 0.2em; }
.result td { padding: 0.35em 1em; }
.result tr.t0 td:first-child { color: var(--green); }
.result tr.t1 td:first-child { color: var(--purple); }
.result .again { margin: 2em 0 0; color: var(--bone); font-size: 0.75rem; }

/* ---- phone ----

   Landscape is the real layout: thumbs on the outside, status in the middle, nothing to reach
   across. Portrait still works (the lobby lives there, and so does anyone with rotation locked),
   it just stacks. */

body.pad {
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
body.pad.t1 { --green: var(--purple); }

.gate { padding: 7vmin 7vw; text-align: center; overflow-y: auto; }
.gate .logo { font-size: clamp(2rem, 12vw, 3.2rem); }
.roomline { color: var(--bone); font-size: 0.8rem; margin: 0 0 2em; }
.roomline b { color: var(--fly); font-size: 1.6em; letter-spacing: 0.25em; }
.namef { display: grid; gap: 0.9em; }
.namef label { font-size: 0.7rem; letter-spacing: 0.3em; color: var(--bone); }
.namef input {
  font: inherit;
  font-size: 1.5rem;
  text-align: center;
  text-transform: uppercase;
  color: var(--pale);
  background: #0a140d;
  border: 3px solid var(--line);
  padding: 0.5em;
}
.namef input:focus { outline: none; border-color: var(--green); }
.namef button { font-size: 1.2rem; }
.gate .install { margin-top: 2.4em; }
.gate .fine { margin-top: 1.4em; }

.install { background: var(--fly); color: var(--ink); font-size: 0.9rem; }

.deck { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 2.5vmin 3vw; gap: 2vmin; }
.deck.dead { filter: grayscale(0.8) brightness(0.6); }
.status { display: flex; flex-direction: column; gap: 2vmin; min-height: 0; flex: 1; }
.padhead { display: flex; justify-content: space-between; align-items: baseline; gap: 1em; font-size: 0.7rem; }
.padhead .who { color: var(--green); }
.padhead .tally { color: var(--bone); }
.hint {
  margin: 0;
  flex: 1;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: clamp(0.95rem, 5vw, 1.5rem);
  line-height: 1.5;
  color: var(--fly);
  border: 2px solid var(--line);
  padding: 0.6em;
}

.lobbyctl { display: grid; gap: 2.2vmin; align-content: center; }
.lobbyctl button { width: 100%; font-size: clamp(0.9rem, 4.4vw, 1.2rem); background: #1b2b1f; color: var(--pale); }
.lobbyctl button.lit { background: var(--green); color: var(--ink); }
.lobbyctl button.start { background: var(--fly); color: var(--ink); font-size: clamp(1.1rem, 5.4vw, 1.5rem); }

.pad-side { display: none; gap: 3vw; min-width: 0; }
.pad-side button {
  width: 100%;
  height: 100%;
  min-height: 0;
  font-size: 1.6rem;
  background: #1b2b1f;
  color: var(--pale);
  border-color: var(--ink);
  display: grid;
  place-content: center;
  padding: 0;
}
.pad-side .dir { font-size: clamp(1.8rem, 7vw, 3rem); }
.pad-side .flap { background: var(--green); color: var(--ink); font-size: clamp(1.3rem, 5vw, 2.2rem); }
.pad-side .drop { font-size: 0.78rem; line-height: 1.3; }
.pad-side .drop small { font-size: 0.78em; color: var(--bone); }
.pad-side .drop.lit { background: var(--fly); color: var(--ink); }
.pad-side button.down { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--ink); filter: brightness(1.35); }

/* in a match the deck becomes a controller */
.deck.playing { display: grid; gap: 3vw; }
.deck.playing .pad-side { display: grid; }
.deck.playing .lobbyctl { display: none; }

@media (orientation: landscape) {
  .deck.playing {
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr) minmax(0, 1fr);
    grid-template-areas: "left status right";
    align-items: stretch;
  }
  .deck.playing .status { grid-area: status; }
  .deck.playing .pad-left { grid-area: left; grid-template-columns: 1fr 1fr; }
  .deck.playing .pad-right { grid-area: right; grid-template-rows: 0.42fr 1fr; }
  .deck.playing .hint { font-size: clamp(0.8rem, 2.6vw, 1.3rem); }
  .deck.playing .padhead {
    flex-direction: column;
    align-items: center;
    gap: 0.25em;
    font-size: 0.6rem;
    white-space: nowrap;
  }
}

@media (orientation: portrait) {
  .deck.playing {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-areas: "status status" "left right";
    align-content: end;
  }
  .deck.playing .status { grid-area: status; }
  .deck.playing .pad-left { grid-area: left; grid-template-columns: 1fr 1fr; height: 30vh; }
  .deck.playing .pad-right { grid-area: right; grid-template-rows: 0.4fr 1fr; height: 30vh; }
}

/* turn your phone */
.rotate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--night);
  place-content: center;
  text-align: center;
  padding: 10vw;
  gap: 1.2em;
}
body.pad.playing #rotate.armed { display: grid; }
@media (orientation: landscape) { body.pad.playing #rotate.armed { display: none; } }
.rotate .big-line { margin: 0; font-size: clamp(1.3rem, 7vw, 2rem); color: var(--fly); }
.rotate button { background: #1b2b1f; color: var(--bone); font-size: 0.78rem; justify-self: center; }
.phone-turn { justify-self: center; }
.phone-turn .ph {
  display: block;
  width: 52px;
  height: 86px;
  border: 4px solid var(--pale);
  border-radius: 2px;
  animation: turnit 2.4s ease-in-out infinite;
}
@keyframes turnit {
  0%, 30% { transform: rotate(0deg); }
  60%, 100% { transform: rotate(-90deg); }
}
@media (prefers-reduced-motion: reduce) {
  .phone-turn .ph { animation: none; transform: rotate(-90deg); }
}

/* the install hint on the landing page */
.steps { margin-top: 2.6em; border-top: 2px solid var(--line); padding-top: 1.4em; }
.steps h2 { font-size: 0.8rem; letter-spacing: 0.26em; color: var(--green); margin: 0 0 1em; }
.steps ol { margin: 0; padding-left: 1.4em; line-height: 1.9; font-size: 0.84rem; text-transform: none; letter-spacing: 0.03em; }
.steps b { color: var(--fly); }

/* ---- bufos ----

   Faces from bufo.fun, used for players and for the win conditions. They are drawings, not pixel
   art, so they scale smoothly rather than with the nearest-neighbour the canvas uses. Team one's
   bufos are hue-rotated to the purple pond so a face reads as a side at a glance. */

.av, .face, .trophy {
  display: block;
  flex: none;
  image-rendering: auto;
  object-fit: contain;
}
.av { width: clamp(26px, 3.2vw, 44px); height: clamp(26px, 3.2vw, 44px); }
.av.small { width: 24px; height: 24px; }
.av.tiny { width: 20px; height: 20px; display: inline-block; vertical-align: -4px; margin-right: .4em; }
.av.lg { width: clamp(42px, 6.4vw, 70px); height: clamp(42px, 6.4vw, 70px); }
.av.win { width: 54px; height: 54px; margin-bottom: .8em; }
.av.t1, .face.t1, .trophy.t1 { filter: hue-rotate(175deg) saturate(1.25); }

.strip { display: flex; flex-wrap: wrap; gap: .6rem; margin: 0 0 2.4em; }

.wins { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1.4rem; margin-bottom: 1.6em; }
.wincard { border: 2px solid var(--line); padding: 1.1rem; background: #0d1711; }
.wincard h3 { margin: 0 0 .5em; font-size: .78rem; letter-spacing: .18em; color: var(--green); }
.wincard p { margin: 0; font-size: .76rem; color: var(--bone); line-height: 1.7; text-transform: none; letter-spacing: .03em; }
.credit .av.tiny { float: left; margin: .1em .6em 0 0; }

.trophy { width: clamp(64px, 9vw, 112px); height: clamp(64px, 9vw, 112px); margin: 0 auto .4rem; }

.result td:first-child { width: 1px; padding-right: 0; }

.face { width: 30px; height: 30px; }
.padhead { align-items: center; }
.deck.playing .face { width: 22px; height: 22px; }
