:root {
  --purple: #4a0080;
  --purple-deep: #1a0a2e;
  --purple-mid: #2d1054;
  --gold: #d4af37;
  --gold-soft: #f0d060;
  --gold-dim: #8a7020;
  --cream: #f6ecd0;
  --ink: #14081f;
  --card: rgba(20, 8, 32, 0.78);
  --ok: #3ecf8e;
  --bad: #e85d5d;
  --safe-top: max(14px, env(safe-area-inset-top));
  --safe-bot: max(16px, env(safe-area-inset-bottom));
}

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

html, body {
  height: 100%;
  background: var(--ink);
  color: var(--cream);
  font-family: Outfit, "Segoe UI", sans-serif;
  overflow: hidden;
}

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

img { display: block; max-width: 100%; }

#app {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  overflow: hidden;
  background: #0b0614;
  box-shadow: 0 0 80px rgba(74, 0, 128, 0.35);
}

p, h1, h2, .bio, .brief-copy, .where, .act-brief {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.screen.on { display: flex; }

.bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  transform: scale(1.04);
}

.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(10, 4, 18, 0.35) 0%, rgba(10, 4, 18, 0.2) 38%, rgba(10, 4, 18, 0.88) 100%);
}

.veil {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  width: 100%;
  padding: var(--safe-top) 18px var(--safe-bot);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.veil > * { flex-shrink: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
}

.ghost, .icon-btn {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: 999px;
  color: var(--gold-soft);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(10, 4, 18, 0.45);
  backdrop-filter: blur(8px);
}

.icon-btn { width: 40px; padding: 0; font-size: 1.1rem; }

h1, h2, .serif { font-family: "Cormorant Garamond", Georgia, serif; }

.kicker {
  color: var(--gold);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  font-size: 0.68rem;
  font-weight: 500;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  width: 100%;
  border-radius: 14px;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.btn:active { transform: scale(0.98); }

.btn-gold {
  background: linear-gradient(180deg, #f0d060, #d4af37 55%, #b8901f);
  color: #2a1600;
  box-shadow: 0 8px 24px rgba(212, 175, 55, 0.28);
}

.btn-ghost {
  border: 1px solid rgba(246, 236, 208, 0.22);
  background: rgba(255, 255, 255, 0.05);
  color: var(--cream);
}

.btn:disabled {
  filter: grayscale(0.4) brightness(0.7);
  pointer-events: none;
}

.card {
  background: var(--card);
  border: 1px solid rgba(212, 175, 55, 0.18);
  border-radius: 18px;
  padding: 16px;
  backdrop-filter: blur(14px);
}

/* TITLE */
#title .veil { justify-content: flex-end; gap: 10px; padding-bottom: calc(var(--safe-bot) + 18px); }
#title .mark {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  border: 2px solid var(--gold);
  object-fit: cover;
  box-shadow: 0 0 28px rgba(212, 175, 55, 0.35);
}
#title h1 {
  font-size: 2.35rem;
  line-height: 0.95;
  color: #fff;
  text-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
}
#title h1 span { display: block; color: var(--gold-soft); font-style: italic; font-weight: 500; font-size: 1.55rem; }
#title .tag { color: var(--gold); letter-spacing: 0.16em; text-transform: uppercase; font-size: 0.72rem; margin: 4px 0 10px; }
#title .where { font-size: 0.9rem; color: rgba(246, 236, 208, 0.78); margin-bottom: 14px; }
#title .progress-hint { text-align: center; font-size: 0.78rem; color: rgba(246, 236, 208, 0.6); margin-top: 8px; }

/* BRIEFING */
#briefing .veil { justify-content: flex-end; gap: 8px; }
.pass {
  border: 1px dashed rgba(212, 175, 55, 0.55);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 14px;
  background: rgba(20, 8, 32, 0.55);
}
.pass strong { color: var(--gold-soft); display: block; font-size: 0.72rem; letter-spacing: 0.18em; text-transform: uppercase; }
.pass em { font-style: normal; font-family: "Cormorant Garamond", serif; font-size: 1.35rem; }
.brief-copy { display: grid; gap: 10px; margin: 8px 0 18px; color: rgba(246, 236, 208, 0.86); font-size: 0.92rem; line-height: 1.45; max-width: 100%; }

/* STAGE */
#stage .veil, #backstage .veil { padding: 0; }
.hud-float {
  position: absolute;
  top: var(--safe-top);
  left: 14px;
  right: 14px;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}
.hud-float .ghost { pointer-events: auto; }
.hotspots { position: absolute; inset: 0; z-index: 3; }
.hot {
  position: absolute;
  transform: translate(-50%, -50%);
  min-width: 128px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(12, 6, 20, 0.62);
  border: 1px solid rgba(212, 175, 55, 0.45);
  backdrop-filter: blur(8px);
  text-align: left;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}
.hot .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 6px rgba(212, 175, 55, 0.18), 0 0 16px var(--gold);
  margin-bottom: 6px;
  animation: pulse 1.8s ease-in-out infinite;
}
.hot b { display: block; font-size: 0.86rem; }
.hot span { display: block; font-size: 0.7rem; color: rgba(246, 236, 208, 0.7); }
.stage-sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 4;
  padding: 16px 16px calc(var(--safe-bot) + 12px);
  background: linear-gradient(180deg, transparent, rgba(8, 3, 14, 0.92) 28%);
}
.stage-sheet h2 { font-size: 1.8rem; line-height: 1; }
.meta { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 12px; }
.chip {
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 5px 8px;
  border-radius: 999px;
  border: 1px solid rgba(212, 175, 55, 0.3);
  color: var(--gold-soft);
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: 0.7; }
}

/* BACKSTAGE */
.corridor {
  position: relative;
  z-index: 2;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: calc(var(--safe-top) + 56px) 14px calc(var(--safe-bot) + 10px);
}
.corridor h2 { font-size: 1.7rem; }
.corridor p.sub { color: rgba(246, 236, 208, 0.7); font-size: 0.86rem; margin: 4px 0 12px; }
.rooms {
  overflow: auto;
  display: grid;
  gap: 10px;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
}
.room-door {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 12px;
  align-items: center;
  text-align: left;
  padding: 12px;
  border-radius: 16px;
  background: rgba(16, 8, 28, 0.78);
  border: 1px solid rgba(212, 175, 55, 0.16);
  backdrop-filter: blur(10px);
}
.room-door.open { border-color: rgba(212, 175, 55, 0.5); }
.room-door.done { border-color: rgba(62, 207, 142, 0.45); }
.room-door.locked { opacity: 0.55; }
.badge {
  width: 56px; height: 56px;
  border-radius: 14px;
  display: grid; place-items: center;
  font-family: "Cormorant Garamond", serif;
  font-size: 1.15rem;
  color: #1a0a2e;
  background: var(--gold);
  font-weight: 700;
}
.room-door.locked .badge { background: #3a2a18; color: #8a7a55; }
.room-door b { display: block; font-size: 0.98rem; }
.room-door small { color: rgba(246, 236, 208, 0.62); font-size: 0.76rem; }
.status {
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
}
.room-door.done .status { color: var(--ok); }
.room-door.locked .status { color: #8a7a55; }

/* ROOM */
#room .veil { justify-content: flex-end; gap: 10px; }
.artist-head { display: flex; gap: 12px; align-items: center; }
.artist-head .badge { width: 64px; height: 64px; font-size: 1.3rem; }
.artist-head h2 { font-size: 1.7rem; line-height: 1; }
.artist-head .role { color: var(--gold-soft); font-size: 0.8rem; margin-top: 2px; }
.song-line { margin: 8px 0; }
.song-line b { color: var(--gold-soft); font-family: "Cormorant Garamond", serif; font-size: 1.2rem; font-weight: 600; }
.bio { font-size: 0.9rem; line-height: 1.45; color: rgba(246, 236, 208, 0.86); }
.tasks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.task {
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(212, 175, 55, 0.25);
  background: rgba(10, 4, 18, 0.45);
  text-align: left;
}
.task.on { border-color: var(--gold); }
.task.done { border-color: rgba(62, 207, 142, 0.55); }
.task .lbl { font-size: 0.66rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold); }
.task b { display: block; margin-top: 4px; font-size: 0.92rem; }

/* QUIZ */
#quiz .veil, #activity .veil, #result .veil, #finale .veil { overflow: auto; }
.q-progress { height: 4px; background: rgba(255,255,255,0.08); border-radius: 99px; overflow: hidden; margin: 10px 0 14px; }
.q-progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-soft)); width: 0; }
.question { font-family: "Cormorant Garamond", serif; font-size: 1.45rem; line-height: 1.2; margin-bottom: 14px; }
.options { display: grid; gap: 8px; }
.opt {
  text-align: left;
  padding: 14px;
  border-radius: 14px;
  background: rgba(20, 8, 32, 0.72);
  border: 1px solid rgba(246, 236, 208, 0.12);
  font-size: 0.95rem;
}
.opt.good { border-color: var(--ok); background: rgba(62, 207, 142, 0.15); }
.opt.bad { border-color: var(--bad); background: rgba(232, 93, 93, 0.14); }
.why { margin-top: 12px; font-size: 0.88rem; color: rgba(246, 236, 208, 0.78); min-height: 3em; }

/* ACTIVITY */
.act-brief { font-size: 0.92rem; line-height: 1.4; color: rgba(246, 236, 208, 0.82); margin: 8px 0 14px; }
.act-stage {
  position: relative;
  flex: 1;
  min-height: 280px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(212, 175, 55, 0.18);
  background: rgba(8, 3, 14, 0.55);
}
.act-hud {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold-soft);
  margin-bottom: 8px;
}
.hold-wrap { height: 100%; display: grid; place-items: center; padding: 20px; }
.hold-btn {
  width: 168px; height: 168px;
  border-radius: 50%;
  border: 4px solid var(--gold);
  background: radial-gradient(circle at 40% 35%, rgba(240, 208, 96, 0.35), rgba(74, 0, 128, 0.4));
  color: #fff;
  font-family: "Cormorant Garamond", serif;
  font-size: 1.2rem;
  box-shadow: 0 0 0 10px rgba(212, 175, 55, 0.08);
}
.hold-btn.holding { transform: scale(0.97); box-shadow: 0 0 40px rgba(212, 175, 55, 0.45); }
.phrase { position: absolute; top: 18px; left: 0; right: 0; text-align: center; font-family: "Cormorant Garamond", serif; font-size: 1.5rem; color: var(--gold-soft); }
.bar { position: absolute; left: 20px; right: 20px; bottom: 20px; height: 8px; background: rgba(255,255,255,0.1); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--gold); }

.grid16, .grid-words, .path-row, .order-list {
  height: 100%;
  display: grid;
  gap: 8px;
  padding: 12px;
}
.grid16 { grid-template-columns: repeat(4, 1fr); }
.tile {
  border-radius: 10px;
  background: #120816;
  border: 1px solid rgba(255,255,255,0.06);
}
.tile.lit {
  background: radial-gradient(circle, #f0d060, #7b2cbf);
  box-shadow: 0 0 16px rgba(212, 175, 55, 0.45);
}

.falling { position: absolute; padding: 8px 12px; border-radius: 999px; background: rgba(74, 0, 128, 0.8); border: 1px solid var(--gold); font-size: 0.78rem; letter-spacing: 0.06em; }
.falling.bad { border-color: #8a4a4a; background: rgba(40, 10, 16, 0.8); }

.rhythm {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 16px;
  gap: 16px;
}
.letters { display: flex; gap: 8px; font-family: "Cormorant Garamond", serif; font-size: 2rem; }
.letters i { width: 36px; text-align: center; opacity: 0.25; }
.letters i.on { opacity: 1; color: var(--gold-soft); }
.pulse-hit {
  width: 120px; height: 120px; border-radius: 50%;
  border: 3px solid var(--gold);
  font-size: 1.1rem;
}
.pulse-hit.now { box-shadow: 0 0 0 10px rgba(212, 175, 55, 0.25); background: rgba(212, 175, 55, 0.2); }

.holy-board, .thanks-board, .provision-board, .revive-board {
  height: 100%;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: 8px;
  padding: 14px;
}
.chip-word {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(246, 236, 208, 0.18);
  background: rgba(20, 8, 32, 0.7);
}
.chip-word.pick { border-color: var(--gold); }
.chip-word.good { border-color: var(--ok); color: var(--ok); }
.chip-word.bad { border-color: var(--bad); color: var(--bad); }

.basket {
  width: 56px; height: 56px; border-radius: 14px;
  background: linear-gradient(180deg, #f0d060, #b8860b);
  color: #2a1600;
  font-size: 1.3rem;
  position: absolute;
}
.heart {
  width: 54px; height: 54px; border-radius: 50%;
  background: #2a1630;
  border: 2px solid #5a3a48;
  font-size: 1.2rem;
}
.heart.live { background: #6b1b3d; border-color: #e07a9a; box-shadow: 0 0 16px rgba(224, 122, 154, 0.4); }

.frenzy-wrap { height: 100%; display: grid; place-items: center; }
.frenzy-btn {
  width: 180px; height: 180px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff8a65, #c0392b 60%, #4a0080);
  font-family: "Cormorant Garamond", serif;
  font-size: 1.5rem;
  box-shadow: 0 0 30px rgba(255, 107, 74, 0.35);
}
.frenzy-btn:active { transform: scale(0.94); }

.order-list { grid-auto-rows: min-content; align-content: center; }
.order-item {
  padding: 14px;
  border-radius: 12px;
  background: rgba(20, 8, 32, 0.75);
  border: 1px solid rgba(212, 175, 55, 0.2);
  font-family: "Cormorant Garamond", serif;
  font-size: 1.15rem;
}
.path-row { grid-template-columns: repeat(4, 1fr); align-content: center; }
.step {
  aspect-ratio: 1;
  border-radius: 12px;
  background: #1a1024;
  border: 1px solid rgba(255,255,255,0.08);
}
.step.next { border-color: var(--gold); box-shadow: 0 0 16px rgba(212, 175, 55, 0.35); }
.step.done { background: linear-gradient(180deg, #d4af37, #7b2cbf); }

/* RESULT / FINALE */
.stars { color: var(--gold); letter-spacing: 4px; font-size: 1.4rem; margin: 6px 0; }
.finale-art {
  width: 100%;
  height: 220px;
  object-fit: cover;
  border-radius: 16px;
  border: 1px solid rgba(212, 175, 55, 0.3);
  margin: 10px 0;
}
.toast {
  position: absolute;
  left: 16px; right: 16px; bottom: calc(var(--safe-bot) + 18px);
  z-index: 20;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(12, 6, 20, 0.92);
  border: 1px solid rgba(212, 175, 55, 0.4);
  font-size: 0.86rem;
  display: none;
}
.toast.on { display: block; }

@media (min-width: 700px) {
  #app { height: 100%; border-left: 1px solid rgba(212,175,55,0.12); border-right: 1px solid rgba(212,175,55,0.12); }
}
