/* The free room — the game layer that sits on top of the 3D world.
   Tokens (colours, fonts) come from sealed-room.css. */
html, body { height: 100%; }
body.room { margin: 0; background: #000; overflow: hidden; color: var(--ink); font-family: var(--font-body); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
body.room [hidden] { display: none !important; }
body.room button { font-family: inherit; }

#world { position: fixed; inset: 0; z-index: 0; }
body.no-webgl #world { background: radial-gradient(ellipse at 50% 65%, #1a2030 0%, #0a0c12 55%, #05060a 100%); }
#vignette { position: fixed; inset: 0; z-index: 2; pointer-events: none; background: radial-gradient(ellipse at center, transparent 45%, rgba(0,0,0,.72) 100%); }
#grain { position: fixed; inset: -60px; z-index: 3; pointer-events: none; opacity: .09; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  animation: grain 0.9s steps(5) infinite; }
@keyframes grain { 0% { transform: translate(0,0) } 20% { transform: translate(-22px,14px) } 40% { transform: translate(16px,-24px) } 60% { transform: translate(-10px,-8px) } 80% { transform: translate(24px,18px) } 100% { transform: translate(0,0) } }

/* ---------- the gate: title over the dark room ---------- */
#gate { position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 24px; text-align: center;
  background: radial-gradient(ellipse at center, rgba(6,7,11,.15) 0%, rgba(6,7,11,.72) 75%); transition: opacity 1.1s var(--ease); }
#gate.leaving { opacity: 0; pointer-events: none; }
.mark { width: clamp(46px, 9vw, 64px); height: auto; filter: drop-shadow(0 0 18px var(--ghost-glow)); animation: breathe 5s ease-in-out infinite; }
@keyframes breathe { 0%,100% { opacity: .82; transform: translateY(0) } 50% { opacity: 1; transform: translateY(-3px) } }
.wordmark { font-family: var(--font-brand); font-weight: 700; text-transform: lowercase; letter-spacing: -0.045em; line-height: .9; margin: 0;
  font-size: clamp(54px, 13vw, 128px); color: var(--ink); position: relative; display: inline-block; text-shadow: 0 0 40px rgba(224,96,63,.18); }
.wordmark::before { content: attr(data-text); position: absolute; inset: 0; color: var(--accent-strong); filter: blur(14px); opacity: .55; z-index: -1; animation: seam 6s ease-in-out infinite; }
@keyframes seam { 0%,100% { opacity: .4 } 50% { opacity: .7 } }
.tag { margin: 0; color: var(--dim); font-size: clamp(14px, 3.6vw, 17px); max-width: 30ch; line-height: 1.45; }
.holdcap { margin: 0; font-family: var(--font-mono); font-size: 11px; letter-spacing: .28em; text-transform: uppercase; color: var(--ghost-dim); }
.linkbtn { background: none; border: 0; padding: 0; color: var(--faint); font-size: 13px; letter-spacing: .03em; cursor: pointer; text-decoration: underline; text-underline-offset: 4px; }
.linkbtn:hover { color: var(--ghost); }

/* ---------- topbar + hud ---------- */
#topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: calc(12px + env(safe-area-inset-top,0px)) 16px 12px; pointer-events: none; }
#topbar > * { pointer-events: auto; }
#topbar .brand { white-space: nowrap; display: flex; align-items: center; gap: 8px; font-family: var(--font-brand); font-weight: 700; letter-spacing: -0.02em; font-size: 15px; text-transform: lowercase; text-shadow: 0 1px 10px #000; }
#topbar .spacer { flex: 1; }
.iconbtn { width: 38px; height: 38px; display: grid; place-items: center; background: rgba(10,12,18,.55); border: 1px solid var(--line); color: var(--dim); border-radius: 50%; cursor: pointer; backdrop-filter: blur(6px); transition: color .2s, border-color .2s; }
.iconbtn:hover { color: var(--ghost); border-color: var(--ghost-dim); }
.iconbtn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#acct { white-space: nowrap; background: none; border: 0; color: var(--faint); font-size: 12px; letter-spacing: .04em; cursor: pointer; text-shadow: 0 1px 8px #000; }
#acct:hover { color: var(--ghost); }

#hud { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(76px + env(safe-area-inset-bottom,0px)); z-index: 20; display: flex; flex-direction: column; align-items: center; gap: 7px; pointer-events: none; }
#hud .pips { display: flex; gap: 8px; }
#hud .pip { width: 9px; height: 15px; border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%; border: 1px solid var(--faint); background: transparent; transition: all .5s var(--ease); }
#hud .pip.on { background: var(--ghost); border-color: var(--ghost); box-shadow: 0 0 10px var(--ghost), 0 0 22px var(--ghost-glow); animation: flick 2.4s ease-in-out infinite; }
#hud .pip.pop { animation: pippop .8s var(--ease); }
@keyframes flick { 0%,100% { opacity: 1 } 45% { opacity: .82 } 60% { opacity: 1 } 80% { opacity: .9 } }
@keyframes pippop { 0% { transform: scale(2.4); } 100% { transform: scale(1) } }
#hud .rank { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .26em; text-transform: uppercase; color: var(--dim); text-shadow: 0 1px 8px #000; }
#hud .rank b { color: var(--ghost); font-weight: 500; }

#nudge { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom,0px)); z-index: 21; display: inline-flex; align-items: center; gap: 12px; max-width: calc(100vw - 32px);
  padding: 14px 22px; background: rgba(9,11,16,.78); border: 1px solid var(--ghost-dim); color: var(--ink); font-size: 14.5px; letter-spacing: .01em; cursor: pointer; backdrop-filter: blur(10px); box-shadow: 0 0 28px rgba(224,96,63,.12); transition: border-color .2s, box-shadow .2s, transform .2s; }
#nudge:hover { border-color: var(--ghost); box-shadow: 0 0 34px var(--ghost-glow); transform: translateX(-50%) translateY(-2px); }
#nudge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ghost); box-shadow: 0 0 10px var(--ghost); animation: flick 1.8s ease-in-out infinite; flex: none; }
#nudge.wait { border-color: var(--line); box-shadow: none; color: var(--dim); cursor: default; }
#nudge.wait .dot { background: var(--faint); box-shadow: none; animation: none; }
#nudge.wait:hover { transform: translateX(-50%); }
#hint { position: fixed; left: 50%; transform: translateX(-50%); top: calc(64px + env(safe-area-inset-top,0px)); z-index: 15; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .24em; text-transform: uppercase; color: var(--faint); pointer-events: none; transition: opacity 1s; text-shadow: 0 1px 8px #000; }

/* ---------- overlay panel ---------- */
#panel { position: fixed; inset: 0; z-index: 40; overflow-y: auto; overscroll-behavior: contain; padding: 0 18px; background: rgba(5,6,10,.74); backdrop-filter: blur(9px) saturate(.9); animation: fadein .35s var(--ease); }
#panel.thin { background: rgba(5,6,10,.38); backdrop-filter: blur(2px); }
#panel.game { padding: 0; overflow: hidden; background: rgba(5,6,10,.86); }
#panel.game > #sheet { max-width: none; padding: 0; height: 100%; position: relative; display: block; animation: none; }
@keyframes fadein { from { opacity: 0 } to { opacity: 1 } }
.sheet { width: 100%; max-width: 560px; margin: 0 auto; padding: clamp(28px, 8vh, 80px) 0 80px; display: flex; flex-direction: column; gap: 20px; animation: rise .5s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(14px) } to { opacity: 1; transform: none } }
.eyebrow { font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .28em; text-transform: uppercase; color: var(--ghost); }
.sheet h2 { margin: 0; font-family: var(--font-brand); font-weight: 700; text-transform: lowercase; letter-spacing: -0.035em; line-height: .95; font-size: clamp(34px, 8.5vw, 58px); text-wrap: balance; }
.sheet h2.sm { font-size: clamp(26px, 6vw, 38px); }
.sheet p { margin: 0; font-size: 16px; line-height: 1.55; color: var(--dim); }
.sheet p.lead { color: var(--ink); font-size: 18px; }
.sheet p.fine { font-size: 13px; color: var(--faint); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.center { text-align: center; align-items: center; }
.btn.wax { background: var(--wax); border-color: var(--wax); color: var(--ink); }
.btn.wax:hover { background: var(--accent-strong); border-color: var(--accent-strong); box-shadow: 0 0 26px rgba(138,34,51,.45); }
.btn.big { padding: 17px 28px; font-size: 13px; }
.fields { display: flex; flex-direction: column; gap: 10px; }
.sheet input[type=email], .sheet input[type=password], .sheet input[type=text] { width: 100%; background: rgba(13,15,21,.85); color: var(--ink); border: 1px solid var(--line); padding: 14px 15px; font: 500 16px var(--font-body); user-select: text; -webkit-user-select: text; }
.sheet input:focus { outline: none; border-color: var(--ghost); box-shadow: 0 0 0 3px rgba(224,96,63,.12); }
.err { min-height: 1.3em; font-size: 14px; color: #c9707f; }
.opts { display: flex; flex-direction: column; gap: 9px; }
.opt { text-align: left; width: 100%; background: rgba(13,15,21,.8); color: var(--ink); border: 1px solid var(--line); padding: 16px 18px; font-size: 16px; line-height: 1.35; cursor: pointer; transition: border-color .15s, background .15s, transform .12s; }
.opt:hover { border-color: var(--ghost-dim); transform: translateX(3px); }
.opt.sel { border-color: var(--ghost); background: rgba(224,96,63,.08); }

/* ---------- swipe deck ---------- */
.deckwrap { position: relative; height: min(360px, 52vh); margin: 4px 0; touch-action: none; }
.card { position: absolute; inset: 0; display: grid; place-items: center; padding: 26px 24px; text-align: center; background: linear-gradient(160deg, #171a24, #0d0f15); border: 1px solid #2a2e3b;
  font-family: var(--font-brand); font-weight: 700; letter-spacing: -0.03em; text-transform: lowercase; font-size: clamp(25px, 6.4vw, 36px); line-height: 1.08; color: var(--ink); box-shadow: 0 24px 50px rgba(0,0,0,.55); cursor: grab; touch-action: none; will-change: transform; }
.card.behind { transform: scale(.95) translateY(14px); opacity: .7; }
.card.behind2 { transform: scale(.9) translateY(28px); opacity: .4; }
.card.dragging { cursor: grabbing; transition: none; }
.card .stamp { position: absolute; top: 18px; font-family: var(--font-mono); font-size: 13px; letter-spacing: .24em; padding: 6px 12px; border: 2px solid; opacity: 0; text-transform: uppercase; }
.card .stamp.y { left: 16px; color: var(--ghost); border-color: var(--ghost); transform: rotate(-8deg); }
.card .stamp.n { right: 16px; color: var(--dim); border-color: var(--dim); transform: rotate(8deg); }
.pipsrow { display: flex; gap: 6px; justify-content: center; }
.pipsrow i { width: 24px; height: 3px; background: var(--line); transition: background .3s; }
.pipsrow i.on { background: var(--ghost); box-shadow: 0 0 8px var(--ghost-glow); }
.swipebtns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.swipebtns .btn { padding: 16px 10px; }

.readbox { border-left: 2px solid var(--ghost); padding: 2px 0 2px 18px; display: flex; flex-direction: column; gap: 10px; }
.sigilrow { display: flex; align-items: center; gap: 16px; }
.sigilrow canvas { width: 76px; height: 76px; flex: none; }

/* ---------- seal ritual ---------- */
.waxstage { position: relative; display: grid; place-items: center; height: 230px; margin: 0 auto; width: 100%; max-width: 360px;
  background: radial-gradient(ellipse at 50% 60%, rgba(224,96,63,.06), transparent 65%); }
.waxstage .paper { position: absolute; width: 250px; height: 170px; background: linear-gradient(160deg, #d9d3c5, #a9a394); transform: rotate(-3deg); box-shadow: 0 20px 36px rgba(0,0,0,.6); }
.waxstage .paper::after { content: ""; position: absolute; left: 22px; right: 22px; top: 30px; height: 70px; background: repeating-linear-gradient(180deg, rgba(20,20,26,.28) 0 2px, transparent 2px 14px); }
.waxstage canvas { position: relative; width: 190px; height: 190px; }
.waxstage canvas.final { width: 240px; height: 240px; animation: land .5s var(--ease); }
@keyframes land { 0% { transform: scale(1.35); opacity: 0 } 60% { transform: scale(.94); opacity: 1 } 100% { transform: scale(1) } }
.stamptool { position: absolute; top: -60px; width: 120px; height: 120px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #4a505e, #14161c 70%); border: 2px solid #0a0b0f; box-shadow: 0 10px 24px rgba(0,0,0,.6); display: grid; place-items: center; transition: transform .28s cubic-bezier(.5,0,.8,.4); z-index: 3; }
.stamptool svg { width: 62px; height: 62px; stroke: #8b909b; fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: .9; }
.stamptool.down { transform: translateY(96px) scale(1.06); }
.stamptool.up { transform: translateY(-140px); opacity: 0; transition: transform .5s var(--ease), opacity .5s; }
.gauge { width: 100%; max-width: 360px; margin: 6px auto 0; }
.gauge .bar { position: relative; height: 12px; background: #0b0d12; border: 1px solid var(--line); overflow: hidden; }
.gauge .band { position: absolute; top: 0; bottom: 0; left: 62%; width: 26%; background: rgba(224,96,63,.22); border-left: 1px solid var(--ghost); border-right: 1px solid var(--ghost); }
.gauge .fill { position: absolute; top: 0; bottom: 0; left: 0; width: 0; background: linear-gradient(90deg, #4a0f19, #8a2233 70%, #c2566a); }
.gauge .labels { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .2em; color: var(--faint); margin-top: 6px; text-transform: uppercase; }
.holdbtn { touch-action: none; width: 100%; }
.shake { animation: shk .34s; }
@keyframes shk { 0%,100% { transform: none } 20% { transform: translate(-7px,3px) } 40% { transform: translate(6px,-4px) } 60% { transform: translate(-4px,2px) } 80% { transform: translate(3px,-2px) } }

/* ---------- misc ---------- */
.sharecard { width: 100%; max-width: 320px; border: 1px solid var(--line); box-shadow: 0 20px 44px rgba(0,0,0,.6); align-self: center; }
.offer { border: 1px solid var(--accent-strong); background: linear-gradient(180deg, rgba(74,15,25,.35), rgba(13,15,21,.9)); padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.offer ul { margin: 0; padding-left: 18px; color: var(--dim); font-size: 15.5px; line-height: 1.6; }
.offer li::marker { color: var(--accent-strong); }
.price { font-family: var(--font-brand); font-size: 46px; font-weight: 700; letter-spacing: -0.03em; color: var(--ink); }
.price small { font-family: var(--font-body); font-size: 16px; color: var(--dim); font-weight: 400; letter-spacing: 0; }
.rankbanner { position: fixed; top: 22%; left: 50%; transform: translateX(-50%); z-index: 60; text-align: center; pointer-events: none; animation: banner 2.6s var(--ease) forwards; }
.rankbanner small { display: block; font-family: var(--font-mono); font-size: 11px; letter-spacing: .4em; color: var(--ghost); text-transform: uppercase; margin-bottom: 6px; }
.rankbanner b { font-family: var(--font-brand); font-size: clamp(40px, 11vw, 84px); letter-spacing: -0.04em; text-transform: lowercase; text-shadow: 0 0 30px var(--ghost-glow); }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, 12px) scale(.94) } 14% { opacity: 1; transform: translate(-50%, 0) scale(1) } 78% { opacity: 1 } 100% { opacity: 0; transform: translate(-50%, -14px) } }
.toast { position: fixed; left: 50%; top: calc(74px + env(safe-area-inset-top,0px)); transform: translateX(-50%); z-index: 70; background: rgba(9,11,16,.9); border: 1px solid var(--ghost-dim); color: var(--ink); padding: 10px 18px; font-size: 14px; letter-spacing: .02em; animation: toast 2.4s var(--ease) forwards; pointer-events: none; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, -8px) } 12% { opacity: 1; transform: translate(-50%, 0) } 82% { opacity: 1 } 100% { opacity: 0 } }
.cracked { animation: shk .34s; }
#dev { position: fixed; left: 0; right: 0; bottom: 0; z-index: 80; background: #10131a; border-top: 1px solid var(--line); padding: 7px 12px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-family: var(--font-mono); font-size: 11px; letter-spacing: .1em; color: var(--faint); text-transform: uppercase; }
#dev button { background: none; border: 1px solid var(--line); color: var(--dim); padding: 4px 10px; font: inherit; cursor: pointer; }
#dev button:hover { color: var(--ghost); border-color: var(--ghost-dim); }

@media (max-width: 640px) {
  #hud { bottom: calc(82px + env(safe-area-inset-bottom,0px)); }
  #nudge { padding: 13px 18px; font-size: 14px; }
  .sheet { padding-top: 34px; }
}
@media (prefers-reduced-motion: reduce) { #grain, .mark, .wordmark::before, .holdwrap::after { animation: none; } }


/* ---------- the cold open ---------- */
.btn.enter { letter-spacing: .26em; padding: 18px 44px; margin-top: 6px; }
#intro { position: fixed; inset: 0; z-index: 35; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 30px; padding: 24px;
  background: radial-gradient(ellipse at center, rgba(4,5,8,.30), rgba(4,5,8,.80)); transition: opacity .9s var(--ease); }
#intro.leaving { opacity: 0; pointer-events: none; }
#introLines { text-align: center; display: flex; flex-direction: column; gap: 16px; min-height: 160px; justify-content: center; max-width: 900px; }
#introLines p { margin: 0; font-family: var(--font-brand); font-weight: 700; letter-spacing: -0.035em; text-transform: lowercase; line-height: 1.02; font-size: clamp(26px, 6.4vw, 54px); color: var(--ink); text-shadow: 0 0 34px rgba(224,96,63,.28); min-height: 1em; }
#introLines p.out { opacity: 0; transition: opacity .9s; }
.caret::after { content: ""; display: inline-block; width: .07em; height: .82em; background: var(--ghost); margin-left: .07em; animation: blink 1s steps(2) infinite; vertical-align: -.06em; }
@keyframes blink { 50% { opacity: 0; } }
#matchBox { display: flex; flex-direction: column; align-items: center; gap: 16px; animation: rise .6s var(--ease); }
#matchSvg { width: min(440px, 90vw); touch-action: none; cursor: grab; filter: drop-shadow(0 14px 26px rgba(0,0,0,.6)); }
#matchSvg.grab { cursor: grabbing; }
#introSkip { position: absolute; bottom: calc(22px + env(safe-area-inset-bottom,0px)); right: 24px; }
.spark { fill: #ffb27a; }

/* ---------- hold the light ---------- */
#panel.hold { display: flex; align-items: flex-end; background: linear-gradient(180deg, rgba(5,6,10,0) 0%, rgba(5,6,10,.55) 55%, rgba(5,6,10,.9) 100%); backdrop-filter: none; }
#panel.hold > #sheet { padding: 0 0 calc(26px + env(safe-area-inset-bottom,0px)); }
.holdui { display: flex; flex-direction: column; gap: 16px; align-items: center; text-align: center; }
.g2 { position: relative; width: 100%; max-width: 460px; height: 16px; background: #0b0d12; border: 1px solid var(--line); margin-top: 22px; }
.g2 .fill { position: absolute; left: 0; top: 0; bottom: 0; width: 28%; background: linear-gradient(90deg, #4a120c, var(--ghost)); box-shadow: 0 0 16px var(--ghost-glow); }
.g2 .mk { position: absolute; top: -9px; bottom: -9px; left: 25%; width: 2px; background: var(--ink); }
.g2 .mk span { position: absolute; top: -21px; left: 50%; transform: translateX(-50%); font: 500 9.5px var(--font-mono); letter-spacing: .2em; color: var(--dim); text-transform: uppercase; white-space: nowrap; }
.tapbtn { width: 100%; max-width: 460px; padding: 28px; font-size: 15px; touch-action: manipulation; }
.holdtime { font: 500 12px var(--font-mono); letter-spacing: .18em; text-transform: uppercase; color: var(--dim); }
.holdtime b { color: var(--ink); font-weight: 500; font-size: 24px; letter-spacing: 0; }

/* ---------- the wall ---------- */
svg.rise { width: 100%; max-width: 440px; height: auto; display: block; margin: 4px 0; }
svg.rise .mk { stroke: var(--faint); stroke-width: 1.5; stroke-dasharray: 4 4; }
svg.rise .tr { fill: none; stroke: var(--ghost); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 460; stroke-dashoffset: 460; animation: drawtr 2.8s .35s var(--ease) forwards; filter: drop-shadow(0 0 6px var(--ghost-glow)); }
@keyframes drawtr { to { stroke-dashoffset: 0; } }
svg.rise text { font: 500 9px var(--font-mono); letter-spacing: .2em; fill: var(--dim); text-transform: uppercase; }
.wallname { font: 500 12px var(--font-mono); letter-spacing: .28em; text-transform: uppercase; color: var(--dim); }
.stackline { padding: 14px 0 14px 18px; border-left: 2px solid var(--ghost-dim); font-size: 19px; line-height: 1.45; color: var(--ink); animation: rise .6s var(--ease) both; }
.stackline:last-of-type { border-left-color: var(--ghost); font-family: var(--font-brand); font-weight: 700; font-size: 26px; letter-spacing: -.02em; text-transform: lowercase; }
.carved { font-family: var(--font-brand); font-weight: 700; letter-spacing: -.02em; text-transform: lowercase; color: var(--ink); }
.foundlabel { font: 500 11.5px var(--font-mono); letter-spacing: .2em; text-transform: uppercase; color: var(--ghost); }
.was { color: var(--faint); text-decoration: line-through; font-size: 20px; margin-left: 8px; font-weight: 400; font-family: var(--font-body); letter-spacing: 0; }

/* the flash when the match catches */
.flare { position: fixed; inset: 0; z-index: 50; pointer-events: none; background: radial-gradient(circle at 50% 62%, rgba(255,150,80,.55), rgba(255,90,40,0) 62%); animation: flareA 1.1s ease-out forwards; }
@keyframes flareA { 0% { opacity: 0 } 14% { opacity: 1 } 100% { opacity: 0 } }
