/* Snowballs pixel UI kit (T-33, docs/gdd.md «Интерфейс»; the look: the mockups on the canvas
   linked there). Screens opt in with these classes; the in-match HUD and the overlays not yet
   restyled keep the old rules in index.html.

   Tokens  --navy ground, --panel raised panels, --ink outlines and drop shadows,
           --snow / --snow-2 snow and its shade, --blue / --blue-2 / --blue-3 (light edge),
           --gold / --gold-2 (dark edge) / --gold-3 (light edge), --red / --red-2, --muted text.
   Fonts   --font-title: Press Start 2P (titles, buttons, numbers), self-hosted in /fonts (OFL);
           --font-text: Arial (everything small: names, option buttons, lines of text) — the GD's
           call (T-42): the pixel fonts tried for it (Tiny5, Pixelify Sans) are hard to read.
   Buttons .px-btn plus a color: .px-primary (gold, the one main action), .px-blue, .px-dark;
           plus a shape: .px-big (the main action), .px-tile (square: icon over a short label),
           .px-icon (52×52, icon only — give it an aria-label), .px-small (forms).
           A choice that stays picked: .sel (renderMenu sets it) — a gold frame.
   Plates  .px-plate (dark plate: the player's name), .px-label (small caps caption).
   Screens .screen — a full-viewport screen (title, mode select, settings); it is also an
           .overlay, so showOverlay(id) switches it like the others. Inside: .screen-col (the
           centered phone-wide column), .screen-bar (back button + .screen-title).
   Seats   .seat — a kid in the team's colors over a name plate (.me gold); .empty is the kid's
           silhouette with blinking .dots. The waiting screen and the 2v2 lobby (T-38).
   Icons   js/icons.js: icon(name, size) and <i data-icon="…"> placeholders.
   Pause   .pause — the window over the field in a match (T-43): .pause-box, .pause-btn.
   Lesson  .lesson-task — the task over the field (T-53); .lesson-offer — the window over the
           title that offers the lesson; .lesson-box inside a .pause-box: .lesson-title,
           .lesson-line, .lesson-go (a text button), .lesson-btns.
   Frame   #wrap holds the whole game — the match (#stage: canvas, HUD) and every overlay. On a
           phone it is the window. On a computer (the @media block «Phone frame» at the end) it is
           a phone-shaped column in the middle of the page, and the containing block of everything
           inside it: a .screen's `position: fixed; inset: 0` (and any other fixed element of a
           screen) fills the frame, not the window. JS that sizes things to the screen measures
           viewSize() from js/frame.js, not innerWidth / innerHeight (T-39). */

@font-face {
  font-family: 'Press Start 2P';
  src: url(../fonts/press-start-2p-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
  font-display: swap;
}
@font-face {
  font-family: 'Press Start 2P';
  src: url(../fonts/press-start-2p-cyrillic.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
  font-display: swap;
}

:root {
  --navy: #1b2a3a;
  --panel: #24384d;
  --ink: #0f1e2e;
  --snow: #e8eef5;
  --snow-2: #c9d6e3;
  --blue: #2f6fd6;
  --blue-2: #2558b0;
  --blue-3: #5b8fe6;
  --gold: #f2c443;
  --gold-2: #c99a1e;
  --gold-3: #fff2b8;
  --red: #d0453b;
  --red-2: #a8352d;
  --muted: #9fb3c8;
  --font-title: 'Press Start 2P', ui-monospace, Menlo, monospace;
  --font-text: Arial, 'Helvetica Neue', Helvetica, sans-serif;
}

.px-ico { display: block; flex: none; }

/* ---------- buttons ---------- */

.px-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  box-sizing: border-box; min-width: 0; margin: 0; padding: 0 16px;
  font-family: var(--font-title); font-size: 14px; line-height: 1.2; text-transform: uppercase;
  color: #fff; border: 4px solid var(--ink); border-radius: 0; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.px-btn:active { transform: translateY(4px); }
.px-btn:focus-visible { outline: 3px solid var(--gold-3); outline-offset: 3px; }
.px-btn:disabled { opacity: 0.6; cursor: default; transform: none; }

.px-primary {
  color: var(--navy); background: var(--gold);
  box-shadow: inset -4px -4px 0 var(--gold-2), inset 4px 4px 0 var(--gold-3), 0 6px 0 var(--ink);
}
.px-primary:active { box-shadow: inset -4px -4px 0 var(--gold-2), inset 4px 4px 0 var(--gold-3), 0 2px 0 var(--ink); }
.px-blue {
  color: #fff; background: var(--blue);
  box-shadow: inset -4px -4px 0 var(--blue-2), inset 4px 4px 0 var(--blue-3), 0 6px 0 var(--ink);
}
.px-blue:active { box-shadow: inset -4px -4px 0 var(--blue-2), inset 4px 4px 0 var(--blue-3), 0 2px 0 var(--ink); }
.px-dark { color: var(--snow-2); background: var(--panel); box-shadow: 0 4px 0 var(--ink); }
.px-dark:active { box-shadow: 0 0 0 var(--ink); }
.px-btn.sel { border-color: var(--gold); }
.px-dark.sel { color: #fff; background: var(--blue); }

.px-big { width: 286px; max-width: 100%; height: 76px; font-size: 22px; }
.px-tile { flex-direction: column; gap: 14px; width: 132px; height: 112px; padding: 0 6px; font-size: 10px; }
.px-icon { width: 52px; height: 52px; padding: 0; }
.px-small { height: 48px; font-size: 11px; }

/* ---------- plates and captions ---------- */

.px-plate {
  display: inline-flex; align-items: center; gap: 12px; box-sizing: border-box;
  padding: 6px 14px; font-family: var(--font-text); font-size: 20px; font-weight: 400;
  color: var(--gold); background: var(--ink); border: 4px solid #2f4e6d;
}
button.px-plate { min-width: 0; min-height: 48px; cursor: pointer; box-shadow: none; text-transform: none; }
button.px-plate:active { transform: translateY(2px); box-shadow: none; }
button.px-plate:focus-visible { outline: 3px solid var(--gold-3); outline-offset: 3px; }
.px-label {
  font-family: var(--font-title); font-size: 10px; line-height: 14px; letter-spacing: 1px;
  text-transform: uppercase; color: var(--muted);
}
.sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- full-viewport screens ---------- */

.overlay.screen {
  position: fixed; inset: 0; z-index: 2; padding: 0; gap: 0;
  align-items: stretch; justify-content: flex-start; text-align: center;
  background: var(--navy); font-family: var(--font-text); color: #fff;
  overflow-x: hidden; overflow-y: auto;
}
.screen-col {
  position: relative; box-sizing: border-box; width: 100%; max-width: 420px; margin: 0 auto;
  padding: 16px 24px 28px; display: flex; flex-direction: column; align-items: center; gap: 24px;
}
.screen-bar { position: relative; align-self: stretch; height: 56px; display: flex; align-items: center; }
.screen-title {
  position: absolute; left: 64px; right: 64px; margin: 0;
  font-family: var(--font-title); font-size: 18px; font-weight: 400; line-height: 24px;
  letter-spacing: 0; text-transform: uppercase; text-shadow: none; color: #fff;
}

/* ---------- title screen ---------- */

.title { min-height: 560px; }
.title .sky { position: relative; flex: 1 0 auto; min-height: 330px; display: flex; background: var(--navy); }
.title .sky-col {
  position: relative; width: 100%; max-width: 390px; margin: 0 auto;
  display: flex; flex-direction: column; align-items: center;
  padding-top: clamp(76px, 12vh, 100px);
}
.title .corner { position: absolute; top: 16px; right: 16px; }
.logo {
  margin: 0; font-family: var(--font-title); font-size: 32px; font-weight: 400; line-height: 40px;
  letter-spacing: 0; color: #fff; text-shadow: 4px 4px 0 var(--blue), 8px 8px 0 var(--ink);
}
.title .player { display: flex; justify-content: center; margin-top: 24px; min-height: 56px; }
.title .rename { margin-top: 20px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.title .rename.hidden { display: none; }
#rename-input {
  width: 260px; box-sizing: border-box; padding: 10px 12px; font-family: var(--font-text);
  font-size: 20px; color: #fff; background: var(--ink); border: 4px solid var(--blue); border-radius: 0;
  outline: none; -webkit-user-select: text; user-select: text;
}
.title .rename-row { display: flex; gap: 10px; width: 260px; }
.title .rename-row .px-btn { flex: 1; }
.title .rename-error { min-height: 18px; font-size: 16px; color: var(--gold-3); }
.scene { position: relative; width: 100%; height: 150px; margin-top: auto; flex: none; }
.scene > * { position: absolute; }
.scene .flake, .sky .flake { width: 4px; height: 4px; background: var(--snow-2); }
.scene .trail { width: 6px; height: 6px; background: #6f86a0; }
.scene .hill, .scene .ground { background: var(--snow); }
.moon {
  position: absolute; width: 32px; height: 32px; background: var(--snow);
  box-shadow: 4px 0 0 var(--snow), -4px 0 0 var(--snow), 0 4px 0 var(--snow), 0 -4px 0 var(--snow);
}
.moon::after { content: ''; position: absolute; left: 12px; top: 8px; width: 8px; height: 8px; background: var(--snow-2); }
.title .snow {
  flex: none; display: flex; flex-direction: column; align-items: center;
  gap: 32px; padding: clamp(28px, 7vh, 70px) 16px 28px; background: var(--snow);
}
.title .tiles { display: flex; gap: 22px; }

/* ---------- mode select ---------- */

.card {
  position: relative; display: block; box-sizing: border-box; width: 100%; padding: 0;
  overflow: hidden; color: inherit; background: var(--snow); border: 4px solid var(--ink);
  border-radius: 0; box-shadow: 0 6px 0 var(--ink); cursor: pointer; text-align: left;
  -webkit-tap-highlight-color: transparent;
}
.card:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.card:focus-visible { outline: 3px solid var(--gold-3); outline-offset: 3px; }
.card.sel { border-color: var(--gold); }
.card-duel { height: clamp(190px, 31vh, 264px); }
.card-teams { height: clamp(170px, 26vh, 224px); background: #dfe7ef; }
.card .field-line { position: absolute; left: 16px; right: 16px; border-top: 4px dashed var(--snow-2); }
.card .art { position: absolute; left: 0; right: 0; top: 0; bottom: 52px; }
.card .art > * { position: absolute; }
.card-bar {
  position: absolute; left: 0; right: 0; bottom: 0; height: 52px; box-sizing: border-box;
  display: flex; align-items: center; justify-content: space-between; padding: 0 18px;
  background: var(--panel);
}
.card.sel .card-bar { background: var(--blue); }
.card-name { font-family: var(--font-title); font-size: 16px; text-transform: uppercase; color: #fff; }
.card-note { font-family: var(--font-title); font-size: 10px; text-transform: uppercase; color: #dce8ff; }
.play-row { display: flex; gap: 16px; align-self: stretch; margin-top: 8px; }
.play-row .px-tile { flex: 1; width: auto; height: 108px; font-size: 11px; }

/* ---------- settings for tests ---------- */

.settings-group { align-self: stretch; display: flex; flex-direction: column; gap: 10px; }
.settings-group .px-label { text-align: left; }
.seg { display: flex; gap: 8px; }
.seg .px-btn {
  flex: 1; height: 52px; padding: 0 6px; font-family: var(--font-text); font-size: 16px;
  font-weight: 400; text-transform: none;
}
/* Many switches (the mechanics): three to a row, the rest share the next row. */
.seg-wrap { flex-wrap: wrap; }
.seg-wrap .px-btn { flex: 1 1 calc((100% - 16px) / 3); }
/* The map picker (T-47): a tile per map, a small top-down picture of it over its name. */
.map-seg .px-btn { height: auto; flex-direction: column; gap: 6px; padding: 8px 4px 6px; font-size: 14px; line-height: 1.15; }
.map-tile canvas { display: block; width: 52px; height: 92px; image-rendering: pixelated; border: 2px solid var(--ink); }
.settings-note { align-self: stretch; margin: 0; font-size: 16px; line-height: 1.4; color: var(--muted); text-align: left; }

/* ---------- waiting for a friend, the 2v2 lobby (T-38) ---------- */

/* A seat: a kid in the team's colors and the name plate under it; an empty seat is the kid's
   silhouette with blinking dots. js/main.js fillSeat builds them. */
.seat { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; max-width: 100%; }
.seat-kid { display: block; }
.seat.empty .seat-kid svg { filter: brightness(0); opacity: 0.18; }
.seat-name {
  max-width: 100%; box-sizing: border-box; padding: 3px 8px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-text); font-size: 16px;
  line-height: 18px; color: #fff; background: var(--ink);
}
.seat.me .seat-name { color: var(--gold); }
.dots { display: flex; align-items: center; gap: 6px; height: 24px; }
.dots i { width: 6px; height: 6px; background: var(--muted); animation: px-blink 1.2s steps(1) infinite; }
.dots i:nth-child(2) { animation-delay: 0.4s; }
.dots i:nth-child(3) { animation-delay: 0.8s; }
@keyframes px-blink { 0%, 100% { opacity: 0.25; } 33% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .dots i { animation: none; opacity: 0.6; } }

/* Waiting for a friend: the duel field, me at the bottom, the empty seat across the line. */
.wait-field {
  position: relative; align-self: stretch; height: clamp(230px, 40vh, 320px); box-sizing: border-box;
  background: var(--snow); border: 4px solid var(--ink); box-shadow: 0 6px 0 var(--ink);
}
.wait-field .field-line { position: absolute; left: 16px; right: 16px; top: 50%; border-top: 4px dashed var(--snow-2); }
.wait-seat { position: absolute; left: 8px; right: 8px; display: flex; justify-content: center; }
.wait-seat.top { top: 7%; }
.wait-seat.bottom { bottom: 7%; }

/* The 2v2 lobby: two team columns; the other team's column is a button — tap to switch. */
.lobby { align-self: stretch; display: flex; gap: 16px; }
.team-col {
  flex: 1; min-width: 0; margin: 0; padding: 0 8px 18px; box-sizing: border-box; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  font: inherit; color: inherit; background: var(--snow); border: 4px solid var(--ink); border-radius: 0;
  box-shadow: 0 6px 0 var(--ink); cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.team-col .team-bar { align-self: stretch; height: 16px; margin: 0 -8px; }
.team-col.blue .team-bar { background: var(--blue); }
.team-col.red .team-bar { background: var(--red); }
.team-col.mine { border-color: var(--gold); }
.team-col:disabled { opacity: 1; cursor: default; }
.team-col.full:not(.mine) { opacity: 0.6; }
.team-col:not(:disabled):active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.team-col:focus-visible { outline: 3px solid var(--gold-3); outline-offset: 3px; }
.lobby-time {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  font-family: var(--font-title); font-size: 20px; line-height: 24px; color: var(--gold);
}
.invite {
  align-self: stretch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--font-text); font-size: 14px; line-height: 16px; color: var(--muted);
  -webkit-user-select: text; user-select: text;
}

/* ---------- short screens (an older phone, a landscape laptop window) ---------- */

@media (max-height: 700px) {
  .title { min-height: 0; }
  .title .sky { min-height: 300px; }
  .title .sky-col { padding-top: 64px; }
  .logo { font-size: 26px; line-height: 32px; }
  .title .player { margin-top: 14px; }
  .title .snow { gap: 20px; padding: 20px 16px; }
  .px-big { height: 64px; font-size: 20px; }
  .title .px-tile, .play-row .px-tile { height: 92px; gap: 10px; }
  .screen-col { gap: 16px; }
  .card-duel { height: 160px; }
  .card-teams { height: 140px; }
  .card .kid-top { transform: scale(0.75); transform-origin: 50% 0; }
  .card .kid-bottom { transform: scale(0.75); transform-origin: 50% 100%; }
  .wait-field { height: 220px; }
  .wait-field .seat-kid svg { width: 40px; height: 56px; } /* 4 px per art pixel instead of 5 */
  .team-col { gap: 10px; padding-bottom: 12px; }
}

/* ---------- pause in a match (T-43) ---------- */

/* Over the field only, and lightly dimmed: the match goes on underneath (the server does not
   stop it). The whole layer catches taps, so the joystick and the throw button rest; a tap
   outside the box goes on (main.js). */
.pause {
  position: absolute; inset: 0; z-index: 1;
  display: flex; align-items: center; justify-content: center;
  background: rgba(16, 28, 44, 0.38);
}
.pause-box {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 16px 20px 22px; background: var(--navy);
  border: 4px solid var(--ink); box-shadow: inset 0 0 0 3px var(--panel), 0 6px 0 var(--ink);
}
.pause-btns { display: flex; gap: 16px; }
.pause-btn { width: 76px; height: 76px; padding: 0; }

/* ---------- the lesson (T-53) ---------- */

.title .corner-left { position: absolute; top: 16px; left: 16px; }
/* The task: over the top of the field (a lesson has no clock), clear of the pause button. */
.lesson-task {
  position: absolute; left: 6px; right: 50px; top: 6px; z-index: 1; pointer-events: none;
  display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; box-sizing: border-box;
  background: rgba(15, 30, 46, 0.86); border: 3px solid var(--ink); text-align: left;
  font-family: var(--font-text);
}
.lesson-dots { display: flex; gap: 4px; }
.lesson-dots i { width: 16px; height: 5px; background: #3d5a78; }
.lesson-dots i.on { background: var(--gold); }
.lesson-text { font-size: 15px; font-weight: 700; line-height: 1.3; color: #fff; }
.lesson-task.passed .lesson-text { font-size: 20px; color: var(--gold); }
.lesson-offer {
  position: fixed; inset: 0; z-index: 3; box-sizing: border-box; padding: 16px;
  display: flex; align-items: center; justify-content: center; background: rgba(16, 28, 44, 0.6);
}
.lesson-box { max-width: 300px; box-sizing: border-box; text-align: center; }
.lesson-title {
  margin: 0; font-family: var(--font-title); font-size: 18px; font-weight: 400; line-height: 24px;
  text-transform: uppercase; color: #fff; text-shadow: none;
}
.lesson-line { margin: 0; font-family: var(--font-text); font-size: 16px; line-height: 1.35; color: var(--snow-2); }
.lesson-btns { display: flex; gap: 12px; }
.lesson-go { height: 64px; min-width: 120px; font-size: 16px; }

/* ---------- phone frame on a computer (T-39) ---------- */

/* A window that is roomy both ways gets the game as a phone: a centered column of a phone's
   proportions (9 : 19.5) up to 420 × 900 and never narrower than a small phone (375 — a laptop
   window is shorter than a phone, so there it is a bit stubbier), a pixel bezel, snowflakes on the
   page around it.
   `contain: layout` makes #wrap the containing block of fixed-position descendants, so the
   full-screen .screen overlays fill the frame. A phone (narrow, or a short landscape window)
   misses this block and stays full screen. js/frame.js repeats the query: keep them in step. */
@media (min-width: 600px) and (min-height: 600px) {
  html, body {
    background-color: #132131;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' shape-rendering='crispEdges'%3E%3Cpath fill='%23223548' d='M6 8h4v4H6zM38 4h4v4h-4zM24 30h4v4h-4zM52 40h4v4h-4zM12 50h4v4h-4zM44 22h2v2h-2zM2 32h2v2H2zM30 56h2v2h-2z'/%3E%3C/svg%3E");
  }
  #wrap {
    margin: auto;
    width: min(420px, max(375px, calc((100vh - 56px) * 9 / 19.5)));
    height: min(900px, calc(100vh - 56px));
    overflow: hidden; contain: layout;
    background: var(--navy);
    box-shadow: 0 0 0 4px var(--ink), 0 0 0 12px #2f4e6d, 0 0 0 16px var(--ink), 0 16px 0 16px var(--ink);
  }
}
