:root {
  color-scheme: light;
  --night: #102f38;
  --teal: #1e5960;
  --teal-dark: #123d44;
  --paper: #fff7dc;
  --paper-deep: #ead7a4;
  --ink: #213638;
  --muted: #657174;
  --gold: #f2bd45;
  --gold-dark: #8f5d12;
  --coral: #e86850;
  --coral-dark: #913727;
  --mint: #8bd8bd;
  font-family: "Avenir Next", "Trebuchet MS", system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; height: 100%; min-width: 900px; min-height: 650px; overflow: hidden; }
body { margin: 0; color: var(--ink); background: var(--night); }
button { color: inherit; font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 4px solid #fff; outline-offset: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.lesson { height: 100%; padding: 14px; }
.world { position: relative; height: 100%; min-height: 620px; overflow: hidden; isolation: isolate; border: 1px solid #4e7779; border-radius: 26px; background: #386d6c; box-shadow: 0 9px 0 #0b252c, 0 28px 65px rgba(0,0,0,.32); }
.backdrop { position: absolute; z-index: -4; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.shade { position: absolute; z-index: -3; inset: 0; background: linear-gradient(90deg,rgba(8,35,42,.35),rgba(8,35,42,.04) 40%,rgba(8,35,42,.18)), linear-gradient(0deg,rgba(8,32,37,.42),transparent 45%); }

.quest-hud { position: absolute; z-index: 8; left: 22px; right: 22px; top: 18px; height: 70px; display: grid; grid-template-columns: 245px 1fr auto; align-items: center; gap: 18px; }
.quest-mark,.difficulty,.scoreboard { border: 1px solid rgba(255,255,255,.32); background: rgba(16,47,56,.91); box-shadow: 0 5px 0 rgba(6,25,30,.45); backdrop-filter: blur(9px); color: white; }
.quest-mark { height: 70px; display: flex; align-items: center; gap: 11px; padding: 8px 15px 8px 8px; border-radius: 17px; }
.quest-mark img { width: 52px; height: 52px; object-fit: contain; filter: drop-shadow(0 3px 2px rgba(0,0,0,.3)); }
.quest-mark div { display: flex; flex-direction: column; }.quest-mark strong { margin-top: 2px; font-size: 18px; }
.quest-mark span,.difficulty span,.scoreboard span { color: #cce4df; font-size: 10px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.difficulty { justify-self: center; width: min(340px,100%); display: grid; grid-template-columns: 1fr auto; gap: 5px 12px; padding: 10px 15px; border-radius: 15px; }
.difficulty span b { color: var(--gold); font-size: 16px; }.difficulty strong { color: #fff3c9; font-size: 12px; }
.difficulty > i { grid-column: 1 / -1; height: 7px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.18); }
.difficulty > i b { display: block; width: 20%; height: 100%; border-radius: inherit; background: linear-gradient(90deg,var(--mint),var(--gold),var(--coral)); transition: width 240ms ease-out; }
.scoreboard { height: 70px; display: flex; align-items: stretch; padding: 7px; border-radius: 17px; }
.scoreboard > div { min-width: 70px; display: grid; place-content: center; padding: 0 11px; text-align: center; }.scoreboard > div + div { border-left: 1px solid rgba(255,255,255,.18); }
.scoreboard strong { display: block; margin-top: 3px; color: white; font-size: 21px; line-height: 1; }.scoreboard strong i { color: var(--gold); font-style: normal; font-size: 15px; }

.mascot-stage { position: absolute; z-index: 4; left: 3.5%; bottom: 5%; width: 255px; height: 440px; pointer-events: none; }
.mascot { position: absolute; z-index: 2; left: 20px; bottom: 0; width: 220px; max-height: 305px; object-fit: contain; object-position: bottom; transform-origin: 55% 90%; filter: drop-shadow(0 12px 8px rgba(0,0,0,.38)); transition: transform 170ms ease-out, filter 170ms ease-out; }
.mascot-shadow { position: absolute; left: 35px; right: 20px; bottom: -5px; height: 28px; border-radius: 50%; background: rgba(4,24,26,.34); filter: blur(3px); }
.speech { position: absolute; z-index: 4; left: 6px; top: 0; width: 235px; padding: 15px 17px; border: 3px solid var(--night); border-radius: 18px 18px 18px 5px; background: var(--paper); box-shadow: 0 5px 0 rgba(5,28,32,.35); font-size: 14px; font-weight: 850; line-height: 1.28; }
.world.is-striking .mascot { transform: translate(54px,-9px) rotate(8deg) scale(1.06); }.world.is-happy .mascot { transform: translateY(-12px) rotate(-4deg) scale(1.06); filter: drop-shadow(0 13px 8px rgba(0,0,0,.34)) brightness(1.08); }.world.is-miss .mascot { transform: rotate(-7deg); }

.gate-console { position: absolute; z-index: 3; left: max(285px,22%); right: 4.2%; top: 108px; bottom: 35px; display: grid; grid-template-rows: 33px auto minmax(130px,1fr) 44px 34px 80px; align-content: start; padding: 18px 30px 24px; overflow: hidden; border: 2px solid #785b31; border-radius: 25px; background: linear-gradient(150deg,rgba(255,250,226,.98),rgba(246,226,177,.97)); box-shadow: 0 9px 0 rgba(72,46,24,.7), 0 25px 55px rgba(0,0,0,.28), inset 0 0 0 5px rgba(255,255,255,.36); }
.gate-console::before { position: absolute; inset: 11px; content: ""; pointer-events: none; border: 1px solid rgba(132,93,41,.25); border-radius: 17px; }
.lock-row { z-index: 1; display: flex; justify-content: center; gap: 13px; }
.lock-row i { width: 25px; height: 25px; border: 3px solid #896d4c; border-radius: 50% 50% 44% 44%; background: #c7b891; box-shadow: inset 0 3px rgba(255,255,255,.35); transition: transform 180ms ease-out, background 180ms ease-out; }
.lock-row i.is-open { transform: translateY(-3px) rotate(-8deg); border-color: var(--gold-dark); background: var(--gold); box-shadow: 0 0 0 5px rgba(242,189,69,.17), inset 0 3px rgba(255,255,255,.5); }
.mission-heading { z-index: 1; text-align: center; }.mission-heading span { color: var(--coral-dark); font-size: 10px; font-weight: 1000; letter-spacing: .13em; text-transform: uppercase; }
.mission-heading h1 { margin: 5px 0 5px; color: #173b40; font-family: Georgia,"Times New Roman",serif; font-size: clamp(29px,3.1vw,45px); line-height: 1; letter-spacing: -.035em; }.mission-heading p { margin: 0; color: var(--muted); font-size: 14px; }
.sentence-wrap { position: relative; z-index: 1; min-height: 0; display: grid; place-items: center; overflow: hidden; margin: 13px 0 7px; padding: 20px; border: 2px solid #b79c6f; border-radius: 20px; background: rgba(255,253,243,.82); box-shadow: inset 0 4px 15px rgba(91,62,25,.08); }
.sentence { position: relative; z-index: 2; max-width: 900px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 8px; }
.word { position: relative; min-width: 54px; min-height: 58px; padding: 8px 13px 7px; border: 2px solid #9b8969; border-radius: 13px; color: #2b4041; background: #fffdf3; box-shadow: 0 5px 0 #c6b28a; font-size: clamp(20px,2.1vw,31px); font-weight: 850; letter-spacing: -.02em; transition: transform 140ms ease-out, box-shadow 140ms ease-out, border-color 140ms ease-out, background 140ms ease-out; }
.word:hover { transform: translateY(-2px); border-color: var(--teal); box-shadow: 0 7px 0 #b7a47e; }.word:active { transform: translateY(4px); box-shadow: 0 1px 0 #b7a47e; }
.word.is-selected { transform: translateY(-3px); border-color: var(--gold-dark); color: #56370b; background: #ffe59b; box-shadow: 0 7px 0 #b7771c, 0 0 0 4px rgba(242,189,69,.16); }.word.is-selected::before { position: absolute; top: -15px; left: 50%; content: "◆"; transform: translateX(-50%); color: var(--coral); font-size: 15px; text-shadow: 0 2px #fff; }
.word.is-wrong { border-color: var(--coral-dark); background: #ffd9cc; }.word.is-missed { border-color: #187162; background: #d2f4e7; box-shadow: 0 0 0 5px rgba(39,151,124,.15), 0 5px 0 #92c8b8; }
.lantern-sweep { position: absolute; z-index: 3; top: -20%; bottom: -20%; left: -28%; width: 28%; opacity: 0; transform: skewX(-13deg); background: linear-gradient(90deg,transparent,rgba(255,229,133,.55),transparent); pointer-events: none; }
.world.is-revealing .lantern-sweep { animation: sweep 750ms ease-out; }
.rule-crest { z-index: 1; min-height: 40px; display: flex; align-items: center; justify-content: center; gap: 8px; color: #45605e; font-size: 13px; font-weight: 900; text-align: center; }.rule-crest b { display: inline-grid; place-items: center; min-width: 34px; height: 30px; padding: 0 9px; border-radius: 9px; color: #fff7d9; background: var(--teal); box-shadow: 0 3px 0 var(--teal-dark); }
.feedback { z-index: 1; min-height: 28px; display: grid; place-items: center; color: var(--teal-dark); font-size: 14px; font-weight: 900; text-align: center; }.feedback.is-error { color: var(--coral-dark); }
.action-area { z-index: 1; min-height: 76px; display: flex; align-items: center; justify-content: center; gap: 12px; }
.lever,.primary,.explain-choice { min-height: 58px; border: 2px solid; border-radius: 14px; font-weight: 1000; transition: transform 140ms ease-out,box-shadow 140ms ease-out; }
.lever { position: relative; min-width: 260px; padding: 0 64px 0 25px; border-color: var(--coral-dark); color: white; background: var(--coral); box-shadow: 0 7px 0 var(--coral-dark); font-size: 17px; text-align: left; }.lever::after { position: absolute; right: 18px; top: 9px; width: 26px; height: 39px; content: ""; transform: rotate(20deg); border: 3px solid #5e3c1a; border-radius: 12px 12px 8px 8px; background: var(--gold); box-shadow: 0 3px 0 #71430d; }.lever:hover,.primary:hover,.explain-choice:hover { transform: translateY(-2px); }.lever:active,.primary:active,.explain-choice:active { transform: translateY(5px); box-shadow: 0 2px 0 currentColor; }
.primary { min-width: 230px; padding: 0 25px; border-color: var(--teal-dark); color: white; background: var(--teal); box-shadow: 0 6px 0 var(--teal-dark); font-size: 16px; }
.explain-grid { width: min(720px,100%); display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }.explain-choice { padding: 8px 11px; border-color: #907c58; background: #fffdf3; box-shadow: 0 5px 0 #c6b28a; font-size: 13px; }
.gate-glow { position: absolute; z-index: -1; right: -5%; bottom: -15%; width: 45%; height: 90%; opacity: 0; border-radius: 50%; background: radial-gradient(circle,rgba(255,212,91,.8),rgba(255,196,70,.12) 45%,transparent 70%); transition: opacity 220ms ease-out; }.world.is-happy .gate-glow { opacity: 1; }
.sparks { position: absolute; z-index: 20; right: 18%; top: 48%; pointer-events: none; }.sparks i { position: absolute; width: 14px; height: 14px; opacity: 0; transform: rotate(45deg); border-radius: 3px; background: var(--gold); }.world.is-celebrating .sparks i { animation: spark 750ms ease-out both; }.sparks i:nth-child(1){--x:-105px;--y:-100px}.sparks i:nth-child(2){--x:35px;--y:-145px;animation-delay:55ms}.sparks i:nth-child(3){--x:120px;--y:-80px;animation-delay:100ms}.sparks i:nth-child(4){--x:145px;--y:25px;animation-delay:145ms}.sparks i:nth-child(5){--x:70px;--y:110px;animation-delay:190ms}.sparks i:nth-child(6){--x:-55px;--y:120px;animation-delay:230ms}.sparks i:nth-child(7){--x:-135px;--y:50px;animation-delay:270ms}.sparks i:nth-child(8){--x:-25px;--y:-45px;animation-delay:310ms}
.world.is-shaking .gate-console { animation: shake 340ms ease-out; }
.toast { position: absolute; z-index: 30; left: 50%; bottom: 30px; max-width: 74%; padding: 11px 18px; opacity: 0; transform: translate(-50%,12px); border-radius: 999px; color: white; background: var(--night); box-shadow: 0 4px 0 rgba(0,0,0,.32); pointer-events: none; font-size: 13px; font-weight: 900; transition: opacity 150ms ease-out,transform 150ms ease-out; }.toast.is-showing { opacity: 1; transform: translate(-50%,0); }

@keyframes sweep { 0% { left: -28%; opacity: 0; } 18% { opacity: 1; } 82% { opacity: 1; } 100% { left: 105%; opacity: 0; } }
@keyframes spark { 0% { opacity: 0; transform: translate(0,0) rotate(45deg) scale(.2); } 35% { opacity: 1; } 100% { opacity: 0; transform: translate(var(--x),var(--y)) rotate(190deg) scale(1.2); } }
@keyframes shake { 20% { transform: translateX(-7px) rotate(-.4deg); } 45% { transform: translateX(6px) rotate(.35deg); } 70% { transform: translateX(-3px); } }
@media (max-height: 740px) { .gate-console { top: 94px; bottom: 24px; padding-top: 12px; grid-template-rows: 28px auto minmax(110px,1fr) 38px 29px 68px; }.quest-hud { top: 11px; }.mascot-stage { bottom: 2%; transform: scale(.88); transform-origin: bottom left; }.word { min-height: 50px; font-size: 20px; }.sentence-wrap { margin-top: 7px; padding: 14px; } }
@media (prefers-reduced-motion: reduce) { *,*::before,*::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }
