:root {
  color-scheme: dark;
  --bg: #1a1a2e;
  --bg-2: #2d2b55;
  --gold: #ffd700;
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.72);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  min-height: 100dvh;
}

button, input { font: inherit; color: inherit; }

.app {
  min-height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(255, 140, 0, 0.18), transparent 50%),
    linear-gradient(180deg, #1a1a2e 0%, #242246 48%, #1a1a2e 100%);
}

.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(12px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
}

.screen.night {
  background: linear-gradient(180deg, #0b1026 0%, #1a1a2e 100%);
}

.top {
  display: grid;
  grid-template-columns: 44px 1fr 64px;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.top h1, .logo {
  margin: 0;
  text-align: center;
  font-size: 22px;
}

.logo span, .gold-text { color: var(--gold); }

.icon-btn, .text-btn, .ghost, .gold, .mic, .next, .card, .choice, .pad, .num, .pane, .frame {
  border: 0;
  cursor: pointer;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  font-size: 22px;
}

.stars { text-align: right; font-weight: 700; color: var(--gold); }

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
}

.fox {
  font-size: 72px;
  line-height: 1;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.35));
}

.fox.big { font-size: 96px; margin-top: 28px; }

.fox.listen { animation: pulse 0.8s ease-in-out infinite; }
.fox.think { animation: bob 0.9s ease-in-out infinite; }

@keyframes pulse {
  50% { transform: scale(1.08); }
}
@keyframes bob {
  50% { transform: translateY(-6px); }
}

.bubble, .lead, .subtitle, .kicker, .hint-line {
  margin: 0;
}

.bubble, .lead {
  font-size: 20px;
  line-height: 1.4;
  max-width: 28rem;
}

.subtitle, .hint-line, .kicker { color: var(--muted); }
.subtitle { margin: 8px 0 18px; text-align: center; }
.kicker { text-align: center; }

.home, .center-screen { align-items: center; text-align: center; }
.center-screen { justify-content: center; gap: 12px; }
.center-screen .top { align-self: stretch; }

.home-actions, .cards, .choices, .form { width: 100%; }

.mode, .card {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  border-radius: 20px;
  padding: 16px 18px;
  margin-bottom: 12px;
  color: white;
  background: linear-gradient(90deg, var(--a, #ff8c00), var(--b, #ff6b35));
  min-height: 84px;
}

.mode.day { background: linear-gradient(90deg, #ff8c00, #ff6b35); }
.mode.night-btn { background: linear-gradient(90deg, #3d3a6b, #2a274f); }
.mode span:first-child, .card-emoji { font-size: 30px; }
.mode strong, .card-text strong { display: block; font-size: 20px; }
.mode small, .card-text small { display: block; opacity: 0.88; font-size: 14px; margin-top: 2px; }

.cards { padding-bottom: 12px; }

.dock {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: sticky;
  bottom: 0;
  padding-top: 8px;
  background: linear-gradient(180deg, transparent, rgba(26, 26, 46, 0.92) 24%);
}

.mic, .gold, .next {
  min-height: 56px;
  border-radius: 999px;
  font-size: 18px;
  font-weight: 700;
}

.mic { background: #ff8c00; color: white; }
.gold { background: var(--gold); color: #1a1a2e; padding: 0 18px; }
.gold.small, .ghost { min-height: 48px; border-radius: 16px; padding: 0 14px; }
.ghost { background: rgba(255, 255, 255, 0.12); }

.form input {
  flex: 1;
  min-height: 48px;
  border-radius: 14px;
  border: 0;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 16px;
}

.text-btn {
  background: transparent;
  color: var(--gold);
  font-weight: 700;
  min-height: 44px;
}

.install { color: var(--muted); font-size: 13px; line-height: 1.4; margin-top: 8px; }

.form { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.form label { display: flex; flex-direction: column; gap: 6px; text-align: left; color: var(--muted); }
.gender { display: flex; gap: 12px; justify-content: center; }
.gender label {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 10px 16px;
  color: white;
}
.gender input { width: 18px; height: 18px; accent-color: #ffd700; }
.error { color: #ff8a80; min-height: 1.2em; margin: 0; }

.big-word, .twister, .story-title {
  font-size: 34px;
  font-weight: 800;
  margin: 0;
  overflow-wrap: anywhere;
}
.twister { font-size: 26px; line-height: 1.35; }

.chips, .choices, .nums, .split, .frames, .order, .row-actions, .pads {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  width: 100%;
}

.chip, .choice, .num, .frame, .pad {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  min-height: 48px;
  padding: 10px 14px;
}

.chip.static { display: inline-flex; align-items: center; }
.choice { width: 100%; text-align: left; font-size: 17px; }
.num { width: 56px; height: 56px; font-size: 20px; font-weight: 700; }
.count-row { font-size: 32px; letter-spacing: 4px; margin: 0; }
.task-card {
  width: 100%;
  min-height: 148px;
  display: grid;
  place-items: center;
  background: white;
  color: #1a1a2e;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}
.task-card .count-row { font-size: 42px; letter-spacing: 10px; }

.split { display: grid; grid-template-columns: 1fr 1fr; }
.split.three { grid-template-columns: 1fr 1fr 1fr; }
.pane {
  min-height: 120px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.pane small { color: var(--muted); }

.shape { display: block; background: #ffd700; }
.shape.circle { width: 54px; height: 54px; border-radius: 50%; }
.shape.square { width: 50px; height: 50px; }
.shape.rect { width: 70px; height: 42px; }
.shape.tri { width: 0; height: 0; background: transparent; border-left: 28px solid transparent; border-right: 28px solid transparent; border-bottom: 50px solid #ffd700; }
.shape.star { width: 54px; height: 54px; background: #ffd700; clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }

.letter-wrap { position: relative; width: min(100%, 340px); height: 280px; }
.letter-ghost {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 180px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.16);
  pointer-events: none;
}
#pad { width: 100%; height: 100%; touch-action: none; background: rgba(255, 255, 255, 0.04); border-radius: 20px; }

.frame { width: calc(50% - 8px); display: flex; flex-direction: column; align-items: center; font-size: 36px; }
.frame small { font-size: 13px; color: var(--muted); }
.frame:disabled { opacity: 0.35; }
.order { min-height: 72px; }

.pads { gap: 18px; }
.pad { width: 120px; height: 120px; border-radius: 28px; font-size: 48px; }
.pad.drum { background: #e65100; }
.pad.bell { background: #6a1b9a; }
.pad.on { transform: scale(1.06); outline: 3px solid var(--gold); }

.breath {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 28px;
  font-weight: 800;
  background: rgba(100, 149, 237, 0.35);
  animation: inhale 4s ease-in-out infinite;
}
.breath.out { animation-name: exhale; }
@keyframes inhale { from { transform: scale(0.72); } to { transform: scale(1); } }
@keyframes exhale { from { transform: scale(1); } to { transform: scale(0.72); } }

.story-img { width: min(100%, 320px); border-radius: 20px; }
audio { width: min(100%, 360px); margin-top: 12px; }

.report-card {
  width: 100%;
  text-align: left;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 10px;
}
.report-card p { margin: 6px 0 0; color: var(--muted); }

.menu-screen {
  overflow: auto;
  min-height: 100dvh;
  background:
    radial-gradient(1.5px 1.5px at 12% 8%, rgba(255, 255, 255, 0.7), transparent),
    radial-gradient(1.5px 1.5px at 82% 14%, rgba(255, 255, 255, 0.45), transparent),
    radial-gradient(1.5px 1.5px at 70% 36%, rgba(255, 255, 255, 0.35), transparent),
    radial-gradient(1.5px 1.5px at 18% 48%, rgba(255, 255, 255, 0.4), transparent),
    radial-gradient(1.5px 1.5px at 90% 62%, rgba(255, 255, 255, 0.35), transparent),
    linear-gradient(180deg, #1a1040 0%, #2d2060 52%, #1a1040 100%);
}

.home-screen {
  position: relative;
  min-height: 100dvh;
  background: #1a1a2e;
  overflow: hidden;
}
.home-video, .menu-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #1a1a2e;
}
.home-copy {
  position: relative;
  z-index: 2;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: calc(24px + var(--safe-top)) 20px calc(28px + var(--safe-bottom));
  background: linear-gradient(180deg, rgba(26,26,46,0.2) 0%, rgba(26,26,46,0.05) 38%, rgba(26,26,46,0.82) 100%);
}
.home-copy:has(.home-hero) {
  justify-content: flex-start;
  background: linear-gradient(180deg, rgba(26,26,46,0.72) 0%, rgba(26,26,46,0.28) 24%, rgba(26,26,46,0) 46%, rgba(26,26,46,0.45) 100%);
}
.home-hero { width: 100%; display: flex; flex-direction: column; align-items: center; }
.home-hero .logo { font-size: 34px; font-weight: 800; letter-spacing: -0.5px; }
.home-hero .subtitle { margin: 8px 0 36px; font-size: 14px; }
.home-hero .mode { width: min(300px, 100%); min-height: 88px; margin-bottom: 0; }
.home-hero .home-actions { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.home-hero .text-btn { margin-top: 4px; }
.home-links {
  width: 100%;
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.home-copy h1 { margin: 0 0 6px; }

.play {
  position: relative;
  min-height: 100dvh;
  background: #1a1a2e;
}
.archie-video {
  position: absolute;
  left: 0;
  right: 0;
  top: 64px;
  bottom: 88px;
  width: 100%;
  height: calc(100% - 152px);
  margin: 0 auto;
  object-fit: contain;
  object-position: center center;
  background: #1a1a2e;
}
.play-top, .menu-top {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 64px;
  padding: calc(8px + var(--safe-top)) 12px 8px;
  background: #1a1a2e;
}
.top-left, .menu-tools, .talk-tools { display: flex; align-items: center; gap: 8px; }
.gold-icon { background: #ffd700; }
.menu-star { background: rgba(255, 152, 0, 0.35); }
.avatar-btn { padding: 3px; overflow: hidden; }
.avatar-btn img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.bar-talk .star-badge { display: none; }
.bar-math .play-title { color: #ffd700; font-size: 16px; }
.menu-screen.night { background: #0b1026; }
.menu-screen.night .menu-video,
.menu-screen.night .menu-slip {
  background: #0b1026;
  transition: opacity 0.9s ease;
}
.menu-screen.night .menu-slip {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
}
.menu-screen.night.settled .menu-slip { opacity: 1; }
.menu-screen.night.settled .menu-video { opacity: 0; }
.menu-screen.night::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.28);
  pointer-events: none;
  z-index: 1;
}
.menu-screen.night .menu-top,
.menu-screen.night .menu-title,
.menu-screen.night .subtitle { position: relative; z-index: 2; }
.menu-screen.night .cards,
.menu-screen.night .story-list,
.menu-screen.night .text-btn { position: relative; z-index: 2; }
.play-title { flex: 1; text-align: center; font-weight: 800; }
.play-title:empty { display: none; }
.star-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #ffd700;
  color: #333;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
}
.star-badge.marks {
  width: auto;
  min-width: 32px;
  height: auto;
  background: none;
  font-size: 22px;
}
.play-bubbles {
  position: relative;
  z-index: 2;
  padding: 8px 16px 120px;
}
.play .bubble {
  width: 100%;
  max-width: none;
  background: rgba(26, 26, 46, 0.78);
  border-radius: 16px;
  padding: 16px 18px;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.35;
}
.bubble-kicker {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
}
.bar-math .bubble {
  background: rgba(0, 0, 0, 0.55);
  border-radius: 12px;
  padding: 6px 12px;
  font-size: 15px;
}
.play-dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 84px;
  padding: 8px 16px calc(8px + var(--safe-bottom));
  background: #1a1a2e;
}
.next-round {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: #4caf50;
  color: white;
  font-size: 22px;
  font-weight: 800;
}
.say-btn {
  width: min(240px, 100%);
  height: 72px;
  border: 0;
  border-radius: 30px;
  background: #ffa500;
  color: white;
  font-size: 18px;
  font-weight: 800;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.28);
}
.say-btn.listen { background: #e53935; }
.say-btn.think { background: #777; }
.menu-title {
  position: relative;
  z-index: 2;
  margin: 0;
  text-align: center;
  font-size: 30px;
}
.menu-title span { color: #ffd54f; }
.sticker-card {
  width: 100%;
  border: 0;
  border-radius: 24px;
  padding: 12px 12px 16px;
  color: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.sticker-frame {
  width: 100%;
  background: #fff8e7;
  border-radius: 18px;
  padding: 10px 12px;
}
.sticker-frame img {
  width: 100%;
  aspect-ratio: 512 / 284;
  object-fit: contain;
  display: block;
}
.sticker-card .badge {
  margin-top: 12px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 12px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 600;
}
.sticker-card strong { font-size: 22px; margin-top: 8px; }
.sticker-card small { font-size: 14px; opacity: 0.92; margin-top: 4px; line-height: 1.35; }
.sticker-card .action {
  margin-top: 12px;
  background: white;
  border-radius: 14px;
  padding: 10px 28px;
  font-weight: 800;
}
.cards { position: relative; z-index: 2; display: flex; flex-direction: column; gap: 16px; padding: 8px 16px 24px; }
.story-list { display: flex; flex-direction: column; gap: 10px; padding: 8px 16px 24px; }
.story-btn {
  border: 0;
  border-radius: 18px;
  min-height: 64px;
  background: rgba(255, 255, 255, 0.14);
  color: white;
  font-size: 18px;
  font-weight: 700;
}
.noise-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }
.noise-card {
  aspect-ratio: 1;
  border: 0;
  border-radius: 16px;
  padding: 8px;
  background: rgba(74, 74, 90, 0.9);
}
.noise-card img { width: 100%; height: 100%; object-fit: contain; display: block; }
.noise-card.on { background: rgba(102, 126, 234, 0.95); }
.frame img { width: 100%; border-radius: 12px; display: block; }
.play.theater {
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #1a1040, #2d2060 40%, #1a1a2e);
}
.play.theater .archie-video, .play.theater .star-badge { display: none; }
.play.theater .play-title { text-align: left; font-size: 18px; }
.play.theater .play-top { justify-content: flex-start; }
.play.theater .play-bubbles { flex: 1; overflow: auto; padding-bottom: 12px; }
.play.theater .play-dock { position: relative; justify-content: flex-start; }
.theater-label { width: 100%; margin: 4px 0 0; text-align: left; color: rgba(255, 255, 255, 0.75); font-size: 13px; }
.order-slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: 100%; }
.order-slot {
  aspect-ratio: 1;
  border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.45);
  font-size: 20px;
  font-weight: 800;
  padding: 0;
  overflow: hidden;
}
.order-slot.filled { border-color: #ffd700; }
.order-slot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.theater-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.theater-grid .frame {
  width: auto;
  min-height: 0;
  aspect-ratio: 1.6;
  padding: 0;
  border-radius: 16px;
  overflow: hidden;
  background: white;
}
.theater-grid .frame img { height: 100%; object-fit: cover; border-radius: 0; }
.dock-link { background: none; border: 0; color: white; font-weight: 700; font-size: 16px; min-height: 44px; }
.check-btn {
  margin-left: auto;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 16px;
  background: #ff8c00;
  color: white;
  font-weight: 800;
}
.check-btn:disabled { background: rgba(255, 255, 255, 0.2); }
.center-copy { padding-top: 28vh; text-align: center; }
.center-copy h1 { margin-bottom: 12px; }

.math-card {
  width: min(100%, 420px);
  min-height: 200px;
  margin-top: 8px;
  background: white;
  color: #1a1a2e;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
}
.math-card .pane { background: transparent; color: #333; }
.math-card .count-row { font-size: 34px; letter-spacing: 4px; }
.bar-math .next-round { width: 58px; height: 58px; background: #43a047; font-size: 28px; }

.profile-screen, .report-screen {
  min-height: 100dvh;
  overflow: auto;
  padding: calc(24px + var(--safe-top)) 20px calc(28px + var(--safe-bottom));
  background: linear-gradient(180deg, #1a1a2e, #2d2b55 48%, #12121f);
}
.profile-logo { width: 88px; height: 88px; object-fit: contain; display: block; margin: 0 auto 12px; }
.profile-screen h1 { margin: 0; text-align: center; font-size: 28px; }
.profile-lead, .profile-note { text-align: center; color: rgba(255, 255, 255, 0.85); font-size: 15px; }
.profile-card { background: rgba(255, 255, 255, 0.1); border-radius: 20px; padding: 16px; margin: 16px 0; }
.profile-card p { font-size: 14px; line-height: 1.45; }
.profile-q { margin: 8px 0; font-size: 18px; }
.gender-row { display: flex; gap: 12px; }
.gender-chip {
  flex: 1;
  min-height: 56px;
  border-radius: 16px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.12);
}
.gender-chip.on { background: #667eea; border-color: #667eea; font-weight: 800; }
.profile-form label { display: block; margin: 10px 0; font-size: 14px; color: rgba(255, 255, 255, 0.75); }
.profile-form input, .pin-card input {
  width: 100%;
  margin-top: 6px;
  min-height: 48px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: transparent;
  padding: 0 14px;
}
.report-link, .profile-form .gold { width: 100%; min-height: 52px; border-radius: 16px; }
.report-link { border: 0; background: #667eea; font-weight: 800; margin: 8px 0 4px; }
.pin-screen { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: rgba(0, 0, 0, 0.45); }
.pin-card { width: min(100%, 420px); background: #2d2b55; border-radius: 24px; padding: 24px; text-align: center; }
.pin-lock { font-size: 36px; margin: 0; }
.pin-card h1 { margin: 0 0 8px; font-size: 20px; }
.report-head { display: flex; align-items: center; gap: 8px; }
.report-head h1 { margin: 0; font-size: 20px; text-align: left; }
.report-head p { margin: 0; color: #90a4ae; font-size: 14px; }
.summary-card { background: #2d2b55; border-radius: 20px; padding: 16px; margin: 16px 0; }
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; text-align: center; }
.summary-grid b { display: block; font-size: 17px; }
.summary-grid small { color: #90a4ae; font-size: 11px; }
.regular { color: #b0bec5; font-size: 13px; }
.week-bar { height: 8px; border-radius: 8px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.week-bar i { display: block; height: 100%; background: #66bb6a; }
.week-label { color: #66bb6a; font-weight: 800; }
.cat-row { background: #252347; border-radius: 14px; padding: 10px 12px; margin: 8px 0; }
.tip-card { background: #1b3a4b; color: #b3e5fc; border-radius: 16px; padding: 14px; }
.science-card { background: rgba(27, 94, 32, 0.35); color: #a5d6a7; border-radius: 16px; padding: 16px; font-size: 13px; line-height: 1.45; }
.report-card { display: flex; gap: 12px; align-items: flex-start; }
.report-card span { font-size: 28px; }
.report-card small { color: #ffd700; }
.report-card.empty { display: block; text-align: center; font-size: 15px; }

@font-face {
  font-family: "Snell Roundhand";
  src: url("./fonts/snell_roundhand.otf") format("opentype");
  font-display: swap;
}

.scene {
  position: relative;
  min-height: 100dvh;
  background: #1a1a2e;
  overflow: hidden;
}
.scene-fox {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(64px + var(--safe-top));
  bottom: calc(84px + var(--safe-bottom));
  width: 100%;
  height: calc(100% - 148px - var(--safe-top) - var(--safe-bottom));
  margin: auto;
  object-fit: contain;
  background: #1a1a2e;
}
.scene-bar {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  padding: calc(8px + var(--safe-top)) 16px 8px;
  background: #1a1a2e;
}
.scene-bar.bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  height: calc(84px + var(--safe-bottom));
  padding-bottom: calc(8px + var(--safe-bottom));
  justify-content: center;
}
.scene-bar.bottom.end { justify-content: flex-end; }
.scene-back {
  position: absolute;
  z-index: 4;
  top: calc(12px + var(--safe-top));
  left: 16px;
}
.icon-spacer { width: 44px; }
.icon-btn.big { width: 56px; height: 56px; font-size: 26px; background: rgba(255, 255, 255, 0.16); }
.icon-btn.danger { background: rgba(255, 82, 82, 0.35); }

.letter-stack {
  position: relative;
  z-index: 2;
  padding: 8px 24px 0;
  text-align: center;
}
.letter-instruction { margin: 0 0 8px; font-size: 18px; font-weight: 800; }
.letter-hint { margin: 0 0 8px; color: #ffd700; font-size: 14px; }
.letter-stars { min-width: 72px; text-align: right; font-size: 22px; }
#pad {
  width: 100%;
  height: 320px;
  border-radius: 16px;
  background: white;
  touch-action: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.refresh-btn {
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  background: #667eea;
  font-size: 28px;
}

.rhythm-scene { background: #1a1040; display: flex; flex-direction: column; }
.rhythm-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(8px + var(--safe-top)) 20px 0;
}
.rhythm-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px 20px calc(12px + var(--safe-bottom));
  text-align: center;
}
.rhythm-kicker { margin: 0; color: rgba(255, 255, 255, 0.7); font-size: 14px; font-weight: 800; }
.rhythm-body h1 { margin: 8px 0 0; font-size: 28px; }
.rhythm-sub { margin: 6px 0 0; color: rgba(255, 255, 255, 0.8); font-size: 15px; }
.rhythm-marks {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  margin-top: 22px;
}
.rhythm-chip, .rhythm-dot { display: inline-block; }
.rhythm-chip {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  line-height: 54px;
  font-size: 26px;
}
.rhythm-chip.on { background: white; transform: scale(1.08); }
.rhythm-dot { width: 18px; height: 18px; border-radius: 50%; background: rgba(255, 255, 255, 0.28); }
.rhythm-dot.on { background: white; }
.rhythm-pads { display: flex; gap: 16px; margin-top: auto; }
.rhythm-pad {
  flex: 1;
  height: 168px;
  border: 0;
  border-radius: 28px;
  color: white;
  font-size: 16px;
  font-weight: 800;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.rhythm-pad span { font-size: 42px; }
.rhythm-pad.drum { background: #e65100; }
.rhythm-pad.bell { background: #f9a825; }
.rhythm-pad.drum.on { background: #ffcc80; }
.rhythm-pad.bell.on { background: #fff59d; color: #4e342e; }
.rhythm-next, .rhythm-next-gap { height: 56px; margin-top: 18px; }
.rhythm-next {
  width: 100%;
  border: 0;
  border-radius: 18px;
  background: #4caf50;
  color: white;
  font-size: 18px;
  font-weight: 800;
}

.breathe-scene { background: #0b1026; }
.breathe-scene .scene-fox, .lullaby-scene .scene-fox {
  inset: 0;
  width: 100%;
  height: 100%;
  max-height: none;
  top: 0;
  bottom: 0;
}
.breathe-scene .scene-fox { object-fit: cover; }
.lullaby-scene .scene-fox { object-fit: contain; background: #0f0f1e; }
.breathe-shade {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(180deg, rgba(11, 16, 38, 0.55), transparent 28%, transparent 68%, rgba(11, 16, 38, 0.65));
}
.breathe-copy {
  position: relative;
  z-index: 2;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(72px + var(--safe-top)) 24px calc(32px + var(--safe-bottom));
  text-align: center;
}
.breathe-copy h1 { margin: 0; font-size: 24px; }
.breathe-copy #phase { margin: 8px 0 0; color: rgba(184, 201, 255, 0.85); font-size: 16px; }
.breathe-foot { margin-top: auto; color: rgba(255, 255, 255, 0.55); font-size: 14px; }

.noise-scene .scene-fox { top: 0; bottom: 0; height: 100%; }
.noise-copy {
  position: relative;
  z-index: 2;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(120px + var(--safe-top)) 24px calc(24px + var(--safe-bottom));
  text-align: center;
  background: linear-gradient(180deg, rgba(15, 12, 41, 0.2), rgba(48, 43, 99, 0.25));
}
.noise-copy h1 { margin: 0; font-size: 28px; }
.noise-copy > p { margin: 4px 0 32px; color: rgba(255, 255, 255, 0.8); font-size: 14px; }
.volume { width: 100%; margin-top: 8px; font-size: 14px; }
.volume input { width: 100%; margin-top: 8px; accent-color: #667eea; }

.story-scene .scene-bar h1 {
  margin: 0;
  flex: 1;
  text-align: center;
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.story-card {
  position: relative;
  z-index: 2;
  height: 286px;
  margin: 0 24px;
  border-radius: 16px;
  overflow: hidden;
  background: white;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}
.story-card img { width: 100%; height: 100%; object-fit: fill; display: block; }

.lullaby-scene { background: #0f0f1e; }
.lullaby-title {
  position: absolute;
  z-index: 3;
  top: calc(16px + var(--safe-top));
  left: 72px;
  right: 72px;
  margin: 0;
  text-align: center;
  font-size: 20px;
}
.lullaby-soon {
  position: absolute;
  z-index: 3;
  left: 28px;
  right: 28px;
  bottom: calc(120px + var(--safe-bottom));
  margin: 0;
  text-align: center;
  color: rgba(255, 255, 255, 0.85);
}
.lullaby-controls {
  position: absolute;
  z-index: 3;
  left: 0;
  right: 0;
  bottom: calc(28px + var(--safe-bottom));
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
}

.pick-screen {
  position: relative;
  min-height: 100dvh;
  background: #0f0f1e;
  padding: calc(64px + var(--safe-top)) 16px 24px;
}
.pick-screen h1 { margin: 0 0 16px; text-align: center; font-size: 28px; }
.pick-lead { margin: -12px 0 12px; text-align: center; color: rgba(255, 255, 255, 0.75); font-size: 15px; }
.pick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pick-card {
  min-height: 72px;
  border: 0;
  border-radius: 16px;
  padding: 8px 12px;
  background: rgba(102, 126, 234, 0.9);
  color: white;
  font-size: 14px;
  font-weight: 800;
  text-align: center;
}
.pick-card.lullaby { background: rgba(92, 77, 138, 0.92); }
.pick-card small { display: block; margin-top: 2px; font-size: 12px; font-weight: 500; color: rgba(255, 255, 255, 0.75); }
.pick-status, .pick-empty { grid-column: 1 / -1; text-align: center; }
.pick-empty { padding-top: 48px; }
.pick-empty p { color: rgba(255, 255, 255, 0.8); }


@media (min-width: 800px) {
  body { background: #101221; }
  .app {
    min-height: calc(100dvh - 32px);
    margin: 16px auto;
    border-radius: 28px;
    overflow: hidden;
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.45);
  }
  .screen { min-height: calc(100dvh - 32px); }
}
