/* G22 · GeoGuessr по-англійськи — YAPOO Arcade */
:root {
  --bg: #F3F4F8;
  --card: #FFFFFF;
  --card-2: #ECEEF5;
  --text: #1B1E2B;
  --muted: #565C72;
  --line: #D9DCE8;
  --accent: #D9691F;
  --accent-strong: #B9500C;
  --accent-soft: #FCE9DA;
  --teal: #0F7E76;
  --teal-strong: #0B655E;
  --teal-soft: #D8F0ED;
  --danger: #C62E2E;
  --danger-soft: #FBE3E3;
  --good: #1E8A4C;
  --good-soft: #DDF3E5;
  --on-accent: #FFFFFF;
  --shadow: 0 6px 24px rgba(27, 30, 43, .10);
  --font-head: "Unbounded", system-ui, sans-serif;
  --font-body: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
:root[data-theme="dark"] {
  --bg: #11131D; --card: #1B1E2C; --card-2: #252940; --text: #EEF0F8; --muted: #A8AEC4; --line: #333852;
  --accent: #F39A55; --accent-strong: #F39A55; --accent-soft: #3A2A1D;
  --teal: #45C3B5; --teal-strong: #45C3B5; --teal-soft: #17353A;
  --danger: #FF7B7B; --danger-soft: #3C2024; --good: #5FD08A; --good-soft: #18362A;
  --on-accent: #1A1208; --shadow: 0 6px 24px rgba(0, 0, 0, .45);
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #11131D; --card: #1B1E2C; --card-2: #252940; --text: #EEF0F8; --muted: #A8AEC4; --line: #333852;
    --accent: #F39A55; --accent-strong: #F39A55; --accent-soft: #3A2A1D;
    --teal: #45C3B5; --teal-strong: #45C3B5; --teal-soft: #17353A;
    --danger: #FF7B7B; --danger-soft: #3C2024; --good: #5FD08A; --good-soft: #18362A;
    --on-accent: #1A1208; --shadow: 0 6px 24px rgba(0, 0, 0, .45);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; overscroll-behavior: none; }
body { font-family: var(--font-body); font-size: 16px; line-height: 1.4; -webkit-text-size-adjust: 100%; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
img { max-width: 100%; }

#app {
  position: fixed; left: 0; right: 0;
  top: var(--vtop, 0px); height: var(--vh, 100dvh);
  display: flex; flex-direction: column;
  max-width: 1280px; margin: 0 auto;
  padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right);
}
.topbar { flex: none; display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 6px 12px; }
.brand { font-family: var(--font-head); font-weight: 700; font-size: 15px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-g { color: var(--accent); }
@media (max-width: 559px) { .brand-t { display: none; } }
.topbar-actions { margin-left: auto; display: flex; gap: 6px; }
.icon-btn {
  width: 44px; height: 44px; min-width: 44px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--card); font-size: 18px; font-weight: 800; display: grid; place-items: center; padding: 0;
}
.icon-btn:active { transform: scale(.94); }
.teacher-btn[aria-pressed="true"] { background: var(--teal-soft); border-color: var(--teal); box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 25%, transparent); }
:is(.icon-btn, button, input, summary, a):focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }

.screen { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 4px 16px calc(24px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
h1, h2, h3 { font-family: var(--font-head); margin: 0; letter-spacing: -.02em; }
h1 { font-size: clamp(24px, 6.4vw, 38px); line-height: 1.1; }
.lead { margin: 8px 0 0; color: var(--muted); font-size: 16px; }
.hint { color: var(--muted); font-size: 14px; margin: 10px 0 0; }
.center { text-align: center; }
.field-label { font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 10px; }

.btn-primary, .btn-cta {
  display: block; width: 100%; min-height: 58px; border: 0; border-radius: 18px; background: var(--accent-strong); color: var(--on-accent);
  font-family: var(--font-head); font-weight: 700; font-size: 17px; padding: 12px 18px; text-align: center; text-decoration: none;
  box-shadow: 0 8px 20px rgba(185, 80, 12, .28); transition: transform .1s;
}
.btn-primary:active, .btn-cta:active { transform: translateY(1px) scale(.99); }
.btn-primary:disabled { opacity: .6; }
.btn-ghost { display: block; width: 100%; min-height: 50px; border-radius: 16px; border: 2px solid var(--line); background: var(--card); font-weight: 800; font-size: 16px; padding: 10px 14px; }
.link-btn { background: none; border: 0; color: var(--muted); text-decoration: underline; font-weight: 700; font-size: 14px; min-height: 44px; padding: 0 12px; }

/* Головна */
.home-hero { display: flex; gap: 14px; align-items: center; margin: 6px 0 14px; }
.loop-canvas { width: 88px; height: 88px; image-rendering: pixelated; flex: none; animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.home-photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 16px; }
.home-photos div { aspect-ratio: 4 / 3; border-radius: 16px; background-size: cover; background-position: center; border: 1px solid var(--line); box-shadow: var(--shadow); position: relative; overflow: hidden; }
.home-photos div::after { content: "?"; position: absolute; right: 8px; bottom: 6px; width: 28px; height: 28px; border-radius: 50%; background: var(--accent-strong); color: var(--on-accent); font-family: var(--font-head); font-weight: 800; display: grid; place-items: center; font-size: 15px; }
.teacher-switch { display: flex; gap: 12px; align-items: center; margin: 16px 0 14px; cursor: pointer; }
.ts-ico { font-size: 30px; }
.ts-txt { flex: 1; display: grid; gap: 2px; }
.ts-txt small { color: var(--muted); font-size: 13.5px; }
.teacher-switch input { width: 26px; height: 26px; accent-color: var(--teal); flex: none; }
.rules-inline summary { font-weight: 800; cursor: pointer; font-size: 17px; min-height: 28px; }
.rules-body { font-size: 15.5px; }
.rules-body ol { margin: 10px 0 0; padding-left: 22px; }
.rules-body li { margin-bottom: 8px; }
.rules-body b { color: var(--accent-strong); }
:root[data-theme="dark"] .rules-body b { color: var(--accent); }
@media (prefers-color-scheme: dark) { :root[data-theme="auto"] .rules-body b { color: var(--accent); } }

/* Гра */
.screen.game { padding: 0 12px calc(12px + env(safe-area-inset-bottom)); }
.gamebar { display: flex; align-items: center; gap: 10px; margin: 0 2px 8px; }
.progress { display: flex; gap: 6px; flex: 1; }
.progress i { flex: 1; height: 12px; border-radius: 8px; background: var(--card-2); border: 1px solid var(--line); transition: background .2s; display: block; }
.progress i.cur { background: var(--accent); border-color: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.progress i.ok { background: var(--good); border-color: var(--good); }
.progress i.no { background: var(--danger); border-color: var(--danger); }
@keyframes pulse { 50% { opacity: .55; } }
.scorebox { font-family: var(--font-mono); font-weight: 800; font-size: 20px; white-space: nowrap; }
.scorebox .sc-l { font-family: var(--font-body); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 800; }

.play { display: grid; gap: 12px; grid-template-columns: 1fr; align-items: start; }
.photo {
  position: relative; margin: 0; border-radius: 20px; overflow: hidden; background: #000; border: 1px solid var(--line); box-shadow: var(--shadow);
  aspect-ratio: 4 / 3; max-height: 46vh; width: 100%; isolation: isolate;
}
.photo::before { content: ""; position: absolute; inset: -20px; background: var(--bg-img) center / cover; filter: blur(22px) brightness(.8); z-index: -1; }
.photo img { width: 100%; height: 100%; object-fit: contain; display: block; cursor: zoom-in; opacity: 0; transition: opacity .25s; }
.photo img.loaded { opacity: 1; }
.zoom-btn { position: absolute; right: 10px; top: 10px; width: 44px; height: 44px; border-radius: 14px; border: 0; background: rgba(15, 17, 26, .62); color: #fff; font-size: 22px; backdrop-filter: blur(4px); }
.photo-credit { position: absolute; left: 0; right: 0; bottom: 0; padding: 6px 10px; font-size: 11.5px; line-height: 1.3; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.78)); }
.photo-credit a { color: #fff; text-underline-offset: 2px; }
.loopbox { position: absolute; left: 8px; bottom: 6px; display: flex; align-items: flex-end; gap: 6px; pointer-events: none; z-index: 3; }
.loopbox .loop-canvas { width: 56px; height: 56px; filter: drop-shadow(0 2px 4px rgba(0,0,0,.5)); }
.photo-credit:not([hidden]) ~ .loopbox { bottom: 34px; }
.bubble { order: 2; max-width: 190px; background: var(--card); color: var(--text); border: 2px solid var(--line); border-radius: 14px 14px 14px 4px; padding: 5px 10px; font-size: 13.5px; font-weight: 800; opacity: 0; transform: translateY(4px); transition: opacity .2s, transform .2s; margin-bottom: 26px; }
.bubble.show { opacity: 1; transform: none; }

.panel { min-width: 0; }
.step { display: grid; gap: 12px; animation: stepin .3s ease-out; }
@keyframes stepin { from { opacity: 0; transform: translateY(8px); } }
.step-head { display: flex; align-items: center; gap: 10px; font-family: var(--font-head); font-weight: 700; font-size: 18px; }
.step-n { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-strong); color: var(--on-accent); display: grid; place-items: center; font-size: 16px; flex: none; }

.timer-top { display: flex; align-items: baseline; gap: 6px; }
.timer-num { font-family: var(--font-mono); font-weight: 800; font-size: 48px; line-height: 1; min-width: 2ch; }
.timer-s { font-weight: 800; color: var(--muted); }
.timer-bonus { margin-left: auto; font-weight: 800; font-size: 14px; color: var(--muted); text-align: right; }
.timer-bonus.on { color: var(--good); }
.bar { position: relative; height: 14px; border-radius: 10px; background: var(--card-2); border: 1px solid var(--line); margin-top: 8px; overflow: hidden; }
.bar-fg { position: absolute; inset: 0; width: 100%; background: var(--teal); transform-origin: left; border-radius: 10px; }
.bar.danger .bar-fg { background: var(--danger); }
.bar-mark { position: absolute; top: 0; bottom: 0; left: 50%; width: 3px; background: var(--accent); }
.timer.danger .timer-num { color: var(--danger); animation: pulse .5s infinite; }
.say-hint { margin: 0; color: var(--muted); font-size: 14.5px; }
.phrases { display: flex; flex-wrap: wrap; gap: 8px; }
.phrase { min-height: 44px; border-radius: 14px; border: 2px solid var(--line); background: var(--card); padding: 6px 14px; font-weight: 800; font-size: 16px; text-align: left; line-height: 1.15; }
.phrase small { display: block; color: var(--muted); font-size: 11.5px; font-weight: 600; }
.phrase.used { border-color: var(--teal); background: var(--teal-soft); }
.phrase.used::after { content: " ✓"; color: var(--teal-strong); }

.teacher-box { border: 2px dashed var(--teal); background: var(--teal-soft); border-radius: 16px; padding: 12px 14px; font-size: 15px; }
.teacher-box h4 { margin: 0 0 6px; font-family: var(--font-head); font-size: 14px; }
.teacher-box ul { margin: 6px 0 0; padding-left: 20px; }
.teacher-box li { margin-bottom: 4px; font-weight: 600; }
.teacher-ans { font-weight: 800; font-size: 17px; }

.options { display: grid; gap: 10px; grid-template-columns: 1fr; }
.option {
  display: flex; align-items: center; gap: 14px; min-height: 64px; border-radius: 18px; border: 2px solid var(--line); background: var(--card);
  padding: 8px 16px; text-align: left; font-weight: 800; font-size: 19px; box-shadow: var(--shadow); transition: transform .1s, border-color .15s, background .15s;
}
.option:hover { border-color: var(--accent); }
.option:active { transform: scale(.98); }
.option .flag { font-size: 34px; line-height: 1; }
.option.picked-bad { border-color: var(--danger); background: var(--danger-soft); animation: shake .4s; }
.option.picked-ok { border-color: var(--good); background: var(--good-soft); }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(6px); } }

.verdict { border-radius: 18px; padding: 14px 16px; display: flex; gap: 14px; align-items: center; border: 2px solid var(--line); }
.verdict.ok { background: var(--good-soft); border-color: var(--good); }
.verdict.no { background: var(--danger-soft); border-color: var(--danger); }
.verdict .v-flag { font-size: 48px; line-height: 1; }
.verdict .v-title { font-family: var(--font-head); font-weight: 800; font-size: 20px; line-height: 1.15; }
.verdict .v-sub { color: var(--muted); font-weight: 700; font-size: 14px; margin-top: 2px; }
.pts { display: flex; gap: 8px; flex-wrap: wrap; }
.pts span { background: var(--card-2); border-radius: 12px; padding: 6px 12px; font-weight: 800; font-size: 14.5px; }
.pts .gain { background: var(--accent-soft); color: var(--accent-strong); }
:root[data-theme="dark"] .pts .gain { color: var(--accent); }
.sect-title { font-family: var(--font-head); font-weight: 700; font-size: 14px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin-top: 4px; }
.clues { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.clues li { background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--teal); border-radius: 12px; padding: 9px 12px; font-weight: 600; font-size: 15.5px; }
.words { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; grid-template-columns: 1fr 1fr; }
.words li { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 8px 12px; display: grid; gap: 0; }
.words li b { font-size: 17px; font-weight: 800; color: var(--accent-strong); }
:root[data-theme="dark"] .words li b { color: var(--accent); }
.words li span { color: var(--muted); font-weight: 700; font-size: 14px; }
.words.big { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.credit-line { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.credit-line a { color: var(--muted); text-underline-offset: 2px; }
#btnNext { position: sticky; bottom: 4px; }

/* Підсумок */
.result-hero { text-align: center; margin: 4px 0 16px; }
.rh-score { font-family: var(--font-head); font-weight: 800; font-size: clamp(54px, 18vw, 96px); line-height: 1; color: var(--accent-strong); }
:root[data-theme="dark"] .rh-score { color: var(--accent); }
.rh-title { font-family: var(--font-head); font-weight: 800; font-size: clamp(20px, 5.4vw, 30px); margin-top: 6px; }
.rh-sub { color: var(--muted); font-weight: 700; margin-top: 6px; }
.rh-loop { width: 96px; height: 96px; margin: 0 auto 6px; display: block; }
.result-locs { display: grid; gap: 8px; }
.loc-row { display: grid; grid-template-columns: 76px 1fr auto; gap: 12px; align-items: center; background: var(--card-2); border-radius: 14px; padding: 6px; border-left: 5px solid var(--line); }
.loc-row.ok { border-left-color: var(--good); }
.loc-row.no { border-left-color: var(--danger); }
.loc-row img { width: 76px; height: 56px; object-fit: cover; border-radius: 10px; display: block; }
.loc-row .lr-c { font-weight: 800; font-size: 16px; }
.loc-row .lr-s { color: var(--muted); font-size: 13px; font-weight: 700; }
.loc-row .lr-p { font-family: var(--font-mono); font-weight: 800; font-size: 17px; padding-right: 6px; }
.result-grid { display: grid; gap: 0; }
.result-actions { display: grid; gap: 10px; margin-bottom: 14px; }
.cta { text-align: center; background: linear-gradient(135deg, var(--accent-soft), var(--teal-soft)); }
.cta-text { font-family: var(--font-head); font-weight: 700; font-size: 17px; margin-bottom: 12px; line-height: 1.3; }
.btn-cta { background: var(--teal-strong); box-shadow: 0 8px 20px rgba(11, 101, 94, .28); }
:root[data-theme="dark"] .btn-cta { background: var(--teal); color: #08211E; }
@media (prefers-color-scheme: dark) { :root[data-theme="auto"] .btn-cta { background: var(--teal); color: #08211E; } }

/* Діалоги */
dialog { border: 0; border-radius: 22px; background: var(--card); color: var(--text); padding: 16px; width: min(640px, calc(100vw - 24px)); max-height: calc(var(--vh, 90vh) - 24px); box-shadow: 0 20px 60px rgba(0,0,0,.4); }
dialog::backdrop { background: rgba(10, 12, 20, .6); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; position: sticky; top: -16px; background: var(--card); padding: 4px 0; z-index: 2; }
.credits-body { display: grid; gap: 8px; }
.cr-row { display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: center; font-size: 13px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.cr-row img { width: 64px; height: 48px; object-fit: cover; border-radius: 8px; background: var(--card-2); }
.cr-row b { font-size: 14px; }
.cr-row a { color: var(--teal-strong); }
:root[data-theme="dark"] .cr-row a { color: var(--teal); }
.zoom-dlg { padding: 0; width: 100vw; max-width: 100vw; height: 100vh; height: 100dvh; max-height: 100dvh; border-radius: 0; background: #000; }
.zoom-scroll { position: absolute; inset: 0; overflow: auto; display: grid; place-items: center; -webkit-overflow-scrolling: touch; }
.zoom-scroll img { max-width: 100vw; max-height: 100dvh; object-fit: contain; cursor: zoom-in; display: block; }
.zoom-scroll.zoomed { place-items: start; }
.zoom-scroll.zoomed img { max-width: none; max-height: none; width: 220vw; cursor: zoom-out; }
.zoom-close { position: fixed; right: 14px; top: calc(14px + env(safe-area-inset-top)); background: rgba(15, 17, 26, .7); color: #fff; border-color: rgba(255,255,255,.25); z-index: 3; }
.zoom-tip { position: fixed; left: 0; right: 0; bottom: calc(14px + env(safe-area-inset-bottom)); text-align: center; color: #fff; font-size: 13px; font-weight: 700; text-shadow: 0 1px 4px #000; pointer-events: none; }

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

/* Ноутбук: фото крупно зліва, панель справа */
@media (min-width: 900px) {
  .screen:not(.game) { padding-left: 28px; padding-right: 28px; }
  #screen-home { max-width: 760px; width: 100%; margin: 0 auto; }
  .screen.game { padding: 0 20px 20px; display: flex; flex-direction: column; overflow: hidden; }
  .gamebar { flex: none; }
  .play { flex: 1; min-height: 0; grid-template-columns: minmax(0, 1.6fr) minmax(380px, 1fr); gap: 20px; align-items: stretch; }
  .photo { aspect-ratio: auto; max-height: none; height: 100%; min-height: 0; }
  .loopbox .loop-canvas { width: 84px; height: 84px; }
  .bubble { font-size: 15px; margin-bottom: 40px; }
  .photo-credit { font-size: 13px; padding: 8px 14px; }
  .photo-credit:not([hidden]) ~ .loopbox { bottom: 44px; }
  .panel { overflow-y: auto; padding: 2px 4px 8px 2px; }
  .step { gap: 14px; }
  .step-head { font-size: 22px; }
  .step-n { width: 38px; height: 38px; font-size: 19px; }
  .timer-num { font-size: 64px; }
  .phrase { font-size: 18px; }
  .option { min-height: 72px; font-size: 22px; }
  .option .flag { font-size: 40px; }
  .words.big { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
  #screen-result { max-width: 920px; width: 100%; margin: 0 auto; }
  .result-actions { grid-template-columns: 1fr 1fr 1fr; }
  .scorebox { font-size: 26px; }
  .progress i { height: 14px; }
  #btnNext { position: static; }
}
@media (min-width: 900px) and (max-height: 640px) { .rh-loop { display: none; } }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
