/* ===== YAPOO Arcade · G07 «1 секунда» ===== */
:root {
  --bg: #F3F4F8;
  --card: #FFFFFF;
  --card-2: #E9ECF4;
  --text: #1A1D29;
  --muted: #565C70;
  --line: #D3D8E6;
  --accent: #D9691F;
  --accent-ink: #1B1308;
  --teal: #0F7E76;
  --teal-ink: #FFFFFF;
  --good: #12805C;
  --good-bg: #D9F3E6;
  --bad: #C73030;
  --bad-bg: #FBE0E0;
  --shadow: 0 6px 24px rgba(20, 24, 50, .10);
  --font-h: "Unbounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-b: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-m: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11131D; --card: #1B1E2C; --card-2: #252940; --text: #F1F2F7; --muted: #A9AEC2; --line: #333857;
    --accent: #F39A55; --accent-ink: #1B1308; --teal: #45C3B5; --teal-ink: #0A1A18;
    --good: #4FD69C; --good-bg: #123B2C; --bad: #FF7B7B; --bad-bg: #4A1D22; --shadow: 0 6px 24px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  --bg: #11131D; --card: #1B1E2C; --card-2: #252940; --text: #F1F2F7; --muted: #A9AEC2; --line: #333857;
  --accent: #F39A55; --accent-ink: #1B1308; --teal: #45C3B5; --teal-ink: #0A1A18;
  --good: #4FD69C; --good-bg: #123B2C; --bad: #FF7B7B; --bad-bg: #4A1D22; --shadow: 0 6px 24px rgba(0,0,0,.4);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: var(--font-b); font-size: 16px; line-height: 1.45;
  overflow-x: hidden; -webkit-font-smoothing: antialiased;
}
body.reel-on { overflow: hidden; cursor: none; background: #07080d; }
body.reel-on * { cursor: none !important; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }

/* ----- постійні кнопки ----- */
#chrome {
  position: fixed; z-index: 30; top: calc(var(--safe-t) + 10px); left: 12px; right: 12px;
  display: flex; gap: 8px; align-items: center; pointer-events: none;
}
#chrome > * { pointer-events: auto; }
#chrome .spacer { flex: 1; pointer-events: none; }
body.reel-on #chrome { display: none; }
.icon-btn {
  width: 46px; height: 46px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--card); box-shadow: var(--shadow); font-size: 20px; cursor: pointer;
  display: grid; place-items: center; transition: transform .12s;
}
.icon-btn:active { transform: scale(.92); }

.screen { min-height: 100dvh; padding: calc(var(--safe-t) + 66px) 16px calc(var(--safe-b) + 28px); display: flex; justify-content: center; }
.home-wrap, .game-wrap, .result-wrap { width: 100%; max-width: 560px; }
.home-wrap { text-align: center; }

/* ----- типографіка ----- */
.eyebrow { font-family: var(--font-m); font-weight: 700; font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--teal); margin: 6px 0 2px; }
.title { font-family: var(--font-h); font-weight: 800; font-size: clamp(40px, 12vw, 72px); line-height: 1.05; margin: 0 0 10px; color: var(--accent); letter-spacing: -.02em; }
.title-sm { font-size: clamp(28px, 8vw, 44px); }
.lead { font-size: 17px; color: var(--muted); margin: 0 auto 18px; max-width: 460px; }
.h2 { font-family: var(--font-h); font-weight: 700; font-size: 15px; letter-spacing: .04em; text-transform: uppercase; margin: 22px 0 10px; }
.h3 { font-family: var(--font-h); font-weight: 700; font-size: 16px; margin: 0 0 10px; }
.fineprint { color: var(--muted); font-size: 14px; margin: 14px 0 0; font-family: var(--font-m); }

/* ----- Loop ----- */
:root[data-theme="dark"] .loop { filter: drop-shadow(0 0 8px rgba(243,154,85,.28)); }
.loop { image-rendering: pixelated; image-rendering: crisp-edges; display: block; margin: 0 auto; }
.loop-xl { width: 176px; height: 176px; }
.loop-lg { width: 154px; height: 154px; }
.loop-sm { width: 66px; height: 66px; margin: 0; }
.loop.bounce { animation: bounce .5s ease; }
.loop.shake { animation: shake .45s ease; }
@keyframes bounce { 0%,100% { transform: translateY(0); } 35% { transform: translateY(-14px) scale(1.06); } 65% { transform: translateY(0) scale(.97); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(4px); } }

/* ----- кнопки ----- */
.btn {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 54px; padding: 12px 22px; border-radius: 16px; border: 2px solid transparent;
  font-family: var(--font-h); font-weight: 700; font-size: 16px; cursor: pointer; text-decoration: none;
  transition: transform .12s, filter .12s;
}
.btn small { font-family: var(--font-b); font-weight: 600; font-size: 12.5px; opacity: .85; }
.btn:active { transform: scale(.97); }
.btn:hover { filter: brightness(1.06); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-teal { background: var(--teal); color: var(--teal-ink); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.home-actions { display: grid; gap: 10px; margin-top: 22px; }

/* ----- вибір рівня ----- */
.levels { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.level-card {
  text-align: left; padding: 14px 16px; border-radius: 18px; background: var(--card); border: 2px solid var(--line);
  cursor: pointer; display: grid; gap: 2px; min-height: 76px; transition: transform .12s, border-color .12s;
}
.level-card:active { transform: scale(.97); }
.level-card .lv { font-family: var(--font-h); font-weight: 800; font-size: 26px; color: var(--text); }
.level-card .lv-name { font-weight: 800; font-size: 14px; }
.level-card .lv-best { font-family: var(--font-m); font-size: 12.5px; color: var(--muted); }
.level-card[aria-checked="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--card)); }
.level-card[aria-checked="true"] .lv { color: var(--accent); }

/* ----- гра ----- */
.game-wrap { display: grid; align-content: start; gap: 12px; }
.game-top { display: flex; align-items: center; gap: 12px; }
.level-pill { font-family: var(--font-h); font-weight: 800; background: var(--accent); color: var(--accent-ink); padding: 4px 14px; border-radius: 999px; font-size: 15px; }
.count { font-family: var(--font-m); font-weight: 700; font-size: 15px; }
.speed { margin-left: auto; font-family: var(--font-m); font-weight: 700; font-size: 15px; color: var(--teal); }
.dots { display: flex; gap: 6px; }
.dots i { flex: 1; height: 8px; border-radius: 4px; background: var(--card-2); transition: background .2s, transform .2s; }
.dots i.cur { background: var(--accent); transform: scaleY(1.4); }
.dots i.ok { background: var(--good); }
.dots i.bad { background: var(--bad); }

.word-card {
  position: relative; background: var(--card); border: 2px solid var(--line); border-radius: 26px; box-shadow: var(--shadow);
  padding: 14px 14px 22px; min-height: clamp(220px, 34dvh, 300px);
  display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr auto auto; justify-items: center; align-items: center; overflow: hidden;
  transition: background .2s, border-color .2s;
}
.word-card .loop-sm { position: absolute; left: 12px; top: 12px; }
.word-card.ok { border-color: var(--good); background: color-mix(in srgb, var(--good) 12%, var(--card)); }
.word-card.bad { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, var(--card)); animation: shake .45s ease; }
.phase-label { font-family: var(--font-m); font-weight: 700; font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }
.word-stage { width: 100%; min-width: 0; text-align: center; display: grid; place-items: center; min-height: 100px; padding: 0 4px; }
.word-text { display: inline-block; white-space: nowrap; font-family: var(--font-h); font-weight: 800; font-size: 56px; line-height: 1.1; color: var(--text); }
.word-text.pop { animation: pop .18s ease-out; }
.word-text.ghost { color: var(--muted); opacity: .5; }
.word-text.num { color: var(--accent); }
@keyframes pop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.reveal { min-height: 30px; font-family: var(--font-h); font-weight: 700; font-size: 20px; text-align: center; padding: 0 6px; }
.reveal.ok { color: var(--good); }
.reveal.bad { color: var(--bad); }
.reveal .sub { display: block; font-family: var(--font-b); font-weight: 600; font-size: 14px; color: var(--muted); margin-top: 2px; }
.timer { width: 100%; height: 10px; border-radius: 6px; background: var(--card-2); overflow: hidden; margin-top: 8px; }
.timer-bar { height: 100%; width: 100%; transform-origin: left center; background: var(--accent); border-radius: 6px; }
.timer-bar.choose { background: var(--teal); }

.options { display: grid; gap: 10px; grid-template-columns: 1fr; }
.opt {
  position: relative; min-height: 58px; padding: 10px 16px 10px 48px; border-radius: 16px; border: 2px solid var(--line);
  background: var(--card); font-weight: 800; font-size: 18px; text-align: left; cursor: pointer;
  display: flex; align-items: center; transition: transform .1s, background .15s, border-color .15s, opacity .15s;
}
.opt::before {
  content: attr(data-n); position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 26px; height: 26px; border-radius: 8px; background: var(--card-2); color: var(--muted);
  font-family: var(--font-m); font-weight: 700; font-size: 13px; display: grid; place-items: center;
}
.opt:active { transform: scale(.98); }
.opt.hole { border-style: dashed; background: transparent; color: transparent; cursor: default; opacity: .6; }
.opt.hole::before { opacity: .4; }
.opt.pop { animation: pop .16s ease-out backwards; }
.opt.ok { background: var(--good-bg); border-color: var(--good); }
.opt.ok::before { background: var(--good); color: var(--accent-ink); content: "✓"; }
.opt.bad { background: var(--bad-bg); border-color: var(--bad); }
.opt.bad::before { background: var(--bad); color: #fff; content: "✕"; }
.opt.dim { opacity: .45; }
.kbd-hint { text-align: center; }
@media (min-width: 700px) {
  .game-wrap { max-width: 760px; }
  .options { grid-template-columns: 1fr 1fr; }
  .opt { font-size: 19px; min-height: 66px; }
  .word-text { font-size: 76px; }
  .kbd-hint { display: block; }
}
@media (hover: none) { .kbd-hint { display: none; } }

/* ----- підсумок ----- */
.result-wrap { text-align: center; }
.big-score { font-family: var(--font-h); font-weight: 800; font-size: clamp(64px, 20vw, 110px); line-height: 1; color: var(--accent); margin: 4px 0 6px; }
.res-label { color: var(--muted); margin: 0; font-weight: 600; }
.res-title { font-family: var(--font-h); font-weight: 800; font-size: clamp(24px, 7vw, 36px); line-height: 1.15; margin: 6px 0 8px; }
.res-tag { color: var(--muted); margin: 0 auto 4px; max-width: 420px; }
.res-stats { font-family: var(--font-m); font-size: 14px; color: var(--teal); margin: 6px 0 0; font-weight: 700; }
.res-actions { display: grid; gap: 10px; margin: 22px 0 8px; }
.errors { text-align: left; margin-top: 22px; }
.err-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.err-list li { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; display: grid; gap: 2px; }
.err-list .e-word { font-family: var(--font-h); font-weight: 700; font-size: 17px; }
.err-list .e-right { font-weight: 800; color: var(--good); }
.err-list .e-right::before { content: "→ "; color: var(--muted); }
.err-list .e-pick { font-size: 14px; color: var(--muted); }
.err-list .e-pick b { color: var(--bad); font-weight: 800; }
.err-empty { background: var(--good-bg); border: 1px solid var(--good); border-radius: 14px; padding: 14px; font-weight: 800; text-align: center; }
.cta {
  display: block; margin-top: 24px; padding: 18px; border-radius: 20px; text-decoration: none; color: var(--accent-ink);
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #ffd18a)); text-align: center; box-shadow: var(--shadow);
}
.cta-main { display: block; font-family: var(--font-h); font-weight: 700; font-size: 16px; }
.cta-sub { display: block; font-size: 13px; font-weight: 700; margin-top: 4px; opacity: .85; }

.tips { text-align: left; color: var(--muted); font-size: 14.5px; margin: 22px auto 0; padding-left: 22px; max-width: 460px; }
.tips b { color: var(--text); font-family: var(--font-m); }

/* ----- модалка / пауза ----- */
.modal, .pause { position: fixed; inset: 0; z-index: 50; background: rgba(8, 9, 16, .78); display: grid; place-items: center; padding: 16px; backdrop-filter: blur(4px); }
.modal-box { background: var(--card); border-radius: 22px; padding: 14px; max-width: 420px; width: 100%; max-height: 96dvh; overflow: auto; text-align: center; }
.modal-box img { width: auto; max-width: 100%; max-height: 62dvh; border-radius: 14px; display: block; margin: 0 auto 12px; box-shadow: var(--shadow); }
.modal-actions { display: grid; gap: 8px; }
.pause-box { background: var(--card); border-radius: 22px; padding: 26px; text-align: center; display: grid; gap: 14px; }
.pause-title { font-family: var(--font-h); font-weight: 800; font-size: 28px; margin: 0; }

#fx { position: fixed; inset: 0; z-index: 40; pointer-events: none; width: 100%; height: 100%; }

/* ===== РЕЖИМ «РИЛС»: рамка 9:16 ===== */
#screen-reel {
  position: fixed; inset: 0; z-index: 20; background: #07080d; display: grid; place-items: center;
}
.reel-frame {
  --u: 4px; /* 1% ширини рамки, ставить JS */
  position: relative; overflow: hidden; color: var(--text);
  height: min(100dvh, calc(100vw * 16 / 9)); width: calc(min(100dvh, calc(100vw * 16 / 9)) * 9 / 16);
  background:
    radial-gradient(120% 60% at 50% 0%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%),
    var(--bg);
  display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) auto auto; padding: calc(var(--u) * 5) calc(var(--u) * 6) calc(var(--u) * 6);
  gap: calc(var(--u) * 3); font-size: calc(var(--u) * 4);
}
/* телефон вужчий за 9:16 — рамка на весь екран, без чорних смуг на записі */
@media (max-aspect-ratio: 9/16) { .reel-frame { width: 100vw; height: 100dvh; } }
.r-top { display: flex; align-items: center; gap: calc(var(--u) * 3); }
.r-brand { font-family: var(--font-h); font-weight: 800; font-size: calc(var(--u) * 5); color: var(--accent); letter-spacing: .04em; }
.r-level { font-family: var(--font-h); font-weight: 800; font-size: calc(var(--u) * 4); background: var(--accent); color: var(--accent-ink); padding: calc(var(--u) * .8) calc(var(--u) * 3); border-radius: 999px; }
.r-count { margin-left: auto; font-family: var(--font-m); font-weight: 700; font-size: calc(var(--u) * 4.4); }
.r-dots { display: flex; gap: calc(var(--u) * 1.2); }
.r-dots i { flex: 1; height: calc(var(--u) * 1.6); border-radius: 99px; background: var(--card-2); }
.r-dots i.cur { background: var(--accent); }
.r-dots i.done { background: var(--teal); }
.r-stage { min-width: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: calc(var(--u) * 4); text-align: center; min-height: 0; }
.r-label { font-family: var(--font-m); font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-size: calc(var(--u) * 3.6); }
.r-wordbox, .r-answerbox { width: 100%; min-width: 0; display: grid; place-items: center; min-height: 0; }
.r-word { display: inline-block; white-space: nowrap; font-family: var(--font-h); font-weight: 800; color: var(--text); line-height: 1.1; transition: transform .25s, opacity .25s; }
.r-word.ghost { color: var(--muted); opacity: .4; }
.r-word.small { color: var(--teal); }
.r-word.pop { animation: pop .2s ease-out; }
.r-answer { display: inline-block; font-family: var(--font-h); font-weight: 800; color: var(--good); line-height: 1.15; text-align: center; animation: pop .25s ease-out; }
.r-options { display: grid; gap: calc(var(--u) * 2.2); }
.r-opt {
  display: flex; align-items: center; gap: calc(var(--u) * 3); min-height: calc(var(--u) * 13); padding: calc(var(--u) * 2) calc(var(--u) * 4);
  border-radius: calc(var(--u) * 4); border: calc(var(--u) * .6) solid var(--line); background: var(--card);
  font-weight: 800; font-size: calc(var(--u) * 5.2); transition: background .2s, border-color .2s, opacity .2s, transform .2s;
}
.r-opt .n { flex: none; width: calc(var(--u) * 7); height: calc(var(--u) * 7); border-radius: calc(var(--u) * 2); background: var(--card-2); color: var(--muted); font-family: var(--font-m); font-size: calc(var(--u) * 3.6); display: grid; place-items: center; }
.r-opt.ok { background: var(--good-bg); border-color: var(--good); transform: scale(1.03); }
.r-opt.ok .n { background: var(--good); color: var(--accent-ink); }
.r-opt.dim { opacity: .35; }
.r-opt.hidden { background: transparent; border-style: dashed; color: transparent; opacity: .5; }
.r-opt.hidden .n { opacity: .4; }
.r-loop-mini { width: calc(var(--u) * 24); height: calc(var(--u) * 24); image-rendering: pixelated; image-rendering: crisp-edges; }
.r-timer { height: calc(var(--u) * 2.2); border-radius: 99px; background: var(--card-2); overflow: hidden; }
.r-bar { height: 100%; width: 100%; transform-origin: left center; background: var(--teal); border-radius: 99px; }
.r-bar.show { background: var(--accent); }
.r-pause { position: absolute; top: calc(var(--u) * 5); right: calc(var(--u) * 6); font-size: calc(var(--u) * 7); opacity: .85; }
.r-overlay {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; text-align: center; gap: calc(var(--u) * 3);
  background: var(--bg); padding: calc(var(--u) * 8); animation: fadein .25s ease;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.r-ov-title { font-family: var(--font-h); font-weight: 800; font-size: calc(var(--u) * 13); line-height: 1.05; color: var(--accent); }
.r-ov-sub { font-size: calc(var(--u) * 5); font-weight: 700; color: var(--text); max-width: 90%; }
.r-ov-mono { font-family: var(--font-m); font-weight: 700; font-size: calc(var(--u) * 4); color: var(--teal); letter-spacing: .1em; text-transform: uppercase; }
.r-ov-num { font-family: var(--font-h); font-weight: 800; font-size: calc(var(--u) * 46); line-height: 1; color: var(--accent); animation: pop .35s ease-out; }
.r-ov-q { font-family: var(--font-h); font-weight: 800; font-size: calc(var(--u) * 10); line-height: 1.12; color: var(--text); }
.r-ov-hint { position: absolute; bottom: calc(var(--u) * 5); font-family: var(--font-m); font-size: calc(var(--u) * 3.2); color: var(--muted); opacity: .6; }
.r-loop { width: calc(var(--u) * 40); height: calc(var(--u) * 40); image-rendering: pixelated; image-rendering: crisp-edges; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .loop { filter: drop-shadow(0 0 8px rgba(243,154,85,.28)); } }
