*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  background: #000000; overflow: hidden; height: 100%; width: 100%;
  -webkit-tap-highlight-color: transparent; user-select: none;
  -webkit-user-select: none; cursor: none;
}
@supports (height: 100dvh) { html, body { height: 100dvh; } }
@media (pointer: coarse) { html, body { cursor: auto; } }
#textCanvas { position:fixed; inset:0; z-index:0; pointer-events:none; visibility:hidden; }
/* No CSS filter: it darkened every backdrop. Brightness lives in the palettes. */
#glowCanvas { position:fixed; inset:0; z-index:10; touch-action:none; }

#inputLayer {
  position:fixed; inset:0; z-index:30;
  pointer-events:none; opacity:0; transition:opacity 0.8s ease;
}
#inputLayer.active  { opacity:1; pointer-events:auto; }
#inputLayer.exiting { opacity:0; pointer-events:none; transition:opacity 1s ease; }

/* Question: fixed at the exact canvas position (matches JS: min(W*0.045, H*0.04, 48)) */
#inputQuestion {
  position:fixed; top:50%; left:50%;
  transform:translate(-50%,-50%);
  font-size: min(4.5vw, 4vh, 48px);
  font-family:'Cormorant Garamond',Georgia,serif; font-style:italic; font-weight:300;
  color:#e8dfc0; text-align:center;
  white-space: nowrap;
  width:92vw; /* prevent wrapping on portrait phones */
  pointer-events:none;
}

/* Input row: flows below the question */
#inputContainer {
  position:fixed; top:calc(50% + 3.2rem); left:50%;
  transform:translateX(-50%);
  display:flex; flex-direction:column; align-items:center;
  width:100%; max-width:480px; padding:0 2rem;
}
#inputWrap { position:relative; width:100%; }
#gateInput {
  width:100%; background:transparent; border:none;
  border-bottom:1px solid rgba(200,160,60,.4); color:#ede0b8;
  font-family:'Cormorant Garamond',Georgia,serif; font-size:max(1.1rem, 16px); line-height:1.8;
  padding:0.6rem 0; outline:none; caret-color:#b88a28; transition:border-color 0.3s;
}
#gateInput:focus { border-bottom-color:rgba(220,180,60,.75); }
#gateInput::placeholder { color:rgba(190,160,70,.32); font-style:italic; }
#gateSubmit {
  position:absolute; right:0; bottom:0.4rem; background:none; border:none;
  color:rgba(180,140,60,.5); font-size:1.4rem; cursor:pointer; padding:0.3rem 0.5rem;
  transition:color 0.3s,opacity 0.3s; opacity:0; pointer-events:none;
}
#gateSubmit.visible { opacity:1; pointer-events:auto; }
#gateMessage {
  font-family:'Cormorant Garamond',Georgia,serif; font-style:italic; font-size:1rem;
  color:#c06040; text-align:center; margin-top:1.2rem; min-height:1.5rem;
  opacity:0; transition:opacity 0.5s;
}
#gateMessage.visible { opacity:1; }
#starsOnlyBtn {
  font-family:'Cormorant Garamond',Georgia,serif; font-style:italic; font-size:1rem;
  color:rgba(180,140,60,.4); background:none; border:1px solid rgba(180,140,60,.15);
  padding:0.8rem 2rem; cursor:pointer; transition:all 0.4s;
  opacity:0; pointer-events:none; margin-top:1.5rem;
}
#starsOnlyBtn.visible { opacity:1; pointer-events:auto; }
#starsOnlyBtn:hover { color:rgba(200,160,60,.8); border-color:rgba(200,160,60,.4); }
@media (max-width: 480px) {
  #inputContainer { top: calc(50% + 2.6rem); padding: 0 1.2rem; }
  #starsOnlyBtn { padding: 0.65rem 1.4rem; }
}
#glossaryLink {
  position:fixed; bottom:1.8rem; left:50%; transform:translateX(-50%); z-index:40;
  opacity:0; pointer-events:none; transition:opacity 1s ease;
  font-family:'Cormorant Garamond',Georgia,serif; font-style:italic; font-size:0.75rem;
  color:rgba(180,140,60,0.7); text-decoration:none; border-bottom:1px dotted rgba(180,140,60,0.35);
  white-space:nowrap; cursor:pointer;
}
#glossaryLink.visible { opacity:1; pointer-events:auto; }

/* ── BEACON KEYBOARD TARGETS ──────────────────────── */
/* Invisible 72 px buttons over each in-scene beacon. Pointer events
   pass through to the canvas; Tab and Enter reach them. The canvas
   draws the focus ring; the outline is a backstop. */
#wqBeacons { position:fixed; inset:0; z-index:15; pointer-events:none; }
.wqBeacon {
  position:absolute; width:72px; height:72px; border-radius:50%;
  background:transparent; border:none; color:transparent;
  pointer-events:none; cursor:none;
}
.wqBeacon:focus { outline:none; }
.wqBeacon:focus-visible { outline:2px solid rgba(255,248,230,.55); outline-offset:-2px; }

/* ── WRITINGS GLYPH ───────────────────────────────── */
#wqWritings {
  position:fixed; z-index:40;
  left:max(12px, env(safe-area-inset-left)); bottom:max(12px, env(safe-area-inset-bottom));
  width:44px; height:44px; display:flex; align-items:center; justify-content:center;
  background:none; border:none; border-radius:50%;
  color:#f2e6c8; opacity:.4; cursor:pointer; transition:opacity .4s ease;
}
#wqWritings[hidden] { display:none; }
#wqWritings:hover, #wqWritings:focus-visible { opacity:.9; }
#wqWritings:focus-visible { outline:2px solid #f2e6c8; outline-offset:2px; }

/* ── SHARED BUTTON ────────────────────────────────── */
.wqBtn {
  min-height:48px; padding:0 18px; display:inline-flex; align-items:center;
  font-family:'Cormorant Garamond',Georgia,serif; font-style:italic; font-size:18px;
  color:#f3e9d2; background:transparent;
  border:1px solid rgba(214,182,110,.45); border-radius:24px;
  cursor:pointer; white-space:nowrap; transition:border-color .25s, color .25s;
}
.wqBtn:hover { border-color:rgba(236,206,140,.9); color:#fff6e4; }
.wqBtn:focus-visible { outline:2px solid #f3e9d2; outline-offset:2px; }

/* ── ESSAY READER ─────────────────────────────────── */
/* The iframe is the only scroll surface. */
#wqReader {
  position:fixed; inset:0; width:100%; height:100%; max-width:none; max-height:none;
  margin:0; padding:0; border:none; background:#060508; color:#f3e9d2;
  overflow:hidden; cursor:auto; user-select:auto; -webkit-user-select:auto;
}
@supports (height: 100dvh) { #wqReader { height:100dvh; } }
#wqReader[open] { display:flex; flex-direction:column; }
#wqReader::backdrop { background:#000; }
.wqReaderBar {
  flex:0 0 56px; height:56px; display:flex; align-items:center; gap:10px;
  padding:0 max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left));
  padding-top:env(safe-area-inset-top); box-sizing:content-box;
  background:#0b0a0d; border-bottom:1px solid rgba(214,182,110,.2);
}
.wqReaderTitle {
  flex:1 1 auto; min-width:0; text-align:center;
  font-family:'Cormorant Garamond',Georgia,serif; font-style:italic; font-weight:400;
  font-size:18px; color:#d9ccaf; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.wqReaderLink {
  flex:1 1 auto; min-width:0; min-height:44px; padding:0 12px;
  font:16px/1 ui-monospace,Menlo,monospace; color:#f3e9d2;
  background:#141217; border:1px solid rgba(214,182,110,.45); border-radius:8px;
}
.wqReaderLink[hidden], .wqBtn[hidden] { display:none; }
#wqReaderFrame { flex:1 1 auto; width:100%; min-height:0; border:none; background:#060508; display:block; }
@media (max-width: 520px) {
  .wqReaderTitle { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); }
  .wqReaderBar { justify-content:space-between; }
  .wqBtn { padding:0 14px; font-size:17px; }
}

/* ── WRITINGS INDEX ───────────────────────────────── */
#wqIndex {
  margin:auto; padding:0; border:1px solid rgba(214,182,110,.3); border-radius:6px;
  width:min(520px, calc(100vw - 24px)); max-height:calc(100vh - 24px);
  background:#0b0a0d; color:#f3e9d2; cursor:auto; user-select:auto; -webkit-user-select:auto;
}
@supports (height: 100dvh) { #wqIndex { max-height:calc(100dvh - 24px); } }
#wqIndex::backdrop { background:rgba(0,0,0,.72); }
.wqIndexInner { padding:24px 22px 20px; display:flex; flex-direction:column; gap:14px; }
#wqIndexTitle {
  font-family:'Cormorant Garamond',Georgia,serif; font-style:italic; font-weight:300;
  font-size:26px; color:#f3e9d2;
}
.wqIndexList { list-style:none; display:flex; flex-direction:column; gap:6px; }
.wqIndexItem {
  width:100%; min-height:52px; padding:10px 14px; text-align:left;
  font-family:'Cormorant Garamond',Georgia,serif; font-size:20px; color:#f6eedc;
  background:transparent; border:1px solid rgba(214,182,110,.28); border-radius:6px; cursor:pointer;
}
.wqIndexItem:hover { border-color:rgba(236,206,140,.85); }
.wqIndexItem:focus-visible { outline:2px solid #f3e9d2; outline-offset:2px; }
.wqIndexSoon {
  min-height:44px; padding:10px 14px; display:flex; align-items:center;
  font-family:'Cormorant Garamond',Georgia,serif; font-style:italic; font-size:18px;
  color:#a89f8c;
}
.wqIndexClose { align-self:flex-end; }

/* ── DEVELOPER SCENE PICKER ───────────────────────── */
#devPicker {
  position:fixed; inset:0; z-index:900;
  background:rgba(4,4,10,0.94); backdrop-filter:blur(6px);
  display:none; flex-direction:column;
  align-items:center; justify-content:center; gap:1.4rem;
  padding:2rem; overflow:auto; cursor:auto;
}
#devPicker.visible { display:flex; }
#devPickerTitle {
  font-family:'DM Mono',monospace; font-size:0.68rem;
  color:rgba(180,140,60,0.5); letter-spacing:0.22em; text-transform:uppercase;
}
#devPickerGrid {
  display:grid; grid-template-columns:repeat(auto-fill,minmax(155px,1fr));
  gap:0.55rem; width:min(640px,90vw);
}
.dpBtn {
  font-family:'Cormorant Garamond',Georgia,serif; font-style:italic;
  font-size:0.95rem; color:rgba(215,190,140,0.78);
  background:rgba(18,14,8,0.85); border:1px solid rgba(180,140,60,0.18);
  padding:0.6rem 0.9rem; cursor:pointer; transition:all 0.18s; text-align:left;
  border-radius:1px;
}
.dpBtn:hover, .dpBtn:focus { color:#f0d890; border-color:rgba(210,170,60,0.55);
  background:rgba(28,22,10,0.95); outline:none; }
#devPickerShare { width:min(640px,90vw); display:flex; flex-direction:column; gap:0.4rem; }
.dpShareTitle {
  font-family:'DM Mono',monospace; font-size:0.62rem;
  color:rgba(180,140,60,0.5); letter-spacing:0.2em; text-transform:uppercase;
}
.dpShareRow { display:flex; gap:0.6rem; align-items:center; }
.dpShareLabel {
  flex:0 0 11rem; font-family:'Cormorant Garamond',Georgia,serif; font-style:italic;
  font-size:0.95rem; color:rgba(215,190,140,0.78);
}
.dpShareUrl {
  flex:1 1 auto; min-width:0; padding:0.35rem 0.5rem;
  font-family:'DM Mono',monospace; font-size:0.72rem; color:rgba(230,215,180,0.85);
  background:rgba(18,14,8,0.85); border:1px solid rgba(180,140,60,0.18);
  user-select:text; -webkit-user-select:text;
}
#devPickerHint {
  font-family:'DM Mono',monospace; font-size:0.62rem;
  color:rgba(140,120,80,0.32); letter-spacing:0.1em; text-align:center;
}
/* Tiny corner button that reveals the picker */
#devTrigger {
  position:fixed; bottom:0.5rem; right:0.6rem; z-index:500;
  background:none; border:none; color:rgba(255,255,255,0.07);
  font-family:'DM Mono',monospace; font-size:0.75rem;
  cursor:pointer; padding:0.3rem 0.45rem; line-height:1;
  transition:color 0.3s;
}
#devTrigger:hover { color:rgba(255,255,255,0.28); }

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