/* Кузница игр — основа: шрифты, токены, сброс, каркас страницы, кнопки, формы, шапка, всплывающие окна */
@font-face { font-family: 'Tiny5'; font-weight: 400 700; font-style: normal; font-display: swap; size-adjust: 128%;
  src: url(/fonts/tiny5-cyrillic-400-normal.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Tiny5'; font-weight: 400 700; font-style: normal; font-display: swap; size-adjust: 128%;
  src: url(/fonts/tiny5-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+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Press Start 2P'; font-weight: 400; font-style: normal; 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; }
@font-face { font-family: 'Press Start 2P'; font-weight: 400; font-style: normal; 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+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Golos Text'; font-weight: 400 900; font-style: normal; font-display: swap;
  src: url(/fonts/golos-text-cyrillic-wght-normal.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Golos Text'; font-weight: 400 900; font-style: normal; font-display: swap;
  src: url(/fonts/golos-text-latin-wght-normal.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-face { font-family: 'JetBrains Mono'; font-weight: 100 800; font-style: normal; font-display: swap;
  src: url(/fonts/jetbrains-mono-cyrillic-wght-normal.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'JetBrains Mono'; font-weight: 100 800; font-style: normal; font-display: swap;
  src: url(/fonts/jetbrains-mono-latin-wght-normal.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; }

:root {
  --navy-950: #061030; --navy-900: #081433; --navy-800: #0b1f4b; --navy-700: #12306b; --navy-600: #1b3f8a;
  --paper: #fff1e8; --text: #eaf1ff; --muted: #a3b5dc; --faint: #8ea3d1;
  --cyan: #29adff; --orange: #ffa300; --pink: #ff77a8; --green: #00e436; --red: #ff004d; --yellow: #ffec27;
  --line: rgba(255, 241, 232, .2); --line-2: rgba(255, 241, 232, .45);
  --panel: rgba(8, 20, 51, .8); --panel-solid: #0a1b44;
  --pixel: 'Tiny5', 'Press Start 2P', system-ui, sans-serif;
  --hud: 'Press Start 2P', 'Tiny5', monospace;
  --body: 'Golos Text', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --wrap: 1200px; --gutter: clamp(16px, 4vw, 40px);
  --header-h: 64px; --tabbar-h: 0px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 16px); }
body { margin: 0; min-height: 100vh; background: var(--navy-800); color: var(--text); font: 400 1.0625rem/1.65 var(--body); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
img, svg, video { max-width: 100%; }
img { display: block; height: auto; }
a { color: var(--cyan); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: #7cc9ff; }
h1, h2, h3, h4 { font-family: var(--pixel); font-weight: 700; line-height: 1.12; margin: 0 0 .5em; letter-spacing: .01em; color: var(--paper); text-wrap: balance; }
h1 { font-size: clamp(2.2rem, 5.2vw, 3.9rem); }
h2 { font-size: clamp(1.6rem, 3.2vw, 2.4rem); }
h3 { font-size: clamp(1.2rem, 2vw, 1.5rem); }
h4 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
ul, ol { margin: 0 0 1em; padding-left: 1.25em; }
li { margin: .25em 0; }
code, kbd, pre { font-family: var(--mono); font-size: .9em; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
hr { border: 0; border-top: 1px dashed var(--line-2); margin: 2rem 0; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 3px; }
::selection { background: var(--orange); color: #1a0f00; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -80px; z-index: 200; background: var(--orange); color: #1a0f00; padding: 10px 16px; font-weight: 700; text-decoration: none; }
.skip:focus { top: 12px; }
.spr { image-rendering: pixelated; display: inline-block; vertical-align: middle; flex: none; }

/* чертёжная сетка и еле заметный CRT */
body::before { content: ''; position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background:
    linear-gradient(rgba(41, 173, 255, .075) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(90deg, rgba(41, 173, 255, .075) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(rgba(255, 241, 232, .07) 1px, transparent 1px) 0 0 / 120px 120px,
    linear-gradient(90deg, rgba(255, 241, 232, .07) 1px, transparent 1px) 0 0 / 120px 120px,
    radial-gradient(ellipse at 50% -10%, #17408f 0%, var(--navy-800) 55%, var(--navy-950) 100%); }
body::after { content: ''; position: fixed; inset: 0; z-index: 150; pointer-events: none; opacity: .5;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, .13) 0 1px, transparent 1px 3px);
  animation: crt 7s ease-in-out infinite; }
@keyframes crt { 0%, 100% { opacity: .42; } 48% { opacity: .5; } 50% { opacity: .38; } 52% { opacity: .5; } }

.wrap { width: 100%; max-width: calc(var(--wrap) + var(--gutter) * 2); margin: 0 auto; padding: 0 var(--gutter); }
main { display: block; min-height: 60vh; outline: none; }
.page { padding-block: clamp(28px, 5vw, 56px) clamp(48px, 8vw, 96px); }
.page-head { margin-bottom: clamp(22px, 4vw, 40px); }
.page-head p { color: var(--muted); max-width: 62ch; font-size: 1.15rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.hud-font { font-family: var(--hud); font-size: .7rem; line-height: 1.6; letter-spacing: 0; }

/* кнопки: клавиши A/B с физичным нажатием */
.btn { --c: var(--orange); --c-dark: #a86400; --c-ink: #1a0f00;
  display: inline-flex; align-items: center; justify-content: center; gap: .55em; min-height: 46px; padding: .5em 1.15em; border: 0; border-radius: 6px;
  font: 700 1.05rem/1.1 var(--pixel); letter-spacing: .01em; color: var(--c-ink); text-decoration: none; background: var(--c); cursor: pointer; position: relative; top: 0;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .4), inset 0 -4px 0 rgba(0, 0, 0, .22), 0 4px 0 var(--c-dark), 0 6px 0 var(--navy-950);
  transition: transform .12s var(--ease), box-shadow .12s var(--ease), filter .15s; user-select: none; -webkit-tap-highlight-color: transparent; }
.btn:hover { transform: translateY(-2px); filter: brightness(1.08); color: var(--c-ink); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .4), inset 0 -4px 0 rgba(0, 0, 0, .22), 0 6px 0 var(--c-dark), 0 8px 0 var(--navy-950); }
.btn:active { transform: translateY(4px); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .3), inset 0 -2px 0 rgba(0, 0, 0, .22), 0 0 0 var(--c-dark), 0 2px 0 var(--navy-950); filter: none; }
.btn[disabled], .btn[aria-disabled='true'] { opacity: .5; pointer-events: none; filter: grayscale(.4); }
.btn-b { --c: var(--cyan); --c-dark: #0a6aa8; }
.btn-g { --c: var(--green); --c-dark: #00872a; }
.btn-p { --c: var(--pink); --c-dark: #b5406f; }
.btn-ghost { --c-ink: var(--paper); background: transparent; color: var(--paper); box-shadow: inset 0 0 0 2px var(--line-2), 0 4px 0 var(--navy-950); }
.btn-ghost:hover { background: rgba(255, 241, 232, .08); color: #fff; box-shadow: inset 0 0 0 2px var(--paper), 0 6px 0 var(--navy-950); }
.btn-ghost:active { box-shadow: inset 0 0 0 2px var(--paper), 0 0 0 var(--navy-950); }
.btn-sm { min-height: 44px; padding: .35em .85em; font-size: .95rem; }
.btn-block { width: 100%; }
.btn .spr { margin: -2px 0; }
.btn-link { display: inline-block; font: 700 1rem var(--pixel); color: var(--navy-950); background: var(--orange); padding: .55em 1em; text-decoration: none; box-shadow: 0 4px 0 #a86400; border-radius: 4px; }
.btn-link:hover { color: var(--navy-950); filter: brightness(1.08); }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border: 2px solid var(--line-2); background: transparent; border-radius: 6px; color: var(--paper); }
.icon-btn:hover { border-color: var(--paper); background: rgba(255, 241, 232, .08); }
.link-btn { background: none; border: 0; padding: 0; color: var(--cyan); text-decoration: underline; text-underline-offset: 3px; font: inherit; cursor: pointer; }

/* формы */
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field > label, .label { font: 700 .95rem var(--pixel); color: var(--paper); letter-spacing: .02em; }
.hint { font-size: .85rem; color: var(--faint); }
.input, input[type='text'], input[type='email'], input[type='password'], input[type='search'], input[type='url'], input[type='date'], select, textarea {
  width: 100%; min-height: 46px; padding: .6em .8em; background: var(--navy-900); border: 2px solid var(--line-2); border-radius: 4px; color: var(--text); font: 1rem/1.4 var(--body); transition: border-color .15s, box-shadow .15s; }
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: #6f86b8; }
input:hover, select:hover, textarea:hover { border-color: var(--paper); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255, 163, 0, .3); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--paper) 50%), linear-gradient(135deg, var(--paper) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
input[type='checkbox'], input[type='radio'] { width: 20px; height: 20px; min-height: 0; accent-color: var(--orange); }
.form-error { min-height: 1.4em; color: #ff9bb8; font-weight: 500; margin: 8px 0; }
.form-error:empty { display: none; }
.form-actions { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-top: 8px; }
.counter { text-align: right; font-size: .8rem; color: var(--faint); }

/* шапка и навигация */
.site-header { position: sticky; top: 0; z-index: 90; background: rgba(6, 16, 48, .985); border-bottom: 2px solid var(--line); }
.site-header .wrap { display: flex; align-items: center; gap: 18px; min-height: var(--header-h); }
.brand { display: inline-flex; align-items: center; gap: 10px; font: 700 1.45rem var(--pixel); color: var(--paper); text-decoration: none; white-space: nowrap; }
.brand:hover { color: #fff; }
.brand .spr { animation: bob 3.2s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
.nav { display: flex; gap: 4px; margin-left: 12px; }
.nav a { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; color: var(--muted); text-decoration: none; font: 700 1.02rem var(--pixel); border-bottom: 3px solid transparent; }
.nav a:hover { color: var(--paper); }
.nav a[aria-current='page'] { color: var(--paper); border-bottom-color: var(--orange); }
.nav .spr { filter: grayscale(.6) brightness(.9); }
.nav a[aria-current='page'] .spr, .nav a:hover .spr { filter: none; }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.hud-chip { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border: 2px solid var(--line-2); background: var(--navy-900); color: var(--paper); text-decoration: none; border-radius: 4px; }
.hud-chip:hover { border-color: var(--orange); color: #fff; }
.hud-chip .lv { font: 400 .62rem/1 var(--hud); color: var(--orange); white-space: nowrap; }
.hud-chip .xpbar { width: 64px; height: 10px; }
.hud-chip.bump { animation: bump .6s var(--ease); }
@keyframes bump { 0% { transform: scale(1); } 30% { transform: scale(1.12); border-color: var(--yellow); box-shadow: 0 0 18px rgba(255, 236, 39, .6); } 100% { transform: scale(1); } }

.site-footer { border-top: 2px solid var(--line); background: rgba(6, 16, 48, .92); padding: 36px 0 48px; color: var(--muted); font-size: .95rem; }
.site-footer .cols { display: grid; gap: 28px; grid-template-columns: 1.4fr 1fr 1fr; }
.site-footer h4 { font-size: 1rem; color: var(--paper); }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin: .4em 0; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: #fff; }
.site-footer .legal { margin-top: 28px; padding-top: 18px; border-top: 1px dashed var(--line); font-size: .85rem; color: var(--faint); }

/* всплывающие окна и уведомления */
.modal-back { position: fixed; inset: 0; z-index: 120; background: rgba(3, 8, 24, .78); display: grid; place-items: center; padding: 16px; animation: fade .18s ease-out; overflow-y: auto; }
.modal { position: relative; width: min(100%, 560px); max-height: calc(100vh - 32px); overflow: auto; background: var(--panel-solid); border: 2px solid var(--paper); box-shadow: 0 8px 0 var(--navy-950), 0 0 0 6px rgba(41, 173, 255, .18); padding: clamp(20px, 4vw, 32px); animation: rise .22s var(--ease); }
.modal.wide { width: min(100%, 960px); }
.modal h2 { font-size: 1.7rem; padding-right: 48px; }
.modal-close { position: absolute; right: 10px; top: 10px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.toasts { position: fixed; z-index: 130; right: 16px; bottom: calc(16px + var(--tabbar-h)); display: grid; gap: 10px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; background: var(--panel-solid); border: 2px solid var(--cyan); box-shadow: 0 5px 0 var(--navy-950); animation: toast-in .3s var(--ease); }
.toast strong { display: block; font: 700 1.05rem var(--pixel); color: var(--paper); }
.toast span { color: var(--muted); font-size: .92rem; line-height: 1.4; }
.toast.ok { border-color: var(--green); }
.toast.warn { border-color: var(--orange); }
.toast.err { border-color: var(--red); }
.toast.gold { border-color: var(--yellow); box-shadow: 0 5px 0 var(--navy-950), 0 0 22px rgba(255, 236, 39, .35); }
.toast.out { animation: toast-out .25s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateX(30px); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(30px); } }

/* состояния: загрузка, пусто, ошибка */
.state { display: grid; justify-items: center; gap: 12px; text-align: center; padding: clamp(36px, 8vw, 72px) 16px; color: var(--muted); }
.state h3 { color: var(--paper); margin: 0; }
.state p { max-width: 44ch; margin: 0; }
.skeleton { background: linear-gradient(90deg, rgba(255, 241, 232, .06), rgba(255, 241, 232, .16), rgba(255, 241, 232, .06)); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; min-height: 18px; border-radius: 3px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.pixel-spinner { width: 36px; height: 36px; display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); gap: 3px; }
.pixel-spinner i { background: var(--orange); animation: blink 1.1s steps(2) infinite; }
.pixel-spinner i:nth-child(2n) { background: var(--cyan); animation-delay: .15s; }
.pixel-spinner i:nth-child(3n) { animation-delay: .3s; }
@keyframes blink { 50% { opacity: .15; } }

@media (max-width: 900px) {
  :root { --tabbar-h: 62px; --header-h: 56px; }
  body { padding-bottom: var(--tabbar-h); }
  .site-header .wrap { gap: 10px; }
  .brand { font-size: 1.25rem; }
  .nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 95; margin: 0; gap: 0; height: var(--tabbar-h); background: #061030; border-top: 2px solid var(--line-2); padding-bottom: env(safe-area-inset-bottom); }
  .nav a { flex: 1; flex-direction: column; justify-content: center; gap: 2px; padding: 0 2px; font-size: .78rem; border-bottom: 0; border-top: 3px solid transparent; min-width: 0; }
  .nav a[aria-current='page'] { border-top-color: var(--orange); background: rgba(255, 163, 0, .08); }
  .hud-chip .xpbar { display: none; }
  .site-footer .cols { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .hud-chip { padding: 0 8px; gap: 6px; }
  .hud-chip .spr { display: none; }
  .brand span.brand-name { font-size: 1.1rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  body::after { animation: none; opacity: .4; }
}
