:root {
  --bg: #101820;
  --bg-soft: #182531;
  --panel: #20313f;
  --panel-2: #263b4b;
  --line: rgba(255,255,255,.10);
  --text: #f4f7f8;
  --muted: #aebdc7;
  --accent: #e6b15b;
  --accent-strong: #f2c875;
  --accent-ink: #291d0b;
  --good: #89d3a7;
  --danger: #ee8c84;
  --shadow: 0 24px 60px rgba(0,0,0,.28);
  --radius: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
body { background: radial-gradient(circle at top left, rgba(71,115,127,.16), transparent 36%), var(--bg); }
.app-shell { min-height: 100vh; }
.topbar { height: 72px; display: flex; align-items: center; justify-content: space-between; padding: 0 clamp(18px, 4vw, 64px); border-bottom: 1px solid var(--line); background: rgba(16,24,32,.92); backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 50; }
.brand { display: flex; align-items: center; gap: 12px; background: none; border: 0; cursor: pointer; text-align: left; padding: 4px; }
.brand-mark { width: 34px; height: 34px; border: 2px solid var(--accent); display: grid; place-items: center; border-radius: 9px; color: var(--accent); font-size: 18px; }
.brand strong { display: block; font-size: 15px; letter-spacing: .02em; }
.brand small { display: block; color: var(--muted); margin-top: 2px; font-size: 11px; text-transform: uppercase; letter-spacing: .12em; }
.topbar-actions { display: flex; gap: 8px; }
.icon-button, .zoom-controls button { background: rgba(255,255,255,.04); color: var(--muted); border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; cursor: pointer; }
.icon-button:hover, .zoom-controls button:hover { background: rgba(255,255,255,.08); color: var(--text); }
.app-main { width: min(1540px, 100%); margin: 0 auto; padding: clamp(24px, 4vw, 56px); }
.screen { display: none; animation: screenIn .28s ease; }
.screen.active { display: block; }
@keyframes screenIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.hero-card, .panel { background: linear-gradient(145deg, rgba(38,59,75,.95), rgba(28,43,55,.96)); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); }
.hero-card { min-height: 430px; padding: clamp(28px, 5vw, 70px); display: grid; grid-template-columns: 1.05fr .95fr; align-items: center; gap: clamp(28px, 5vw, 80px); overflow: hidden; position: relative; }
.hero-copy { max-width: 680px; position: relative; z-index: 2; }
.eyebrow { margin: 0 0 10px; color: var(--accent-strong); font-size: 12px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
h1, h2 { margin: 0; line-height: 1.04; letter-spacing: -.025em; }
h1 { font-size: clamp(42px, 6vw, 82px); max-width: 720px; }
h2 { font-size: clamp(32px, 4vw, 52px); }
.hero-text, .result-subtitle { color: var(--muted); line-height: 1.7; font-size: clamp(16px, 1.5vw, 19px); max-width: 640px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; }
.hero-actions.centered { justify-content: center; }
.primary-button, .secondary-button, .text-button, .back-button { border: 0; cursor: pointer; transition: transform .15s ease, background .15s ease, border-color .15s ease; }
.primary-button, .secondary-button { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 0 18px; border-radius: 12px; font-weight: 800; }
.primary-button { background: var(--accent); color: var(--accent-ink); }
.primary-button:hover { background: var(--accent-strong); transform: translateY(-1px); }
.secondary-button { background: rgba(255,255,255,.06); border: 1px solid var(--line); color: var(--text); }
.secondary-button:hover { background: rgba(255,255,255,.10); }
.primary-button.compact, .secondary-button.compact { min-height: 40px; padding: 0 14px; }
.text-button, .back-button { background: transparent; color: var(--muted); padding: 8px 0; }
.text-button:hover, .back-button:hover { color: var(--text); }
.hero-preview { min-height: 300px; position: relative; transform: rotate(-2deg); }
.preview-window { position: absolute; width: 58%; height: 68%; border-radius: 18px; border: 8px solid rgba(255,255,255,.92); box-shadow: 0 18px 45px rgba(0,0,0,.28); background: linear-gradient(#d9d2b8 0 45%, #9eb38d 45% 100%); overflow: hidden; }
.preview-window::before { content: ""; position: absolute; width: 42%; height: 42%; border-radius: 50%; background: #e6c270; right: -10%; top: -14%; }
.preview-window::after { content: ""; position: absolute; left: 8%; right: 8%; bottom: 18%; height: 9%; border-radius: 999px; background: #6d4931; box-shadow: 0 26px 0 #415a49; }
.preview-window span { position: absolute; width: 16%; aspect-ratio: 1; background: #d26c53; border-radius: 50% 50% 45% 55%; left: 18%; top: 28%; }
.preview-window i { position: absolute; width: 13%; height: 30%; background: #476a77; left: 49%; top: 24%; border-radius: 8px 8px 2px 2px; }
.preview-window b { position: absolute; width: 16%; aspect-ratio: 1; border: 5px solid #f6f0dd; border-radius: 50%; right: 12%; bottom: 25%; }
.preview-left { left: 4%; top: 12%; }
.preview-right { right: 1%; bottom: 5%; }
.preview-right span { background: #e1b953; }
.preview-right b { border-radius: 3px; }
.preview-marker { position: absolute; right: 7%; top: 4%; width: 64px; height: 64px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-size: 25px; font-weight: 900; border-radius: 50%; box-shadow: 0 12px 28px rgba(0,0,0,.25); }
.feature-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 18px; }
.feature-grid article { background: rgba(255,255,255,.035); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.feature-grid strong { display: block; margin-bottom: 8px; }
.feature-grid span { color: var(--muted); font-size: 14px; line-height: 1.55; }
.panel { padding: clamp(24px, 4vw, 48px); }
.narrow-panel { max-width: 1040px; margin: 0 auto; }
.mode-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; margin-top: 30px; }
.mode-card { min-height: 245px; padding: 28px; text-align: left; background: rgba(255,255,255,.035); color: var(--text); border: 1px solid var(--line); border-radius: 18px; cursor: pointer; transition: transform .15s ease, border-color .15s ease, background .15s ease; display: flex; flex-direction: column; gap: 12px; }
.mode-card:hover { transform: translateY(-3px); border-color: rgba(230,177,91,.55); background: rgba(255,255,255,.06); }
.mode-kicker { color: var(--accent); font-weight: 900; letter-spacing: .14em; font-size: 12px; }
.mode-card strong { font-size: 28px; }
.mode-card span:not(.mode-kicker) { color: var(--muted); line-height: 1.55; }
.mode-card em { margin-top: auto; color: #d7e0e5; font-style: normal; font-size: 13px; }
.section-heading, .game-toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 22px; }
.legend { color: var(--muted); font-size: 13px; }
.legend-dot { width: 9px; height: 9px; display: inline-block; border-radius: 50%; background: var(--good); margin: 0 5px 0 12px; }
.legend-dot.locked { background: #62717a; }
.level-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-top: 30px; }
.level-card { border: 1px solid var(--line); background: rgba(255,255,255,.035); border-radius: 18px; overflow: hidden; padding: 0; color: var(--text); text-align: left; cursor: pointer; position: relative; }
.level-card:hover:not(:disabled) { transform: translateY(-2px); border-color: rgba(230,177,91,.45); }
.level-card:disabled { cursor: not-allowed; opacity: .48; filter: grayscale(.35); }
.level-thumb { aspect-ratio: 16/10; background-size: cover; background-position: center; border-bottom: 1px solid var(--line); position: relative; }
.level-badge { position: absolute; top: 12px; left: 12px; padding: 6px 9px; border-radius: 9px; background: rgba(16,24,32,.84); border: 1px solid rgba(255,255,255,.16); font-size: 11px; font-weight: 900; letter-spacing: .06em; }
.level-card-body { padding: 16px; }
.level-card-body strong { display: block; font-size: 18px; }
.level-card-meta { margin-top: 7px; color: var(--muted); font-size: 13px; display: flex; justify-content: space-between; gap: 8px; }
.game-screen { max-width: 1540px; margin: 0 auto; }
.game-toolbar { margin-bottom: 18px; }
.game-heading { display: flex; gap: 20px; align-items: flex-end; }
.game-heading h2 { font-size: clamp(24px, 3vw, 38px); }
.game-metrics { display: flex; gap: 10px; }
.metric { min-width: 110px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.035); }
.metric span { color: var(--muted); display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .11em; }
.metric strong { display: block; margin-top: 3px; font-size: 20px; font-variant-numeric: tabular-nums; }
.game-board-wrap { border: 1px solid var(--line); background: rgba(255,255,255,.025); border-radius: 20px; padding: clamp(12px, 2vw, 22px); box-shadow: var(--shadow); }
.image-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.image-panel { min-width: 0; position: relative; }
.image-label { position: absolute; left: 12px; top: 12px; z-index: 12; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: rgba(16,24,32,.82); border: 1px solid rgba(255,255,255,.20); font-weight: 900; }
.image-viewport { aspect-ratio: 16/10; overflow: hidden; background: #0b1217; border-radius: 13px; border: 1px solid rgba(255,255,255,.12); position: relative; touch-action: none; cursor: crosshair; outline: none; }
.image-viewport:focus-visible { box-shadow: 0 0 0 3px rgba(230,177,91,.45); }
.scene-stage { width: 100%; height: 100%; position: relative; transform-origin: center center; will-change: transform; }
.scene-stage img { display: block; width: 100%; height: 100%; object-fit: fill; user-select: none; pointer-events: none; }
.marker-layer { position: absolute; inset: 0; pointer-events: none; }
.found-marker, .debug-hotspot, .hint-marker { position: absolute; border-radius: 50%; transform: translate(-50%, -50%); pointer-events: none; }
.found-marker { border: max(3px, .28vw) solid #f4d989; background: rgba(230,177,91,.12); box-shadow: 0 0 0 2px rgba(16,24,32,.55), 0 0 18px rgba(230,177,91,.45); animation: markerIn .24s ease; }
@keyframes markerIn { from { transform: translate(-50%, -50%) scale(.45); opacity: .1; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }
.debug-hotspot { border: 2px dashed rgba(111,213,241,.95); background: rgba(111,213,241,.12); color: #d9f8ff; font-size: 10px; display: grid; place-items: center; font-weight: 900; }
.hint-marker { border: 4px solid #fff2aa; box-shadow: 0 0 0 8px rgba(255,242,170,.16), 0 0 25px rgba(255,242,170,.9); animation: hintPulse .75s ease-in-out 3; }
@keyframes hintPulse { 50% { transform: translate(-50%, -50%) scale(1.28); opacity: .58; } }
.wrong-flash { position: absolute; width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--danger); transform: translate(-50%,-50%); pointer-events: none; animation: wrong .45s ease forwards; z-index: 10; }
@keyframes wrong { 100% { transform: translate(-50%,-50%) scale(1.8); opacity: 0; } }
.zoom-controls { display: flex; justify-content: flex-end; gap: 6px; padding-top: 7px; }
.zoom-controls button { min-width: 36px; padding: 6px 9px; font-size: 12px; }
.game-bottom-bar { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-top: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.progress-block { flex: 1; min-width: 0; }
.progress-copy { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.progress-copy strong { color: var(--text); }
.progress-dots { display: flex; gap: 7px; flex-wrap: wrap; }
.progress-dot { width: 12px; height: 12px; border: 2px solid rgba(255,255,255,.35); border-radius: 50%; }
.progress-dot.found { background: var(--accent); border-color: var(--accent); }
.game-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.result-panel { max-width: 720px; margin: 0 auto; text-align: center; }
.result-burst { width: 74px; height: 74px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 900; font-size: 34px; margin: 0 auto 18px; animation: burst .45s cubic-bezier(.2,.8,.2,1.2); }
@keyframes burst { from { transform: scale(.25) rotate(-12deg); opacity: 0; } }
.result-subtitle { margin: 14px auto 0; }
.stars { display: flex; justify-content: center; gap: 10px; margin: 24px 0; font-size: 36px; }
.star { color: #5d6970; }
.star.earned { color: var(--accent); }
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.result-stats div { padding: 18px 10px; background: rgba(255,255,255,.025); }
.result-stats div + div { border-left: 1px solid var(--line); }
.result-stats span { display: block; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .1em; }
.result-stats strong { display: block; margin-top: 6px; font-size: 22px; }
.overlay { position: fixed; inset: 0; background: rgba(7,12,16,.72); backdrop-filter: blur(10px); z-index: 100; display: grid; place-items: center; padding: 20px; }
.overlay[hidden] { display: none; }
.overlay-card { width: min(420px, 100%); padding: 34px; border-radius: 20px; border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow); display: grid; gap: 11px; text-align: center; }
.overlay-card h2 { margin-bottom: 16px; }
.debug-panel { position: fixed; right: 14px; bottom: 14px; z-index: 120; width: min(390px, calc(100vw - 28px)); max-height: 70vh; overflow: auto; background: #111c24; border: 1px solid rgba(111,213,241,.35); border-radius: 14px; padding: 14px; box-shadow: var(--shadow); font-size: 12px; }
.debug-panel[hidden] { display: none; }
.debug-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.debug-head button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 22px; }
.debug-panel label { display: block; padding: 8px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.debug-panel dl { margin: 8px 0; }
.debug-panel dl div { display: grid; grid-template-columns: 90px 1fr; gap: 8px; padding: 4px 0; }
.debug-panel dt { color: var(--muted); }
.debug-panel dd { margin: 0; font-variant-numeric: tabular-nums; }
.debug-panel pre { white-space: pre-wrap; word-break: break-word; max-height: 230px; overflow: auto; color: #b9e9f6; background: #0b1319; padding: 8px; border-radius: 8px; }
kbd { border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 1px 5px; }
.debug-tip { color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); background: #f3f6f7; color: #16212a; border-radius: 999px; padding: 10px 16px; font-weight: 800; box-shadow: 0 12px 30px rgba(0,0,0,.3); z-index: 140; opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 980px) {
  .hero-card { grid-template-columns: 1fr; }
  .hero-preview { min-height: 250px; }
  .feature-grid { grid-template-columns: repeat(2, 1fr); }
  .level-grid { grid-template-columns: repeat(2, 1fr); }
  .image-pair { grid-template-columns: 1fr; }
  .image-viewport { aspect-ratio: 16/10; }
  .game-toolbar { align-items: flex-start; }
}
@media (max-width: 640px) {
  .topbar { height: 62px; padding: 0 14px; }
  .brand small, #soundButton { display: none; }
  .app-main { padding: 18px 12px 28px; }
  .hero-card { padding: 24px 20px; min-height: auto; }
  .hero-preview { min-height: 210px; }
  .feature-grid, .mode-grid, .level-grid { grid-template-columns: 1fr; }
  .section-heading, .game-toolbar, .game-bottom-bar { align-items: stretch; flex-direction: column; }
  .game-heading { align-items: flex-start; flex-direction: column; gap: 4px; }
  .game-metrics { width: 100%; }
  .metric { flex: 1; min-width: 0; }
  .game-actions { width: 100%; justify-content: stretch; }
  .game-actions button { flex: 1; }
  .result-stats { grid-template-columns: 1fr; }
  .result-stats div + div { border-left: 0; border-top: 1px solid var(--line); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .001ms !important; }
}
