:root {
  --bg: #0a0a0f;
  --panel: #14141c;
  --panel2: #1b1b26;
  --accent: #e8862e;
  --accent-hi: #ffb347;
  --text: #e8e6e3;
  --text-dim: #8a8794;
  --danger: #c0392b;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100%;
}

#app { max-width: 560px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

.hidden { display: none !important; }

/* ---------- Stats bar ---------- */
#statsbar {
  display: flex; gap: 14px; padding: 10px 16px 8px;
  background: linear-gradient(180deg, rgba(20,20,28,.95), rgba(20,20,28,.6));
  position: sticky; top: 0; z-index: 10;
}
.stat { flex: 1; }
.stat-label {
  display: block; font-size: 9px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--text-dim); margin-bottom: 3px;
}
.stat-track { height: 3px; background: #26262f; border-radius: 2px; overflow: hidden; }
.stat-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hi));
  border-radius: 2px;
  transition: width .6s cubic-bezier(.22,1,.36,1);
}
.stat-fill.pulse { animation: statPulse .9s ease; }
@keyframes statPulse {
  0%, 100% { filter: brightness(1); }
  30% { filter: brightness(2.2); box-shadow: 0 0 8px var(--accent-hi); }
}

/* ---------- Timer ---------- */
#timerbar { height: 3px; background: #1a1a24; position: sticky; top: 34px; z-index: 10; }
#timerfill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hi));
  transform-origin: left;
}

/* ---------- Title screen ---------- */
.title-screen {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 88vh; text-align: center; padding: 32px; gap: 10px;
  background:
    radial-gradient(ellipse at 50% 20%, rgba(232,134,46,.12), transparent 55%),
    radial-gradient(ellipse at 50% 100%, rgba(232,134,46,.06), transparent 50%);
}
.title-sigil { font-size: 44px; color: var(--accent); text-shadow: 0 0 30px rgba(232,134,46,.6); margin-bottom: 12px; }
.title-name {
  font-size: 40px; font-weight: 800; letter-spacing: .14em;
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.title-sub { font-size: 15px; letter-spacing: .5em; color: var(--text-dim); text-transform: uppercase; margin-bottom: 30px; }
.title-tag { font-size: 13px; color: var(--text-dim); max-width: 300px; line-height: 1.6; margin-bottom: 36px; font-style: italic; }

.btn {
  display: block; width: 100%; max-width: 320px;
  background: var(--panel); color: var(--text);
  border: 1px solid #2a2a36; border-radius: 10px;
  padding: 15px 20px; font-size: 15px; font-family: inherit;
  cursor: pointer; text-align: center;
  transition: border-color .2s, background .2s, transform .1s;
}
.btn:hover, .btn:active { border-color: var(--accent); background: var(--panel2); }
.btn-primary { border-color: var(--accent); color: var(--accent-hi); font-weight: 600; letter-spacing: .06em; }
.btn-ghost { border-color: transparent; color: var(--text-dim); font-size: 13px; }

/* ---------- Scene ---------- */
.scene { display: flex; flex-direction: column; flex: 1; }
.scene-img {
  width: 100%; aspect-ratio: 3 / 2; position: relative; overflow: hidden;
  background: linear-gradient(135deg, #17131f 0%, #241428 45%, #3a1a14 100%);
}
.scene-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.scene-img::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 90px 30px rgba(0,0,0,.65);
}
.scene-body { padding: 18px 20px 8px; }
.speaker {
  font-size: 11px; font-weight: 700; letter-spacing: .28em; text-transform: uppercase;
  color: var(--accent-hi); margin-bottom: 10px;
}
.scene-text { font-size: 17px; line-height: 1.62; color: var(--text); }

.choices { padding: 18px 20px 34px; display: flex; flex-direction: column; gap: 10px; margin-top: auto; }
.choice {
  background: var(--panel); border: 1px solid #262632; border-radius: 10px;
  color: var(--text); font-family: inherit; font-size: 14.5px; line-height: 1.45;
  padding: 13px 16px; text-align: left; cursor: pointer;
  opacity: 0; transform: translateY(10px);
  animation: choiceIn .4s cubic-bezier(.22,1,.36,1) forwards;
  transition: border-color .18s, background .18s;
}
.choice:nth-child(1) { animation-delay: .08s; }
.choice:nth-child(2) { animation-delay: .2s; }
.choice:nth-child(3) { animation-delay: .32s; }
.choice:nth-child(4) { animation-delay: .44s; }
.choice:hover, .choice:active { border-color: var(--accent); background: var(--panel2); }
.choice.locked { opacity: .35 !important; pointer-events: none; }
@keyframes choiceIn { to { opacity: 1; transform: translateY(0); } }

/* ---------- Flowchart ---------- */
.flow-screen { padding: 26px 20px 40px; flex: 1; display: flex; flex-direction: column; }
.flow-title {
  font-size: 12px; letter-spacing: .3em; text-transform: uppercase;
  color: var(--accent-hi); text-align: center; margin-bottom: 4px;
}
.flow-sub { font-size: 18px; font-weight: 700; text-align: center; margin-bottom: 28px; }
.flow-graph { display: flex; flex-direction: column; align-items: center; margin-bottom: 30px; }
.flow-node {
  width: 100%; max-width: 320px;
  background: var(--panel); border: 1px solid #23232e; border-radius: 8px;
  padding: 10px 14px; font-size: 12.5px; color: var(--text-dim);
  text-align: center; position: relative;
}
.flow-node.visited {
  border-color: var(--accent); color: var(--text);
  box-shadow: 0 0 14px rgba(232,134,46,.18);
}
.flow-node.visited .flow-node-id { color: var(--accent-hi); }
.flow-node-id { font-size: 9.5px; letter-spacing: .16em; text-transform: uppercase; display: block; margin-bottom: 2px; color: #55525e; }
.flow-link { width: 1px; height: 18px; background: #2c2c38; }
.flow-link.visited { background: var(--accent); box-shadow: 0 0 6px rgba(232,134,46,.5); }
.flow-actions { display: flex; flex-direction: column; gap: 10px; align-items: center; margin-top: auto; }

/* ---------- Ending ---------- */
.ending-screen {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 40px 24px; min-height: 70vh; gap: 8px;
  background: radial-gradient(ellipse at 50% 30%, rgba(232,134,46,.14), transparent 60%);
}
.ending-label { font-size: 11px; letter-spacing: .4em; text-transform: uppercase; color: var(--text-dim); }
.ending-name {
  font-size: 28px; font-weight: 800; letter-spacing: .06em;
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  margin-bottom: 8px;
}
.ending-text { font-size: 15px; color: var(--text); line-height: 1.6; max-width: 340px; margin-bottom: 24px; }
.endings-count { font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.endings-list { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 30px; max-width: 340px; }
.ending-chip {
  font-size: 11px; padding: 5px 11px; border-radius: 20px;
  border: 1px solid var(--accent); color: var(--accent-hi); background: rgba(232,134,46,.08);
}
.ending-chip.unknown { border-color: #2a2a36; color: #55525e; background: transparent; }

.fade-in { animation: fadeIn .5s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.notice { text-align:center; color: var(--text-dim); padding: 40px 24px; font-size: 14px; line-height: 1.6; }
