/* Blob — page chrome. The board itself is drawn on the canvas by client.js.
 *
 * This one is dark in both themes, unlike onreyn.nl. A game board wants a
 * quiet background so the moving colours carry the eye, and a light board makes
 * pale blobs disappear into it.
 */

:root {
  color-scheme: dark;
  --bg: #14140f;
  --fg: #f0efe9;
  --muted: #8f8f86;
  --rule: #2c2c26;
  --panel: #1b1b15;
  --accent: #9dbe6b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font: 400 16px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#board {
  display: block;
  width: 100%;
  height: 100%;
  /* The board owns every gesture on it: without this, dragging to steer scrolls
     the page on a phone and pinch-zooms it on a tablet. */
  touch-action: none;
  cursor: crosshair;
}

/* ------------------------------------------------------------------ hud --- */

.hud {
  position: fixed;
  inset: 0;
  padding: max(.75rem, env(safe-area-inset-top)) clamp(.75rem, 2vw, 1.25rem);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  /* The HUD is information, not controls — clicks belong to the board beneath
     it. Individual children opt back in where they need to. */
  pointer-events: none;
}

.hud[hidden] { display: none; }

.hud-left { display: flex; flex-direction: column; gap: .4rem; }

.stat { display: flex; align-items: baseline; gap: .45rem; }

.stat-label {
  font-size: .625rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-value {
  font-size: 1.35rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  /* A dark outline keeps the number readable when a bright blob slides under
     it. Cheaper and sharper than a drop-shadow filter. */
  text-shadow: 0 1px 3px rgba(0, 0, 0, .8);
}

.stat-quiet .stat-value { font-size: .9rem; font-weight: 400; color: var(--muted); }

.board-panel {
  min-width: 8.5rem;
  padding: .6rem .75rem .7rem;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: color-mix(in srgb, var(--panel) 82%, transparent);
  backdrop-filter: blur(6px);
}

.board-title {
  margin: 0 0 .35rem;
  font-size: .625rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}

.board-list {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: .8rem;
  font-variant-numeric: tabular-nums;
}

.board-list li {
  display: flex;
  justify-content: space-between;
  gap: .6rem;
  padding: .07rem 0;
  color: var(--muted);
}

.board-list li.me { color: var(--accent); font-weight: 600; }
.board-list .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* -------------------------------------------------------------- overlays --- */

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(4px);
  z-index: 10;
}

.overlay[hidden] { display: none; }

.panel {
  width: min(24rem, 100%);
  text-align: center;
  padding: 2rem 2rem 1.5rem;
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 20px 50px rgba(0, 0, 0, .5);
}

.title {
  margin: 0;
  font-size: clamp(2.25rem, 9vw, 3rem);
  font-weight: 600;
  letter-spacing: -.035em;
}

.sub { margin: .5rem 0 1.5rem; color: var(--muted); font-size: .9rem; }

.kicker {
  margin: 0;
  font-size: .7rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}

.score {
  margin: .3rem 0 .2rem;
  font-size: clamp(2.5rem, 11vw, 3.5rem);
  font-weight: 600;
  letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
}

.form { display: flex; flex-direction: column; gap: .6rem; }

.input {
  font: inherit;
  text-align: center;
  padding: .6rem .9rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: #101009;
  color: var(--fg);
}

.input::placeholder { color: #5f5f58; }
.input:focus { outline: none; border-color: var(--accent); }

.button {
  font: inherit;
  font-weight: 600;
  padding: .6rem 1.4rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent);
  color: #14140f;
  cursor: pointer;
  transition: opacity .15s ease, transform .15s ease;
}

.button:hover { opacity: .9; }
.button:active { transform: translateY(1px); }
.button:disabled { opacity: .45; cursor: default; }

.hint { margin: .9rem 0 0; font-size: .75rem; color: var(--muted); }
.foot { margin: 1.25rem 0 0; font-size: .7rem; color: #5f5f58; }

kbd {
  font: inherit;
  font-size: .95em;
  padding: 0 .3em;
  border: 1px solid var(--rule);
  border-radius: 4px;
}

/* ----------------------------------------------------- instructions list --- */

.keys {
  margin: 0 0 .25rem;
  padding: 0;
  list-style: none;
  text-align: left;
  font-size: .8rem;
  color: var(--muted);
}

.keys li { display: flex; align-items: baseline; gap: .5rem; padding: .12rem 0; }
.keys-k { flex: none; width: 4.2rem; text-align: right; }
.keys-touch { display: none; margin: 0; font-size: .8rem; color: var(--muted); }
.keys-touch b { color: var(--fg); font-weight: 600; }

/* A finger cannot press space, and a keyboard list is noise on a phone. */
@media (pointer: coarse) {
  .keys { display: none; }
  .keys-touch { display: block; }
}

/* ------------------------------------------------------- touch controls --- */

.pad {
  position: fixed;
  right: max(.9rem, env(safe-area-inset-right));
  bottom: max(1.1rem, env(safe-area-inset-bottom));
  display: none;              /* enabled for coarse pointers below */
  align-items: flex-end;
  gap: .7rem;
  z-index: 5;
}

.pad[hidden] { display: none !important; }

.pad-btn {
  -webkit-tap-highlight-color: transparent;
  font: inherit;
  display: grid;
  place-items: center;
  gap: .05rem;
  width: 4.6rem;
  height: 4.6rem;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 50%;
  background: color-mix(in srgb, var(--panel) 78%, transparent);
  backdrop-filter: blur(6px);
  color: var(--fg);
  /* The canvas listens for pointer events too; these buttons must take their
     own and stop them propagating, or every tap also yanks the aim. */
  touch-action: none;
  user-select: none;
  transition: transform .08s ease, background .12s ease;
}

.pad-btn-main {
  width: 5.4rem;
  height: 5.4rem;
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 22%, var(--panel));
}

/* Pressed state is driven by a class from JS rather than :active, because a
   captured pointer does not always give :active on touch. */
.pad-btn.held {
  transform: scale(.93);
  background: color-mix(in srgb, var(--accent) 42%, var(--panel));
}

.pad-icon { font-size: 1.25rem; line-height: 1; }
.pad-btn-main .pad-icon { font-size: 1.5rem; }

.pad-label {
  font-size: .625rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

.pad-btn-main .pad-label { color: var(--fg); }

@media (pointer: coarse) {
  .pad { display: flex; }
}

/* On a short landscape phone the leaderboard and the buttons compete for the
   right-hand side. The board is the one that can afford to shrink. */
@media (pointer: coarse) and (max-height: 500px) {
  .board-panel { min-width: 7rem; font-size: .75rem; }
  .pad-btn { width: 3.9rem; height: 3.9rem; }
  .pad-btn-main { width: 4.5rem; height: 4.5rem; }
}

/* ---------------------------------------------------------------- toast --- */

.toast {
  position: fixed;
  left: 50%;
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: .45rem 1rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: .8rem;
  z-index: 20;
}

.toast[hidden] { display: none; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-height: 560px) {
  .panel { padding: 1.25rem 1.5rem 1rem; }
  .sub { margin-bottom: 1rem; }
}
