/* БИТЫЙ ПИКСЕЛЬ — стиль в духе 8-битного ZX Spectrum.
   Палитра — 8 цветов Спектрума (без BRIGHT) + яркий белый; задана здесь один раз,
   canvas-игры читают её через Arcade.palette(). */

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

:root {
  --black: #000000;
  --blue: #0000d7;
  --red: #d70000;
  --magenta: #d700d7;
  --green: #00d700;
  --cyan: #00d7d7;
  --yellow: #d7d700;
  --white: #d7d7d7;
  --bright-white: #ffffff;

  --f-pixel: "Pixel", ui-monospace, monospace;
  --px: 4px;                        /* «пиксель» интерфейса: рамки, тени, отступы кратны ему */
  --shadow: var(--px) var(--px) 0 var(--black);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--white);
  color: var(--black);
  font: 12px/1.9 var(--f-pixel);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: inherit; }
main { flex: 1; }
h1, h2, h3 { font-weight: 400; }
.wrap { width: min(1180px, 100% - 32px); margin-inline: auto; }

/* Цвет раздела/игры: --c — «бумага», --ci — «чернила» поверх неё (как PAPER/INK). */
.c-green { --c: var(--green); --ci: var(--black); }
.c-magenta { --c: var(--magenta); --ci: var(--bright-white); }
.c-cyan { --c: var(--cyan); --ci: var(--black); }
.c-red { --c: var(--red); --ci: var(--bright-white); }
.c-blue { --c: var(--blue); --ci: var(--bright-white); }
.c-yellow { --c: var(--yellow); --ci: var(--black); }

/* Радужная полоска: четыре диагонали красный-жёлтый-зелёный-голубой. */
.stripes {
  display: inline-block; width: 64px; height: 24px; flex: none;
  background: linear-gradient(115deg,
    transparent 0 20%, var(--red) 20% 35%, var(--yellow) 35% 50%,
    var(--green) 50% 65%, var(--cyan) 65% 80%, transparent 80%);
}

/* ---------- top bar ---------- */
.topbar { background: var(--black); color: var(--bright-white); position: sticky; top: 0; z-index: 10; }
.topbar .wrap { display: flex; align-items: center; gap: 16px; padding-block: 12px; }
.logo { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; font-size: 14px; line-height: 1; text-transform: uppercase; margin-right: auto; white-space: nowrap; }
.logo svg { width: 28px; height: 28px; }
.logo b { font-weight: 400; color: var(--yellow); }
.topnav { display: flex; gap: 8px; }
.chip { font-size: 10px; line-height: 1; text-transform: uppercase; text-decoration: none; padding: 8px 10px; color: var(--bright-white); border: 2px solid var(--bright-white); }
.chip:hover { background: var(--bright-white); color: var(--black); }

/* ---------- buttons ---------- */
.btn {
  appearance: none; cursor: pointer; user-select: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 12px/1 var(--f-pixel); text-transform: uppercase; text-decoration: none;
  color: var(--black); background: var(--bright-white);
  border: var(--px) solid var(--black); border-radius: 0;
  padding: 12px 14px; box-shadow: var(--shadow);
}
.btn:hover { background: var(--black); color: var(--bright-white); }   /* инверсия, как INVERSE 1 */
.btn:active { transform: translate(var(--px), var(--px)); box-shadow: none; }
.btn:focus-visible, .chip:focus-visible, .card:focus-visible, .cells button:focus-visible, .levels button:focus-visible {
  outline: 3px solid var(--red); outline-offset: 2px;
}
.btn.primary { background: var(--yellow); }
.btn.primary:hover { background: var(--black); color: var(--yellow); }
.btn.on { background: var(--black); color: var(--yellow); }
.btn.small { font-size: 10px; padding: 9px 10px; }
.btn[disabled] { opacity: .4; pointer-events: none; }

/* ---------- hero ---------- */
.hero { padding-block: 56px 48px; position: relative; }
.hero h1 { margin: 0; font-size: clamp(30px, 7.5vw, 88px); line-height: 1.25; text-transform: uppercase; }
.hero h1 .inv { background: var(--blue); color: var(--bright-white); padding: 0 .12em; }
.prompt { margin: 28px 0 0; font-size: 16px; }
.cursor { display: inline-block; margin-left: .3em; padding: 0 .15em; background: var(--black); color: var(--bright-white); animation: flash .64s steps(1) infinite; }
@keyframes flash { 50% { background: var(--bright-white); color: var(--black); } }
.hero-stripes { position: absolute; right: 0; bottom: 48px; width: 280px; height: 140px; }
@media (max-width: 860px) { .hero-stripes { display: none; } }

/* ---------- marquee ---------- */
.marquee { background: var(--blue); color: var(--bright-white); overflow: hidden; white-space: nowrap; border-block: var(--px) solid var(--black); }
.marquee .track { display: inline-flex; gap: 48px; padding: 14px 0; font-size: 12px; line-height: 1; text-transform: uppercase; animation: marquee 40s steps(600) infinite; }
.marquee .track span::after { content: "*"; margin-left: 48px; color: var(--yellow); }
@keyframes marquee { to { transform: translateX(-33.3333%); } }

/* ---------- game cards ---------- */
.section-title { font-size: clamp(20px, 3vw, 32px); line-height: 1.2; text-transform: uppercase; margin: 56px 0 28px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 16px; }
.section-title small { font-size: 10px; color: var(--blue); }
.grid { display: grid; gap: 28px; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); padding-bottom: 64px; }
.card {
  position: relative; display: flex; flex-direction: column; text-decoration: none;
  background: var(--bright-white); border: var(--px) solid var(--black); box-shadow: 8px 8px 0 var(--black);
}
.card:hover { transform: translate(-4px, -4px); box-shadow: 12px 12px 0 var(--black); }
.card .art { background: var(--black); border-bottom: var(--px) solid var(--black); aspect-ratio: 16 / 10; display: grid; place-items: center; }
.card .art svg { width: 62%; height: 78%; }
.card h3 { margin: -14px -16px 4px; padding: 12px 16px; border-bottom: var(--px) solid var(--black); font-size: 18px; line-height: 1.2; text-transform: uppercase; background: var(--c); color: var(--ci); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card h3::after { content: ""; width: 48px; height: 18px; flex: none;
  background: linear-gradient(115deg, transparent 0 20%, var(--red) 20% 35%, var(--yellow) 35% 50%, var(--green) 50% 65%, var(--cyan) 65% 80%, transparent 80%); }
.card.c-red h3::after { background: linear-gradient(115deg, transparent 0 20%, var(--black) 20% 35%, var(--yellow) 35% 50%, var(--green) 50% 65%, var(--cyan) 65% 80%, transparent 80%); }
.card:hover h3 { background: var(--ci); color: var(--c); }
.card .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.card p { margin: 0; font-size: 10px; line-height: 2; }
.card .meta { margin-top: auto; padding-top: 6px; display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 9px; line-height: 1.4; text-transform: uppercase; color: var(--blue); }
.card .best { background: var(--black); color: var(--yellow); padding: 6px 8px; }
.card .num { position: absolute; top: 10px; left: 10px; font-size: 10px; line-height: 1; color: var(--bright-white); }

/* ---------- footer ---------- */
footer { background: var(--black); color: var(--white); font-size: 9px; line-height: 2; }
footer .wrap { padding-block: 24px; display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; }
footer a { color: var(--yellow); }

/* ---------- game page ---------- */
.game-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 32px 0 24px; }
.game-head h1 { margin: 0; font-size: clamp(24px, 5vw, 48px); line-height: 1.2; text-transform: uppercase; }
.game-head h1 span { background: var(--c, var(--black)); color: var(--ci, var(--bright-white)); padding: 0 .15em; }
.game-head p { margin: 16px 0 0; max-width: 560px; font-size: 10px; line-height: 2; }

.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; align-items: start; padding-bottom: 56px; }

/* Экран: чёрная область внутри цветного BORDER. */
.screen {
  position: relative; background: var(--black); border: 16px solid var(--c, var(--blue));
  outline: var(--px) solid var(--black); outline-offset: 0; box-shadow: 12px 12px 0 var(--black);
  padding: 16px; display: grid; place-items: center; overflow: hidden; touch-action: none;
}
.screen canvas { display: block; max-width: 100%; height: auto; image-rendering: pixelated; }
/* Видимые границы поля там, где они есть в игре (стены толщиной 2 «пикселя» интерфейса):
   змейка — со всех сторон; стакан — бока и дно; отскок — бока и верх, низ открыт. */
.screen canvas { --w: calc(2 * var(--px)); --nw: calc(-2 * var(--px)); }
.screen canvas.walls-all { box-shadow: 0 0 0 var(--w) var(--white); }
.screen canvas.walls-lrb { box-shadow: var(--nw) 0 0 var(--white), var(--w) 0 0 var(--white), 0 var(--w) 0 var(--white),
  var(--nw) var(--w) 0 var(--white), var(--w) var(--w) 0 var(--white); }
.screen canvas.walls-ltr { box-shadow: var(--nw) 0 0 var(--white), var(--w) 0 0 var(--white), 0 var(--nw) 0 var(--white),
  var(--nw) var(--nw) 0 var(--white), var(--w) var(--nw) 0 var(--white); }
.screen.scroll { overflow: auto; place-items: start center; touch-action: manipulation; }

.overlay {
  position: absolute; inset: 0; z-index: 2; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 20px;
  background: rgba(0, 0, 0, .86); color: var(--bright-white); text-align: center; padding: 24px;
}
.overlay.show { display: flex; }
.overlay h2 { margin: 0; font-size: clamp(16px, 3vw, 24px); line-height: 1.4; color: var(--yellow); }
.overlay p { margin: 0; font-size: 10px; line-height: 2; color: var(--white); }
.overlay .btn { background: var(--yellow); }
.overlay .btn:hover { background: var(--bright-white); color: var(--black); }

.panel { display: flex; flex-direction: column; gap: 20px; }
.box { background: var(--bright-white); border: var(--px) solid var(--black); box-shadow: var(--shadow); padding: 14px 16px; }
.box h2 { margin: 0 0 12px; font-size: 11px; line-height: 1; text-transform: uppercase; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
.stat { background: var(--black); color: var(--yellow); padding: 10px; }
.stat dt { font-size: 8px; line-height: 1; color: var(--cyan); text-transform: uppercase; margin-bottom: 10px; }
.stat dd { margin: 0; font-size: 14px; line-height: 1; white-space: nowrap; }
.stat.wide { grid-column: 1 / -1; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.keys { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; font-size: 9px; line-height: 1.6; }
.keys li { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
/* клавиши — чёрная «резина» с белой надписью */
kbd { font: 9px/1 var(--f-pixel); background: var(--black); color: var(--bright-white); padding: 5px 6px; white-space: nowrap; box-shadow: 0 3px 0 var(--blue); }
.mini { background: var(--black); display: block; width: 100%; max-width: 110px; height: auto; image-rendering: pixelated; }
.minis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.minis figure { margin: 0; }
.minis figcaption { font-size: 8px; line-height: 1; text-transform: uppercase; margin-bottom: 8px; }

/* ---------- touch pad ---------- */
.pad { display: none; gap: 10px; margin-top: 24px; user-select: none; -webkit-user-select: none; touch-action: none; }
.pad button {
  appearance: none; border: var(--px) solid var(--black); border-radius: 0; background: var(--bright-white); box-shadow: var(--shadow);
  font: 18px/1 var(--f-pixel); min-height: 56px; color: var(--black); touch-action: none;
}
.pad button.on, .pad button:active { background: var(--black); color: var(--yellow); transform: translate(var(--px), var(--px)); box-shadow: none; }
.pad.cross { grid-template-columns: repeat(3, 64px); grid-template-areas: ". u ." "l a r" ". d ."; justify-content: center; }
.pad.cross [data-a=up] { grid-area: u; } .pad.cross [data-a=left] { grid-area: l; } .pad.cross [data-a=right] { grid-area: r; }
.pad.cross [data-a=down] { grid-area: d; } .pad.cross .mid { grid-area: a; }
.pad.row { grid-template-columns: repeat(auto-fit, minmax(56px, 1fr)); }
@media (pointer: coarse), (hover: none) { .pad { display: grid; } }

/* ---------- сапёр / пятнашки (DOM-сетки) ---------- */
.cells { display: grid; gap: 2px; background: var(--black); }
.cells button {
  appearance: none; border: 0; border-radius: 0; margin: 0; padding: 0; cursor: pointer;
  width: var(--cell, 30px); height: var(--cell, 30px);
  font: calc(var(--cell, 30px) * .45)/1 var(--f-pixel);
  background: var(--blue); color: var(--bright-white);
  box-shadow: inset 3px 3px 0 var(--cyan), inset -3px -3px 0 rgba(0, 0, 0, .55);
  touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.cells button:hover { background: var(--cyan); }
.cells button.open { background: var(--black); box-shadow: inset 0 0 0 1px #202020; cursor: default; }
.cells button.boom { background: var(--red); }
.cells button.n1 { color: var(--cyan); } .cells button.n2 { color: var(--green); } .cells button.n3 { color: var(--red); }
.cells button.n4 { color: var(--magenta); } .cells button.n5 { color: var(--yellow); } .cells button.n6 { color: var(--cyan); }
.cells button.n7, .cells button.n8 { color: var(--bright-white); }

.fifteen { --cell: min(76px, 18vw); gap: 6px; padding: 6px; }
.fifteen button { font-size: calc(var(--cell) * .32); background: var(--yellow); color: var(--black);
  box-shadow: inset 4px 4px 0 var(--bright-white), inset -4px -4px 0 rgba(0, 0, 0, .35); }
.fifteen button:hover { background: var(--bright-white); }
.fifteen button.home { background: var(--green); }
.fifteen button.hole { visibility: hidden; }

/* ---------- выбор уровня (склад) ---------- */
.levels { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 4px; max-height: 220px; overflow: auto; padding: 2px; }
.levels button { font: 9px/1 var(--f-pixel); padding: 8px 0; border: 2px solid var(--black); border-radius: 0; background: var(--bright-white); cursor: pointer; }
.levels button.done { background: var(--green); }
.levels button.cur { background: var(--black); color: var(--yellow); }
details summary { cursor: pointer; font-size: 11px; line-height: 1; text-transform: uppercase; }
details[open] summary { margin-bottom: 12px; }

.credits { font-size: 9px; line-height: 2; color: var(--blue); }

/* ---------- пиксельные иконки (SVG из прямоугольников, буква = цвет) ---------- */
.px { shape-rendering: crispEdges; }
.f-K { fill: var(--black); } .f-B { fill: var(--blue); } .f-R { fill: var(--red); } .f-M { fill: var(--magenta); }
.f-G { fill: var(--green); } .f-C { fill: var(--cyan); } .f-Y { fill: var(--yellow); } .f-W { fill: var(--white); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (max-width: 520px) {
  .logo { font-size: 11px; }
  .logo svg { width: 22px; height: 22px; }
  .topbar .stripes { display: none; }
  .topnav .chip + .chip { display: none; }
  .hero { padding-top: 36px; }
}

/* мобильная раскладка игровой страницы — в конце файла, чтобы перекрыть .panel */
@media (max-width: 860px) {
  .game-layout { grid-template-columns: 1fr; gap: 20px; }
  .panel { display: contents; }               /* блоки панели становятся элементами сетки */
  .panel > .box:first-child { order: -1; }    /* счёт — над экраном, чтобы был виден во время игры */
  .screen { border-width: 10px; padding: 10px; }
}
