:root {
  --paper: #e7d6b1;
  --cream: #f4e8cc;
  --ink: #241b16;
  --red: #c83f2b;
  --red-dark: #89271e;
  --gold: #d39b42;
  --night: #17120f;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; overflow-x: hidden; overscroll-behavior: none; }
body {
  background: #17120f;
  color: var(--cream);
  font-family: "PT Sans", Arial, sans-serif;
  background-image: radial-gradient(circle at 50% 0, #3b2c22 0, transparent 42%), repeating-linear-gradient(90deg, rgba(255,255,255,.018) 0 1px, transparent 1px 5px);
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
button { font: inherit; }

.game-shell { width: 100%; margin: 0; min-height: 100vh; min-height: 100dvh; display: grid; grid-template-rows: auto auto auto; }
.topbar { min-height: 88px; padding: 12px 2.5%; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid #674b35; }
.brand { min-width: 0; display: flex; align-items: baseline; gap: 18px; }
.brand__eyebrow, .kicker { color: var(--gold); font-size: 11px; letter-spacing: .2em; font-weight: 700; }
.brand__title { min-width: 0; }
.brand h1 { font-family: "Russo One", Impact, sans-serif; font-size: clamp(18px, 2.35vw, 36px); line-height: 1.05; margin: 0; letter-spacing: .03em; overflow-wrap: anywhere; text-transform: uppercase; }
.brand__subtitle, .menu-card__subtitle { display: block; color: var(--gold); font-size: clamp(9px, .8vw, 13px); font-weight: 700; letter-spacing: .16em; line-height: 1.15; margin-top: 4px; text-transform: uppercase; }
.level-label { margin-left: auto; display: grid; text-align: right; }
.level-label span { color: var(--red); font-size: 9px; letter-spacing: .18em; font-weight: 700; }
.level-label span:empty { display: none; }
.level-label strong { font-size: 13px; }
.stats { display: flex; gap: 22px; }
.stat { display: grid; gap: 2px; padding-left: 20px; border-left: 2px solid var(--red); }
.stat span { color: #9d8a78; font-size: 10px; letter-spacing: .17em; }
.stat strong { font-family: "Russo One", Impact, sans-serif; font-size: 21px; font-weight: 400; }
.stat b { color: #e7674f; }
.stat--timer { width: 88px; flex: 0 0 88px; }
#timer { display: block; width: 5.2ch; font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; white-space: nowrap; }
.menu-button { align-self: center; padding: 9px 11px; border: 1px solid #6b503b; background: transparent; color: #bda88f; font-size: 10px; letter-spacing: .12em; cursor: pointer; }
.menu-button:hover { color: var(--cream); border-color: var(--gold); }

.audio-player { display: flex; align-items: center; gap: 9px; color: var(--cream); }
.audio-play { min-width: 58px; height: 34px; padding: 0 6px; border: 1px solid #735640; color: var(--cream); background: #2b201a; font: 10px "Russo One", Impact, sans-serif; letter-spacing: .04em; cursor: pointer; }
.audio-play:hover, .audio-play.is-playing { border-color: var(--gold); color: var(--gold); }
.audio-track { display: grid; gap: 2px; }
.audio-track > span, .audio-volume > span { color: #8e7967; font-size: 8px; font-weight: 700; letter-spacing: .11em; }
.audio-track select { width: 142px; height: 28px; padding: 0 22px 0 7px; border: 1px solid #5d4637; border-radius: 0; color: #d8c6b3; background: #17110e; font-size: 10px; outline: none; }
.audio-track select:focus { border-color: var(--gold); }
.audio-track option:disabled { color: #75675c; }
.audio-volume { display: grid; grid-template-columns: 38px 29px; align-items: center; gap: 4px; }
.audio-knob { --angle: calc(-135deg + var(--step, 0) * 90deg); position: relative; width: 29px; height: 29px; padding: 0; border: 1px solid #725744; border-radius: 50%; color: #d9c5ad; background: radial-gradient(circle at 35% 30%, #5b4738 0 12%, #2b211b 48%, #100c0a 100%); box-shadow: inset 0 0 0 3px #1c1511, 0 1px 3px #000; cursor: ns-resize; }
.audio-knob i { position: absolute; left: 50%; top: 3px; width: 2px; height: 7px; transform: translateX(-50%) rotate(var(--angle)); transform-origin: 50% 11.5px; background: var(--gold); pointer-events: none; }
.audio-knob b { position: absolute; inset: 0; display: grid; place-items: center; padding-top: 3px; font-size: 8px; font-weight: 400; pointer-events: none; }
.audio-knob:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.scene-frame { position: relative; width: 100%; display: flex; align-items: center; justify-content: center; background: #080706; border-bottom: 1px solid #674b35; overflow: hidden; touch-action: none; }
.scene { position: relative; width: 100%; aspect-ratio: 1672 / 941; user-select: none; overflow: hidden; cursor: crosshair; transition: transform .12s ease-out; will-change: transform; touch-action: none; }
.scene.is-zoomed { cursor: grab; }
.scene.is-dragging { cursor: grabbing; transition: none; }
.scene > img { display: block; width: 100%; height: 100%; object-fit: fill; pointer-events: none; }
.scene::after { content: ""; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 70px rgba(0,0,0,.42); }
.scene-caption { position: absolute; left: 16px; bottom: 13px; z-index: 2; display: flex; gap: 12px; color: rgba(255,255,255,.62); font: 10px monospace; text-transform: uppercase; }
.scene-caption span:last-child { color: #e35a43; }
.zoom-controls { position: absolute; z-index: 5; left: 12px; top: 50%; transform: translateY(-50%); display: none; gap: 7px; flex-direction: column; }
.zoom-button { width: 42px; height: 42px; padding: 0; border: 1px solid rgba(244,232,204,.42); border-radius: 50%; color: var(--cream); background: rgba(23,18,15,.78); font: 24px/1 "Russo One", Impact, sans-serif; box-shadow: 0 2px 12px rgba(0,0,0,.35); cursor: pointer; }
.zoom-button:disabled { opacity: .35; cursor: default; }
.zoom-button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.hotspot { position: absolute; width: var(--w); aspect-ratio: 1; transform: translate(-50%, -50%); border: 0; border-radius: 50%; background: transparent; cursor: crosshair; z-index: 2; }
.hotspot:focus-visible { outline: 2px dashed var(--cream); outline-offset: 4px; }
.hotspot.found { cursor: default; }
.hotspot.found::before, .hotspot.hinted::before { content: ""; position: absolute; inset: 10%; border: 3px solid #f3c55a; border-radius: 50%; animation: ping .75s ease-out forwards; box-shadow: 0 0 20px #e6a632; }
.hotspot.found::after { content: "✓"; position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; transform: translate(-50%,-50%); display: grid; place-items: center; color: #fff; background: var(--red); border: 2px solid #f9d58b; border-radius: 50%; font-weight: 700; animation: pop .35s ease-out; }
.hotspot.hinted::before { animation: hintPulse 1s ease-in-out infinite; }
.success-effects { position: absolute; inset: 0; z-index: 6; overflow: hidden; pointer-events: none; }
.star-burst { position: absolute; width: 0; height: 0; }
.star-burst::before { content: ""; position: absolute; left: 0; top: 0; width: 12px; height: 12px; border: 2px solid #fff2a4; border-radius: 50%; transform: translate(-50%,-50%); animation: starFlash .48s ease-out forwards; box-shadow: 0 0 14px #ffd34f; }
.star-burst__star { position: absolute; left: 0; top: 0; color: var(--star-color); font-size: 16px; line-height: 1; text-shadow: 0 0 6px currentColor, 0 1px 2px rgba(0,0,0,.5); transform: translate(-50%,-50%) scale(.1); animation: starFirework .72s cubic-bezier(.18,.7,.25,1) var(--star-delay) forwards; }
.miss { position: absolute; z-index: 4; opacity: 0; transform: translate(-50%,-50%) scale(.7); color: #fff; background: var(--red); border-radius: 50%; width: 42px; height: 42px; display: grid; place-items: center; font-family: "Russo One"; pointer-events: none; }
.miss.show { animation: miss .65s ease-out; }
.hint-vignette { position: absolute; inset: 0; z-index: 1; opacity: 0; pointer-events: none; background: rgba(5,3,2,.38); transition: opacity .25s; }
.hint-vignette.show { opacity: 1; }

.search-panel { padding: 18px 3.5% 26px; background: linear-gradient(#211914, #18120f); }
.search-panel__heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.search-panel__heading p { display: inline; color: #a89482; font-size: 12px; margin-left: 12px; }
.hint-button { border: 1px solid #6b503b; background: #2b211a; color: var(--cream); padding: 9px 13px; letter-spacing: .08em; font-size: 11px; cursor: pointer; transition: .2s; }
.hint-button:hover:not(:disabled) { border-color: var(--gold); background: #3b2c21; }
.hint-button span { display: inline-grid; place-items: center; width: 19px; height: 19px; margin-right: 7px; border-radius: 50%; background: var(--gold); color: var(--ink); font-weight: 700; }
.hint-button b { margin-left: 8px; color: var(--gold); }
.hint-button:disabled { opacity: .38; cursor: default; }
.items { display: grid; grid-template-columns: repeat(7, 1fr); border: 1px solid #49372a; }
.item { min-width: 0; padding: 11px 12px; border-right: 1px solid #49372a; display: flex; gap: 10px; align-items: center; background: rgba(255,255,255,.018); transition: .3s; }
.item:last-child { border: 0; }
.item__number { flex: 0 0 24px; height: 24px; display: grid; place-items: center; border: 1px solid #66503e; color: #9c806b; font-size: 10px; }
.item__name { min-width: 0; display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow-wrap: anywhere; font-weight: 700; font-size: clamp(9px, .85vw, 12px); line-height: 1.08; text-transform: uppercase; letter-spacing: .02em; }
.item.found { opacity: .42; background: rgba(200,63,43,.15); }
.item.found .item__name { text-decoration: line-through; }
.item.found .item__number { background: var(--red); color: #fff; border-color: var(--red); }

.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 18px; background: rgba(9,7,5,.82); backdrop-filter: blur(7px); opacity: 0; visibility: hidden; transition: .3s; }
.modal.is-open { opacity: 1; visibility: visible; }
.modal__card { position: relative; width: min(92vw, 510px); padding: 48px 48px 42px; color: var(--ink); background: var(--paper); box-shadow: 14px 14px 0 rgba(0,0,0,.32); border: 1px solid #a48660; background-image: repeating-linear-gradient(0deg, transparent 0 5px, rgba(85,52,24,.025) 5px 6px); }
.modal__card::before { content: ""; position: absolute; inset: 10px; border: 1px solid rgba(78,48,25,.2); pointer-events: none; }
.modal__card .kicker { color: var(--red-dark); }
.modal__card h2 { margin: 10px 0 12px; font: 400 clamp(34px, 6vw, 58px)/.95 "Russo One", Impact, sans-serif; text-transform: uppercase; letter-spacing: -.03em; }
.modal__card > p { color: #5b4636; line-height: 1.45; }
.tape { height: 8px; position: absolute; left: -14px; right: -14px; top: -4px; display: flex; justify-content: space-around; background: var(--red); transform: rotate(-1deg); }
.tape i { width: 20%; background: rgba(255,255,255,.22); }
.rule { display: flex; align-items: center; gap: 14px; padding: 10px 0; border-top: 1px solid #b9a17d; }
.rule span { font: 20px "Russo One"; color: var(--red); }
.rule p { margin: 0; font-size: 13px; font-weight: 700; }
.primary-button { width: 100%; margin-top: 20px; padding: 16px 20px; display: flex; justify-content: space-between; border: 0; background: var(--red); color: #fff; font-family: "Russo One"; letter-spacing: .06em; cursor: pointer; box-shadow: 5px 5px 0 var(--red-dark); transition: transform .15s, box-shadow .15s; }
.primary-button:hover { transform: translate(2px,2px); box-shadow: 3px 3px 0 var(--red-dark); }
.result-card { text-align: center; }
.result-stamp { position: absolute; right: -15px; top: -18px; padding: 8px 12px; border: 3px solid var(--red); color: var(--red); font: 17px "Russo One"; transform: rotate(7deg); }
.result-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 12px; margin-top: 20px; }
.result-actions .primary-button { margin-top: 0; }
.secondary-button { border: 1px solid #8f7354; background: transparent; color: var(--ink); font-family: "Russo One"; letter-spacing: .04em; cursor: pointer; }
.secondary-button:hover { background: rgba(61,39,23,.08); }

.menu-modal { background-color: #15100d; background-image: linear-gradient(rgba(12,8,6,.62), rgba(12,8,6,.78)), url("assets/background.jpg"); background-position: center; background-size: cover; overflow-y: auto; align-items: center; }
.menu-card { width: min(1240px, calc(100% - 36px)); padding: 38px 44px; background: rgba(32,23,19,.9); border: 1px solid #5b4230; box-shadow: 18px 18px 0 rgba(0,0,0,.3); }
.menu-card__header { display: flex; justify-content: space-between; align-items: end; gap: 40px; margin-bottom: 24px; }
.menu-card__header h2 { max-width: 760px; margin: 3px 0 0; font: 400 clamp(32px, 5vw, 64px)/.95 "Russo One", Impact, sans-serif; letter-spacing: .03em; }
.menu-card__subtitle { color: var(--red-dark); font-size: clamp(11px, 1vw, 16px); margin-top: 8px; }
.menu-card__header p { width: 330px; margin: 0; color: #9f8a76; line-height: 1.45; }
.menu-card__side { display: grid; justify-items: end; gap: 14px; }
.audio-player--menu { padding: 8px 10px; border: 1px solid #4e392c; background: #17110e; }
.level-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.level-card { position: relative; padding: 0; text-align: left; border: 1px solid #5a4332; background: #17110e; color: var(--cream); cursor: pointer; transition: transform .2s, border-color .2s; overflow: hidden; }
.level-card:hover, .level-card:focus-visible { transform: translateY(-5px); border-color: var(--gold); outline: none; }
.level-card__image { position: relative; display: block; aspect-ratio: 16/9; background-position: center; background-size: cover; filter: saturate(.82); }
.level-card__image::after { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 50%, rgba(9,6,4,.8)); }
.level-card__image i { position: absolute; z-index: 1; left: 14px; bottom: 8px; color: #fff; font: normal 30px "Russo One"; }
.level-card__copy { display: grid; padding: 13px 15px 15px; }
.level-card__copy { min-width: 0; }
.level-card__copy small { color: var(--red); font-size: 9px; letter-spacing: .13em; }
.level-card__copy strong { min-width: 0; margin: 6px 0 2px; font: 18px "Russo One"; text-transform: uppercase; overflow-wrap: anywhere; }
.level-card__copy em { color: #8e7b6b; font-size: 12px; font-style: normal; }
.level-card__copy em:empty { display: none; }
.level-card.locked { cursor: not-allowed; border-color: #312923; }
.level-card.locked:hover { transform: none; border-color: #312923; }
.level-card.locked .level-card__image { filter: grayscale(1) contrast(.42) brightness(.58); }
.level-card.locked .level-card__copy { opacity: .38; }
.level-card.locked::after { content: attr(data-locked-label); position: absolute; z-index: 3; top: 30%; left: 50%; transform: translate(-50%,-50%) rotate(-3deg); padding: 7px 10px; color: #c9bba9; border: 2px solid #77695d; background: rgba(19,15,12,.82); font: 12px "Russo One"; letter-spacing: .12em; }
.menu-rules { display: flex; justify-content: center; gap: 36px; margin-top: 25px; color: #877363; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }

@media (min-width: 851px) and (min-aspect-ratio: 4/3) {
  html, body { height: 100%; overflow: hidden; }
  .game-shell { height: 100vh; height: 100dvh; min-height: 0; grid-template-rows: auto minmax(0, 1fr) auto; }
  .scene-frame { min-height: 0; }
  .scene { width: auto; height: 100%; max-width: 100%; flex: 0 1 auto; }
}

@keyframes pop { from { transform: translate(-50%,-50%) scale(0); } 70% { transform: translate(-50%,-50%) scale(1.2); } }
@keyframes ping { from { opacity: 1; transform: scale(.4); } to { opacity: 0; transform: scale(1.7); } }
@keyframes hintPulse { 0%,100% { transform: scale(.65); opacity: .45; } 50% { transform: scale(1.15); opacity: 1; } }
@keyframes miss { 0% { opacity: 0; transform: translate(-50%,-50%) scale(.5); } 30% { opacity: 1; transform: translate(-50%,-75%) scale(1); } 100% { opacity: 0; transform: translate(-50%,-130%) scale(.9); } }
@keyframes starFlash { from { opacity: 1; transform: translate(-50%,-50%) scale(.25); } to { opacity: 0; transform: translate(-50%,-50%) scale(2.8); } }
@keyframes starFirework { 0% { opacity: 0; transform: translate(-50%,-50%) scale(.1) rotate(0deg); } 18% { opacity: 1; } 100% { opacity: 0; transform: translate(calc(-50% + var(--star-x)), calc(-50% + var(--star-y))) scale(.45) rotate(var(--star-rotation)); } }

@media (max-width: 850px) {
  html, body { height: 100%; overflow: hidden; }
  .game-shell { height: 100vh; height: 100dvh; min-height: 0; grid-template-rows: auto minmax(0, 1fr) auto; }
  .topbar { min-height: 66px; }
  .brand__eyebrow { display: none; }
  .level-label { display: none; }
  .stats { gap: 10px; }
  .audio-player--game .audio-track > span, .audio-player--game .audio-volume > span { display: none; }
  .audio-player--game .audio-volume { grid-template-columns: 29px; }
  .audio-player--game .audio-track select { width: 105px; }
  .stat { padding-left: 10px; }
  .stat strong { font-size: 16px; }
  .scene-frame { min-height: 0; }
  .scene { width: auto; height: 100%; max-width: none; max-height: none; flex: 0 0 auto; }
  .zoom-controls { display: flex; }
  .scene-caption { left: 64px; }
  .hotspot { width: max(var(--w), 24px); }
  .search-panel { max-height: 34vh; overflow: hidden; padding: 12px 14px 14px; }
  .search-panel__heading { margin-bottom: 9px; }
  .items { grid-template-columns: repeat(4, 1fr); }
  .item { min-height: 42px; padding: 8px 9px; border-bottom: 1px solid #49372a; }
  .item__number { flex-basis: 21px; width: 21px; height: 21px; }
  .item__name { font-size: 11px; }
  .search-panel__heading p { display: none; }
  .menu-card { padding: 30px; margin: 20px 0; }
  .menu-card__header { display: block; }
  .menu-card__header p { width: auto; margin-top: 16px; }
  .menu-card__side { justify-items: start; }
  .audio-player--menu { margin-top: 14px; flex-wrap: wrap; }
  .level-grid { grid-template-columns: 1fr; }
  .level-card { display: grid; grid-template-columns: 42% 58%; }
  .level-card__image { width: 100%; height: 100%; aspect-ratio: auto; }
  .menu-rules { flex-wrap: wrap; gap: 12px 24px; }
}

@media (max-width: 850px) and (orientation: portrait) {
  .level-card { grid-template-columns: minmax(96px, 34%) minmax(0, 1fr); }
  .level-card__image { max-width: 140px; }
  .level-card__copy { padding: 11px 12px 12px; }
  .level-card__copy strong { font-size: 16px; line-height: 1.08; }
}

@media (max-width: 850px) and (orientation: landscape) {
  .topbar { min-height: 42px; padding: 4px 10px; gap: 8px; }
  .brand h1 { max-width: 220px; font-size: clamp(12px, 2.2vw, 17px); }
  .brand__subtitle { font-size: 7px; margin-top: 2px; }
  .audio-player--game { gap: 6px; }
  .audio-play { min-width: 54px; height: 27px; font-size: 9px; }
  .audio-player--game .audio-track select { width: 94px; height: 25px; font-size: 9px; }
  .audio-player--game .audio-volume { grid-template-columns: 24px; }
  .audio-knob { width: 24px; height: 24px; }
  .audio-knob i { top: 2px; height: 6px; transform-origin: 50% 10px; }
  .stats { gap: 7px; }
  .stat { padding-left: 8px; }
  .stat strong { font-size: 14px; }
  .stat--timer { width: 68px; flex-basis: 68px; }
  .menu-button { padding: 6px 8px; font-size: 9px; }
  .search-panel { position: relative; max-height: none; padding: 5px 8px 6px; overflow: visible; }
  .search-panel__heading { position: absolute; z-index: 6; left: 8px; right: 8px; bottom: calc(100% + 6px); min-height: 28px; margin: 0; padding-left: 58px; pointer-events: none; }
  .search-panel__heading .kicker { padding: 6px 9px; background: rgba(23,18,15,.78); border: 1px solid rgba(211,155,66,.45); font-size: 9px; letter-spacing: .14em; }
  .search-panel__heading .hint-button { margin-left: auto; pointer-events: auto; }
  .hint-button { padding: 5px 8px; font-size: 9px; }
  .hint-button span { width: 16px; height: 16px; margin-right: 5px; }
  .items { grid-template-columns: repeat(7, 1fr); }
  .item { min-height: 31px; padding: 4px 6px; gap: 6px; }
  .item__number { flex-basis: 18px; width: 18px; height: 18px; font-size: 9px; }
  .item__name { font-size: clamp(7px, 1.45vw, 10px); }
}
@media (min-width: 851px) and (max-width: 1180px) {
  .topbar { gap: 12px; }
  .level-label { display: none; }
  .audio-player--game .audio-track > span, .audio-player--game .audio-volume > span { display: none; }
  .audio-player--game .audio-volume { grid-template-columns: 29px; }
  .audio-player--game .audio-track select { width: 110px; }
  .stats { gap: 10px; }
  .level-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 520px) {
  .game-shell { min-width: 340px; }
  .topbar { padding-inline: 14px; flex-wrap: wrap; }
  .brand { flex: 1 1 180px; }
  .brand h1 { max-width: 210px; font-size: clamp(15px, 5vw, 20px); }
  .brand__subtitle { font-size: 8px; }
  .audio-player--game { order: 3; width: 100%; gap: 7px; justify-content: center; padding-top: 7px; border-top: 1px solid #49372a; }
  .audio-player--game .audio-track { display: grid; }
  .audio-player--game .audio-track select { width: 125px; }
  .stats { margin-left: auto; }
  .stat span { display: none; }
  .items { grid-template-columns: repeat(2, 1fr); max-height: 28vh; overflow: auto; }
  .search-panel { padding: 10px 10px 12px; }
  .hint-button { padding: 7px 9px; font-size: 10px; }
  .modal__card { padding: 40px 28px 30px; }
}

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