@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;650;700;900&family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root { color-scheme: light; --paper: #f7f5ed; --ink: #262d27; --muted: #7c8176; --sun: #ffcb2e; --title-ink: #15190f; --game-cursor: url("crosshair.svg") 16 16, crosshair; }
* { box-sizing: border-box; }
body { margin: 0; min-height: 100svh; padding: 16px; display: grid; place-items: center; background: #e8e7df; color: var(--ink); font-family: 'DM Sans', sans-serif; -webkit-font-smoothing: antialiased; }
.game-shell { width: min(390px, 100%); height: min(844px, calc(100svh - 32px)); min-height: 560px; display: flex; flex-direction: column; overflow: hidden; background: var(--paper); border: 1px solid #d9dbcf; border-radius: 24px; box-shadow: 0 14px 50px #333c2012; }
button, a, .monster, #crowd { -webkit-tap-highlight-color: transparent; }
button:focus:not(:focus-visible), a:focus:not(:focus-visible) { outline: none; }
main { flex: 1; min-height: 0; width: 100%; padding: 0; }
.crowd-card { height: 100%; min-height: 0; position: relative; isolation: isolate; overflow: hidden; background: #eeeee1; border: 0; border-radius: 0; }
.scene-heading { position: absolute; z-index: 3; top: 35px; width: 100%; text-align: center; pointer-events: none; }
.eyebrow { margin: 0 0 11px; font-size: 9px; letter-spacing: 2px; font-weight: 650; color: #7e8474; }
.find-label { margin: 0 0 1px; font-size: 15px; font-weight: 500; color: #868a7c; line-height: 1.2; }
h1 { margin: 0; font-family: 'Space Grotesk', sans-serif; font-size: clamp(30px, 3.1vw, 48px); letter-spacing: -2.2px; line-height: 1.1; font-weight: 600; }
h1 span { color: #b17c49; }
.scene-caption { font-size: 12px; margin: 12px 0 0; color: #858879; }
/* Layers, back to front: terrain lines, the target blob, then the crowd, so
   monsters standing near the blob overlap it. */
.terrain { position: absolute; inset: 0; z-index: 0; width: 100%; height: 100%; pointer-events: none; }
.scene { position: absolute; inset: 0; z-index: 2; }
#crowd { cursor: var(--game-cursor); display: block; width: 100%; height: 100%; overflow: hidden; outline: none; }
.monster-body { transform-origin: 0 0; transition: transform 300ms cubic-bezier(.2,.8,.3,1); }
.monster:hover .monster-body, .monster:focus-visible .monster-body { transform: translateY(-9px) rotate(-3deg); }
.monster-react, .arm-wave, .arm-sway { transform-origin: 0 0; }
.eye-lid { animation: blink var(--blink-dur, 5.6s) ease-in-out var(--blink-delay, 0s) infinite; }
/* Shuts in ~130ms, holds a beat, opens a little slower — like a real blink. */
@keyframes blink {
  0%, 93% { transform: translateY(var(--lid-open, -90px)); }
  95.2%, 95.9% { transform: translateY(0); }
  98.4%, 100% { transform: translateY(var(--lid-open, -90px)); }
}
.arm-sway { animation: arm-sway 3.9s ease-in-out var(--arm-delay, 0s) infinite; }
@keyframes arm-sway { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(5deg); } }
.arm-wave { animation: arm-wave 1.15s ease-in-out var(--arm-delay, 0s) infinite; }
@keyframes arm-wave { 0%, 100% { transform: rotate(-13deg); } 50% { transform: rotate(15deg); } }
.arm-right { animation-direction: reverse; }
/* Celebrating and wrong-guess feedback. */
.crowd-refresh .monster-react { animation: monster-pop .55s cubic-bezier(.2,.9,.3,1.3) var(--pop-delay, 0s) both; }
@keyframes monster-pop { from { opacity: 0; transform: translateY(26px) scale(.84); } to { opacity: 1; transform: none; } }
.monster.found .monster-react { animation: monster-cheer .62s cubic-bezier(.3,.9,.35,1.25) 2; }
@keyframes monster-cheer { 0% { transform: translateY(0) scale(1); } 32% { transform: translateY(-28px) scale(1.04, .96); } 66% { transform: translateY(0) scale(.95, 1.06); } 100% { transform: translateY(0) scale(1); } }
.monster.wrong .monster-react { animation: monster-shake .5s ease-in-out; }
@keyframes monster-shake { 0%, 100% { transform: translateX(0) rotate(0); } 20% { transform: translateX(-10px) rotate(-3deg); } 50% { transform: translateX(9px) rotate(3deg); } 78% { transform: translateX(-5px) rotate(-1.5deg); } }
.monster { cursor: var(--game-cursor); opacity: 1; outline: none; }
.monster:focus-visible { outline: none; }
.monster:focus-visible .monster-body { filter: drop-shadow(0 0 3px #525c38); }
/* The target sits in a soft blob at the top centre; the crowd tucks in around it. */
.target-card { z-index: 1; top: 22px; left: 50%; transform: translateX(-50%); width: 184px; height: 194px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 10px 14px 20px; border-radius: 54% 46% 50% 50% / 46% 50% 50% 54%; background: #fbfaf3; }
.target-copy { min-width: 0; max-width: 100%; margin-top: 2px; }
.target-card .find-label { margin: 0 0 1px; font-size: 10px; line-height: 12px; }
.target-card h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 19px; line-height: 21px; font-weight: 700; letter-spacing: -.5px; }
.portrait-window { position: relative; flex: 0 0 auto; width: 132px; height: 124px; }
#target-preview { display: block; width: 100%; height: 100%; margin: 0; overflow: visible; pointer-events: none; }
#target-preview .monster, .slot-strip .monster, .album-grid .monster { cursor: default; }
#target-preview .monster-react, .slot-strip .monster-react, .album-grid .monster-react { animation: none; }
#target-preview .eye-lid, .slot-strip .eye-lid, .album-grid .eye-lid { animation: none; transform: translateY(var(--lid-open, -90px)); }
#target-preview .arm-wave, #target-preview .arm-sway, .slot-strip .arm-wave, .slot-strip .arm-sway, .album-grid .arm-wave, .album-grid .arm-sway { animation: none; }
/* After a match the portrait becomes a slot-machine reel that spins through the
   coming crowd and lands on the next monster to find. */
.portrait-window.spinning #target-preview { visibility: hidden; }
.slot-reel { position: absolute; inset: 0; overflow: hidden; pointer-events: none; -webkit-mask-image: linear-gradient(transparent, #000 14%, #000 86%, transparent); mask-image: linear-gradient(transparent, #000 14%, #000 86%, transparent); }
.slot-reel[hidden] { display: none; }
.slot-strip svg { display: block; width: 132px; height: 124px; overflow: visible; }
.target-card.landed .portrait-window { animation: slot-land 380ms cubic-bezier(.3,.9,.35,1.4); }
.target-card.landed h1 { animation: slot-name 380ms ease-out; }
@keyframes slot-land { 0% { transform: scale(.9); } 55% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes slot-name { from { transform: translateY(5px); opacity: .4; } to { transform: none; opacity: 1; } }
.score-card { position: absolute; top: 18px; left: 12px; z-index: 5; width: 54px; height: 54px; padding: 6px; display: grid; align-content: center; justify-items: center; gap: 2px; background: #fbfaf3; border-radius: 17px; pointer-events: none; }
.score-label { color: #858a76; font-size: 7px; font-weight: 700; letter-spacing: 1.2px; }
#score { color: #39472d; font: 700 24px/1 'Space Grotesk', sans-serif; font-variant-numeric: tabular-nums; }
.score-card.earned { animation: score-pop 300ms ease-out; }
@keyframes score-pop { 0%, 100% { transform: scale(1); } 45% { transform: scale(1.18) rotate(-4deg); } }
.score-effects { position: absolute; inset: 0; z-index: 7; pointer-events: none; overflow: hidden; }
.score-burst { position: absolute; pointer-events: none; }
.score-particle { position: absolute; left: 0; top: 0; color: #000; -webkit-text-stroke: 1.5px #fff; paint-order: stroke fill; font: 700 33px/1 'Space Grotesk', sans-serif; letter-spacing: -1px; white-space: nowrap; text-shadow: 0 3px 7px #00000026; transform: translate(-50%, -50%); animation: score-flight 1100ms cubic-bezier(.23,.65,.36,1) both; }
@keyframes score-flight {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.45); }
  14% { opacity: 1; transform: translate(-50%, calc(-50% - 24px)) scale(1.2); }
  40% { opacity: 1; transform: translate(calc(-50% + var(--arc-x)), calc(-50% - 90px)) scale(1); }
  88% { opacity: 1; transform: translate(calc(-50% + var(--flight-x)), calc(-50% + var(--flight-y))) scale(.55); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--flight-x)), calc(-50% + var(--flight-y))) scale(.2); }
}
.score-spark { position: absolute; left: 0; top: 0; width: 6px; height: 6px; border-radius: 2px; background: var(--spark-color); animation: score-spark 650ms ease-out both; }
@keyframes score-spark { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.3); } 15% { opacity: 1; } 100% { opacity: 0; transform: translate(var(--spark-x), var(--spark-y)) rotate(110deg) scale(.2); } }
.scene-grain { position: absolute; inset: 0; z-index: 4; pointer-events: none; opacity: .17; mix-blend-mode: multiply; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Cpath fill='%23000' filter='url(%23n)' opacity='.24' d='M0 0h180v180H0z'/%3E%3C/svg%3E"); }
.corner-doodle { display: none; position: absolute; top: 34px; left: 48px; width: 77px; z-index: 3; color: #a0a78a; transform: rotate(-12deg); pointer-events: none; }
.corner-doodle svg { display: block; width: 63px; }
.corner-doodle span { display: block; font-family: Georgia, serif; font-size: 17px; font-style: italic; margin-top: -6px; margin-left: 17px; }
.scene-sticker { position: absolute; right: 32px; top: 43px; display: grid; justify-items: center; align-content: center; width: 87px; height: 87px; z-index: 3; transform: rotate(12deg); background: #e8ba72; color: #655334; border-radius: 50%; outline: 1px dashed #b99152; outline-offset: -6px; pointer-events: none; }
.scene-sticker span { font-size: 10px; font-weight: 700; letter-spacing: 1.3px; text-align: center; line-height: 1.15; }
.scene-sticker svg { width: 25px; height: 12px; margin-top: 2px; }
/* The round clock: a ring of dots around the blob, going out clockwise from the top. */
.timer-dots { position: absolute; inset: 0; pointer-events: none; }
.timer-dots[hidden] { display: none; }
.timer-dots span { position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; margin: -4px; border-radius: 50%; background: #8c9f70; transform: translate(var(--x), var(--y)); transition: opacity 250ms ease, transform 250ms ease, background 250ms ease; }
.timer-dots.low span { background: #e0874a; }
.timer-dots span.spent { opacity: .35; background: #b9bda9; transform: translate(var(--x), var(--y)) scale(.45); }
/* Time ran out: everyone else steps back while the one you were after hops. */
#crowd.time-up .monster:not(.missed):not(.picked), #crowd.solved .monster:not(.found) { opacity: .3; pointer-events: none; transition: opacity 300ms ease; }
.monster.missed .monster-react { animation: monster-cheer .62s cubic-bezier(.3,.9,.35,1.25) 2; }
/* Sound on/off, top right, level with the score on the other side. */
.sound-toggle { position: absolute; top: 27px; right: 12px; z-index: 7; width: 36px; height: 36px; padding: 7px; display: grid; place-items: center; border: 0; border-radius: 50%; background: #fbfaf3; color: #39472d; cursor: pointer; transition: transform 160ms ease; }
.sound-toggle:hover { transform: scale(1.08); }
.sound-toggle:focus-visible { outline: 2px solid #39472d; outline-offset: 2px; }
.sound-toggle svg { width: 100%; height: 100%; }
.sound-toggle .sound-off, .sound-toggle[aria-pressed="false"] .sound-waves { display: none; }
.sound-toggle[aria-pressed="false"] .sound-off { display: inline; }
.menu-open .sound-toggle { top: 18px; right: 18px; background: #fff3c4; color: var(--title-ink); }
/* The title screen: a yellow page with the crowd piled into the bottom half.
   It gets no entrance animation: fading the whole layer in leaves Chrome
   compositing it washed out once the animation ends. */
.menu { position: absolute; inset: 0; z-index: 6; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 30px 22px 26px; text-align: center; }
.menu[hidden] { display: none; }
.menu-head { display: flex; flex-direction: column; align-items: center; }
.menu-monster { width: 96px; height: 108px; color: var(--title-ink); transform: rotate(-7deg); }
.menu-wordmark { display: block; width: 150px; height: 58px; margin: 8px 0 0; fill: var(--title-ink); font-family: 'DM Sans', sans-serif; font-size: 28px; font-weight: 900; letter-spacing: -.6px; overflow: visible; }
.start-button { width: min(100%, 290px); padding: 17px 26px; display: inline-flex; align-items: center; justify-content: center; gap: 12px; border: 0; border-radius: 999px; background: var(--title-ink); color: #fff; font: 700 15px 'DM Sans', sans-serif; cursor: pointer; transition: transform 160ms ease, background 160ms ease; }
.start-button span { font-size: 17px; }
.start-button:hover { background: #2d3426; transform: translateY(-2px); }
.start-button:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
/* The target card steps aside while the title screen is up. */
.menu-open .target-card { display: none; }
.menu-open .score-card, .menu-open .score-effects { display: none; }
.menu-open .game-shell { background: var(--sun); border-color: #e9b61e; }
.menu-open .crowd-card { background: var(--sun); border: 0; border-radius: 0; }
.menu-open .scene-grain { opacity: .12; }
/* Game over: a card over the faded crowd once the clock runs out. Only the card
   animates (transform, not opacity) so the dimmed layer composites cleanly. */
.game-over { position: absolute; inset: 0; z-index: 8; display: grid; place-items: center; padding: 70px 22px 22px; background: #262d2759; }
.game-over[hidden] { display: none; }
.game-over-card { position: relative; width: min(100%, 300px); padding: 62px 22px 14px; border-radius: 30px; background: #fbfaf3; text-align: center; box-shadow: 0 18px 50px #1f261c40; animation: game-over-in 420ms cubic-bezier(.25,.9,.3,1.25) both; }
@keyframes game-over-in { from { transform: translateY(40px) scale(.86); } to { transform: none; } }
.game-over-portrait { position: absolute; top: -54px; left: 50%; width: 108px; height: 108px; padding: 10px; margin-left: -54px; border: 5px solid #fbfaf3; border-radius: 50%; background: #eeeee1; }
#game-over-portrait { display: block; width: 100%; height: 100%; overflow: visible; }
#game-over-portrait .monster-react { animation: monster-shake .5s ease-in-out .35s; }
#game-over-portrait .eye-lid, #game-over-portrait .arm-wave, #game-over-portrait .arm-sway { animation: none; }
#game-over-portrait .eye-lid { transform: translateY(var(--lid-open, -90px)); }
.game-over-card h2 { margin: 0; color: var(--title-ink); font: 700 30px/1.05 'Space Grotesk', sans-serif; letter-spacing: -1.2px; }
.game-over-lead { margin: 7px 0 0; color: var(--muted); font-size: 14px; }
.game-over-lead strong { color: var(--ink); }
.game-over-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 18px 0 0; }
.game-over-stats div { padding: 9px 4px 8px; border-radius: 16px; background: #f1f1e6; }
.game-over-stats dt { color: #858a76; font-size: 8px; font-weight: 700; letter-spacing: 1.3px; text-transform: uppercase; }
.game-over-stats dd { margin: 3px 0 0; color: #39472d; font: 700 24px/1 'Space Grotesk', sans-serif; font-variant-numeric: tabular-nums; }
.game-over-record { display: inline-block; margin: 12px 0 0; padding: 4px 13px 5px; border-radius: 999px; background: var(--sun); color: var(--title-ink); font-size: 11px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; }
.game-over-record[hidden] { display: none; }
.game-over-card .start-button { width: 100%; margin-top: 18px; }
.game-over-card .start-button:focus-visible { outline-color: var(--title-ink); }
.text-button { margin-top: 4px; padding: 10px 14px; border: 0; background: none; color: #6f7468; font: 600 13px 'DM Sans', sans-serif; cursor: pointer; }
.text-button:hover { color: var(--ink); }
.text-button:focus-visible { outline: 2px solid var(--title-ink); outline-offset: 1px; border-radius: 8px; }
/* Speed bonus: the flying points get a little label. */
.score-particle small { display: block; margin-top: 2px; font-size: 12px; letter-spacing: .5px; text-align: center; }
/* Hint: one per game; half the crowd steps back. */
.hint-button { position: absolute; top: 71px; right: 12px; z-index: 7; width: 36px; height: 36px; padding: 8px; display: grid; place-items: center; border: 0; border-radius: 50%; background: #fbfaf3; color: #39472d; cursor: pointer; transition: transform 160ms ease, opacity 160ms ease; }
.hint-button svg { width: 100%; height: 100%; }
.hint-button:hover:not(:disabled) { transform: scale(1.08); }
.hint-button:focus-visible { outline: 2px solid #39472d; outline-offset: 2px; }
.hint-button:disabled { opacity: .4; cursor: default; }
.hint-count { position: absolute; top: -3px; right: -3px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--sun); color: var(--title-ink); font: 700 10px/16px 'DM Sans', sans-serif; }
.hint-button:disabled .hint-count { display: none; }
.menu-open .hint-button { display: none; }
#crowd .monster.hinted { opacity: .22; pointer-events: none; transition: opacity 300ms ease; }
/* Monster album: every named monster you have found, opened from the title screen. */
.menu-actions { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; }
.album-button { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border: 0; border-radius: 999px; background: #fff8d9; color: var(--title-ink); font: 700 14px 'DM Sans', sans-serif; cursor: pointer; box-shadow: 0 4px 14px #5a4a0a26; }
.album-button:hover { background: #fff; }
.album-button:focus-visible { outline: 2px solid var(--title-ink); outline-offset: 1px; }
.album-badge { padding: 2px 8px; border-radius: 999px; background: var(--sun); font-size: 11px; }
.album { position: absolute; inset: 0; z-index: 9; display: grid; padding: 16px; background: #262d2759; }
.album[hidden] { display: none; }
.album-card { display: flex; flex-direction: column; min-height: 0; border-radius: 26px; background: #fbfaf3; box-shadow: 0 18px 50px #1f261c40; overflow: hidden; animation: game-over-in 380ms cubic-bezier(.25,.9,.3,1.2) both; }
.album-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 18px 12px 22px; }
.album-head h2 { margin: 0; color: var(--title-ink); font: 700 24px/1.1 'Space Grotesk', sans-serif; letter-spacing: -.8px; }
.album-count { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.album-close { flex: none; width: 34px; height: 34px; border: 0; border-radius: 50%; background: #f1f1e6; color: var(--ink); font: 400 22px/1 'DM Sans', sans-serif; cursor: pointer; }
.album-close:focus-visible, .album-grid:focus-visible { outline: 2px solid var(--title-ink); outline-offset: 2px; }
.album-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; padding: 4px 14px 18px; list-style: none; overflow-y: auto; }
.album-grid li { padding: 8px 4px 7px; border-radius: 16px; background: #f1f1e6; text-align: center; }
.album-grid svg { display: block; width: 100%; height: 70px; overflow: visible; }
.album-grid .album-name { margin-top: 4px; color: var(--ink); font-size: 11px; font-weight: 650; }
.album-unknown { height: 70px; display: grid; place-items: center; color: #c9ccbb; font: 700 28px 'Space Grotesk', sans-serif; }
.album-grid li.missing .album-name { color: #a7ab9a; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.crowd-refresh { animation: appear .4s ease-out; }
@keyframes appear { from { opacity: .4; } to { opacity: 1; } }
@media(max-width: 430px) {
  body { padding: 0; background: var(--paper); }
  .game-shell { width: 100%; height: 100svh; border: 0; border-radius: 0; box-shadow: none; }
}
@media(prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
