:root {
  color-scheme: light;
  font-family: "Arial Rounded MT Bold", ui-rounded, system-ui, sans-serif;
  --green: #45c7ff;
  --green-dark: #159fe6;
  --green-soft: #d8f5ff;
  --orange: #28b8ff;
  --blue-deep: #0875c9;
  --glass: rgba(255, 255, 255, .42);
  --glass-strong: rgba(255, 255, 255, .66);
  --glass-border: rgba(255, 255, 255, .82);
  --control-blue-gradient: linear-gradient(145deg, #7cddff 0%, var(--green) 55%, #1fb2f0 100%);
  --lesson-blue: #f8fdff;
  --lesson-blue-wash:
    radial-gradient(circle at 12% 15%, rgba(190, 239, 255, .45), transparent 27%),
    radial-gradient(circle at 90% 75%, rgba(203, 245, 255, .38), transparent 28%),
    var(--lesson-blue);
  --ink: #171717;
  --muted: #6b7789;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--lesson-blue);
  color: var(--ink);
}
button { font: inherit; -webkit-tap-highlight-color: transparent; }
button:focus, button:focus-visible { outline: none; }
[tabindex]:focus-visible { outline: 4px solid rgba(53, 127, 230, .38); outline-offset: 3px; }

.lesson-shell {
  position: relative;
  width: 100vw;
  min-height: min(100vh, 760px);
  height: 100vh;
  overflow: hidden;
  border: 0;
  background: var(--lesson-blue);
  box-shadow: none;
}

.lesson-header {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 20;
  height: 100px;
  display: flex;
  align-items: center;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: max(clamp(36px, 4vw, 64px), calc(env(safe-area-inset-left, 0px) + 18px));
  padding-right: max(clamp(36px, 4vw, 64px), calc(env(safe-area-inset-right, 0px) + 18px));
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  color: var(--blue-deep);
}

.lesson-title { display: grid; align-content: center; gap: 2px; margin-right: 20px; color: var(--green); line-height: 1.05; }
#course-code { color: var(--green); font-size: clamp(25px, 2.35vw, 34px); letter-spacing: .02em; text-shadow: none; }
.lesson-title span { font-size: clamp(16px, 1.45vw, 22px); font-weight: 900; letter-spacing: .04em; }
.header-actions { margin-left: auto; display: flex; gap: 18px; }
.round-button, .nav-button, .header-back-button {
  border: 1px solid var(--glass-border); border-radius: 50%; color: var(--blue-deep);
  background: linear-gradient(145deg, rgba(220,246,255,.88), rgba(92,204,250,.38));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.98), inset 0 -2px 0 rgba(20,148,220,.2), 0 10px 0 rgba(14,137,202,.13), 0 15px 28px rgba(3,111,183,.22);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  cursor: pointer; transition: transform .16s ease, filter .16s ease, box-shadow .16s ease;
}
.round-button { width: 84px; height: 84px; font-size: 27px; font-weight: 950; letter-spacing: 1px; }
.lesson-header .round-button, .lesson-header .header-back-button {
  color: white; border-color: rgba(255,255,255,.9); background: var(--control-blue-gradient);
}
.round-button svg { width: 43px; height: 43px; display: block; margin: auto; color: white; fill: currentColor; filter: drop-shadow(0 2px 3px rgba(2,85,140,.35)); }
.header-back-button { flex: 0 0 auto; width: 72px; height: 72px; margin: 0 16px 0 0; padding: 0; color: white; text-shadow: 0 2px 4px rgba(2,85,140,.42); font-size: 44px; font-weight: 900; line-height: 1; }
.header-back-button span {
  display: block;
  width: 32px;
  height: 28px;
  margin: auto;
  background: currentColor;
  clip-path: polygon(0 50%, 55% 8%, 55% 34%, 100% 34%, 100% 66%, 55% 66%, 55% 92%);
  transform: none;
  font-size: 0;
}
.round-button:hover, .nav-button:not(:disabled):hover, .header-back-button:hover { transform: translateY(-2px) scale(1.02); filter: brightness(1.06) saturate(1.12); box-shadow: inset 0 1px 0 white, 0 10px 26px rgba(3,111,183,.28); }
.round-button:active, .nav-button:not(:disabled):active, .header-back-button:active { transform: translateY(5px) scale(.98); box-shadow: inset 0 1px 0 white, inset 0 -1px 0 rgba(20,148,220,.18), 0 4px 0 rgba(14,137,202,.13), 0 8px 18px rgba(3,111,183,.2); }

.sound-bars { display: none; position: absolute; left: 50%; top: 50%; align-items: end; gap: 5px; height: 28px; transform: translate(-50%,-50%); }
.audio-button.playing .replay-icon { display: none; }
.audio-button.playing .sound-bars { display: flex; }
.sound-bars i { display: block; width: 5px; height: 35%; border-radius: 5px; background: #fff; animation: bars .55s infinite alternate; }
.sound-bars i:nth-child(2) { height: 90%; animation-delay: .16s; }
.sound-bars i:nth-child(3) { height: 58%; animation-delay: .32s; }

.lesson-scene { position: absolute; inset: 0; background: var(--lesson-blue-wash); }
.game-stage { position: absolute; inset: 86px 8px 104px; display: grid; place-items: center; }
.scene-canvas {
  position: relative;
  width: min(100%, calc((100vh - 190px) * 1.7928));
  max-height: 100%;
  aspect-ratio: 1800 / 1004;
  overflow: hidden;
  background: transparent;
}
.actor-layer {
  position: absolute;
  z-index: 3;
  left: 32.55%;
  top: 0;
  width: 34.9%;
  height: 100%;
  object-fit: cover;
  mix-blend-mode: multiply;
  user-select: none;
  -webkit-user-drag: none;
  transition: opacity .16s ease, transform .25s ease;
}
.garment-hotspots { position: absolute; z-index: 6; inset: 0; }
.garment-card {
  position: absolute;
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-drag: none;
  transition: box-shadow .2s ease, transform .2s ease;
}
.garment-card img { position: absolute; max-width: none; object-fit: fill; opacity: 1; pointer-events: none; }
.garment-card span { display: none; }
.garment-card:hover { transform: scale(1.03); }
.garment-card.is-worn { opacity: 0; background: transparent; box-shadow: none; cursor: default; }
.garment-card.is-wrong { animation: shake .38s ease; box-shadow: 0 0 0 6px rgba(255,93,79,.6); }
.garment-card.is-dragging { opacity: 0; background: transparent; box-shadow: none; }
.garment-card[data-item="dress"] { left: 3.4%; top: 4.8%; width: 11.7%; height: 35.5%; overflow: hidden; border-radius: 0; background: transparent; }
.garment-card[data-item="jacket"] { left: 78.3%; top: 9.8%; width: 17.2%; height: 25.9%; }
.garment-card[data-item="skirt"] { left: 3.2%; top: 44.4%; width: 11.3%; height: 19.4%; }
.garment-card[data-item="shoes"] { left: 22.3%; top: 49.1%; width: 9.7%; height: 17%; }
.garment-card[data-item="socks"] { left: 64.2%; top: 49%; width: 12%; height: 19%; }
.garment-card[data-item="shirt"] { left: 79.4%; top: 41.2%; width: 15.1%; height: 28.6%; }
.garment-card[data-item="sweater"] { left: 1.6%; top: 71.6%; width: 16.2%; height: 26.2%; }
.garment-card[data-item="pants"] { left: 82.2%; top: 72.8%; width: 10%; height: 27%; }
@keyframes shake { 25% { transform: translateX(-8px) rotate(-2deg); } 60% { transform: translateX(8px) rotate(2deg); } }

.leo-target {
  position: absolute; z-index: 7; left: 38%; top: 2%; width: 24%; height: 80%;
  border: 0; border-radius: 45%; background: transparent; cursor: default;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.leo-target.is-active { cursor: grab; }
.leo-target.is-dragging { cursor: grabbing; }

.caption-wrap {
  position: absolute; z-index: 15;
  left: max(clamp(44px, 5vw, 84px), calc(env(safe-area-inset-left, 0px) + 22px));
  right: max(clamp(44px, 5vw, 84px), calc(env(safe-area-inset-right, 0px) + 22px));
  bottom: 24px;
  --nav-control-height: 108px;
  --caption-height: 104px;
  display: grid; grid-template-columns: var(--nav-control-height) minmax(0, 1fr) var(--nav-control-height); gap: clamp(14px, 2vw, 28px); align-items: center;
}
.nav-button {
  --nav-icon-width: 38px;
  --nav-icon-height: 44px;
  position: relative;
  width: var(--nav-control-height); height: var(--nav-control-height); color: white;
  border-color: rgba(255,255,255,.9);
  background: var(--control-blue-gradient);
  display: grid; place-items: center; padding: 0;
  text-shadow: 0 2px 4px rgba(2,85,140,.42); font-size: 0; line-height: 0;
}
.nav-button::before {
  content: "";
  display: block;
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--nav-icon-width);
  height: var(--nav-icon-height);
  background: currentColor;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 2px 3px rgba(2,85,140,.3));
}
#nav-prev::before { clip-path: polygon(100% 0, 0 50%, 100% 100%); }
#nav-next::before { clip-path: polygon(0 0, 100% 50%, 0 100%); }
.nav-button:disabled {
  color: rgba(255,255,255,.78);
  border-color: rgba(255,255,255,.7);
  background: linear-gradient(145deg, rgba(211,221,228,.9), rgba(153,171,184,.72));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.82), 0 6px 0 rgba(111,132,145,.16), 0 10px 18px rgba(61,83,96,.12);
  filter: saturate(.18);
  cursor: default;
  transform: none;
}
#nav-prev { grid-column: 1; }
#nav-next { grid-column: 3; }
.caption-pill {
  position: relative; grid-column: 2;
  width: 100%; height: var(--caption-height); min-height: var(--caption-height); padding: 4px 24px; display: grid; place-items: center;
  border: 1px solid rgba(255,255,255,.38); border-radius: calc(var(--caption-height) / 2); background: linear-gradient(145deg, rgba(255,255,255,.12), rgba(67,190,244,.045));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.48), 0 5px 16px rgba(3,111,183,.055);
  backdrop-filter: blur(1px) saturate(108%); -webkit-backdrop-filter: blur(1px) saturate(108%);
  color: var(--ink); text-align: center; cursor: default;
}
.sentence-copy { min-width: 0; }
.sentence-copy strong { display: block; margin: 0; font-size: clamp(24px, 2.5vw, 34px); line-height: 1; text-shadow: 0 1px 2px rgba(255,255,255,.98), 0 0 8px rgba(255,255,255,.9); }
.feedback { display: none; }
.feedback.is-wrong { color: #ec574b; }

@keyframes bars { to { height: 100%; } }

.menu-backdrop {
  position: absolute;
  z-index: 29;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(2,45,75,.34);
  cursor: default;
}

.course-menu {
  position: absolute; z-index: 30; inset: 0 0 0 auto; width: min(360px, 58vw);
  padding: 46px 26px 24px; overflow-y: auto; color: #0875c9;
  background: linear-gradient(180deg, rgba(222,247,255,.82), rgba(151,222,252,.68));
  border-left: 1px solid rgba(255,255,255,.86);
  box-shadow: -12px 0 34px rgba(2,98,163,.22);
  backdrop-filter: blur(30px) saturate(180%); -webkit-backdrop-filter: blur(30px) saturate(180%);
  visibility: visible;
  opacity: 1;
  contain: layout paint;
  transform: translateZ(0);
  will-change: opacity;
  scrollbar-gutter: stable;
  transition: opacity .14s ease;
}
.course-menu[hidden] { display: block !important; visibility: hidden; opacity: 0; pointer-events: none; }
.menu-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.menu-head strong { font-size: 26px; }
.menu-head button { width: 44px; height: 44px; border: 1px solid var(--glass-border); border-radius: 50%; background: linear-gradient(145deg, rgba(220,246,255,.86), rgba(92,204,250,.34)); color: #0875c9; box-shadow: inset 0 1px 0 white, 0 7px 0 rgba(14,137,202,.12), 0 12px 20px rgba(3,111,183,.14); backdrop-filter: blur(18px); font-size: 28px; cursor: pointer; }
.menu-section-title { margin: 4px 0 10px; font-size: 18px; }
.chapter-panel, .settings-panel { border: 1px solid rgba(255,255,255,.78); border-radius: 22px; background: rgba(255,255,255,.42); box-shadow: inset 0 1px 0 rgba(255,255,255,.9); backdrop-filter: blur(18px); }
.chapter-panel { padding: 15px; margin-bottom: 12px; }
.chapter-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.chapter-grid button {
  width: min(48px, 100%); aspect-ratio: 1; min-height: 0; justify-self: center; border: 1px solid var(--glass-border); border-radius: 50%; background: linear-gradient(145deg, rgba(220,246,255,.9), rgba(92,204,250,.42)); color: #0875c9; cursor: pointer;
  display: grid; place-items: center; box-shadow: inset 0 1px 0 rgba(255,255,255,.95), 0 7px 20px rgba(3,111,183,.14); backdrop-filter: blur(18px) saturate(170%);
}
.chapter-grid button:hover, .chapter-grid button.active { background: rgba(255,255,255,.72); box-shadow: inset 0 0 0 2px rgba(54,183,241,.66), inset 0 1px 0 white, 0 9px 24px rgba(3,111,183,.17); }
.chapter-grid button:disabled { opacity: .58; cursor: default; }
.chapter-grid b { display: grid; place-items: center; color: #0875c9; font-size: 23px; line-height: 1; }
.settings-panel { padding: 4px 12px; }
.setting-row {
  margin: 0; padding: 10px 2px;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
}
.setting-row + .setting-row { border-top: 1px solid rgba(255,255,255,.7); }
.setting-row span { display: grid; gap: 2px; }.setting-row b { font-size: 14px; }.setting-row small { color: #5d8faa; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch i { display: block; width: 44px; height: 25px; padding: 3px; border: 1px solid rgba(255,255,255,.72); border-radius: 999px; background: rgba(124,172,195,.4); box-shadow: inset 0 1px 4px rgba(8,77,119,.14); cursor: pointer; transition: .2s; }
.switch i::after { content: ""; display: block; width: 19px; height: 19px; border-radius: 50%; background: white; box-shadow: 0 2px 5px rgba(0,0,0,.16); transition: .2s; }
.switch input:checked + i { background: rgba(38,177,242,.82); }.switch input:checked + i::after { transform: translateX(19px); }
.menu-actions { display: grid; gap: 14px; margin-top: 16px; }
.restart-button { width: 100%; height: 58px; margin: 0 auto; border: 1px solid var(--glass-border); border-radius: 29px; background: linear-gradient(145deg, rgba(220,246,255,.86), rgba(92,204,250,.4)); color: #0875c9; box-shadow: inset 0 1px 0 white, 0 7px 0 rgba(14,137,202,.12), 0 12px 22px rgba(3,111,183,.16); backdrop-filter: blur(20px) saturate(170%); font-weight: 900; cursor: pointer; }
.again-button { width: 112px; aspect-ratio: 1; min-height: 0; margin: 14px auto 0; display: grid; place-items: center; border: 1px solid var(--glass-border); border-radius: 50%; background: linear-gradient(145deg, rgba(220,246,255,.86), rgba(92,204,250,.34)); color: #0875c9; box-shadow: inset 0 1px 0 white, 0 9px 0 rgba(14,137,202,.12), 0 15px 24px rgba(3,111,183,.18); backdrop-filter: blur(20px) saturate(170%); font-weight: 900; cursor: pointer; }

.drag-ghost { position: fixed; z-index: 999; pointer-events: none; transform: translate(-50%,-50%) rotate(3deg); transform-origin: center; }
.drag-ghost img { position: absolute; max-width: none; object-fit: fill; pointer-events: none; filter: drop-shadow(0 12px 15px rgba(4,83,132,.28)); }
.demo-ghost { transform: translate(-50%,-50%); }
.demo-pointer {
  position: fixed;
  z-index: 1001;
  width: clamp(76px, 9vw, 112px);
  height: auto;
  object-fit: contain;
  pointer-events: none;
  transform: translate(-53.5%,-88.7%) rotate(90deg);
  transform-origin: 53.5% 88.7%;
  filter: drop-shadow(0 9px 10px rgba(55,71,84,.25));
  user-select: none;
}
.sparkles { position: absolute; z-index: 11; inset: 0; pointer-events: none; overflow: hidden; }
.spark { position: absolute; left: 50%; top: 48%; color: #ffc126; font-size: 25px; animation: sparkle .85s ease-out forwards; }
@keyframes sparkle { to { transform: translate(var(--x),var(--y)) rotate(120deg) scale(.3); opacity: 0; } }

.finish-dialog[hidden] { display: none; }
.finish-dialog { position: fixed; z-index: 200; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(3,73,119,.38); backdrop-filter: blur(18px) saturate(150%); }
.finish-panel { width: min(420px,92vw); padding: 38px; text-align: center; border: 1px solid rgba(255,255,255,.88); border-radius: 32px; background: linear-gradient(145deg, rgba(255,255,255,.76), rgba(186,235,255,.48)); box-shadow: inset 0 1px 0 white, 0 25px 70px rgba(2,83,139,.32); backdrop-filter: blur(28px) saturate(170%); }
.finish-badge { width: 72px; aspect-ratio: 1; margin: -76px auto 16px; display: grid; place-items: center; border: 6px solid white; border-radius: 50%; color: white; background: var(--orange); box-shadow: 0 8px 24px rgba(240,158,16,.34); font-size: 2.3rem; }
.finish-panel p { color: #087fc4; font-weight: 900; letter-spacing: .1em; }
.finish-panel h2 { margin: 4px 0 10px; font-size: 2.5rem; }
.finish-stars { margin: 18px 0 25px; color: #ffc329; font-size: 2rem; letter-spacing: .12em; }
.again-button { width: 112px; padding: 18px; text-align: center; }

@media (max-width: 720px) {
  .lesson-shell { border-width: 0; }
  .lesson-header { height: 72px; padding-top: 5px; padding-bottom: 5px; padding-left: max(28px, calc(env(safe-area-inset-left, 0px) + 18px)); padding-right: max(28px, calc(env(safe-area-inset-right, 0px) + 18px)); }
  #course-code { font-size: 20px; }
  .lesson-title span { font-size: 13px; }
  .round-button { width: 56px; height: 56px; font-size: 20px; }
  .round-button svg { width: 30px; height: 30px; }
  .header-back-button { width: 50px; height: 50px; margin-right: 7px; border-radius: 50%; font-size: 31px; }
  .header-actions { gap: 7px; }
  .game-stage { inset: 66px 4px 74px; }
  .scene-canvas { width: min(100%, calc((100vh - 140px) * 1.7928)); width: min(100%, calc((100dvh - 140px) * 1.7928)); }
  .caption-wrap { --nav-control-height: 66px; --caption-height: 64px; left: max(34px, calc(env(safe-area-inset-left, 0px) + 22px)); right: max(34px, calc(env(safe-area-inset-right, 0px) + 22px)); bottom: 8px; grid-template-columns: var(--nav-control-height) minmax(0,1fr) var(--nav-control-height); gap: 8px; }
  .nav-button { --nav-icon-width: 22px; --nav-icon-height: 26px; width: var(--nav-control-height); height: var(--nav-control-height); border-radius: 50%; }
  .caption-pill { height: var(--caption-height); min-height: var(--caption-height); padding: 4px 10px; border-radius: calc(var(--caption-height) / 2); }
  .sentence-copy strong { font-size: clamp(16px, 4vw, 20px); }
  .course-menu { padding-top: 28px; }
}

@media (max-width: 520px) {
  .lesson-title { margin-right: 6px; }
}

/* Keep the 16:9 game artwork comfortably framed on 4:3-style tablets. */
@media (orientation: landscape) and (min-width: 721px) and (max-width: 1600px) and (min-height: 650px) and (max-aspect-ratio: 8/5) {
  .game-stage { inset: 104px 6vw 120px; }
  .scene-canvas { width: min(88vw, calc((100dvh - 244px) * 1.7928)); }
  .caption-wrap { --nav-control-height: 90px; }
  .nav-button { --nav-icon-width: 38px; --nav-icon-height: 44px; }
}

@media (max-height: 600px) {
  .lesson-header { height: 56px; padding-top: 4px; padding-bottom: 4px; padding-left: max(28px, calc(env(safe-area-inset-left, 0px) + 18px)); padding-right: max(28px, calc(env(safe-area-inset-right, 0px) + 18px)); }
  #course-code { font-size: 19px; }
  .lesson-title span { font-size: 12px; }
  .lesson-title { margin-right: 10px; }
  .round-button { width: 50px; height: 50px; font-size: 18px; }
  .round-button svg { width: 27px; height: 27px; }
  .header-back-button { width: 46px; height: 46px; margin-right: 8px; font-size: 29px; }
  .header-actions { gap: 8px; }
  .game-stage { inset: 50px 4px 62px; }
  .scene-canvas { width: min(100%, calc((100vh - 112px) * 1.7928)); width: min(100%, calc((100dvh - 112px) * 1.7928)); }
  .caption-wrap { --nav-control-height: 58px; --caption-height: 56px; left: max(36px, calc(env(safe-area-inset-left, 0px) + 22px)); right: max(36px, calc(env(safe-area-inset-right, 0px) + 22px)); bottom: 6px; gap: 8px; }
  .caption-pill { height: var(--caption-height); min-height: var(--caption-height); }
  .nav-button { --nav-icon-width: 20px; --nav-icon-height: 24px; width: var(--nav-control-height); height: var(--nav-control-height); }
  .sentence-copy strong { font-size: clamp(16px, 2.6vw, 22px); }
  .course-menu { width: min(320px, 52vw); padding: 8px 14px; }
  .menu-head { margin-bottom: 2px; }
  .menu-head strong { font-size: 20px; }
  .menu-head button { width: 32px; height: 32px; font-size: 21px; }
  .menu-section-title { margin: 0 0 5px; font-size: 15px; }
  .chapter-panel { padding: 7px 8px; margin-bottom: 7px; border-radius: 16px; }
  .chapter-grid { gap: 4px; }
  .chapter-grid button { width: 38px; }
  .chapter-grid b { font-size: 18px; }
  .settings-panel { padding: 2px 10px; border-radius: 16px; }
  .setting-row { padding: 5px 0; }
  .setting-row b { font-size: 12px; }
  .setting-row small { display: block; font-size: 9px; line-height: 1.05; }
  .menu-actions { gap: 10px; margin-top: 10px; }
  .restart-button { height: 44px; border-radius: 22px; font-size: 14px; }
}

@media (orientation: portrait) {
  .lesson-shell {
    position: fixed; left: 50%; top: 50%; width: 100vh; width: 100dvh; height: 100vw; min-height: 0;
    transform: translate(-50%, -50%) rotate(90deg); transform-origin: center;
  }
  .finish-dialog {
    inset: auto; left: 50%; top: 50%; width: 100vh; width: 100dvh; height: 100vw;
    transform: translate(-50%, -50%) rotate(90deg); transform-origin: center;
  }
  .lesson-header { height: 56px; padding-top: 4px; padding-bottom: 4px; padding-left: max(28px, calc(env(safe-area-inset-left, 0px) + 18px)); padding-right: max(28px, calc(env(safe-area-inset-right, 0px) + 18px)); }
  #course-code { font-size: 19px; }
  .lesson-title span { font-size: 12px; }
  .lesson-title { margin-right: 10px; }
  .round-button { width: 50px; height: 50px; font-size: 18px; }
  .round-button svg { width: 27px; height: 27px; }
  .header-back-button { width: 46px; height: 46px; margin-right: 8px; font-size: 29px; }
  .header-actions { gap: 8px; }
  .game-stage { inset: 50px 4px 62px; }
  .scene-canvas { width: min(100%, calc((100vw - 112px) * 1.7928)); }
  .caption-wrap { --nav-control-height: 58px; --caption-height: 56px; left: max(36px, calc(env(safe-area-inset-left, 0px) + 22px)); right: max(36px, calc(env(safe-area-inset-right, 0px) + 22px)); bottom: 6px; gap: 8px; }
  .caption-pill { height: var(--caption-height); min-height: var(--caption-height); }
  .nav-button { width: var(--nav-control-height); height: var(--nav-control-height); font-size: 18px; }
  .sentence-copy strong { font-size: clamp(16px, 2.6vw, 22px); }
  .course-menu { width: min(320px, 52vw); padding: 8px 14px; }
  .menu-head { margin-bottom: 2px; }
  .menu-head strong { font-size: 20px; }
  .menu-head button { width: 32px; height: 32px; font-size: 21px; }
  .menu-section-title { margin: 0 0 5px; font-size: 15px; }
  .chapter-panel { padding: 7px 8px; margin-bottom: 7px; border-radius: 16px; }
  .chapter-grid { gap: 4px; }
  .chapter-grid button { width: 38px; }
  .chapter-grid b { font-size: 18px; }
  .settings-panel { padding: 2px 10px; border-radius: 16px; }
  .setting-row { padding: 5px 0; }
  .setting-row b { font-size: 12px; }
  .setting-row small { display: block; font-size: 9px; line-height: 1.05; }
  .menu-actions { gap: 10px; margin-top: 10px; }
  .restart-button { height: 44px; border-radius: 22px; font-size: 14px; }
}

@media (orientation: portrait) and (min-width: 721px) {
  .game-stage { inset: 64px 6vw 76px; }
  .scene-canvas { width: min(88%, calc((100vw - 190px) * 1.7928)); }
  .caption-wrap { --nav-control-height: 52px; }
  .nav-button { --nav-icon-width: 24px; --nav-icon-height: 30px; }
}

@media (max-width: 720px), (max-height: 600px) {
  .header-back-button span {
    display: block;
    width: 24px;
    height: 22px;
    margin: auto;
    background: currentColor;
    clip-path: polygon(0 50%, 55% 8%, 55% 34%, 100% 34%, 100% 66%, 55% 66%, 55% 92%);
    transform: none;
    font-size: 0;
  }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
