@font-face {
  font-family: 'Press Start 2P'; 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-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+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #0b2f24; --bg2: #08241b; --main: #116e53; --accent: #ffd60a; --pink: #ff5c8a; --cyan: #5cf2ff;
  --ink: #ffffff; --card: rgba(255, 255, 255, 0.08); --line: rgba(255, 255, 255, 0.18);
  --px: 'Press Start 2P', ui-monospace, 'Courier New', monospace;
  --body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}
html, body { height: 100%; }
body {
  font-family: var(--body); color: var(--ink);
  background: radial-gradient(circle at 50% 0%, #14583f 0%, var(--bg) 55%, var(--bg2) 100%) fixed;
  -webkit-text-size-adjust: 100%; overflow-x: hidden;
}
/* лёгкие «строки развёртки» старого монитора */
body::after {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 9999;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.12) 0, rgba(0, 0, 0, 0.12) 1px, transparent 1px, transparent 3px);
}
.hidden { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

#app { max-width: 520px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; padding: calc(10px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom)); }
#top { display: flex; justify-content: space-between; align-items: center; padding: 6px 0 10px; }
.brand { font-family: var(--px); font-size: 15px; color: var(--accent); text-shadow: 2px 2px 0 #000; }
#sound-btn { background: var(--card); border: 2px solid var(--line); color: #fff; width: 42px; height: 42px; font-size: 18px; cursor: pointer; border-radius: 6px; }

.view { flex: 1; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; }
.title { font-family: var(--px); font-size: 22px; line-height: 1.3; color: #fff; text-shadow: 3px 3px 0 #000, 0 0 18px rgba(255, 214, 10, 0.5); margin-top: 4px; }
.title.small { font-size: 16px; }
.lead { font-size: 15px; line-height: 1.5; color: rgba(255, 255, 255, 0.88); max-width: 380px; }
.lead b { color: var(--accent); }
.cta { font-size: 13px; color: rgba(255, 255, 255, 0.7); margin-top: auto; padding-top: 14px; max-width: 360px; line-height: 1.5; }

.progress { display: flex; gap: 8px; align-items: center; font-family: var(--px); font-size: 10px; color: var(--accent); }
.pip { width: 18px; height: 18px; background: rgba(255, 255, 255, 0.12); border: 2px solid var(--line); }
.pip.on { background: var(--accent); border-color: #fff; box-shadow: 0 0 10px rgba(255, 214, 10, 0.6); }

/* кнопки */
.btn {
  font-family: var(--px); font-size: 12px; line-height: 1.4; color: #0b2f24; background: #fff;
  border: none; padding: 14px 18px; cursor: pointer; min-height: 48px; text-decoration: none; display: inline-block;
  box-shadow: 0 4px 0 #9aa, 0 6px 0 #000; border-radius: 4px; transition: transform 0.05s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #9aa, 0 2px 0 #000; }
.btn-yellow { background: var(--accent); box-shadow: 0 4px 0 #b39500, 0 6px 0 #000; }
.btn-pink { background: var(--pink); color: #fff; box-shadow: 0 4px 0 #b02a55, 0 6px 0 #000; }
.btn-ghost { background: transparent; color: #fff; border: 2px solid var(--line); box-shadow: none; }
.btn-small { font-size: 10px; padding: 10px 12px; min-height: 40px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

/* карточки игр */
.games { display: grid; grid-template-columns: 1fr; gap: 10px; width: 100%; }
.game-card {
  display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center; text-align: left;
  background: var(--card); border: 2px solid var(--line); border-radius: 6px; padding: 12px; color: #fff; cursor: pointer; font: inherit;
}
.game-card:hover, .game-card:focus-visible { border-color: var(--accent); background: rgba(255, 214, 10, 0.08); }
.game-card .gi { font-size: 38px; text-align: center; }
.game-card .gn { font-family: var(--px); font-size: 12px; line-height: 1.4; color: var(--accent); }
.game-card .gb { font-size: 13px; color: rgba(255, 255, 255, 0.78); margin-top: 4px; line-height: 1.35; }
.game-card .gs { font-family: var(--px); font-size: 9px; color: rgba(255, 255, 255, 0.7); text-align: right; line-height: 1.7; }
.game-card .tick { color: var(--lime, #9dffb8); font-size: 14px; }

.final {
  width: 100%; border: 3px dashed var(--accent); background: rgba(255, 214, 10, 0.1); color: var(--accent);
  font-family: var(--px); font-size: 12px; line-height: 1.6; padding: 16px; cursor: pointer; border-radius: 6px;
}
.final.locked { border-color: var(--line); background: var(--card); color: rgba(255, 255, 255, 0.55); cursor: default; }
.final.open { animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { background: rgba(255, 214, 10, 0.25); } }

/* игра */
#view-play { gap: 8px; position: relative; align-items: stretch; }
.play-bar { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; }
.play-name { font-family: var(--px); font-size: 11px; color: var(--accent); text-align: center; line-height: 1.4; }
.play-stats { font-family: var(--px); font-size: 14px; text-align: right; display: flex; flex-direction: column; gap: 4px; min-width: 70px; }
.play-stats small { font-size: 9px; color: var(--cyan); min-height: 11px; }
#play-area { flex: 1; min-height: 300px; display: flex; justify-content: center; align-items: center; position: relative; }
.stage { border: 3px solid #000; box-shadow: 0 0 0 3px var(--main), 0 0 30px rgba(0, 0, 0, 0.5); touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; background: #0b2f24; }
.stage canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
#play-controls { display: flex; gap: 10px; justify-content: center; padding-top: 6px; }
#play-controls:empty { display: none; }
.pad {
  flex: 1; max-width: 90px; min-height: 58px; font-family: var(--px); font-size: 20px; color: #fff;
  background: var(--main); border: 3px solid #000; border-radius: 6px; box-shadow: 0 4px 0 #063f2f; touch-action: manipulation;
  -webkit-user-select: none; user-select: none; cursor: pointer;
}
.pad:active { transform: translateY(3px); box-shadow: 0 1px 0 #063f2f; }

.overlay { position: absolute; inset: 0; background: rgba(8, 36, 27, 0.92); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 5; }
.overlay-box { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; max-width: 360px; }
.overlay-icon { font-size: 64px; }
.overlay h2 { font-family: var(--px); font-size: 16px; line-height: 1.4; color: var(--accent); }
.overlay p { font-size: 15px; line-height: 1.5; color: rgba(255, 255, 255, 0.9); }

/* результат */
.score-line { font-family: var(--px); font-size: 13px; line-height: 1.8; color: #fff; }
.score-line b { color: var(--accent); font-size: 20px; }
.pred {
  width: 100%; background: #fffaf0; color: #2b1d0e; border: 4px solid #000; border-radius: 6px; padding: 18px 16px;
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.5), inset 0 0 0 3px var(--accent); text-align: center; min-height: 190px;
  display: flex; flex-direction: column; gap: 12px; justify-content: center; position: relative;
}
.pred-head { font-family: var(--px); font-size: 10px; line-height: 1.6; color: #b5541f; }
.pred-text { font-size: 19px; line-height: 1.45; font-weight: 600; }
.pred.reveal { animation: pop 0.5s ease-out; }
@keyframes pop { 0% { transform: scale(0.85) rotate(-2deg); opacity: 0; } 70% { transform: scale(1.04); } 100% { transform: none; opacity: 1; } }

/* коллекция */
.collection { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.collection .item { background: #fffaf0; color: #2b1d0e; border: 3px solid #000; border-radius: 6px; padding: 12px; text-align: left; font-size: 15px; line-height: 1.4; font-weight: 600; }
.collection .item small { display: block; font-family: var(--px); font-size: 8px; color: #b5541f; margin-bottom: 6px; line-height: 1.6; }
.collection .item.final-item { border-color: var(--pink); box-shadow: 0 0 0 3px var(--accent); }
.empty { color: rgba(255, 255, 255, 0.7); line-height: 1.5; font-size: 15px; padding: 20px 0; }

.modal { position: fixed; inset: 0; z-index: 10000; background: rgba(0, 0, 0, 0.85); display: flex; align-items: center; justify-content: center; padding: 14px; overflow-y: auto; }
.modal-box { display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: 360px; text-align: center; font-size: 14px; }
.modal-box img { width: 100%; max-height: 62vh; object-fit: contain; border: 3px solid #fff; }

@media (prefers-reduced-motion: reduce) { .final.open, .pred.reveal { animation: none; } }
@media (min-width: 700px) { .games { grid-template-columns: 1fr; } }
body.playing #app { height: 100vh; height: 100dvh; overflow: hidden; }
body.playing { overflow: hidden; }
