* { box-sizing: border-box; }
:root { color-scheme: dark; --gold: #d9ca8d; --edge: max(22px, env(safe-area-inset-left)); }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; background: #020605; color: #d4dacb; font-family: Arial, sans-serif; }
body { overscroll-behavior: none; }
button, a { font: inherit; -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: var(--gold); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }
[hidden] { display: none !important; }
#scene { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }
.hud { position: fixed; inset: 0; pointer-events: none; padding: max(24px, env(safe-area-inset-top)) var(--edge) max(22px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; justify-content: space-between; background: linear-gradient(#0009, transparent 23%, transparent 75%, #000b); transition: opacity .5s; }
.top, .bottom { display: flex; justify-content: space-between; gap: 18px; }
.bottom { align-items: end; }
.brand { font: 20px Georgia, serif; letter-spacing: 5px; }
.sub { font-size: 9px; letter-spacing: 3px; color: #879087; margin-top: 10px; }
.objective { font-size: 12px; max-width: 240px; line-height: 1.7; text-align: right; color: #b8c2b5; }
.objective small { display: block; color: var(--gold); letter-spacing: 2px; font-size: 9px; }
.inventory-title { font-size: 9px; letter-spacing: 2px; color: #a3af9f; margin-bottom: 12px; }
.inventory { display: flex; gap: 7px; }
.slot { width: 61px; height: 61px; border: 1px solid #62725888; background: #0a1009cc; display: grid; place-items: center; color: #798a70; font-size: 25px; position: relative; }
.slot.filled { border-color: #bbac68; color: #e5cf7f; box-shadow: inset 0 0 20px #d7c47a18; }
.slot b { font-size: 22px; font-weight: 400; line-height: 1; }
.slot span { font-size: 7px; position: absolute; bottom: 5px; letter-spacing: 1px; white-space: nowrap; }
.help { font-size: 10px; color: #a4b29c; line-height: 1.8; text-align: right; }
.crosshair { position: fixed; left: 50%; top: 50%; width: 4px; height: 4px; border-radius: 50%; background: #d0d8b48c; pointer-events: none; }
.prompt { position: fixed; z-index: 3; left: 50%; top: 62%; transform: translateX(-50%); text-align: center; max-width: 94%; width: max-content; }
.prompt button { min-height: 48px; color: #e7debb; background: #0a120df2; border: 1px solid #b3a774aa; padding: 14px 24px; letter-spacing: 1px; border-radius: 4px; touch-action: manipulation; }
.toast { position: fixed; top: 22%; width: 100%; padding: 0 18px; text-align: center; font-size: 13px; color: #f4e5b0; text-shadow: 0 2px 12px #000; pointer-events: none; }
.tools { position: fixed; z-index: 3; right: var(--edge); top: 103px; display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.tools button, .tools a { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; background: #09100cdd; color: #bdc9b4; border: 1px solid #4e604988; padding: 8px 11px; font-size: 10px; text-decoration: none; }
.overlay { position: fixed; z-index: 5; inset: 0; display: grid; align-items: center; background: linear-gradient(90deg, #020705ee, #02070588 60%, #02070566); padding: max(28px, env(safe-area-inset-top)) max(6vw, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(6vw, env(safe-area-inset-left)); overflow-y: auto; }
.intro { max-width: 640px; text-align: left; }
.label { font-size: 10px; letter-spacing: 3px; color: #c2b47e; }
.intro h1 { font: 400 clamp(40px, 6vw, 84px)/1.05 Georgia, serif; margin: 24px 0; color: #dee2d2; }
.intro h1 em { color: #9baf8a; }
.intro p { font-size: 14px; line-height: 1.8; color: #afbaaa; max-width: 430px; margin: 0 0 26px; }
.primary { display: inline-block; background: #d2c592; color: #10160e; padding: 17px 25px; min-height: 48px; border: 0; letter-spacing: 1.5px; font-size: 11px; text-decoration: none; line-height: 1.4; text-align: center; }
.primary:hover { background: #e4d6a1; }
.intro .hint { font-size: 11px; margin: 18px 0; color: #9aaa91; line-height: 1.7; }
.intro-link { font-size: 12px; text-underline-offset: 4px; display: inline-block; padding: 10px 0; }
.touch-hint { display: none; }
.mobile { display: none; position: fixed; z-index: 2; bottom: max(110px, calc(env(safe-area-inset-bottom) + 90px)); left: var(--edge); right: var(--edge); justify-content: space-between; pointer-events: none; user-select: none; -webkit-user-select: none; }
.pad { display: grid; grid-template-columns: repeat(3, 48px); gap: 5px; pointer-events: auto; }
.pad button { border: 1px solid #71836b88; background: #0d190fe0; color: #d6e3c8; height: 48px; touch-action: none; font-size: 20px; border-radius: 5px; }
.pad button:first-child { grid-column: 2; }
.pad button:nth-child(2) { grid-column: 1; }
.pad button:active { background: #415139; }
.touch-actions { align-self: end; display: grid; justify-items: end; gap: 7px; }
#jump { min-height: 44px; padding: 10px 16px; background: #0d190fe0; color: #d6e3c8; border: 1px solid #71836b88; border-radius: 5px; pointer-events: auto; touch-action: manipulation; }
.lookhint { align-self: end; color: #bccbb3; font-size: 10px; max-width: 115px; text-align: right; padding: 8px; background: #07110b99; }
.pause-note { position: fixed; left: 50%; top: 17%; transform: translateX(-50%); font-size: 9px; letter-spacing: 1px; background: #07110bcc; border: 1px solid #64775a66; color: #c2ceb6; padding: 10px 15px; pointer-events: none; text-align: center; width: max-content; max-width: 90%; }
.collectible-note { display: block; color: #a9b99d; font-size: 9px; letter-spacing: 1.5px; margin-top: 7px; }
.minimap { position: fixed; right: var(--edge); bottom: 100px; width: 128px; height: 128px; border: 1px solid #c8b86f99; border-radius: 50%; background: #07110dcc; box-shadow: 0 0 0 4px #07110d66, 0 8px 28px #0008; pointer-events: none; overflow: hidden; }
.minimap canvas { width: 100%; height: 100%; display: block; }
.timer { position: fixed; left: 50%; top: max(24px, env(safe-area-inset-top)); transform: translateX(-50%); padding: 8px 13px; border: 1px solid #b7a96777; background: #07110dcc; color: #e2d49b; font: 12px Georgia, serif; letter-spacing: 2px; pointer-events: none; }
.timer.warning { color: #ffb18b; border-color: #d66c4d; }
.cinematic :is(.hud, .tools, .crosshair, .mobile, .minimap, .timer, .pause-note, .toast),
.not-started :is(.hud, .tools, .crosshair, .mobile, .minimap, .timer, .pause-note),
.timed-out :is(.mobile, .crosshair, .prompt, .pause-note) { visibility: hidden; pointer-events: none; }
.timed-out .toast { top: 45%; padding: 24px; background: #07110be8; font-size: 16px; }
.look-dragging #scene { cursor: grabbing; }
dialog { position: fixed; inset: 0 4vw 0 auto; margin: auto; width: 365px; max-width: calc(100vw - 32px); max-height: calc(100dvh - 32px); overflow: auto; overscroll-behavior: contain; text-align: center; background: #07110bf2; color: #dfe2d2; border: 1px solid #a49762; border-radius: 8px; padding: 24px; box-shadow: 0 25px 100px #0008; }
dialog::backdrop { background: #0003; }
.book-reveal { position: relative; isolation: isolate; }
.book-reveal::before { content: ''; position: absolute; z-index: -1; inset: 5% -5%; border-radius: 50%; background: radial-gradient(ellipse, #e4c16566, #c6972c22 45%, transparent 70%); filter: blur(12px); }
.real-book { display: block; width: auto; height: min(33dvh, 290px); max-width: 100%; object-fit: contain; margin: 0 auto 20px; filter: drop-shadow(0 0 15px #e4c16555) drop-shadow(0 15px 25px #0009); }
dialog h2 { font: 28px/1.1 Georgia, serif; margin: 16px 0; }
dialog p { font-size: 13px; line-height: 1.7; color: #b7c1af; margin: 12px 0; }
dialog .primary { display: block; margin: 20px 0 5px; }
dialog button { min-height: 44px; background: none; border: 0; color: #b9c7aa; font-size: 12px; padding: 10px; }
.journey { font-size: 9px; letter-spacing: 1px; color: #c8b86f; margin-top: 12px; }
.fatal { position: fixed; inset: 0; background: #07110b; padding: 15vh 10vw; z-index: 20; text-align: center; line-height: 1.8; overflow: auto; }
@media (any-pointer: coarse), (max-width: 760px) {
  .mobile { display: flex; }
  .help, .desktop-hint, .pause-note { display: none; }
  .touch-hint { display: inline; }
  .tools button, .tools a { min-height: 44px; }
  .minimap { bottom: max(22px, env(safe-area-inset-bottom)); width: 100px; height: 100px; }
}
@media (max-width: 650px) {
  :root { --edge: max(16px, env(safe-area-inset-left)); }
  .hud { padding-top: max(20px, env(safe-area-inset-top)); }
  .brand { font-size: 15px; letter-spacing: 3px; }
  .sub { font-size: 7px; letter-spacing: 1.5px; }
  .objective { max-width: 145px; font-size: 10px; }
  .timer { left: var(--edge); top: 88px; transform: none; font-size: 11px; }
  .tools { top: 86px; gap: 4px; }
  .tools button, .tools a { font-size: 9px; padding: 7px; }
  .toast { top: 26%; font-size: 12px; }
  .prompt { top: 55%; }
  .prompt button { font-size: 12px; padding: 12px 16px; }
  .inventory { gap: 4px; }
  .slot { width: 43px; height: 48px; }
  .slot b { font-size: 18px; }
  .slot span { font-size: 5.8px; }
  .inventory-title { font-size: 8px; }
  .overlay { background: #020705c9; }
  .intro h1 { font-size: clamp(39px, 10vw, 62px); }
  .intro p { font-size: 13px; }
  dialog { inset: 0; margin: auto; width: min(88vw, 380px); padding: 20px; }
  .real-book { height: min(30dvh, 245px); margin-bottom: 15px; }
  dialog h2 { font-size: 26px; }
}
@media (max-height: 540px) and (min-width: 560px) {
  .overlay { padding-top: 22px; padding-bottom: 22px; }
  .intro { max-width: 650px; }
  .intro h1 { font-size: 38px; margin: 14px 0; }
  .intro p { font-size: 12px; max-width: 610px; margin-bottom: 14px; }
  .intro .hint { margin: 10px 0 0; }
  .tools { top: 80px; }
  .timer { top: 18px; }
  .mobile { bottom: 80px; }
  .pad { grid-template-columns: repeat(3, 44px); gap: 3px; }
  .pad button { height: 44px; }
  .minimap { width: 78px; height: 78px; }
  .prompt { top: 49%; }
  dialog { inset: 0; width: 620px; padding: 18px; }
  dialog[open] { display: grid; grid-template-columns: 34% 1fr; align-items: center; gap: 20px; }
  .real-book { height: min(70dvh, 320px); margin: auto; }
  dialog h2 { font-size: 25px; margin: 12px 0; }
  dialog .primary { margin-top: 14px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }
