@font-face { font-family: 'Cormorant'; src: url(fonts/cormorant-cyr.woff2) format('woff2'); font-weight: 400 700; font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Cormorant'; src: url(fonts/cormorant-lat.woff2) format('woff2'); font-weight: 400 700; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Marck'; src: url(fonts/marck-cyr.woff2) format('woff2'); font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Marck'; src: url(fonts/marck-lat.woff2) format('woff2'); font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root { --gold: #e6c27a; --gold-dim: #a8884a; --ink: #05040a; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--ink); overflow: hidden; overscroll-behavior: none;
  font-family: 'Cormorant', Georgia, serif; color: #efe6d2; -webkit-user-select: none; user-select: none; touch-action: none; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

#vignette { position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 55%, transparent 45%, rgba(0,0,0,.55) 100%); }

.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 24px; opacity: 0; pointer-events: none; transition: opacity 1.2s ease; }
.screen.on { opacity: 1; pointer-events: auto; }
#intro { background: radial-gradient(ellipse at 50% 40%, #17121f 0%, #05040a 70%); z-index: 20; }
#card { background: radial-gradient(ellipse at 50% 45%, rgba(40,28,8,.55) 0%, rgba(5,4,10,.86) 75%); z-index: 15; }

.intro-inner { max-width: 420px; }
.sigil { font-size: 30px; color: var(--gold); text-shadow: 0 0 18px rgba(230,194,122,.8); animation: pulse 3s ease-in-out infinite; }
h1 { font-weight: 700; font-size: clamp(34px, 10vw, 52px); letter-spacing: .04em; margin: 14px 0 6px;
  color: var(--gold); text-shadow: 0 0 28px rgba(230,194,122,.35); text-wrap: balance; }
.sub { font-size: 20px; line-height: 1.5; margin: 0 0 34px; color: #b9ad94; letter-spacing: .12em; text-transform: uppercase; }
#card .sub { text-transform: none; letter-spacing: .03em; font-size: 22px; color: #e6dcc4; margin-bottom: 30px; }

#loader { width: 180px; height: 2px; margin: 0 auto 26px; background: rgba(230,194,122,.18); overflow: hidden; border-radius: 2px; transition: opacity .6s; }
#bar { height: 100%; width: 0; background: var(--gold); box-shadow: 0 0 10px var(--gold); transition: width .3s ease; }

.btn { font: 700 20px 'Cormorant', Georgia, serif; letter-spacing: .14em; text-transform: uppercase; color: var(--gold);
  background: rgba(12,9,18,.72); border: 1px solid var(--gold-dim); border-radius: 2px; padding: 14px 34px; min-height: 52px;
  cursor: pointer; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 0 22px rgba(230,194,122,.14), inset 0 0 14px rgba(230,194,122,.06); transition: transform .15s, opacity .5s, background .2s; }
.btn:active { transform: scale(.96); background: rgba(230,194,122,.16); }
.btn:disabled { opacity: .45; border-color: transparent; box-shadow: none; }
.btn.ghost { border-color: rgba(168,136,74,.4); color: #b9ad94; box-shadow: none; }

.floating { position: fixed; left: 50%; bottom: calc(26px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 10; }
.floating:active { transform: translateX(-50%) scale(.96); }
#closeLetter, #lockUI { opacity: 0; pointer-events: none; transition: opacity .5s ease; }
#closeLetter.on, #lockUI.on { opacity: 1; pointer-events: auto; }
#lockUI { position: fixed; left: 0; right: 0; bottom: calc(26px + env(safe-area-inset-bottom)); z-index: 10;
  display: flex; gap: 14px; justify-content: center; padding: 0 18px; }
#lockUI .btn { padding: 14px 24px; }

#hint { position: fixed; left: 0; right: 0; bottom: calc(40px + env(safe-area-inset-bottom)); text-align: center; z-index: 5;
  font-size: 21px; font-style: italic; letter-spacing: .05em; color: #e9dfc6; text-shadow: 0 2px 12px #000, 0 0 3px #000;
  opacity: 0; transition: opacity .9s ease; pointer-events: none; padding: 0 24px; }
#hint.on { opacity: .92; animation: breathe 3.2s ease-in-out infinite; }

#sound { position: fixed; top: calc(12px + env(safe-area-inset-top)); right: 12px; z-index: 12; width: 44px; height: 44px; border-radius: 50%;
  background: rgba(12,9,18,.5); border: 1px solid rgba(168,136,74,.35); color: var(--gold); font-size: 19px; cursor: pointer; opacity: 0; transition: opacity .6s; }
#sound.on { opacity: .8; }
#sound.muted { color: #6d6452; text-decoration: line-through; }

#flash { position: fixed; inset: 0; z-index: 14; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at 50% 50%, #fff6d8 0%, #f3c96a 55%, #b9781c 100%); }
#toast { position: fixed; left: 50%; top: 18%; transform: translateX(-50%); z-index: 13; font-size: 20px; font-style: italic; color: #f0c9c0;
  text-shadow: 0 2px 10px #000; opacity: 0; transition: opacity .4s; pointer-events: none; white-space: nowrap; }
#toast.on { opacity: 1; }

@keyframes pulse { 50% { opacity: .45; transform: scale(.9); } }
@keyframes breathe { 50% { opacity: .5; } }

/* ---- map ---- */
#mapWrap { position: fixed; inset: 0; z-index: 16; opacity: 0; pointer-events: none; transition: opacity .9s ease; background: #b9e89c; }
#mapWrap.on { opacity: 1; pointer-events: auto; }
#map { position: absolute; inset: 0; font-family: sans-serif; }
#mapTop { position: absolute; left: 50%; top: calc(14px + env(safe-area-inset-top)); transform: translateX(-50%); text-align: center; padding: 10px 26px 12px;
  background: rgba(12,9,18,.82); border: 1px solid var(--gold-dim); border-radius: 18px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); transition: opacity .5s; white-space: nowrap; }
.mapLabel { font-size: 15px; letter-spacing: .14em; text-transform: uppercase; color: #b9ad94; }
#mapDist { font-size: 38px; font-weight: 700; color: var(--gold); line-height: 1.05; }
#mapBtns { position: absolute; right: 14px; bottom: calc(34px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; transition: opacity .5s; }
.round { width: 56px; height: 56px; border-radius: 50%; background: rgba(12,9,18,.85); border: 1px solid var(--gold-dim); color: var(--gold); font-size: 24px; cursor: pointer; }
.round:active { transform: scale(.94); }
#mapWrap.cine #mapBtns { opacity: 0; pointer-events: none; }
#geoGate { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 34px;
  background: rgba(5,4,10,.9); font-size: 22px; line-height: 1.45; color: #e6dcc4; }
#geoGate.on { display: flex; }
.maplibregl-ctrl-attrib { font-size: 10px; opacity: .7; }

.me { width: 26px; height: 26px; position: relative; }
.me .dot { position: absolute; inset: 3px; border-radius: 50%; background: #ff4fa3; border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.45); }
.me .pulse { position: absolute; inset: -14px; border-radius: 50%; background: rgba(255,79,163,.35); animation: ping 2s ease-out infinite; }
.beacon { width: 60px; height: 190px; position: relative; pointer-events: none; }
.beacon .beam { position: absolute; left: 50%; bottom: 0; width: 26px; height: 100%; transform: translateX(-50%);
  background: linear-gradient(to top, rgba(255,214,90,.95), rgba(255,214,90,0)); border-radius: 13px 13px 0 0; filter: blur(2px); animation: beam 1.8s ease-in-out infinite; }
.beacon .gem { position: absolute; left: 50%; bottom: 46px; transform: translateX(-50%); font-size: 40px; color: #fff; text-shadow: 0 0 12px #ffb300, 0 0 26px #ffb300; animation: bob 1.6s ease-in-out infinite; }
.beacon .ring { position: absolute; left: 50%; bottom: -12px; width: 44px; height: 22px; margin-left: -22px; border-radius: 50%; border: 3px solid #ffb300; animation: ping 1.8s ease-out infinite; }
.beacon.drop .gem { animation: drop .7s cubic-bezier(.3,1.6,.5,1), bob 1.6s ease-in-out .7s infinite; }
@keyframes ping { 0% { transform: scale(.4); opacity: 1; } 100% { transform: scale(1.6); opacity: 0; } }
@keyframes beam { 50% { opacity: .55; } }
@keyframes bob { 50% { transform: translateX(-50%) translateY(-12px); } }
@keyframes drop { 0% { transform: translateX(-50%) translateY(-160px) scale(2); opacity: 0; } 100% { transform: translateX(-50%); opacity: 1; } }

/* ---- puzzle ---- */
#puzzle { position: fixed; inset: 0; z-index: 16; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: radial-gradient(ellipse at 50% 40%, #1b1524 0%, #05040a 75%); opacity: 0; pointer-events: none; transition: opacity .9s ease; padding-bottom: env(safe-area-inset-bottom); }
#puzzle.on { opacity: 1; pointer-events: auto; }
#puzzle h2, #inv h2 { margin: 0; font-size: 30px; color: var(--gold); letter-spacing: .05em; }
#puzzle p { margin: 0 0 16px; font-size: 17px; font-style: italic; color: #b9ad94; padding: 0 20px; text-align: center; }
#board { position: relative; touch-action: none; border-radius: 4px; box-shadow: 0 0 0 1px rgba(230,194,122,.35), 0 18px 50px rgba(0,0,0,.7); background: #0d0a12; }
.tile { position: absolute; left: 0; top: 0; background-repeat: no-repeat; box-shadow: inset 0 0 0 1px rgba(5,4,10,.9); transition: transform .22s ease, box-shadow .5s, filter .5s; filter: brightness(.9); will-change: transform; }
.tile.drag { transition: none; z-index: 5; box-shadow: 0 10px 26px rgba(0,0,0,.8), inset 0 0 0 2px var(--gold); filter: brightness(1.1); }
.tile.ok { filter: brightness(1); box-shadow: inset 0 0 0 1px rgba(230,194,122,.0); animation: lockin .6s ease; }
#board.solved .tile { box-shadow: none; filter: brightness(1.08); }
@keyframes lockin { 30% { filter: brightness(1.7); } }

/* ---- polaroid viewer, inventory ---- */
#continue, #viewerUI, #dock { opacity: 0; pointer-events: none; transition: opacity .5s ease; }
#continue.on, #viewerUI.on, #dock.on { opacity: 1; }
#continue.on, #dock.on, #viewerUI.on #viewerClose { pointer-events: auto; }
#viewerUI { position: fixed; inset: 0; z-index: 10; }
#rotHint { position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); display: none; flex-direction: column; align-items: center; gap: 6px;
  font-size: 22px; font-style: italic; color: #fff; text-shadow: 0 2px 12px #000, 0 0 4px #000; }
#rotHint.on { display: flex; }
#rotHint .hand { font-size: 58px; animation: swipe 1.8s ease-in-out infinite; filter: drop-shadow(0 4px 10px #000); }
@keyframes swipe { 0%, 100% { transform: translateX(-70px) rotate(-12deg); } 50% { transform: translateX(70px) rotate(12deg); } }

#dock { position: fixed; left: 0; right: 0; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 17; display: flex; gap: 12px; justify-content: center; padding: 0 16px; }
#dock .btn { padding: 14px 22px; position: relative; }
#invBadge { display: none; position: absolute; top: -9px; right: -9px; min-width: 24px; height: 24px; border-radius: 12px; background: #ff3d9e; color: #fff;
  font: 700 15px/24px sans-serif; letter-spacing: 0; text-align: center; box-shadow: 0 0 12px #ff3d9e; }
#invBtn.new #invBadge { display: block; }
#invBtn.new { animation: glow 1.4s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 30px rgba(230,194,122,.75), inset 0 0 14px rgba(230,194,122,.2); } }

#inv { position: fixed; inset: 0; z-index: 18; background: rgba(3,2,6,.6); opacity: 0; pointer-events: none; transition: opacity .4s ease; }
#inv.on { opacity: 1; pointer-events: auto; }
#invSheet { position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 20px calc(22px + env(safe-area-inset-bottom)); text-align: center;
  background: linear-gradient(#1a1422, #0a0810); border-top: 1px solid var(--gold-dim); border-radius: 22px 22px 0 0; transform: translateY(100%); transition: transform .45s cubic-bezier(.2,.9,.3,1); }
#inv.on #invSheet { transform: none; }
.grip { width: 44px; height: 4px; border-radius: 2px; background: rgba(230,194,122,.35); margin: 0 auto 12px; }
#invGrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 18px 0 20px; }
.slot { aspect-ratio: 1; border-radius: 10px; border: 1px dashed rgba(168,136,74,.35); background: rgba(255,255,255,.03); display: flex; align-items: center; justify-content: center; color: rgba(168,136,74,.35); font-size: 22px; }
.slot.item { border: 1px solid var(--gold-dim); background: #efe9dc; padding: 7px 7px 20px; cursor: pointer; box-shadow: 0 6px 18px rgba(0,0,0,.6); transform: rotate(-3deg); }
.slot.item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.slot.item:active { transform: rotate(-3deg) scale(.95); }
#invBubble { display: none; position: relative; margin: 14px 4px 0; padding: 14px 16px; border-radius: 14px; background: #f3ead6; color: #2b1a0e; font-size: 19px; line-height: 1.35; font-weight: 500; text-align: left; box-shadow: 0 8px 24px rgba(0,0,0,.5); }
#invBubble::after { content: ''; position: absolute; left: 36px; bottom: -10px; border: 10px solid transparent; border-top-color: #f3ead6; border-bottom: 0; }
#invBubble.on { display: block; animation: pop .45s cubic-bezier(.3,1.5,.5,1); }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } }

#dbgBtn { position: fixed; left: 10px; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 30; display: none; padding: 10px 14px; border-radius: 10px;
  background: #ff3d9e; color: #fff; border: 0; font: 700 14px/1.2 sans-serif; box-shadow: 0 4px 14px rgba(0,0,0,.5); }
#dbgBtn.on { display: block; }
#geoGate .btn { margin-top: 26px; }
#geoGate p { margin: 14px 0 0; }

/* ---- safe: an invisible field that brings up the phone keyboard; the text shows on the 3D display ---- */
#pw { position: fixed; left: 50%; top: 18%; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; z-index: 1; }
#pwInput { width: 200px; font-size: 16px; border: 0; background: transparent; color: transparent; caret-color: transparent; -webkit-user-select: text; user-select: text; }
.slot.item.paper { background: #e6dcc0; padding: 0; font-size: 34px; color: #2b1a0e; transform: rotate(4deg); }
.slot.item.paper span { display: block; }

/* ---- the end ---- */
#finalText { position: fixed; inset: 0; z-index: 12; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px;
  opacity: 0; pointer-events: none; transition: opacity 2.4s ease; background: radial-gradient(ellipse at 50% 50%, rgba(60,0,30,.42) 0%, rgba(60,0,30,0) 62%); }
#finalText.on { opacity: 1; }
#finalText h1 { color: #fff; font-size: clamp(34px, 10.5vw, 56px); line-height: 1.15; margin: 10px 0 0; text-shadow: 0 0 18px #ff2d7a, 0 0 46px #ff2d7a, 0 3px 10px rgba(60,0,30,.9); }
#finalText .sigil { color: #fff; font-size: 44px; text-shadow: 0 0 20px #ff2d7a, 0 0 40px #ff2d7a; }
#finalText.on h1 { animation: rise 2.4s cubic-bezier(.2,.9,.3,1); }
@keyframes rise { 0% { transform: translateY(26px) scale(.94); } }
