/* КЛАД page styles. Same palette as the site; the game reads these variables. */
:root {
  --crt-bg: #0b1410;
  --crt-fg: #7bf7ad;
  --crt-dim: #5bbd8a;
  --crt-hot: #ffd479;
  --crt-rule: #23503c;
  --crt-dark: #163a2a;
  --crt-alert: #ff8a7a;   /* guards: 9.6:1 on --crt-bg */
  --crt-water: #2f5d8a;
  --crt-water-hi: #8fb4d9;
  /* Race ghosts by slot: neither the player's green nor the guards' red. */
  --crt-ghost-0: #f59cff;
  --crt-ghost-1: #7fdcff;
  --crt-ghost-2: #f2f2f2;
  --crt-ghost-3: #b8a4ff;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "DejaVu Sans Mono",
          "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
/* Nothing in the play area is text to select: a long press or a drag that
   starts on the field must not highlight the HUD, the canvas or the pad. */
.hud, .stage, .pad {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--crt-bg);
  color: var(--crt-fg);
  font: .85rem/1.5 var(--mono);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
.app {
  display: grid;
  height: 100vh;
  height: 100dvh;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  grid-template-areas: "hud" "stage" "pad" "foot";
}
.hud {
  grid-area: hud;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .3rem 1rem;
  padding: .45rem .8rem;
  border-bottom: 1px solid var(--crt-rule);
  color: var(--crt-dim);
  font-size: .68rem;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.hud b { color: var(--crt-fg); font-weight: 600; }
.hud .key { color: var(--crt-hot); }
.hud button {
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: var(--crt-dim);
  background: transparent;
  border: 1px solid var(--crt-rule);
  border-radius: .3rem;
  padding: 0 .5rem;
  cursor: pointer;
}
.hud button[aria-pressed="true"] { color: var(--crt-fg); border-color: var(--crt-dim); }
.hud button:focus-visible { outline: 2px solid var(--crt-hot); outline-offset: 2px; }
.hud [hidden] { display: none; }
.stage {
  grid-area: stage;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: .3rem;
}
canvas {
  display: block;
  touch-action: none;
  box-shadow: 0 0 0 1px var(--crt-rule);
  outline: none;
}
canvas:focus-visible { box-shadow: 0 0 0 2px var(--crt-hot); }
.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, .10) 0 1px, rgba(0, 0, 0, 0) 1px 3px);
}
.msg {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  text-align: center;
  background: rgba(11, 20, 16, .86);
}
.msg[hidden] { display: none; }
.msg p { margin: 0; }
.msg-title {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: .3em;
  text-shadow: 0 0 14px rgba(123, 247, 173, .45);
}
#msg-body { margin-top: .6rem; max-width: 30rem; color: var(--crt-dim); font-size: .78rem; }

/* Touch controls: only on coarse pointers. Portrait puts them under the
   field, landscape puts them beside it, thumbs where they already are. */
.pad { grid-area: pad; display: none; }
.pad button {
  font: inherit;
  color: var(--crt-fg);
  background: transparent;
  border: 1px solid var(--crt-dim);
  border-radius: .5rem;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.pad button:active { background: var(--crt-rule); }
.pad button:focus-visible { outline: 2px solid var(--crt-hot); outline-offset: 2px; }
.dpad {
  display: grid;
  grid-template-columns: repeat(3, 2.9rem);
  grid-template-rows: repeat(3, 2.9rem);
  gap: .2rem;
}
.dpad .up { grid-area: 1 / 2; }
.dpad .left { grid-area: 2 / 1; }
.dpad .right { grid-area: 2 / 3; }
.dpad .down { grid-area: 3 / 2; }
.fire {
  width: 5.4rem;
  height: 5.4rem;
  border-radius: 50% !important;
  color: var(--crt-hot) !important;
  border-color: var(--crt-hot) !important;
  letter-spacing: .1em;
  font-size: .75rem;
}
@media (hover: none) and (pointer: coarse) {
  .pad {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .5rem 1.2rem .8rem;
  }
}
/* A phone in portrait has about 660px to work with, and the field matters
   more than the footer (landscape hides it too). The credit is also on the
   home page; the privacy note is not, so a nick prompt must show it. */
@media (hover: none) and (pointer: coarse) and (orientation: portrait) and (max-height: 760px) {
  footer { display: none; }
}
@media (hover: none) and (pointer: coarse) and (orientation: landscape) {
  .app {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: "padl hud padr" "padl stage padr" "padl foot padr";
  }
  .pad { display: contents; }
  .dpad { grid-area: padl; align-self: center; margin: 0 .7rem; }
  .fire { grid-area: padr; align-self: center; margin: 0 .7rem; }
  footer { display: none; }
}
footer {
  grid-area: foot;
  padding: .4rem .8rem .6rem;
  border-top: 1px solid var(--crt-rule);
  color: var(--crt-dim);
  font-size: .62rem;
  line-height: 1.5;
}
footer p { margin: 0; }
footer a { color: var(--crt-hot); text-underline-offset: 3px; }
footer a:focus-visible { outline: 2px solid var(--crt-hot); outline-offset: 3px; }

/* Online: the stage notice, the nick prompt and the boards. Dialogs sit in
   the top layer, outside the unselectable play area; they scroll on a short
   landscape phone. */
.notice {
  position: absolute;
  left: 50%;
  bottom: .6rem;
  z-index: 2;
  transform: translateX(-50%);
  max-width: calc(100% - 1rem);
  margin: 0;
  pointer-events: none;
  font-size: .72rem;
  text-align: center;
}
.notice:not(:empty) {
  padding: .3rem .6rem;
  background: var(--crt-bg);
  border: 1px solid var(--crt-dim);
  border-radius: .3rem;
}
dialog {
  width: min(36rem, calc(100vw - 1rem));
  max-height: calc(100dvh - 1rem);
  overflow: auto;
  padding: .8rem 1rem;
  color: var(--crt-fg);
  background: var(--crt-bg);
  border: 1px solid var(--crt-dim);
  border-radius: .4rem;
  font: .8rem/1.5 var(--mono);
}
dialog::backdrop { background: rgba(11, 20, 16, .85); }
dialog [hidden] { display: none; }
dialog h2 {
  margin: 0 0 .5rem;
  font-size: 1rem;
  letter-spacing: .15em;
  text-transform: uppercase;
}
dialog h3 { margin: 1rem 0 .3rem; font-size: .85rem; color: var(--crt-hot); }
dialog p { margin: .5rem 0; }
dialog .note { color: var(--crt-dim); }
dialog .error { color: var(--crt-alert); }
dialog .error:empty, dialog .note:empty { margin: 0; }
dialog fieldset {
  margin: .5rem 0;
  padding: .3rem .6rem .4rem;
  border: 1px solid var(--crt-rule);
}
dialog fieldset label { display: inline-block; margin-right: 1rem; cursor: pointer; }
dialog .field label { margin-right: .5rem; }
dialog input, dialog select, dialog button { font: inherit; color: var(--crt-fg); }
dialog input[type="radio"] { accent-color: var(--crt-fg); margin-left: 0; }
/* iOS Safari zooms into a field whose text is smaller than 16px. */
dialog input[type="text"], dialog input[type="email"], dialog select {
  font-size: max(16px, 1rem);
  padding: .2rem .4rem;
  background: var(--crt-bg);
  border: 1px solid var(--crt-dim);
  border-radius: .2rem;
}
dialog button {
  padding: .25rem .7rem;
  background: transparent;
  border: 1px solid var(--crt-dim);
  border-radius: .3rem;
  cursor: pointer;
}
dialog button[type="submit"] { color: var(--crt-hot); border-color: var(--crt-hot); }
dialog button:disabled { color: var(--crt-dim); border-color: var(--crt-rule); cursor: default; }
dialog button:active { background: var(--crt-rule); }
dialog :focus-visible { outline: 2px solid var(--crt-hot); outline-offset: 2px; }
dialog .actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 0; }
dialog .switches { display: flex; flex-wrap: wrap; align-items: center; gap: 0 1rem; }
dialog table { width: 100%; margin: .6rem 0; border-collapse: collapse; }
dialog caption { text-align: left; color: var(--crt-hot); padding-bottom: .2rem; }
dialog th, dialog td { padding: .15rem .4rem; text-align: left; border-bottom: 1px solid var(--crt-rule); }
dialog th { color: var(--crt-dim); font-weight: 600; }
dialog .guest { color: var(--crt-dim); font-size: .9em; }
dialog .account { color: var(--crt-hot); font-size: .9em; }
dialog #me-email { overflow-wrap: anywhere; }
dialog .me { border-top: 1px solid var(--crt-rule); margin-top: .8rem; }
dialog .confirm { padding: .1rem .6rem; border: 1px solid var(--crt-alert); border-radius: .3rem; }

/* The lobby: who is in it, the room, its players and their ready marks. */
dialog .people { margin: .3rem 0; padding: 0; list-style: none; }
dialog .people li { padding: .15rem 0; border-bottom: 1px solid var(--crt-rule); overflow-wrap: anywhere; }
dialog .kind, dialog .waiting { color: var(--crt-dim); font-size: .9em; }
dialog .host, dialog .ready { color: var(--crt-hot); font-size: .9em; }
dialog #lobby-link { width: 100%; margin: .2rem 0; }
dialog button[aria-pressed="true"] { color: var(--crt-hot); border-color: var(--crt-hot); }

/* The race: the countdown, the finish screen and its notice at the top of
   the field (the online notice keeps the bottom). */
.race-notice { top: .6rem; bottom: auto; }
dialog .count {
  margin: .8rem 0;
  color: var(--crt-hot);
  font-size: 3rem;
  font-weight: 700;
  text-align: center;
}
dialog .winner td { color: var(--crt-hot); }
dialog .won, dialog .mine { color: var(--crt-hot); font-size: .9em; }
dialog .gone { color: var(--crt-dim); font-size: .9em; }
