@font-face {
  font-family: 'TBJ Interval';
  src: url('../fonts/TBJInterval-Regular.woff2') format('woff2'), url('../fonts/TBJInterval-Regular.woff') format('woff');
  font-weight: 400; font-style: normal; font-display: swap;
}

:root {
  --ink: #050403;
  --paper: #efebe3;
  --gold: #ffb257;
  --gold-soft: rgba(255, 214, 160, 0.85);
  --crimson: #a3132a;
  --text: #f3eee6;
  --muted: rgba(243, 238, 230, 0.55);
  --serif: 'Cormorant Garamond', 'Times New Roman', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, 'Helvetica Neue', sans-serif;
  --display: 'TBJ Interval', var(--sans);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: #000; color: var(--text); overflow: hidden; overscroll-behavior: none; }
body { font-family: var(--serif); -webkit-tap-highlight-color: transparent; touch-action: none; user-select: none; -webkit-user-select: none; }
#gl { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; background: #000; cursor: none; }
body.title #gl, body.paused #gl, body.ended #gl { cursor: default; }

/* ---------- lyrics ---------- */
#lyric {
  position: fixed; left: 0; right: 0; bottom: max(11vh, 64px); text-align: center; pointer-events: none;
  padding: 0 16px; z-index: 3;
}
#lyric p {
  position: absolute; left: 0; right: 0; bottom: 0;
  text-shadow: 0 0 18px rgba(255, 150, 60, 0.5), 0 0 2px rgba(0, 0, 0, 0.9), 0 2px 24px rgba(0, 0, 0, 0.9);
}
#lyric .tv { display: block; font-family: var(--serif); font-style: italic; font-weight: 500; font-size: clamp(22px, 3.3vw, 44px); letter-spacing: 0.03em; line-height: 1.15; color: #fff4e6; }
#lyric p.call .tv { font-style: normal; letter-spacing: 0.16em; font-size: clamp(20px, 2.9vw, 38px); }
#lyric .en {
  display: block; margin-top: 0.7em; font-family: var(--display); font-size: clamp(11px, 1.05vw, 15px); letter-spacing: 0.14em;
  color: rgba(255, 236, 214, 0.72); opacity: 0; transform: translateY(4px); transition: opacity 1s ease 1.1s, transform 1.2s ease 1.1s;
}
#lyric .ch { display: inline-block; opacity: 0; filter: blur(8px); transform: translateY(0.25em); transition: opacity 0.7s ease, filter 0.9s ease, transform 0.9s ease; white-space: pre; }
#lyric p.in .ch { opacity: 1; filter: blur(0); transform: none; }
#lyric p.in .en { opacity: 1; transform: none; }
#lyric p.out .ch, #lyric p.out .en { opacity: 0; filter: blur(10px); transform: translateY(-0.9em); transition-duration: 0.55s; transition-delay: 0s !important; }
body.w2 #lyric p { text-shadow: 0 0 1px rgba(255, 255, 255, 0.6); }
body.w2 #lyric .tv, body.w2 #lyric .en { color: #0b0a09; }

/* ---------- chapter card (anime eyecatch) ---------- */
#chapter {
  position: fixed; left: max(4vw, 16px); top: max(7vh, 40px); z-index: 3; pointer-events: none;
  font-family: var(--display); font-size: clamp(12px, 1.25vw, 17px); letter-spacing: 0.42em; text-transform: uppercase;
  color: var(--gold-soft); opacity: 0; transform: translateX(-12px); transition: opacity 0.9s ease, transform 1.2s ease;
}
#chapter.on { opacity: 1; transform: none; }
#chapter::before { content: ''; display: block; width: 42px; height: 1px; background: currentColor; margin-bottom: 12px; opacity: 0.7; }
body.w2 #chapter { color: #141210; }

/* ---------- prompt ---------- */
#prompt {
  position: fixed; left: 0; right: 0; top: 50%; transform: translateY(-50%); text-align: center; z-index: 4; pointer-events: none;
  font-family: var(--display); font-size: clamp(14px, 1.6vw, 22px); letter-spacing: 0.35em; text-transform: uppercase;
  color: #fff; opacity: 0; transition: opacity 0.5s ease; text-shadow: 0 0 16px rgba(0, 0, 0, 0.9); padding: 0 16px;
}
#prompt.on { opacity: 0.92; }
body.w2 #prompt { color: #0b0a09; text-shadow: 0 0 12px rgba(255, 255, 255, 0.9); }

/* ---------- hud ---------- */
#hud { position: fixed; right: max(3vw, 16px); top: max(4vh, 20px); z-index: 3; pointer-events: none; font-family: var(--display); letter-spacing: 0.3em; font-size: 12px; color: var(--muted); opacity: 0; transition: opacity 0.6s; }
body.playing.mode-play #hud { opacity: 1; }
body.w2 #hud { color: rgba(10, 10, 10, 0.6); }
#progress { position: fixed; left: 0; right: 0; bottom: 0; height: 2px; z-index: 3; background: rgba(255, 255, 255, 0.06); pointer-events: none; }
#progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, rgba(255, 178, 87, 0.2), rgba(255, 178, 87, 0.8)); }
body.w2 #progress i { background: rgba(10, 10, 10, 0.6); }

/* ---------- pause button ---------- */
#btn-pause { position: fixed; right: max(3vw, 16px); bottom: max(4vh, 22px); z-index: 6; width: 46px; height: 46px; padding: 0; border-radius: 50%; display: none; align-items: center; justify-content: center; gap: 5px; opacity: 0; transition: opacity 0.5s; background: rgba(0, 0, 0, 0.35); }
#btn-pause span { display: block; width: 4px; height: 16px; background: var(--text); border-radius: 1px; }
body.playing #btn-pause { display: flex; }
body.playing.awake #btn-pause, #btn-pause:focus-visible { opacity: 0.85; }
body.w2 #btn-pause { background: rgba(255, 255, 255, 0.4); border-color: rgba(0, 0, 0, 0.3); }
body.w2 #btn-pause span { background: #111; }
@media (hover: none) { body.playing #btn-pause { opacity: 0.5; } }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 16px; background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0.75)); transition: opacity 0.8s ease; }
.overlay.hidden { opacity: 0; pointer-events: none; }
body.review .overlay, body.review #lyric .ch, body.review #lyric .en, body.review #chapter, body.review #prompt { transition: none !important; }
.card { text-align: center; max-width: 560px; }
.by { font-family: var(--display); letter-spacing: 0.6em; font-size: 13px; color: var(--gold-soft); margin-bottom: 10px; padding-left: 0.6em; }
h1 { font-family: var(--display); font-weight: 400; font-size: clamp(56px, 12vw, 132px); letter-spacing: 0.16em; padding-left: 0.16em; line-height: 1; color: #fff7ec; text-shadow: 0 0 40px rgba(255, 150, 60, 0.45); }
h2 { font-family: var(--display); font-weight: 400; letter-spacing: 0.3em; font-size: 28px; margin-bottom: 24px; }
.views { font-family: var(--display); font-size: 12px; letter-spacing: 0.3em; text-transform: uppercase; color: rgba(255, 214, 160, 0.55); margin-top: 12px; min-height: 1em; }
.sub { font-family: var(--display); font-size: 14px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--muted); margin-top: 10px; }
.choices { display: flex; gap: 14px; justify-content: center; margin: 34px 0 22px; flex-wrap: wrap; }
button {
  font: inherit; font-family: var(--display); font-size: 14px; letter-spacing: 0.32em; text-transform: uppercase; padding: 14px 30px 14px 34px;
  color: var(--text); background: rgba(0, 0, 0, 0.35); border: 1px solid rgba(255, 214, 160, 0.35); border-radius: 999px; cursor: pointer;
  transition: border-color 0.3s, background 0.3s, box-shadow 0.3s;
}
button:hover, button:focus-visible { border-color: var(--gold); box-shadow: 0 0 24px rgba(255, 150, 60, 0.35); outline: none; }
button.primary { background: rgba(255, 178, 87, 0.14); border-color: rgba(255, 178, 87, 0.7); }
button:disabled { opacity: 0.4; cursor: wait; }
.hint { font-family: var(--sans); font-size: 14px; color: var(--muted); line-height: 1.6; letter-spacing: 0.02em; }
.status { margin-top: 18px; font-family: var(--display); font-size: 11px; letter-spacing: 0.4em; color: rgba(255, 214, 160, 0.5); text-transform: uppercase; min-height: 1em; }
.result { font-family: var(--display); font-size: 18px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--text); margin-top: 18px; }

/* ---------- editor / debug ---------- */
#dbg { position: fixed; left: 8px; top: 8px; z-index: 20; font: 12px/1.4 ui-monospace, Consolas, monospace; color: #9f9; background: rgba(0, 0, 0, 0.6); padding: 6px 8px; white-space: pre; pointer-events: none; }
#editor { position: fixed; right: 8px; top: 8px; bottom: 8px; width: min(420px, 46vw); z-index: 20; overflow: auto; font: 12px/1.5 ui-monospace, Consolas, monospace; color: #eee; background: rgba(0, 0, 0, 0.78); padding: 10px; border: 1px solid #333; }
#editor .row { padding: 2px 6px; border-radius: 3px; display: flex; gap: 10px; }
#editor .row.sel { background: #5a3a12; }
#editor .row.now { color: #ffb257; }
#editor .row b { width: 64px; flex: none; text-align: right; font-weight: normal; color: #9cf; }
#editor h3 { font: 600 12px ui-monospace, monospace; margin: 10px 0 4px; color: #ffb257; }
#editor p { color: #aaa; margin-bottom: 6px; }

@media (max-width: 600px) {
  #lyric { bottom: 9vh; }
  .hint { font-size: 13px; }
  button { padding: 13px 22px 13px 26px; }
}
