/* Относительные ковенанты: 8-битная версия. Без внешних зависимостей. */

@font-face { font-family: "Press"; src: url(fonts/press-lat.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+2190-21FF, U+2212; font-display: swap; }
@font-face { font-family: "Press"; src: url(fonts/press-cyr.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; font-display: swap; }
@font-face { font-family: "Pixel"; src: url(fonts/plex-latin-400.woff2) format("woff2"); font-weight: 400; unicode-range: U+0000-00FF, U+2000-206F, U+2190-21FF, U+2212; font-display: swap; }
@font-face { font-family: "Pixel"; src: url(fonts/plex-cyrillic-400.woff2) format("woff2"); font-weight: 400; unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; font-display: swap; }
@font-face { font-family: "Pixel"; src: url(fonts/plex-latin-700.woff2) format("woff2"); font-weight: 700; unicode-range: U+0000-00FF, U+2000-206F, U+2190-21FF, U+2212; font-display: swap; }
@font-face { font-family: "Pixel"; src: url(fonts/plex-cyrillic-700.woff2) format("woff2"); font-weight: 700; unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; font-display: swap; }

:root {
  --k: #000; --w: #fcfcfc; --y: #f8b800; --yl: #fce0a8; --o: #fca044; --r: #d82800;
  --sky: #5c94fc; --g: #00a800; --gl: #b8f818; --b: #0058f8; --bl: #3cbcfc;
  --grey: #bcbcbc; --dgrey: #7c7c7c; --pur: #2c0070; --brick: #c84c0c;
  --px: 4px;
  --hud-h: 56px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: var(--hud-h); }
body {
  margin: 0; background: var(--k); color: var(--w);
  font: 400 18px/1.6 "Pixel", ui-monospace, Menlo, monospace;
    overflow-x: hidden;
}
a { color: var(--y); }
a:hover { color: var(--w); }
button, input { font: inherit; color: inherit; }
.press { font-family: "Press", ui-monospace, monospace; letter-spacing: 0; line-height: 1.5; }
.spr { display: inline-block; line-height: 0; vertical-align: middle; }
.spr svg { display: block; image-rendering: pixelated; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- HUD ---------- */
.hud {
  position: fixed; inset: 0 0 auto 0; z-index: 50; height: var(--hud-h);
  background: var(--k); border-bottom: var(--px) solid var(--w);
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  font-family: "Press", monospace; font-size: 11px; text-transform: uppercase;
}
.hud .cell { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.hud .cell b { font-weight: 400; color: var(--w); white-space: nowrap; }
.hud .cell span { color: var(--y); white-space: nowrap; }
.hud .grow { flex: 1; }
.hud button {
  background: var(--k); border: 3px solid var(--w); padding: 6px 8px; cursor: pointer;
  font-family: "Press", monospace; font-size: 11px;
}
.hud button:hover, .hud button[aria-pressed="true"] { background: var(--w); color: var(--k); }
.hud .coins { display: flex; align-items: center; gap: 6px; }
@media (max-width: 560px) { .hud .hide-s { display: none; } .hud { gap: 10px; font-size: 9px; } }

.menu {
  position: fixed; top: calc(var(--hud-h) + 8px); right: 16px; z-index: 60;
  background: var(--k); border: var(--px) solid var(--w); outline: var(--px) solid var(--k);
  padding: 12px 8px; width: min(340px, calc(100vw - 32px)); max-height: calc(100vh - var(--hud-h) - 32px); overflow: auto;
  font-family: "Press", monospace; font-size: 11px;
}
.menu[hidden] { display: none; }
.menu a { display: block; padding: 8px 8px 8px 28px; color: var(--w); text-decoration: none; position: relative; line-height: 1.6; }
.menu a:hover, .menu a:focus { color: var(--y); outline: none; }
.menu a:hover::before, .menu a:focus::before { content: "▶"; position: absolute; left: 6px; }
.menu small { color: var(--dgrey); display: block; }

/* ---------- Мир (секция) ---------- */
.world { position: relative; padding: calc(var(--hud-h) + 40px) 16px 120px; overflow: hidden; }
.inner { max-width: 960px; margin: 0 auto; position: relative; z-index: 2; }
.tag { font-family: "Press", monospace; font-size: 12px; text-transform: uppercase; color: var(--y); text-shadow: 3px 3px 0 var(--k); margin: 0 0 14px; }
.world h2 {
  font-family: "Press", monospace; font-weight: 400; font-size: clamp(18px, 4vw, 34px); line-height: 1.35;
  margin: 0 0 28px; color: var(--w); text-shadow: 4px 4px 0 var(--k); text-transform: uppercase; overflow-wrap: anywhere;
}
.world h3 { font-family: "Press", monospace; font-weight: 400; font-size: 13px; line-height: 1.6; margin: 0 0 12px; color: var(--y); text-transform: uppercase; }
.box {
  background: var(--k); color: var(--w); border: var(--px) solid var(--w);
  box-shadow: 0 0 0 var(--px) var(--k), 8px 8px 0 var(--px) rgba(0,0,0,.35);
  padding: 20px 22px; margin: 0 0 28px;
}
.box p { margin: 0 0 14px; }
.box p:last-child { margin-bottom: 0; }
.box strong { color: var(--y); font-weight: 700; }
.box ul, .box ol { margin: 0; padding-left: 22px; }
.box li { margin: 0 0 10px; }
.grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-bottom: 28px; }
.grid .box { margin: 0; }
.card-head { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.card-head h3 { margin: 0; }
.big-quote { font-size: 22px; font-weight: 700; line-height: 1.5; }
.btn {
  display: inline-block; background: var(--r); color: var(--w); border: var(--px) solid var(--k);
  box-shadow: inset -4px -4px 0 rgba(0,0,0,.35), inset 4px 4px 0 rgba(255,255,255,.25);
  font-family: "Press", monospace; font-size: 12px; padding: 14px 18px; cursor: pointer; text-decoration: none; text-transform: uppercase;
}
.btn:hover { background: var(--o); color: var(--k); }
.btn:active { transform: translate(2px, 2px); }
.btn.alt { background: var(--b); }
.btn.alt:hover { background: var(--bl); }
.btn[aria-pressed="true"] { background: var(--y); color: var(--k); }

/* Земля из кирпичей */
.ground {
  position: absolute; left: 0; right: 0; bottom: 0; height: 64px; z-index: 1;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' shape-rendering='crispEdges'%3E%3Crect width='16' height='16' fill='%23c84c0c'/%3E%3Crect y='7' width='16' height='1' fill='%23000'/%3E%3Crect y='15' width='16' height='1' fill='%23000'/%3E%3Crect x='7' width='1' height='7' fill='%23000'/%3E%3Crect x='15' y='8' width='1' height='7' fill='%23000'/%3E%3Crect width='7' height='1' fill='%23fcbcb0'/%3E%3Crect x='8' y='8' width='7' height='1' fill='%23fcbcb0'/%3E%3C/svg%3E") repeat-x;
  background-size: 32px 32px; image-rendering: pixelated;
}
.ground.blue { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' shape-rendering='crispEdges'%3E%3Crect width='16' height='16' fill='%230070ec'/%3E%3Crect y='7' width='16' height='1' fill='%23000'/%3E%3Crect y='15' width='16' height='1' fill='%23000'/%3E%3Crect x='7' width='1' height='7' fill='%23000'/%3E%3Crect x='15' y='8' width='1' height='7' fill='%23000'/%3E%3Crect width='7' height='1' fill='%233cbcfc'/%3E%3Crect x='8' y='8' width='7' height='1' fill='%233cbcfc'/%3E%3C/svg%3E"); }
.ground.stone { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' shape-rendering='crispEdges'%3E%3Crect width='16' height='16' fill='%235c7090'/%3E%3Crect width='16' height='1' fill='%23a4b8d8'/%3E%3Crect y='8' width='16' height='1' fill='%23a4b8d8'/%3E%3Crect y='7' width='16' height='1' fill='%23182030'/%3E%3Crect y='15' width='16' height='1' fill='%23182030'/%3E%3Crect x='10' width='1' height='7' fill='%23182030'/%3E%3Crect x='4' y='8' width='1' height='7' fill='%23182030'/%3E%3C/svg%3E"); }
.ground.crate { height: 80px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' shape-rendering='crispEdges'%3E%3Crect width='16' height='16' fill='%23ac7c00'/%3E%3Crect x='1' y='1' width='14' height='14' fill='%23e49c3c'/%3E%3Crect x='1' y='5' width='14' height='1' fill='%23ac7c00'/%3E%3Crect x='1' y='10' width='14' height='1' fill='%23ac7c00'/%3E%3Crect x='1' y='1' width='14' height='1' fill='%23fcd8a8'/%3E%3Crect x='2' y='2' width='2' height='2' fill='%23000'/%3E%3Crect x='12' y='12' width='2' height='2' fill='%23000'/%3E%3C/svg%3E"); background-size: 40px 40px; }
.ground.wall { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' shape-rendering='crispEdges'%3E%3Crect width='8' height='8' fill='%23a81000'/%3E%3Crect width='8' height='1' fill='%23000'/%3E%3Crect y='4' width='8' height='1' fill='%23000'/%3E%3Crect x='3' y='1' width='1' height='3' fill='%23000'/%3E%3Crect x='7' y='5' width='1' height='3' fill='%23000'/%3E%3Crect y='1' width='3' height='1' fill='%23fca044'/%3E%3Crect x='4' y='5' width='3' height='1' fill='%23fca044'/%3E%3C/svg%3E"); background-size: 32px 32px; }

.deco { position: absolute; z-index: 1; pointer-events: none; }
.float { animation: drift 40s linear infinite; }
@keyframes drift { from { transform: translateX(-10vw); } to { transform: translateX(110vw); } }
.blink { animation: blink 1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }
.bob { animation: bob .6s steps(2) infinite; }
@keyframes bob { 50% { transform: translateY(-4px); } }
.spin { animation: spin .8s steps(4) infinite; }
@keyframes spin { 25% { transform: scaleX(.6); } 50% { transform: scaleX(.15); } 75% { transform: scaleX(.6); } }
.flicker { animation: flick .3s steps(2) infinite; }
@keyframes flick { 50% { transform: scaleY(.85) translateY(2px); } }

/* ---------- Титульный экран ---------- */
#start { background: var(--sky); min-height: 100vh; display: flex; align-items: center; padding-bottom: 140px; }
#start .inner { text-align: center; }
.title {
  font-family: "Press", monospace; font-weight: 400; margin: 0 auto 26px; line-height: 1.25;
  font-size: clamp(22px, 6.2vw, 58px); color: var(--yl);
  text-shadow: 4px 4px 0 var(--brick), 8px 8px 0 var(--k);
  background: var(--brick); border: var(--px) solid var(--k); padding: 28px 16px 32px; max-width: 900px;
  box-shadow: inset 0 0 0 var(--px) #fcbcb0, 8px 8px 0 rgba(0,0,0,.3);
}
.title small { display: block; font-size: clamp(9px, 1.6vw, 14px); color: var(--w); text-shadow: 3px 3px 0 var(--k); margin-top: 18px; line-height: 1.7; }
.select { font-family: "Press", monospace; font-size: clamp(11px, 2.2vw, 16px); text-shadow: 3px 3px 0 var(--k); margin: 0 auto 28px; display: inline-block; text-align: left; }
.select p { margin: 0 0 16px; }
.select .off { color: #c0d8fc; text-decoration: line-through; }
.select .hint { display: block; font-family: "Pixel", monospace; font-size: 17px; text-decoration: none; color: var(--w); margin-top: 6px; }
.press-start { font-size: 14px; }
.copy { font-family: "Press", monospace; font-size: 10px; color: var(--w); text-shadow: 2px 2px 0 var(--k); margin-top: 26px; }

/* ---------- Мир 1-1: атомы ---------- */
#w1-1 { background: var(--sky); }
.mol { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.mol .name { width: 100%; font-family: "Press", monospace; font-size: 11px; color: var(--w); text-shadow: 2px 2px 0 var(--k); }
.qb {
  width: 124px; min-height: 64px; padding: 6px; cursor: pointer; text-align: center; font-size: 15px; line-height: 1.2;
  background: var(--o); color: var(--k); border: var(--px) solid var(--k);
  box-shadow: inset -4px -4px 0 #ac5000, inset 4px 4px 0 var(--yl);
  display: grid; place-items: center; font-family: "Pixel", monospace; font-weight: 700;
}
.qb .q { font-family: "Press", monospace; font-size: 22px; }
.qb.open { background: #9c4a00; color: var(--w); box-shadow: inset -4px -4px 0 #5c2800, inset 4px 4px 0 #d07a30; cursor: default; }
.qb.shared.open { background: var(--y); color: var(--k); box-shadow: inset -4px -4px 0 #ac7c00, inset 4px 4px 0 var(--w), 0 0 0 4px var(--w); }
.qb:not(.open):hover { transform: translateY(-4px); }
.qb.hit { animation: hit .2s steps(2); }
@keyframes hit { 50% { transform: translateY(-10px); } }
.valence { font-family: "Press", monospace; font-size: 13px; margin: 18px 0 0; color: var(--w); text-shadow: 3px 3px 0 var(--k); line-height: 1.8; }
.valence b { color: var(--y); font-weight: 400; font-size: 20px; }

/* ---------- Мир 1-2: подземелье ---------- */
#w1-2 { background: var(--k); }
.gap-scene { display: grid; grid-template-columns: 1fr minmax(120px, 1.2fr) 1fr; align-items: center; gap: 8px; margin-bottom: 28px; }
.island { border: var(--px) solid var(--bl); padding: 14px; text-align: center; background: #001848; }
.island .press { font-size: 11px; color: var(--bl); display: block; margin-top: 8px; }
.ties { display: flex; flex-direction: column; gap: 10px; }
.tie { border-top: 4px dashed var(--grey); text-align: center; font-size: 16px; color: var(--grey); padding-top: 4px; animation: weak 2.4s steps(2) infinite; }
.tie:nth-child(2) { animation-delay: .8s; } .tie:nth-child(3) { animation-delay: 1.6s; }
@keyframes weak { 50% { opacity: .35; } }
@media (max-width: 640px) { .gap-scene { grid-template-columns: 1fr; } }

/* ---------- Мир 2-1: ящики ---------- */
#w2-1 { background: #f8d878; color: var(--k); }
#w2-1 .tag { color: #a81000; text-shadow: none; }
#w2-1 > .inner > h3 { color: #a81000; }
.grid2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
@media (max-width: 400px) { .grid2 { grid-template-columns: 1fr; } }
#w2-1 h2 { color: var(--w); text-shadow: 4px 4px 0 #a81000, 8px 8px 0 var(--k); }
.stairs { display: flex; align-items: flex-end; gap: 0; margin: 0 0 28px; overflow-x: auto; padding-top: 70px; }
.step {
  flex: 1 1 0; min-width: 120px; background: #ac7c00; border: var(--px) solid var(--k); border-right-width: 0;
  box-shadow: inset 4px 4px 0 #e49c3c; display: flex; align-items: flex-start; justify-content: center; padding: 10px 6px;
  font-family: "Press", monospace; font-size: 10px; color: var(--w); text-align: center; line-height: 1.6; position: relative;
}
.step:last-child { border-right-width: 4px; }
.step:nth-child(1) { height: 70px; } .step:nth-child(2) { height: 120px; } .step:nth-child(3) { height: 170px; } .step:nth-child(4) { height: 220px; }
.step .spr { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: 4px; }
.stair-caption { font-family: "Press", monospace; font-size: 11px; display: flex; justify-content: space-between; margin: -18px 0 28px; }

/* ---------- Мир 2-2 и босс: танки ---------- */
#w2-2, #boss { background: var(--k); }
#w2-2 .inner::before { content: ""; }
.enemy .hp { display: flex; gap: 3px; margin: 10px 0 0; }
.enemy .hp i { width: 12px; height: 12px; background: var(--r); display: block; }
.enemy .hp i.e { background: #3c3c3c; }
.fight { display: grid; gap: 14px; }
.row { display: grid; grid-template-columns: 210px 1fr 48px; align-items: center; gap: 14px; }
.row label { font-family: "Press", monospace; font-size: 10px; line-height: 1.6; }
.row output { font-family: "Press", monospace; font-size: 12px; text-align: right; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 24px; background: transparent; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 12px; background: #3c3c3c; border: 3px solid var(--w); }
input[type=range]::-moz-range-track { height: 12px; background: #3c3c3c; border: 3px solid var(--w); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 24px; margin-top: -9px; background: var(--y); border: 3px solid var(--k); box-shadow: 0 0 0 3px var(--w); }
input[type=range]::-moz-range-thumb { width: 16px; height: 20px; background: var(--y); border: 3px solid var(--k); border-radius: 0; box-shadow: 0 0 0 3px var(--w); }
input[type=range]:focus-visible { outline: 3px dashed var(--y); outline-offset: 4px; }
@media (max-width: 640px) { .row { grid-template-columns: 1fr 48px; } .row label { grid-column: 1 / -1; } }
.bars { margin-top: 10px; display: grid; gap: 10px; }
.bar { height: 28px; border: 3px solid var(--w); background: #1c1c1c; display: flex; position: relative; }
.bar i { display: block; height: 100%; transition: width .15s steps(4); }
.bar .a { background: var(--r); }
.bar .d { background: var(--g); }
.bar .s { background: var(--bl); }
.bar .c { background: var(--y); }
.bar-l { font-family: "Press", monospace; font-size: 10px; margin-bottom: -4px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 16px; }
.legend span::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 6px; background: var(--c); }
.verdict { font-family: "Press", monospace; font-size: clamp(13px, 2.6vw, 20px); text-align: center; padding: 16px; margin-top: 8px; border: var(--px) solid; line-height: 1.5; }
.verdict.lose { color: var(--r); border-color: var(--r); }
.verdict.win { color: var(--gl); border-color: var(--gl); }
.formula { font-family: "Press", monospace; font-size: clamp(10px, 2vw, 14px); line-height: 2; text-align: center; color: var(--y); }
.formula .op { color: var(--w); padding: 0 6px; }

/* ---------- Мир 3-1: подземелье принца ---------- */
#w3-1 { background: #203050; }
.torch-l { left: 3%; top: 180px; } .torch-r { right: 3%; top: 180px; }
.typed { min-height: 7.5em; }
.typed .cursor { display: inline-block; width: 12px; height: 20px; background: var(--w); vertical-align: -3px; animation: blink 1s steps(2, start) infinite; }
.axes3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 14px; }
@media (max-width: 640px) { .axes3 { grid-template-columns: 1fr; } }
.part { text-align: left; background: #182030; border: var(--px) solid var(--dgrey); padding: 14px; cursor: pointer; }
.part .press { font-size: 10px; display: block; margin-bottom: 8px; color: var(--grey); }
.part[aria-pressed="true"] { border-color: var(--y); background: #3c2800; }
.part[aria-pressed="true"] .press { color: var(--y); }
.part span:last-child { font-size: 17px; line-height: 1.4; display: block; }

/* ---------- Мир 3-2: закатное небо ---------- */
#w3-2 { background: linear-gradient(#fc7460 0 22%, #fca044 22% 40%, #f8d878 40% 55%, #5c94fc 55%); }
.plane { top: 110px; animation: fly 26s linear infinite; }
@keyframes fly { from { transform: translateX(110vw); } to { transform: translateX(-20vw); } }
.seg { display: grid; grid-template-columns: 140px 1fr 150px; gap: 12px; align-items: center; margin-bottom: 12px; }
.seg .who { font-size: 17px; line-height: 1.25; }
.seg .who small { display: block; color: var(--grey); font-size: 15px; }
.seg .track { height: 26px; border: 3px solid var(--w); background: #1c1c1c; position: relative; }
.seg .fill { height: 100%; background: var(--g); transition: width .2s steps(5); }
.seg .fill.bad { background: var(--r); }
.seg .fill.idle { background: var(--dgrey); }
.seg .note { font-size: 15px; line-height: 1.3; }
@media (max-width: 640px) { .seg { grid-template-columns: 1fr; gap: 4px; margin-bottom: 18px; } }
.switch { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.total { font-family: "Press", monospace; font-size: 12px; line-height: 1.8; margin-top: 14px; border-top: 3px dashed var(--grey); padding-top: 14px; }
.total b { color: var(--y); font-weight: 400; }

/* ---------- Мир 3-3: экран выбора ---------- */
#w3-3 { background: var(--k); }
.cart { border: var(--px) solid var(--w); padding: 16px; background: #1c1c1c; position: relative; }
.cart .num { position: absolute; top: -14px; left: 12px; background: var(--k); padding: 0 8px; font-family: "Press", monospace; font-size: 11px; color: var(--y); }
.cart h3 { color: var(--w); margin-top: 6px; }
.poles { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pole { border: 3px solid var(--bl); padding: 4px 8px; font-size: 16px; line-height: 1.3; }
.vs { font-family: "Press", monospace; font-size: 10px; color: var(--r); }
.cart p { font-size: 16px; margin: 10px 0 0; color: var(--grey); line-height: 1.4; }

/* ---------- Мир 4-1: два экрана ---------- */
#w4-1 { background: var(--pur); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border: var(--px) solid var(--w); margin-bottom: 20px; }
.split > div { padding: 18px; background: var(--k); }
.split > div + div { border-left: var(--px) solid var(--w); }
@media (max-width: 640px) { .split { grid-template-columns: 1fr; } .split > div + div { border-left: 0; border-top: var(--px) solid var(--w); } }
.split .p { font-family: "Press", monospace; font-size: 11px; margin-bottom: 12px; }
.split .p1 { color: var(--bl); } .split .p2 { color: var(--o); }
.meter { height: 30px; border: 3px solid var(--w); background: #1c1c1c; position: relative; margin: 10px 0; }
.meter .fill { height: 100%; background: var(--g); }
.meter .mark { position: absolute; top: -8px; bottom: -8px; width: 4px; background: var(--y); left: 70%; }
.readout { font-family: "Press", monospace; font-size: 11px; line-height: 1.8; min-height: 3.6em; }
.readout .warn { color: var(--r); } .readout .ok { color: var(--gl); }

/* ---------- Мир 4-2: канавы ---------- */
#w4-2 { background: #182030; }
.road-scene { display: grid; grid-template-columns: 1fr 1.3fr 1fr; align-items: end; height: 190px; margin: 0 0 20px; }
.pit { height: 100%; background: var(--k); border-left: var(--px) solid #5c7090; border-right: var(--px) solid #5c7090; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; }
.pit .spikes { width: 100%; height: 32px; background: repeating-linear-gradient(90deg, transparent 0 4px, var(--grey) 4px 12px, transparent 12px 16px); clip-path: polygon(0 100%, 4% 0, 8% 100%, 12% 0, 16% 100%, 20% 0, 24% 100%, 28% 0, 32% 100%, 36% 0, 40% 100%, 44% 0, 48% 100%, 52% 0, 56% 100%, 60% 0, 64% 100%, 68% 0, 72% 100%, 76% 0, 80% 100%, 84% 0, 88% 100%, 92% 0, 96% 100%, 100% 0, 100% 100%); background: var(--grey); }
.pit .lbl { position: absolute; top: 40%; font-family: "Press", monospace; font-size: 10px; color: var(--r); text-align: center; width: 100%; }
.road { height: 120px; position: relative; display: flex; align-items: flex-start; justify-content: center; }
.road .heroes { position: absolute; bottom: 100%; display: flex; gap: 10px; }
.road .ground { height: 120px; }
.road .lbl { position: relative; z-index: 2; margin-top: 44px; font-family: "Press", monospace; font-size: 10px; color: var(--w); text-shadow: 2px 2px 0 var(--k); text-align: center; }
.ach { list-style: none; padding: 0 !important; }
.ach li { display: grid; grid-template-columns: 40px 1fr; gap: 12px; align-items: start; }
.ach input { appearance: none; -webkit-appearance: none; width: 28px; height: 28px; border: 3px solid var(--w); margin: 2px 0 0; cursor: pointer; background: #1c1c1c; }
.ach input:checked { background: var(--y); box-shadow: inset 0 0 0 4px var(--k); }
.ach input:focus-visible { outline: 3px dashed var(--y); outline-offset: 3px; }
.ach label { cursor: pointer; }
.ach-count { font-family: "Press", monospace; font-size: 11px; color: var(--y); margin-top: 12px; }

/* ---------- Книга: карта мира ---------- */
#book { background: var(--g); }
#book .tag { color: var(--w); }
.map { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 20px; margin-bottom: 28px; }
.part-card { background: var(--k); border: var(--px) solid var(--w); padding: 14px; }
.part-card h3 { font-size: 11px; }
.part-card ol { list-style: none; padding: 0; margin: 0; counter-reset: none; }
.part-card li { display: grid; grid-template-columns: 34px 1fr; gap: 8px; font-size: 16px; line-height: 1.3; margin-bottom: 10px; align-items: center; }
.part-card li .n { font-family: "Press", monospace; font-size: 10px; color: var(--grey); }
.part-card.done { border-color: var(--y); }
.part-card .st { font-family: "Press", monospace; font-size: 9px; display: inline-block; margin-bottom: 12px; padding: 4px 6px; border: 2px solid var(--grey); color: var(--grey); }
.part-card.done .st { border-color: var(--y); color: var(--y); }

/* ---------- Секретные уровни ---------- */
#secret { background: var(--pur); background-image: radial-gradient(var(--w) 2px, transparent 2px); background-size: 90px 70px; background-position: 13px 7px; }
.moon { right: 8%; top: 110px; }
.skyline { position: absolute; left: 0; right: 0; bottom: 0; height: 140px; z-index: 1;
  background:
    linear-gradient(var(--k), var(--k)) 0 100% / 8% 60% no-repeat,
    linear-gradient(var(--k), var(--k)) 9% 100% / 6% 90% no-repeat,
    linear-gradient(var(--k), var(--k)) 16% 100% / 10% 45% no-repeat,
    linear-gradient(var(--k), var(--k)) 28% 100% / 5% 100% no-repeat,
    linear-gradient(var(--k), var(--k)) 34% 100% / 12% 55% no-repeat,
    linear-gradient(var(--k), var(--k)) 48% 100% / 7% 80% no-repeat,
    linear-gradient(var(--k), var(--k)) 56% 100% / 11% 40% no-repeat,
    linear-gradient(var(--k), var(--k)) 68% 100% / 6% 95% no-repeat,
    linear-gradient(var(--k), var(--k)) 75% 100% / 9% 65% no-repeat,
    linear-gradient(var(--k), var(--k)) 85% 100% / 5% 85% no-repeat,
    linear-gradient(var(--k), var(--k)) 91% 100% / 9% 50% no-repeat; }
.qmark { font-family: "Press", monospace; font-size: 28px; color: var(--gl); float: left; margin: 0 14px 0 0; }

.contact { border-color: var(--gl); }
.contact .mail a { color: var(--gl); font-weight: 700; }
.contact .fine { font-size: 15px; color: var(--grey); }

/* ---------- Финал ---------- */
#end { background: var(--k); text-align: center; min-height: 80vh; display: flex; align-items: center; }
#end .inner { width: 100%; }
.cont { font-family: "Press", monospace; font-size: clamp(20px, 5vw, 42px); margin: 0 0 18px; }
.count { font-family: "Press", monospace; font-size: clamp(40px, 10vw, 90px); color: var(--y); margin: 0 0 30px; }
.links { display: flex; flex-direction: column; gap: 14px; align-items: center; margin-bottom: 40px; }
.links a { font-family: "Press", monospace; font-size: 12px; color: var(--w); text-decoration: none; line-height: 1.7; }
.links a::before { content: "▶ "; visibility: hidden; color: var(--y); }
.links a:hover::before, .links a:focus::before { visibility: visible; }
.links a:hover, .links a:focus { color: var(--y); outline: none; }

/* Всплывашки */
.pop { position: fixed; z-index: 70; font-family: "Press", monospace; font-size: 12px; color: var(--w); text-shadow: 2px 2px 0 var(--k); pointer-events: none; animation: pop .8s steps(8) forwards; }
@keyframes pop { to { transform: translateY(-50px); opacity: 0; } }
.coin-btn { background: none; border: 0; padding: 4px; cursor: pointer; position: absolute; z-index: 3; }
.coin-btn:focus-visible { outline: 3px dashed var(--w); }
.coin-btn.got { visibility: hidden; }
.toast {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 80; width: min(560px, calc(100vw - 32px));
  background: var(--k); border: var(--px) solid var(--y); box-shadow: 0 0 0 var(--px) var(--k), 0 0 0 9999px rgba(0,0,0,.6);
  padding: 22px; text-align: center;
}
.toast[hidden] { display: none; }
.toast .press { font-size: 13px; color: var(--y); margin: 0 0 14px; }

@media (max-width: 640px) {
  .world { padding-bottom: 130px; }
  .deco[data-s="tank"], .deco[data-s="tankR"], .deco[data-s="torch"], .plane, .moon { display: none; }
  .coin-btn { top: auto !important; bottom: 76px !important; }
  .stairs { padding-top: 60px; }
  .step { min-width: 0; font-size: 8px; padding: 8px 2px; overflow-wrap: anywhere; }
  .step:nth-child(1) { height: 60px; } .step:nth-child(2) { height: 95px; } .step:nth-child(3) { height: 130px; } .step:nth-child(4) { height: 165px; }
  .box { padding: 16px; }
}

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