#app-shell {
  width: min(1180px, calc(100vw - 24px));
  margin: 16px auto;
  min-height: calc(100vh - 32px);
  background:
    linear-gradient(170deg, rgba(12, 14, 27, 0.86), rgba(17, 20, 35, 0.7)),
    radial-gradient(circle at 90% 10%, rgba(77, 228, 247, 0.08), transparent 32%);
  border: 1px solid var(--border);
  border-radius: 24px;
  overflow: hidden;
  box-shadow:
    0 22px 60px var(--shadow),
    inset 0 0 0 1px rgba(255, 126, 95, 0.16);
  backdrop-filter: blur(8px) saturate(120%);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 22px;
  position: relative;
  background:
    linear-gradient(90deg, rgba(17, 17, 31, 0.92), rgba(17, 15, 28, 0.7)),
    radial-gradient(circle at 75% 0, rgba(255, 126, 95, 0.15), transparent 40%);
  border-bottom: 1px solid var(--border);
}

.cyoa-footer {
  justify-content: center;
  border-top: 1px solid var(--border);
  border-bottom: 0;
}

.cyoa-back-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 180px;
  text-decoration: none;
  text-align: center;
}

.topbar-actions {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  gap: 10px;
  justify-content: center;
}

.music-player {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  min-width: min(520px, 52vw);
  margin-inline: auto;
  padding: 9px 12px;
  background: rgba(7, 9, 20, 0.48);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.music-controls,
.volume-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.music-controls {
  min-width: 0;
  display: contents;
}

.music-track {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.music-label {
  color: var(--accent-cyan);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.14rem;
  line-height: 1;
  text-transform: uppercase;
}

.music-status {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 600;
}

.music-transport {
  display: flex;
  align-items: center;
  gap: 5px;
}

.music-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 36px;
  min-height: 36px;
  padding: 6px;
  line-height: 1;
  text-align: center;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.music-button:hover,
.music-button:focus-visible {
  color: var(--accent-strong);
  border-color: rgba(255, 209, 102, 0.62);
  background: rgba(255, 126, 95, 0.16);
  box-shadow: 0 0 16px rgba(255, 126, 95, 0.18);
}

.music-play-pause {
  color: #1f1025;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  border-color: transparent;
  font-size: 0.85rem;
}

.music-play-pause:hover,
.music-play-pause:focus-visible {
  color: #1f1025;
  background: linear-gradient(135deg, #ff997b 0%, #ffe08b 100%);
}

.volume-controls input {
  width: min(150px, 100%);
  height: 20px;
  margin: 0;
  cursor: pointer;
  appearance: none;
  background: transparent;
}

.volume-controls input::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent));
  box-shadow: 0 0 10px rgba(77, 228, 247, 0.25);
}

.volume-controls input::-moz-range-track {
  height: 4px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent));
  box-shadow: 0 0 10px rgba(77, 228, 247, 0.25);
}

.volume-controls input::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  margin-top: -5px;
  appearance: none;
  border: 2px solid var(--text);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(255, 126, 95, 0.55);
}

.volume-controls input::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border: 2px solid var(--text);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(255, 126, 95, 0.55);
}

.volume-controls input:focus-visible {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 4px;
}

.screen {
  display: none;
  min-height: 70vh;
  padding: 24px;
}

.screen.active {
  display: block;
}

.screen.scene-reveal {
  animation: screenFadeIn 380ms ease both;
}

@keyframes screenFadeIn {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.secondary-button,
.ghost-button,
.primary-button,
.choice-button,
.inline-button,
.story-button {
  border: 1px solid transparent;
  border-radius: 12px;
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    background 0.18s ease,
    box-shadow 0.18s ease,
    color 0.18s ease;
}

.secondary-button:hover,
.ghost-button:hover,
.primary-button:hover,
.choice-button:hover,
.inline-button:hover,
.story-button:hover {
  transform: translateY(-2px);
}

.secondary-button,
.ghost-button {
  padding: 10px 16px;
  color: var(--text);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.01));
  border-color: var(--border);
}

.primary-button {
  padding: 12px 20px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #1f1025;
  font-weight: 800;
  box-shadow: 0 10px 30px rgba(255, 126, 95, 0.35);
}

.inline-button {
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border);
  color: var(--text);
}

#music-mute[data-muted="true"] {
  color: var(--danger);
}

.story-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.story-card,
.panel,
.timeline-card,
.summary-card {
  background:
    linear-gradient(180deg, rgba(30, 24, 45, 0.8), rgba(13, 16, 29, 0.9)),
    radial-gradient(circle at 90% 0, rgba(77, 228, 247, 0.12), transparent 42%);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.28);
}

.summary-card {
  padding: 22px;
}
