:root {
  --ink: #10251c;
  --green: #194c36;
  --deep: #0d3525;
  --lime: #c8f34a;
  --purple: #7651a8;
  --cream: #fff9e9;
  --paper: #fffdf7;
  --gold: #f3b857;
  --coral: #ff9463;
  --shadow: 0 9px 0 var(--ink);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; overscroll-behavior: none; }
body { color: var(--ink); background: var(--cream); font-family: "Nunito", sans-serif; -webkit-tap-highlight-color: transparent; }
button, a { font: inherit; }
button { color: inherit; }
img { -webkit-user-drag: none; user-select: none; }

.portal-link {
  position: fixed; z-index: 100; top: 12px; left: 12px; padding: 9px 14px;
  border: 2px solid var(--ink); border-radius: 999px; color: var(--ink); background: #fffdf0e8;
  box-shadow: 3px 4px 0 var(--ink); text-decoration: none; font-size: .76rem; font-weight: 900;
  backdrop-filter: blur(8px);
}

.screen { display: none; }
.screen.active { display: flex; }
.eyebrow { margin: 0 0 9px; color: var(--purple); font-size: .73rem; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
.primary-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 18px; min-height: 54px; padding: 13px 24px;
  border: 2px solid var(--ink); border-radius: 999px; background: var(--lime); box-shadow: 5px 6px 0 var(--ink);
  cursor: pointer; font-weight: 900; letter-spacing: .03em; transition: transform .15s, box-shadow .15s;
}
.primary-button:active { transform: translate(3px, 4px); box-shadow: 2px 2px 0 var(--ink); }
.primary-button span { font-size: 1.35rem; line-height: 1; }

.start-screen {
  min-height: 100svh; align-items: center; justify-content: center; padding: 55px 18px 30px;
  background:
    radial-gradient(circle at 14% 15%, #7651a83b 0 9%, transparent 9.2%),
    radial-gradient(circle at 88% 83%, #c8f34a55 0 14%, transparent 14.2%),
    linear-gradient(135deg, var(--deep), #1d5a40 68%, #284d3d);
}
.start-card { width: min(620px, 100%); text-align: center; color: white; }
.start-art { position: relative; width: min(280px, 70vw); aspect-ratio: 1; margin: 0 auto 23px; }
.start-art img { width: 100%; height: 100%; object-fit: cover; border: 12px solid var(--lime); border-radius: 50%; box-shadow: 14px 16px 0 #071d14; }
.search-ring { position: absolute; inset: -22px; border: 2px dashed #ffffff66; border-radius: 50%; animation: rotate 22s linear infinite; }
.magnifier { position: absolute; right: -20px; bottom: 4px; display: grid; place-items: center; width: 82px; height: 82px; border: 3px solid var(--ink); border-radius: 50%; background: var(--gold); color: var(--ink); box-shadow: 7px 8px 0 var(--ink); font: 900 3.8rem/1 "Baloo 2"; transform: rotate(-16deg); }
.start-card h1 { margin: 0; font: 800 clamp(3.2rem, 11vw, 6.2rem)/.78 "Baloo 2"; letter-spacing: -.045em; text-transform: uppercase; }
.start-card h1 em { color: var(--lime); font-style: normal; }
.start-copy { margin: 24px 0; color: #d9e6df; font-size: clamp(1rem, 2.5vw, 1.25rem); font-weight: 800; }
.start-screen .eyebrow { color: var(--gold); }
.gesture-note { margin: 22px 0 0; color: #b8c8bf; font-size: .76rem; font-weight: 800; }

.game-screen { height: 100svh; min-height: 560px; flex-direction: column; overflow: hidden; background: linear-gradient(180deg, #f0ead9, var(--cream)); }
.game-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: min(1180px, calc(100% - 24px)); min-height: 78px; margin: 0 auto; padding: 10px 0 6px; }
.phase-kicker { margin: 0; color: #6e7771; font-size: .67rem; font-weight: 900; letter-spacing: .1em; }
.game-header h2 { margin: 1px 0 0; font: 800 clamp(1.5rem, 4vw, 2.2rem)/1 "Baloo 2"; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.counter { min-width: 55px; padding: 9px 11px; border: 2px solid var(--ink); border-radius: 999px; background: white; text-align: center; font-weight: 900; }
.hint-button { min-height: 42px; padding: 9px 15px; border: 2px solid var(--ink); border-radius: 999px; background: var(--gold); box-shadow: 3px 4px 0 var(--ink); cursor: pointer; font-size: .78rem; font-weight: 900; }
.hint-button:disabled { opacity: .55; cursor: wait; }

.scene-shell { display: flex; min-height: 0; flex: 1; align-items: center; justify-content: center; padding: 0 10px 8px; }
.scene-viewport {
  position: relative; width: min(100%, calc((100svh - 255px) * 1.5), 1080px); aspect-ratio: 3 / 2; overflow: hidden;
  border: 2px solid var(--ink); border-radius: 20px; background: #cbd9cf; box-shadow: 0 7px 0 var(--ink);
  touch-action: none; user-select: none; cursor: grab;
}
.scene-viewport.dragging { cursor: grabbing; }
.scene-stage { position: absolute; inset: 0; width: 100%; height: 100%; transform-origin: 0 0; will-change: transform; }
.scene-image { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.targets-layer { position: absolute; inset: 0; }
.target {
  position: absolute; z-index: 3; display: grid; place-items: center; min-width: 50px; min-height: 50px;
  padding: 0; border: 0; border-radius: 50%; background: transparent; cursor: pointer; transform: translate(-50%, -50%);
  touch-action: none; outline: none;
}
.target .object-visual { display: block; font-size: clamp(28px, 4.5vw, 62px); filter: drop-shadow(0 2px 1px #0008) drop-shadow(0 0 2px #fff8); line-height: 1; transform: rotate(var(--rotation, 0deg)); transition: transform .2s, opacity .2s; }
.target[data-camo="soft"] .object-visual { opacity: .82; filter: drop-shadow(0 1px 1px #0008); }
.target.found { pointer-events: none; }
.target.found .object-visual { opacity: 0; transform: scale(1.7) rotate(var(--rotation, 0deg)); }
.target::after { content: "✓"; position: absolute; display: grid; place-items: center; width: 30px; height: 30px; border: 2px solid white; border-radius: 50%; background: var(--lime); color: var(--ink); font-weight: 900; opacity: 0; transform: scale(.4); }
.target.found::after { animation: found-pop .7s ease forwards; }
.target.hinted::before { content: ""; position: absolute; inset: -10px; border: 4px solid var(--lime); border-radius: 50%; box-shadow: 0 0 0 8px #c8f34a55; animation: hint-pulse .75s ease-in-out infinite alternate; }
.target-image { max-width: 100%; max-height: 100%; object-fit: contain; filter: drop-shadow(0 3px 2px #0007); transform: rotate(var(--rotation, 0deg)); transition: transform .2s, opacity .2s; }
.target.found .target-image { opacity: 0; transform: scale(1.6); }

.zoom-controls { position: absolute; z-index: 12; top: 9px; right: 9px; display: flex; overflow: hidden; border: 2px solid var(--ink); border-radius: 999px; background: #fffdf3e8; box-shadow: 3px 4px 0 #10251caa; backdrop-filter: blur(7px); }
.zoom-controls button { min-width: 42px; height: 40px; padding: 0 11px; border: 0; border-right: 1px solid #10251c44; background: transparent; cursor: pointer; font-size: 1.15rem; font-weight: 900; }
.zoom-controls button:last-child { border-right: 0; }
#zoom-reset { min-width: 62px; font-size: .72rem; }
.wrong-feedback { position: absolute; z-index: 10; width: 42px; height: 42px; margin: -21px; border: 3px solid #fff; border-radius: 50%; pointer-events: none; opacity: 0; }
.wrong-feedback.show { animation: wrong-tap .55s ease-out; }

.object-tray { position: relative; z-index: 20; flex: 0 0 auto; width: 100%; padding: 9px max(12px, calc((100% - 1000px) / 2)) max(10px, env(safe-area-inset-bottom)); border-top: 2px solid var(--ink); background: var(--deep); color: white; box-shadow: 0 -8px 22px #10251c26; }
.tray-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 7px; font-size: .72rem; letter-spacing: .05em; }
.tray-heading span { color: #c9d7cf; font-weight: 800; }
.object-list { display: flex; gap: 7px; overflow-x: auto; padding: 1px 1px 4px; scrollbar-width: none; }
.object-list::-webkit-scrollbar { display: none; }
.object-chip { display: flex; min-width: 64px; min-height: 52px; flex: 0 0 auto; align-items: center; justify-content: center; gap: 5px; padding: 7px 9px; border: 1px solid #ffffff3a; border-radius: 14px; background: #ffffff12; transition: opacity .2s, transform .2s, background .2s; }
.object-chip .chip-icon { font-size: 1.55rem; }
.object-chip .chip-label { max-width: 68px; font-size: .62rem; font-weight: 900; line-height: 1.05; }
.object-chip.done { opacity: .34; background: #c8f34a2a; text-decoration: line-through; transform: scale(.94); }
.object-chip.done::after { content: "✓"; color: var(--lime); font-weight: 900; }

.phase-modal { position: fixed; z-index: 200; inset: 0; display: grid; place-items: center; padding: 22px; background: #071d14d9; backdrop-filter: blur(8px); }
.phase-modal[hidden] { display: none; }
.modal-card, .final-card { width: min(520px, 100%); padding: 31px 24px; border: 2px solid var(--ink); border-radius: 28px; background: var(--paper); box-shadow: 10px 12px 0 #071d14; text-align: center; }
.happy-simba { width: 124px; height: 124px; margin: -82px auto 18px; border: 8px solid var(--lime); border-radius: 50%; overflow: hidden; background: white; box-shadow: 6px 7px 0 var(--ink); }
.happy-simba img { width: 100%; height: 100%; object-fit: cover; }
.modal-card h2, .final-card h2 { margin: 0; font: 800 clamp(2.3rem, 8vw, 4rem)/.9 "Baloo 2"; }
.modal-card > p:not(.eyebrow) { color: #68736c; font-weight: 800; }

.final-screen { min-height: 100svh; align-items: center; justify-content: center; padding: 55px 18px 30px; background: linear-gradient(145deg, var(--deep), #286145); }
.final-card { position: relative; }
.final-card > img { width: 150px; height: 150px; border: 9px solid var(--lime); border-radius: 50%; object-fit: cover; box-shadow: 7px 8px 0 var(--ink); }
.final-confetti { margin-bottom: 10px; font-size: 1.35rem; }
.final-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 24px 0; }
.final-stats div { padding: 14px; border: 2px solid var(--ink); border-radius: 16px; background: #f1ecdf; }
.final-stats span { display: block; font-size: .65rem; font-weight: 900; letter-spacing: .08em; }
.final-stats strong { display: block; margin-top: 4px; font: 800 2rem/1 "Baloo 2"; }
.back-link { display: block; margin-top: 20px; color: var(--green); font-weight: 900; }

@keyframes rotate { to { transform: rotate(360deg); } }
@keyframes found-pop { 45% { opacity: 1; transform: scale(1.2); } 100% { opacity: 0; transform: scale(1.7); } }
@keyframes hint-pulse { to { transform: scale(1.18); box-shadow: 0 0 0 16px #c8f34a12; } }
@keyframes wrong-tap { 0% { opacity: .95; transform: scale(.35); } 100% { opacity: 0; transform: scale(1.5); } }

@media (max-width: 620px) {
  .portal-link { top: 7px; left: 7px; padding: 7px 10px; font-size: .66rem; }
  .game-header { min-height: 70px; padding-top: 8px; }
  .phase-kicker { font-size: .58rem; }
  .game-header h2 { max-width: 190px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .counter { min-width: 48px; padding: 7px 8px; font-size: .78rem; }
  .hint-button { min-height: 38px; padding: 7px 11px; font-size: .69rem; }
  .scene-shell { padding-inline: 7px; }
  .scene-viewport { width: min(100%, calc((100svh - 232px) * 1.5)); border-radius: 15px; }
  .zoom-controls { top: 6px; right: 6px; }
  .zoom-controls button { min-width: 44px; height: 44px; }
  #zoom-reset { min-width: 60px; }
  .object-tray { padding-top: 7px; }
  .object-chip { min-width: 58px; min-height: 49px; padding: 5px 7px; }
  .object-chip .chip-label { display: none; }
  .object-chip .chip-icon { font-size: 1.65rem; }
}

@media (max-height: 650px) {
  .game-header { min-height: 60px; }
  .scene-viewport { width: min(100%, calc((100svh - 210px) * 1.5)); }
  .object-chip { min-height: 44px; }
  .start-art { width: min(190px, 42vh); }
  .start-card h1 { font-size: clamp(2.7rem, 9vh, 4.3rem); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}
