:root {
  color-scheme: dark;
  --ink: #f8fbf7;
  --muted: rgba(248, 251, 247, 0.72);
  --panel: rgba(17, 25, 23, 0.78);
  --panel-solid: #16231f;
  --line: rgba(255, 255, 255, 0.18);
  --teal: #17a398;
  --teal-dark: #0a6d66;
  --coral: #f06449;
  --gold: #f4c542;
  --blue: #60a5fa;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  color: var(--ink);
  background: #09100f;
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  letter-spacing: 0;
}

button {
  font: inherit;
}

.cinema-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #09100f;
}

.cinema-stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 12px;
  padding: 18px;
}

.hud {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.lesson-chip,
.hud-actions,
.playbar,
.teacher-cue,
.practice-board,
.card-focus,
.drawer-head,
.activity-tabs,
.transcript-line,
.step-list li {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.lesson-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 10px 13px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 10px;
  color: #fff;
  background: var(--teal-dark);
  font-size: 30px;
  font-weight: 900;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.18);
}

.lesson-chip strong,
.lesson-chip small {
  display: block;
}

.lesson-chip strong {
  font-size: 20px;
  line-height: 1.15;
}

.lesson-chip small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.hud-actions {
  display: flex;
  gap: 8px;
  padding: 7px;
}

.hud-button,
.play-button,
.round-button,
.main-play,
.ghost-button,
.tab,
.activity-chip {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  font-weight: 900;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.hud-button,
.play-button,
.ghost-button,
.tab,
.activity-chip {
  padding: 0 14px;
}

.round-button {
  width: 46px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 30px;
  line-height: 1;
}

.main-play {
  min-width: 140px;
  padding: 0 18px;
  color: #101815;
  border-color: rgba(244, 197, 66, 0.82);
  background: var(--gold);
}

.primary,
.tab.active,
.activity-chip.active,
.ghost-button.primary {
  color: #fff;
  border-color: var(--teal);
  background: var(--teal-dark);
}

.playing {
  color: #101815;
  border-color: var(--gold);
  background: var(--gold);
}

button:hover {
  transform: translateY(-1px);
}

.animated-slide {
  position: relative;
  width: min(100%, calc((100vh - 228px) * 16 / 9));
  max-height: calc(100vh - 228px);
  aspect-ratio: 16 / 9;
  justify-self: center;
  align-self: center;
  margin: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 16px;
  background: #111715;
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.58);
  outline: none;
  transform-origin: center;
}

.animated-slide:focus-visible {
  box-shadow: 0 0 0 4px rgba(244, 197, 66, 0.5), 0 32px 90px rgba(0, 0, 0, 0.58);
}

.scene-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #111715;
  transition: filter 220ms ease;
}

.scene-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 110px rgba(0, 0, 0, 0.28);
  z-index: 2;
}

.scene-motion,
.scene-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 5;
}

.scene-caption {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 16px;
  z-index: 12;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 12px;
  align-items: end;
  padding: 12px 15px;
  border-radius: 12px;
  background: rgba(9, 16, 15, 0.78);
  backdrop-filter: blur(12px);
}

.scene-caption span {
  color: var(--gold);
  font-size: 13px;
  font-weight: 900;
}

.scene-caption strong {
  font-size: 23px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.scene-caption small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.35;
}

.enter-a {
  animation: slideZoom 760ms cubic-bezier(0.18, 0.8, 0.2, 1);
}

.enter-b {
  animation: slideSweep 760ms cubic-bezier(0.18, 0.8, 0.2, 1);
}

.enter-c {
  animation: slideFlip 760ms cubic-bezier(0.18, 0.8, 0.2, 1);
}

.pulse-stage .scene-image {
  filter: brightness(0.72) saturate(0.86);
}

@keyframes slideZoom {
  from { opacity: 0; transform: scale(0.86); filter: blur(10px); }
  to { opacity: 1; transform: scale(1); filter: blur(0); }
}

@keyframes slideSweep {
  from { opacity: 0; transform: translateX(8%) scale(0.96); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes slideFlip {
  from { opacity: 0; transform: perspective(900px) rotateY(-10deg) scale(0.94); }
  to { opacity: 1; transform: perspective(900px) rotateY(0) scale(1); }
}

.scene-fragment {
  position: absolute;
  overflow: hidden;
  border-radius: 12px;
  opacity: 0;
  transform-origin: center;
  will-change: transform, opacity, filter;
  box-shadow: 0 22px 46px rgba(0, 0, 0, 0.36), 0 0 0 4px rgba(244, 197, 66, 0.38);
}

.scene-fragment img {
  position: absolute;
  display: block;
  max-width: none;
  object-fit: fill;
}

.anim-fade { animation: fragmentFade 1200ms ease-out forwards; }
.anim-fly { animation: fragmentFly 1250ms cubic-bezier(0.16, 0.9, 0.18, 1) forwards; }
.anim-zoom { animation: fragmentZoom 1200ms cubic-bezier(0.16, 0.9, 0.18, 1) forwards; }
.anim-spin { animation: fragmentSpin 1250ms cubic-bezier(0.16, 0.9, 0.18, 1) forwards; }
.anim-bounce { animation: fragmentBounce 1150ms cubic-bezier(0.16, 0.9, 0.18, 1) forwards; }
.anim-flip { animation: fragmentFlip 1250ms cubic-bezier(0.16, 0.9, 0.18, 1) forwards; }
.anim-exit { animation: fragmentExit 1000ms ease-in forwards; }

@keyframes fragmentFade {
  0% { opacity: 0; transform: scale(0.98); filter: blur(10px); }
  55% { opacity: 1; filter: blur(0); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes fragmentFly {
  0% { opacity: 0; transform: translateY(-88%) translateX(-10%) scale(0.82); filter: blur(8px); }
  60% { opacity: 1; transform: translateY(7%) translateX(2%) scale(1.06); filter: blur(0); }
  100% { opacity: 1; transform: translateY(0) translateX(0) scale(1); }
}

@keyframes fragmentZoom {
  0% { opacity: 0; transform: scale(0.05) rotate(-7deg); filter: blur(8px); }
  72% { opacity: 1; transform: scale(1.12) rotate(1deg); filter: blur(0); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

@keyframes fragmentSpin {
  0% { opacity: 0; transform: scale(0.1) rotate(-150deg); filter: blur(8px); }
  70% { opacity: 1; transform: scale(1.08) rotate(10deg); filter: blur(0); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

@keyframes fragmentBounce {
  0% { opacity: 0; transform: translateY(60px) scale(0.55); }
  48% { opacity: 1; transform: translateY(-16px) scale(1.12); }
  72% { transform: translateY(6px) scale(0.98); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes fragmentFlip {
  0% { opacity: 0; transform: perspective(700px) rotateX(82deg) scale(0.72); }
  70% { opacity: 1; transform: perspective(700px) rotateX(-8deg) scale(1.05); }
  100% { opacity: 1; transform: perspective(700px) rotateX(0) scale(1); }
}

@keyframes fragmentExit {
  0% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: translateY(80%) scale(0.72); filter: blur(8px); }
}

.sound-pop {
  position: absolute;
  z-index: 14;
  min-width: 96px;
  min-height: 96px;
  display: grid;
  place-items: center;
  padding: 14px;
  border-radius: 50%;
  color: #101815;
  background: var(--gold);
  box-shadow: 0 20px 52px rgba(0, 0, 0, 0.38), 0 0 0 10px rgba(244, 197, 66, 0.22);
  font-size: 38px;
  font-weight: 900;
  animation: soundPop 1300ms cubic-bezier(0.14, 0.9, 0.2, 1) forwards;
}

@keyframes soundPop {
  0% { opacity: 0; transform: scale(0.2) rotate(-10deg); }
  34% { opacity: 1; transform: scale(1.16) rotate(3deg); }
  74% { opacity: 1; transform: scale(0.96) rotate(0); }
  100% { opacity: 0; transform: scale(1.26) translateY(-22px); }
}

.scene-particles span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--c);
  animation: particleBurst 950ms ease-out forwards;
}

@keyframes particleBurst {
  from { opacity: 0; transform: translate(0, 0) scale(0.2); }
  20% { opacity: 1; }
  to { opacity: 0; transform: translate(var(--x), var(--y)) scale(1); }
}

.playbar {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: 46px auto auto auto minmax(160px, 1fr) auto 46px;
  gap: 8px;
  align-items: center;
  padding: 9px;
}

.timeline {
  min-width: 0;
}

.timeline span {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

progress {
  width: 100%;
  height: 9px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
}

progress::-webkit-progress-bar {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
}

progress::-webkit-progress-value {
  border-radius: 999px;
  background: var(--gold);
}

.phonics-marquee {
  position: relative;
  z-index: 18;
  display: flex;
  gap: 10px;
  min-height: 48px;
  overflow: hidden;
  padding: 0 4px;
}

.sound-chip {
  flex: 0 0 auto;
  min-width: 78px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #101815;
  background: #fff8d9;
  font-size: 22px;
  font-weight: 900;
  animation: chipDance 1800ms ease-in-out infinite;
}

@keyframes chipDance {
  0%, 100% { transform: translateY(0) rotate(0); }
  45% { transform: translateY(-8px) rotate(-2deg); }
  70% { transform: translateY(2px) rotate(1deg); }
}

.mini-strip {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 92px;
  z-index: 19;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(96px, 128px);
  gap: 8px;
  overflow-x: auto;
  opacity: 0.18;
  transition: opacity 180ms ease;
}

.mini-strip:hover {
  opacity: 1;
}

.thumb-button {
  aspect-ratio: 16 / 9;
  padding: 0;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 8px;
  background: #111;
  cursor: pointer;
}

.thumb-button.active {
  border-color: var(--gold);
}

.thumb-button img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.lesson-drawer,
.tool-drawer {
  position: fixed;
  z-index: 50;
  top: 0;
  bottom: 0;
  width: min(420px, calc(100vw - 24px));
  padding: 18px;
  overflow: auto;
  background: rgba(9, 16, 15, 0.94);
  backdrop-filter: blur(18px);
  transition: transform 260ms ease;
}

.lesson-drawer {
  left: 0;
  transform: translateX(-104%);
}

.tool-drawer {
  right: 0;
  transform: translateX(104%);
}

.lesson-drawer.open,
.tool-drawer.open {
  transform: translateX(0);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding: 10px;
}

.lesson-list,
.phase-list,
.activity-menu,
.card-grid,
.transcript,
.step-list {
  display: grid;
  gap: 8px;
}

.lesson-button,
.phase-button {
  width: 100%;
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 9px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  text-align: left;
}

.lesson-button span {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--coral);
  font-weight: 900;
}

.lesson-button strong,
.lesson-button small,
.phase-button strong,
.phase-button small {
  display: block;
}

.lesson-button small,
.phase-button small {
  color: var(--muted);
  font-size: 12px;
}

.lesson-button.active,
.phase-button.active {
  border-color: var(--gold);
  background: rgba(244, 197, 66, 0.16);
}

.phase-list {
  margin-top: 12px;
}

.phase-button {
  grid-template-columns: 1fr auto;
}

.teacher-cue {
  padding: 13px;
  margin-bottom: 12px;
}

.teacher-cue span {
  display: block;
  margin-bottom: 7px;
  color: var(--gold);
  font-weight: 900;
}

.teacher-cue p {
  margin: 0;
  line-height: 1.55;
}

.activity-tabs,
.card-tools,
.practice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.activity-menu {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 10px;
}

.activity-chip {
  min-width: 0;
  padding: 0 8px;
  font-size: 13px;
}

.practice-board {
  padding: 14px;
}

.practice-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

#activityKind {
  display: inline-grid;
  place-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 8px;
  color: #101815;
  background: var(--gold);
  font-weight: 900;
}

#activityTitle {
  margin: 10px 0 6px;
  font-size: 22px;
}

#activityPrompt {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.target-card {
  min-height: 160px;
  display: grid;
  place-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 12px;
  border: 2px solid rgba(244, 197, 66, 0.35);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
}

.target-card img {
  max-width: 132px;
  max-height: 104px;
  object-fit: contain;
}

.target-card strong {
  font-size: 42px;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.choice-button {
  min-height: 92px;
  display: grid;
  place-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
}

.choice-button.correct {
  border-color: var(--gold);
  background: rgba(244, 197, 66, 0.22);
}

.choice-button img {
  max-width: 70px;
  max-height: 58px;
  object-fit: contain;
}

.choice-button span {
  font-size: 24px;
  font-weight: 900;
}

.answer-panel {
  margin-top: 10px;
  padding: 10px 12px;
  border-left: 4px solid var(--gold);
  background: rgba(255, 255, 255, 0.08);
  font-weight: 900;
}

.card-focus {
  min-height: 190px;
  display: grid;
  place-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding: 12px;
}

.card-focus img {
  max-width: 100%;
  max-height: 138px;
  object-fit: contain;
}

.card-focus strong {
  font-size: 36px;
}

.card-grid {
  grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
}

.card-button {
  aspect-ratio: 1;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
}

.card-button.active {
  border-color: var(--gold);
  background: rgba(244, 197, 66, 0.16);
}

.card-button img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.transcript-line,
.step-list li {
  padding: 10px;
  line-height: 1.45;
}

.step-list {
  padding: 0;
  margin: 10px 0 0;
  list-style: none;
}

.step-list li {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 8px;
}

.step-list li.active {
  border-color: var(--gold);
}

.step-list li span {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--teal-dark);
  font-weight: 900;
}

.step-list li strong,
.step-list li small {
  display: block;
}

.step-list li small {
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 900px) {
  html,
  body {
    overflow-y: auto;
  }

  .cinema-shell {
    min-height: 100vh;
    height: auto;
    overflow: visible;
  }

  .cinema-stage {
    min-height: 100vh;
    padding: 12px;
    grid-template-rows: auto auto auto auto;
  }

  .hud {
    align-items: flex-start;
    flex-direction: column;
  }

  .hud-actions {
    flex-wrap: wrap;
  }

  .animated-slide {
    width: 100%;
    max-height: none;
  }

  .scene-caption {
    left: 8px;
    right: 8px;
    bottom: 8px;
    padding: 9px 10px;
  }

  .scene-caption strong {
    font-size: 18px;
  }

  .scene-caption small {
    font-size: 13px;
  }

  .playbar {
    grid-template-columns: 46px 1fr 46px;
  }

  #prevSlideBtn { grid-column: 1; grid-row: 1; }
  #playCourseBtn { grid-column: 2; grid-row: 1; }
  #nextSlideBtn { grid-column: 3; grid-row: 1; }
  #playPageBtn { grid-column: 1 / 2; grid-row: 2; }
  #prevStepBtn { grid-column: 2 / 3; grid-row: 2; }
  #nextStepBtn { grid-column: 3 / 4; grid-row: 2; }
  .timeline { grid-column: 1 / -1; grid-row: 3; }

  .mini-strip {
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
    opacity: 1;
  }

  .lesson-drawer,
  .tool-drawer {
    width: min(420px, 100vw);
  }
}

@media (max-width: 520px) {
  .lesson-chip {
    width: 100%;
  }

  .hud-actions,
  .hud-button {
    width: 100%;
  }

  .hud-button {
    flex: 1 1 auto;
  }

  .activity-menu,
  .choice-grid {
    grid-template-columns: 1fr;
  }
}
