:root {
  --ink: #f1e6d0;
  --ink-dim: rgba(241, 230, 208, 0.62);
  --ink-faint: rgba(241, 230, 208, 0.34);
  --ember: #e8a35a;
  --night: #05070b;
  --serif: 'Cormorant Garamond', 'Iowan Old Style', Georgia, serif;
  --caps: 'Cormorant SC', 'Cormorant Garamond', Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--night); color: var(--ink); overflow: hidden; }
body { font-family: var(--serif); -webkit-font-smoothing: antialiased; user-select: none; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* Screens */
.screen { position: fixed; inset: 0; display: none; z-index: 20; }
.screen.show { display: flex; }

/* Title */
#title { align-items: flex-end; justify-content: flex-start; background: var(--night); }
#title-art { position: absolute; inset: 0; width: 100%; height: 100%; }
.title-block { position: relative; padding: 0 0 12vh 9vw; max-width: 640px; }
.chapter { font-family: var(--caps); letter-spacing: 0.32em; font-size: 15px; color: var(--ink-dim); text-transform: lowercase; }
#title h1 { font-weight: 400; font-size: clamp(44px, 7vw, 88px); line-height: 0.95; margin: 10px 0 34px; letter-spacing: 0.01em; }
.menu { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.menu button { font-size: 24px; padding: 4px 0; color: var(--ink-dim); transition: color .25s, transform .25s; }
.menu button:hover, .menu button:focus-visible, .menu button.focus { color: var(--ink); transform: translateX(6px); outline: none; }
.menu button.focus::before, .menu button:hover::before { content: ''; position: absolute; margin: 15px 0 0 -22px; width: 10px; height: 1px; background: var(--ember); }
.hint { margin-top: 34px; font-style: italic; font-size: 15px; color: var(--ink-faint); }

/* Fade and cards */
#fade { position: fixed; inset: 0; background: #000; opacity: 1; pointer-events: none; z-index: 15; transition: opacity 1.6s ease; }
.card { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none; z-index: 16; opacity: 0; transition: opacity 1.4s ease; text-align: center; }
.card.show { opacity: 1; }
.card-kicker { font-family: var(--caps); letter-spacing: 0.34em; font-size: 14px; color: var(--ink-dim); text-transform: lowercase; }
.card-title { font-size: clamp(34px, 5vw, 56px); margin: 8px 0 10px; }
.card-sub { font-style: italic; font-size: 18px; color: var(--ink-dim); }

/* Interaction icon */
#prompt { position: fixed; left: 0; top: 0; z-index: 12; pointer-events: none; display: flex; flex-direction: column; align-items: center;
  gap: 5px; opacity: 0; transition: opacity .35s ease; transform: translate(-50%, -50%); }
#prompt.show { opacity: 1; }
#prompt .glyph { position: relative; width: 30px; height: 30px; border-radius: 50%; border: 1px solid rgba(241, 230, 208, 0.75); display: grid; place-items: center;
  font: 600 13px/1 ui-sans-serif, system-ui, sans-serif; color: var(--ink); background: rgba(8, 6, 4, 0.35); backdrop-filter: blur(2px); }
#prompt .glyph.hold { box-shadow: 0 0 0 3px rgba(241, 230, 208, 0.12); }
#prompt .glyph.wide { width: auto; padding: 0 9px; border-radius: 15px; }
#prompt .verb { font-family: var(--caps); font-size: 13px; letter-spacing: 0.16em; color: var(--ink-dim); text-transform: lowercase; text-shadow: 0 1px 3px #000; }
#prompt .verb:empty { display: none; }

/* Subtitles */
#subs { position: fixed; left: 50%; bottom: 7vh; transform: translateX(-50%); width: min(880px, 90vw); z-index: 17; text-align: center; pointer-events: none; }
#subs .line { font-size: 25px; line-height: 1.35; margin-top: 6px; text-shadow: 0 1px 4px #000, 0 0 18px rgba(0,0,0,.7);
  opacity: 0; transition: opacity .5s ease; }
#subs .line.show { opacity: 1; }
#subs .who { font-family: var(--caps); font-size: 0.72em; letter-spacing: 0.2em; color: var(--ember); margin-right: 0.6em; text-transform: lowercase; }
#subs .line.caption { font-style: italic; color: var(--ink-dim); font-size: 21px; }
#subs .line.divine .who { color: #f3d27a; }
body.sub-s #subs .line { font-size: 20px; } body.sub-s #subs .line.caption { font-size: 17px; }
body.sub-l #subs .line { font-size: 31px; } body.sub-l #subs .line.caption { font-size: 26px; }

/* Assist HUD */
#assist-ring { position: fixed; left: 50%; top: 50%; width: 46px; height: 46px; transform: translate(-50%, -50%) rotate(-90deg); z-index: 11; pointer-events: none; }
#assist-ring circle { fill: none; stroke-width: 4; }
#assist-ring .track { stroke: rgba(241, 230, 208, 0.14); }
#assist-ring .fill { stroke: rgba(241, 230, 208, 0.7); stroke-dasharray: 276.5; stroke-dashoffset: 0; transition: stroke-dashoffset .3s; }
#assist-dial { position: fixed; right: 28px; top: 24px; width: 64px; height: 34px; overflow: hidden; z-index: 11; pointer-events: none; }
#assist-dial .dial-sky { position: absolute; left: 0; top: 0; width: 64px; height: 64px; border-radius: 50%; border: 1px solid var(--ink-faint);
  background: radial-gradient(circle at 50% 100%, #1b2235, #070910 70%); }
#assist-dial .dial-hand { position: absolute; left: 31px; top: 4px; width: 2px; height: 28px; background: var(--ink); transform-origin: 1px 28px; }
#assist-dial .dial-time { position: absolute; left: 0; right: 0; bottom: -1px; text-align: center; font-size: 12px; color: var(--ink-dim); }

/* Pause and settings */
#pause, #settings { flex-direction: column; justify-content: center; padding-left: 9vw; background: rgba(3, 4, 7, 0.62); backdrop-filter: blur(3px); }
.pause-where { font-size: 30px; font-style: italic; margin-bottom: 30px; }
#settings h2 { font-weight: 400; font-size: 40px; margin: 0 0 20px; }
.opts { display: flex; flex-direction: column; gap: 12px; margin-bottom: 28px; font-size: 20px; color: var(--ink-dim); }
.opts label { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.opts input { accent-color: var(--ember); width: 18px; height: 18px; }
.opts select { font: inherit; font-size: 18px; background: #11100d; color: var(--ink); border: 1px solid var(--ink-faint); padding: 2px 6px; }

@media (max-width: 640px) {
  .title-block { padding: 0 16px 10vh; }
  #pause, #settings { padding-left: 16px; }
  #subs .line { font-size: 19px; }
}

/* ---------- Touch ---------- */
html, body, #view { touch-action: none; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
.hint-touch { display: none; }
body.touch .hint-pad { display: none; }
body.touch .hint-touch { display: block; }
#touch { display: none; position: fixed; inset: 0; z-index: 14; pointer-events: none; }
body.touch.playing #touch { display: block; }
#stick-zone { position: absolute; left: 0; top: 0; bottom: 0; width: 45%; pointer-events: auto; }
#look-zone { position: absolute; right: 0; top: 0; bottom: 0; width: 55%; pointer-events: auto; }
#stick { position: absolute; width: 112px; height: 112px; margin: -56px 0 0 -56px; border-radius: 50%;
  border: 1px solid rgba(241, 230, 208, 0.22); background: rgba(8, 6, 4, 0.18); opacity: 0; transition: opacity .2s; pointer-events: none;
  left: calc(16px + env(safe-area-inset-left) + 70px); top: calc(100% - 16px - env(safe-area-inset-bottom) - 70px); }
#stick.on { opacity: 1; }
#stick .knob { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%;
  background: rgba(241, 230, 208, 0.28); border: 1px solid rgba(241, 230, 208, 0.5); }
.tbtns { position: absolute; right: calc(16px + env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom));
  display: grid; grid-template-columns: auto auto; gap: 10px; align-items: end; pointer-events: none; }
.tbtns button { pointer-events: auto; width: 62px; height: 62px; border-radius: 50%; border: 1px solid rgba(241, 230, 208, 0.38);
  background: rgba(8, 6, 4, 0.32); color: var(--ink-dim); font-family: var(--caps); font-size: 13px; letter-spacing: 0.08em;
  text-transform: lowercase; backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); touch-action: none; }
.tbtns button.big { width: 78px; height: 78px; font-size: 15px; color: var(--ink); border-color: rgba(241, 230, 208, 0.6); }
.tbtns button.down { background: rgba(232, 163, 90, 0.28); color: var(--ink); border-color: var(--ember); }
.tbtns .t-child { visibility: hidden; }
body.has-child .tbtns .t-child { visibility: visible; }
#tpause { position: absolute; left: calc(14px + env(safe-area-inset-left)); top: calc(12px + env(safe-area-inset-top)); pointer-events: auto;
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(241, 230, 208, 0.25); color: var(--ink-dim); font-size: 12px;
  background: rgba(8, 6, 4, 0.25); }
#rotate { display: none; position: fixed; inset: 0; z-index: 30; background: rgba(3, 4, 7, 0.92); color: var(--ink);
  flex-direction: column; align-items: center; justify-content: center; text-align: center; font-size: 26px; font-style: italic; gap: 10px; }
#rotate small { font-size: 15px; color: var(--ink-faint); font-style: normal; }
@media (orientation: portrait) { body.touch.playing:not(.rotate-ok) #rotate { display: flex; } }
body.touch #prompt .glyph { width: auto; min-width: 34px; padding: 0 9px; border-radius: 15px; font-family: var(--caps); font-weight: 500;
  font-size: 12px; letter-spacing: 0.08em; text-transform: lowercase; }
body.touch #subs { bottom: calc(110px + env(safe-area-inset-bottom)); width: min(620px, 62vw); }
@media (max-height: 460px) {
  #subs .line { font-size: 18px; } #subs .line.caption { font-size: 15px; }
  .title-block { padding-bottom: 7vh; } #title h1 { margin-bottom: 18px; }
  .menu button { font-size: 20px; }
  .card-title { font-size: 34px; }
}

/* ---------- Hold progress ring ---------- */
#prompt .ring { position: absolute; left: -6px; top: -6px; width: calc(100% + 12px); height: calc(100% + 12px); pointer-events: none;
  transform: rotate(-90deg); overflow: visible; }
#prompt .glyph.wide .ring { left: -6px; top: -6px; }
#prompt .ring circle { fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-dasharray: 113.1; stroke-dashoffset: 113.1;
  opacity: 0; transition: opacity .15s; filter: drop-shadow(0 0 3px rgba(255,255,255,.6)); }
#prompt.progress .ring circle { opacity: 1; }
#prompt.draining .ring circle { stroke: rgba(241, 230, 208, 0.85); }
#prompt .glyph.wide .ring { width: calc(100% + 12px); height: calc(100% + 12px); }

/* ---------- Directions ---------- */
#goal { position: fixed; left: calc(28px + env(safe-area-inset-left)); top: calc(24px + env(safe-area-inset-top)); z-index: 12; max-width: min(420px, 46vw);
  pointer-events: none; opacity: 0; transition: opacity .8s ease; text-shadow: 0 1px 4px #000; }
#goal.show { opacity: 0.92; }
#goal.dim { opacity: 0.5; }
#goal .goal-k { display: block; font-family: var(--caps); font-size: 12px; letter-spacing: 0.3em; color: var(--ember); text-transform: lowercase; margin-bottom: 3px; }
#goal .goal-t { font-size: 20px; font-style: italic; line-height: 1.3; color: var(--ink); }
body.touch #goal { left: calc(66px + env(safe-area-inset-left)); top: calc(14px + env(safe-area-inset-top)); }
body.touch #goal .goal-t { font-size: 16px; }
#marker { position: fixed; left: 0; top: 0; z-index: 11; pointer-events: none; opacity: 0; transition: opacity .4s; }
#marker.show { opacity: 1; }
#marker .dot { position: absolute; left: -7px; top: -7px; width: 14px; height: 14px; transform: rotate(45deg);
  border: 1.5px solid rgba(241, 230, 208, 0.85); box-shadow: 0 0 10px rgba(232, 163, 90, 0.6); animation: pulse 1.8s ease-in-out infinite; }
#marker .arrow { display: none; position: absolute; left: -9px; top: -9px; width: 0; height: 0;
  border-left: 9px solid transparent; border-right: 9px solid transparent; border-bottom: 16px solid rgba(241, 230, 208, 0.85);
  filter: drop-shadow(0 0 6px rgba(232, 163, 90, 0.7)); }
#marker.edge .dot { display: none; }
#marker.edge .arrow { display: block; }
@keyframes pulse { 0%, 100% { transform: rotate(45deg) scale(0.85); opacity: 0.65; } 50% { transform: rotate(45deg) scale(1.1); opacity: 1; } }
