/* Student layout; shared /ops styles stay in style.css. */
.student-page { background-image: linear-gradient(90deg, #eff7e75c, #f6f8ef9c), url('/static/sillu-world-home.webp'); }
.student-page[data-scene=game] { background-image: linear-gradient(#fff9edb3, #fff9edb3), url('/static/sillu-world-practice.webp'); }
.student-page[data-scene=finished] { background-image: linear-gradient(#fff9eddf, #fff9eddf), url('/static/sillu-world-finish.webp'); }
.student-page .site-header { height: 60px; border-radius: 0; background: transparent; backdrop-filter: none; padding-inline: 0; }
.student-main { min-height: 0; }
.student-page .site-footer { padding: 18px 0; }
.welcome-layout { min-height: 0; max-width: 850px; margin: 54px auto 24px; padding: 0; grid-template-columns: 260px minmax(0, 420px); gap: 38px; justify-content: center; }
.welcome-copy > p { text-align: center; font-size: 18px; font-weight: 700; }
.welcome-art { height: 280px; margin: 0; }
.welcome-art img { width: 250px; height: 280px; filter: none; }
.start-card { border-width: 2px; padding: 28px; box-shadow: 0 6px 0 #30233e15; background: var(--paper); }
.start-card h1 { font: 500 34px/1.15 Fredoka, Nunito, sans-serif; margin: 0 0 12px; }
.start-card > p { font-size: 17px; }
.start-card label[for=display-name] { font-size: 18px; margin-bottom: 8px; }
.start-card input[type=text] { height: 54px; font-size: 22px; margin-bottom: 16px; border-color: #797185; }
.start-card .primary-button { font-size: 20px; border-width: 2px; box-shadow: 0 4px 0 var(--ink); }
.start-card .enter-note { text-align: center; font-size: 14px; color: var(--ink-soft); margin: 12px 0 18px; }
.start-levels { border-top: 1px solid #ded5c5; padding-top: 12px; }
.start-levels summary { cursor: pointer; font-weight: 700; min-height: 30px; }
.start-levels .level-fieldset { margin: 12px 0 0; }
.start-levels .level-options { grid-template-columns: 1fr 1fr; }
.start-levels .level-option { min-height: 64px; padding: 10px; border-width: 1px; border-radius: 9px; gap: 8px; }
.start-levels .level-copy strong { font-size: 14px; }
.start-levels .level-copy small { font-size: 12px; }
.start-card .form-error:empty { display: none; }
.game-layout { grid-template-columns: minmax(0, 1fr) 224px; gap: 12px 24px; padding: 8px 0 0; }
.game-top { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; min-height: 48px; padding: 0; border: 0; border-radius: 0; background: transparent; }
.player-pill { border: 0; background: transparent; padding: 0; max-width: 140px; font-size: 15px; }
.level-indicator { border-radius: 8px; border: 1px solid #b4bcaa; background: var(--paper); padding: 6px 10px; font-size: 15px; font-weight: 700; }
.progress-text { color: var(--ink-soft); font-size: 14px; }
.game-actions { margin: 0 0 0 auto; gap: 16px; }
.game-actions .small-button { background: var(--paper); border: 1px solid #a69bae; min-height: 38px; font-size: 13px; }
.game-actions .text-button { font-size: 15px; font-weight: 700; }
.game-message { flex-basis: 100%; min-height: 0; margin: 0; font-size: 14px; border-radius: 8px; background: var(--paper); padding: 8px 12px; }
.game-message:empty { display: none; }
.practice-card { background: var(--paper); border-width: 2px; border-radius: 20px; padding: 22px 26px; box-shadow: 0 5px 0 #30233e15; }
.practice-instruction { margin: 0 0 8px; font-size: 17px; font-weight: 700; }
.typing-prompt { min-height: 70px; font: 700 54px/1.25 Nunito, sans-serif; letter-spacing: 0; overflow-wrap: anywhere; }
.typing-prompt .prompt-word { max-width: 100%; white-space: normal; }
.game-layout[data-level="2"] .typing-prompt { font-size: 42px; }
.game-layout[data-level="3"] .typing-prompt, .game-layout[data-level="4"] .typing-prompt { font-size: 29px; line-height: 1.4; min-height: 82px; }
.exercise-source { font-size: 12px; font-weight: 600; margin: 6px 0 0; }
.exercise-source a { text-decoration: underline; }
.typing-prompt .current-char { border-bottom: 3px solid #b65b24; background: #ffdf80; }
.typing-prompt .typed-correct { color: #08756b; }
.typing-input { height: 64px; min-height: 64px; padding: 10px 14px; margin-top: 14px; border-width: 2px; border-color: #54455e; border-radius: 12px; font: 600 34px/1.3 Nunito, sans-serif; resize: vertical; }
.game-layout[data-level="3"] .typing-input, .game-layout[data-level="4"] .typing-input { height: 98px; min-height: 98px; font: 600 26px/1.35 Nunito, sans-serif; }
.typing-input:focus { box-shadow: 0 0 0 4px #ffdf80; }
.typing-feedback { min-height: 30px; font-size: 17px; font-weight: 700; margin: 12px 0 0; }
.typing-feedback kbd { display: inline-block; min-width: 32px; margin-inline: 3px; padding: 2px 8px; border: 1px solid #8e7f99; border-bottom-width: 3px; border-radius: 6px; font: inherit; background: white; text-align: center; }
.keyboard-panel { border: 1px solid #c7cebf; background: #f9fbf4; border-radius: 16px; padding: 12px 18px; margin-top: 16px; box-shadow: none; }
.keyboard-caption { color: #596251; font-size: 14px; font-weight: 600; margin: 0 0 8px; }
.keyboard { max-width: none; gap: 4px; }
.key-row { gap: 5px; }
.key { height: 30px; border: 1px solid #aa9db3; border-bottom-width: 3px; border-radius: 6px; background: white; font-size: 14px; font-weight: 700; }
.key.active { background: #ffdf80; border-color: #aa6924; transform: none; }
.key.backspace { font-size: 21px; }
.game-side { position: static; display: grid; gap: 14px; align-content: start; }
.companion { border-radius: 16px; background: #e4f0e4; padding: 12px; text-align: center; }
.companion img { width: 96px; height: 106px; object-fit: contain; }
.companion h2 { font-size: 18px; line-height: 1.3; margin: 6px 0; }
.companion p { font-size: 14px; margin: 6px 0 0; }
.goal-dots { display: flex; justify-content: center; gap: 8px; margin: 10px 0; }
.goal-dot { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: white; border: 1px solid #879780; font-size: 13px; color: #596251; }
.goal-dot.completed { background: #177566; border-color: #177566; color: white; }
.companion.celebrating img { animation: sillu-cheer .5s ease; }
@keyframes sillu-cheer { 50% { transform: translateY(-7px) rotate(4deg); } }
.qr-card { background: var(--paper); border-color: #c7cebf; border-radius: 16px; padding: 12px; }
.qr-card h2 { font: 700 15px/1.3 Nunito, sans-serif; margin: 0 0 6px; color: #596251; }
.qr-card p { font-size: 13px; font-weight: 600; margin: 0 0 8px; }
.qr-frame { width: 190px; height: 190px; border: 0; border-radius: 0; }
.qr-frame img { width: 190px; height: 190px; }
.qr-status { font-size: 12px; font-weight: 700; margin-top: 6px; }
.qr-status::before { display: none; }
.student-stats { border: 0; padding: 0; margin: 0; background: transparent; box-shadow: none; border-radius: 0; }
.student-stats summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink-soft); padding: 6px; }
.student-stats > div { background: var(--paper); border: 1px solid #c7cebf; border-radius: 12px; padding: 8px 12px; }
.student-stat { padding: 8px 0; }
.student-stat strong { min-width: 36px; font: 700 22px/1 Nunito, sans-serif; }
.student-stat span { font-size: 12px; font-weight: 600; }
.finish-screen { margin: 36px auto 20px; border-width: 2px; background: var(--paper); padding: 28px; grid-template-columns: minmax(0,1fr) 224px; }
.finish-intro h1 { font-size: 40px; }
.finish-intro img { width: 110px; height: 120px; }
.finish-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.finish-teacher-note { flex-basis: 100%; max-width: none; margin-bottom: 6px; }
.finish-actions .primary-button { padding: 0 20px; }
.finish-actions .form-error { flex-basis: 100%; margin: 0; }
.finish-actions .form-error:empty { display: none; }
@media (min-width: 1000px) and (max-height: 740px) {
  .student-page .site-header { height: 52px; }
  .welcome-layout { margin-top: 30px; }
  .practice-card { padding: 18px 22px; }
  .game-layout[data-level="3"] .typing-prompt, .game-layout[data-level="4"] .typing-prompt { font-size: 27px; min-height: 76px; }
  .game-layout[data-level="3"] .typing-input, .game-layout[data-level="4"] .typing-input { height: 92px; min-height: 92px; font-size: 26px; }
}
@media (max-width: 999px) {
  .game-layout { grid-template-columns: minmax(0,1fr) 210px; gap: 12px 16px; }
  .game-top { gap: 8px; }
  .progress-text { display: none; }
  .practice-card { padding: 20px; }
  .qr-frame, .qr-frame img { width: 184px; height: 184px; }
}
@media (max-width: 720px) {
  .student-page .site-header { height: 52px; }
  .welcome-layout { grid-template-columns: 1fr; margin: 24px auto; gap: 0; max-width: 420px; }
  .welcome-copy { display: none; }
  .start-card { padding: 22px; }
  .start-card h1 { font-size: 31px; }
  .game-layout { grid-template-columns: 1fr; grid-template-areas: "top" "side" "main"; padding-top: 8px; gap: 12px; }
  .game-top { min-height: 48px; }
  .game-actions { gap: 10px; }
  .game-actions .text-button { font-size: 13px; }
  .game-actions .small-button { font-size: 12px; }
  .game-side { gap: 10px; grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
  .companion { padding: 10px; display: grid; align-content: center; }
  .companion img { display: none; }
  .companion h2 { font-size: 16px; }
  .companion p { font-size: 12px; }
  .goal-dots { gap: 4px; }
  .qr-card { display: flex; flex-direction: column; padding: 8px; text-align: center; gap: 4px; }
  .qr-card p { display: block; font-size: 11px; margin: 0; }
  .qr-card h2 { font-size: 13px; margin: 0; }
  .qr-copy { display: contents; }
  .qr-status { order: 2; margin: 0; font-size: 10px; }
  .qr-frame, .qr-frame img { width: 136px; height: 136px; }
  .student-stats { grid-column: 1/-1; display: block; }
  .student-stats > div { display: flex; gap: 12px; justify-content: space-around; }
  .student-stat { display: block; border: 0; }
  .typing-prompt { font-size: 42px; min-height: 58px; }
  .game-layout[data-level="2"] .typing-prompt { font-size: 34px; }
  .game-layout[data-level="3"] .typing-prompt, .game-layout[data-level="4"] .typing-prompt { font-size: 25px; }
  .typing-input { font-size: 28px; height: 60px; min-height: 60px; }
  .game-layout[data-level="3"] .typing-input, .game-layout[data-level="4"] .typing-input { font-size: 24px; height: 108px; min-height: 108px; }
  .typing-feedback { font-size: 15px; }
  .keyboard-panel { padding: 12px 8px; }
  .keyboard-caption { font-size: 12px; }
  .key-row { gap: 3px; }
  .key { font-size: 10px; }
  .key.shift { font-size: 9px; }
  .finish-screen { grid-template-columns: 1fr; padding: 22px; margin-top: 24px; }
  .finish-intro { gap: 8px; }
  .finish-intro h1 { font-size: 33px; }
  .finish-intro img { width: 85px; height: 100px; }
  .finish-qr, .finish-actions { grid-column: 1; grid-row: auto; }
  .finish-qr .qr-card { width: 100%; display: grid; grid-template-columns: 1fr 190px; text-align: left; padding: 12px; align-items: center; }
  .finish-qr .qr-copy { display: block; }
  .finish-qr .qr-frame, .finish-qr .qr-frame img { width: 190px; height: 190px; }
}
@media (prefers-reduced-motion: reduce) { .companion.celebrating img { animation: none; } }

/* A desktop stage: Sillu on the left, exercise in the middle, teacher QR on the right. */
.companion { grid-area: companion; }
.keyboard-panel { grid-area: keyboard; }
.student-stats h2 { font: 700 15px/1.3 Nunito, sans-serif; margin: 0 0 4px; }
.student-stats { background: var(--paper); border: 1px solid #c7cebf; border-radius: 16px; padding: 12px; }
.student-stats > div { border: 0; padding: 0; }
.student-stat strong { font-size: 26px; }
.student-stat span { font-size: 13px; }
@media (min-width: 1000px) {
  .student-page .wrap { width: calc(100% - 48px); max-width: none; }
  .student-page .site-header { height: 60px; }
  .student-page .site-footer { padding: 12px 0; font-size: 11px; }
  .welcome-layout { max-width: 1320px; min-height: calc(100svh - 116px); margin: 0 auto; grid-template-columns: minmax(0, 1fr) minmax(420px, 480px); gap: clamp(40px, 6vw, 100px); }
  .welcome-art { width: 100%; height: clamp(360px, 58svh, 620px); }
  .welcome-art img { width: 100%; height: 100%; filter: drop-shadow(0 16px 14px #493b3426); }
  .welcome-copy > p { font: 500 38px/1.2 Fredoka, Nunito, sans-serif; margin: 20px 0 0; }
  .start-card { padding: 36px; }
  .start-card h1 { font-size: 40px; }
  .start-card input[type=text] { height: 64px; font-size: 26px; }
  .start-card .primary-button { min-height: 62px; font-size: 24px; }
  .game-layout { min-height: calc(100svh - 110px); grid-template-columns: clamp(250px, 22vw, 420px) minmax(0, 1fr) 224px; grid-template-areas: "top top top" "companion main side" "keyboard keyboard keyboard"; grid-template-rows: auto minmax(min-content, 1fr) auto; gap: 16px 28px; padding: 0; }
  .game-top { min-height: 44px; }
  .game-main { align-self: center; }
  .companion { align-self: center; background: transparent; padding: 0; }
  .companion img { width: 100%; height: clamp(240px, 38svh, 460px); filter: drop-shadow(0 12px 12px #493b3426); }
  .companion h2 { font: 500 clamp(22px, 2vw, 32px)/1.2 Fredoka, Nunito, sans-serif; margin: 10px 0; }
  .companion p { font-size: 16px; font-weight: 700; }
  .goal-dots { margin: 12px 0; }
  .goal-dot { width: 30px; height: 30px; font-size: 16px; border-width: 2px; }
  .game-side { align-self: center; gap: 12px; }
  .practice-card { padding: 28px 32px; border-radius: 24px; background: #fffaf1f5; }
  .practice-instruction { font-size: 20px; margin-bottom: 12px; }
  .typing-prompt { font-size: clamp(60px, 5vw, 88px); min-height: 104px; }
  .game-layout[data-level="2"] .typing-prompt { font-size: clamp(42px, 3.8vw, 68px); }
  .game-layout[data-level="3"] .typing-prompt, .game-layout[data-level="4"] .typing-prompt { font-size: clamp(28px, 2.3vw, 40px); line-height: 1.35; min-height: 100px; }
  .typing-input { font-size: 42px; height: 80px; min-height: 80px; margin-top: 20px; }
  .game-layout[data-level="3"] .typing-input, .game-layout[data-level="4"] .typing-input { font-size: 30px; height: 112px; min-height: 112px; }
  .typing-feedback { font-size: 20px; min-height: 36px; }
  .keyboard-panel { align-self: end; margin: 0; padding: 16px 24px 20px; border-width: 2px; background: #fffaf1f5; border-radius: 20px; }
  .keyboard-caption { font-size: 16px; margin-bottom: 12px; }
  .keyboard, .key-row { gap: 8px; }
  .key { height: clamp(40px, 5.8svh, 68px); font-size: clamp(20px, 1.8vw, 30px); border-width: 2px; border-bottom-width: 5px; border-radius: 10px; }
  .key.backspace { font-size: 32px; }
  .key.shift { font-size: 19px; }
  .key.space { max-width: 60%; font-size: 20px; }
  .finish-screen { max-width: 1000px; margin-top: 8svh; }
  .finish-intro img { width: 220px; height: 250px; }
}
@media (min-width: 1000px) and (max-height: 900px) {
  .student-page .site-header { height: 48px; }
  .game-layout { min-height: calc(100svh - 98px); gap: 10px 20px; grid-template-columns: clamp(230px, 20vw, 340px) minmax(0,1fr) 224px; }
  .companion img { height: 250px; }
  .companion h2 { font-size: 23px; }
  .companion p { font-size: 14px; }
  .goal-dots { margin: 8px 0; }
  .practice-card { padding: 18px 24px; }
  .practice-instruction { font-size: 17px; margin-bottom: 8px; }
  .typing-prompt { min-height: 78px; font-size: 62px; }
  .game-layout[data-level="2"] .typing-prompt { font-size: 46px; }
  .game-layout[data-level="3"] .typing-prompt, .game-layout[data-level="4"] .typing-prompt { font-size: 28px; min-height: 76px; }
  .typing-input { margin-top: 12px; height: 64px; min-height: 64px; font-size: 36px; }
  .game-layout[data-level="3"] .typing-input, .game-layout[data-level="4"] .typing-input { height: 88px; min-height: 88px; font-size: 26px; }
  .typing-feedback { margin-top: 10px; min-height: 30px; font-size: 17px; }
  .keyboard-panel { padding: 10px 18px 12px; }
  .keyboard-caption { margin-bottom: 8px; font-size: 14px; }
  .keyboard, .key-row { gap: 5px; }
  .key { height: 40px; font-size: 21px; border-bottom-width: 4px; }
  .key.space { font-size: 18px; }
  .welcome-layout { min-height: calc(100svh - 98px); }
  .welcome-art { height: 380px; }
}
@media (min-width: 721px) and (max-width: 999px) {
  .game-layout { grid-template-areas: "top top" "companion side" "main main" "keyboard keyboard"; }
  .companion img { width: 180px; height: 190px; }
}
@media (max-width: 720px) {
  .game-layout { grid-template-columns: minmax(0,1fr) minmax(0,1fr); grid-template-areas: "top top" "companion side" "main main" "keyboard keyboard"; }
  .game-side { grid-template-columns: 1fr; }
  .companion { align-self: start; min-height: 170px; }
  .keyboard-panel { margin-top: 0; }
  .student-stats { padding: 8px; }
  .student-stats h2 { font-size: 12px; }
  .student-stats > div { display: grid; gap: 0; }
  .student-stat { display: flex; gap: 5px; padding: 4px 0; align-items: center; }
  .student-stat strong { font-size: 20px; min-width: 27px; }
  .student-stat span { font-size: 10px; }
}

/* A persistent comic bubble and celebrations for error-free word streaks. */
.companion { position: relative; display: flex; flex-direction: column; align-items: center; }
.speech-bubble { position: relative; width: 100%; padding: 16px 18px; border: 3px solid var(--ink); border-radius: 24px; background: #fffaf1; box-shadow: 0 5px 0 #30233e18; margin-bottom: 26px; z-index: 1; }
.speech-bubble::before { content: ''; position: absolute; bottom: -20px; left: 57%; border-top: 20px solid var(--ink); border-right: 22px solid transparent; }
.speech-bubble::after { content: ''; position: absolute; bottom: -14px; left: calc(57% + 3px); border-top: 16px solid #fffaf1; border-right: 16px solid transparent; }
.companion .speech-bubble h2 { margin: 0 0 6px; font: 500 28px/1.15 Fredoka, Nunito, sans-serif; }
.companion .speech-bubble p { margin: 0; font-size: 17px; font-weight: 800; }
.companion.has-milestone .speech-bubble { background: #ffe399; }
.companion.has-milestone .speech-bubble::after { border-top-color: #ffe399; }
.companion.has-milestone .speech-bubble h2 { color: #914512; font-size: 32px; }
.confetti { pointer-events: none; position: absolute; inset: 18% -8% 0; overflow: hidden; }
.confetti i { position: absolute; left: var(--x); top: -20px; width: 10px; height: 16px; border-radius: 2px; opacity: 0; animation: confetti-fall 2.1s var(--delay) ease-out forwards; }
@keyframes confetti-fall { 8% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(var(--drift), 450px) rotate(var(--spin)); } }
.companion.celebrating img { animation: sillu-cheer .6s ease 2; }
.student-stats { margin-top: 0; }
.student-stats .student-stat { padding: 7px 0; }
.student-stats .streak-stat { background: #eee6ff; border: 1px solid #b7a0dc; border-radius: 10px; padding: 8px; margin: 8px 0; align-items: center; }
.streak-stat strong { color: #6842a4; font-size: 30px; }
.streak-stat span b, .streak-stat span small { display: block; }
.streak-stat span small { font-size: 11px; margin-top: 3px; }
.restart-warning { padding: 18px; background: #fff0bd; border: 2px solid #b56c25; border-radius: 14px; }
.restart-warning p { font-size: 19px; margin: 0 0 14px; }
.restart-warning button { margin-right: 12px; }
@media (min-width: 1000px) {
  .companion img { height: clamp(230px, 32svh, 400px); }
  .key { height: clamp(40px, 5.2svh, 60px); }
  .game-layout { grid-template-rows: auto minmax(min-content, 1fr) auto; }
  .game-side { gap: 10px; }
}
@media (min-width: 1000px) and (max-height: 900px) {
  .companion img { height: 235px; }
  .speech-bubble { padding: 12px; margin-bottom: 22px; }
  .companion .speech-bubble h2, .companion.has-milestone .speech-bubble h2 { font-size: 25px; }
  .companion .speech-bubble p { font-size: 15px; }
  .qr-card { padding: 8px; }
  .qr-card p { display: none; }
  .qr-card h2 { margin-bottom: 4px; }
  .qr-frame, .qr-frame img { width: 160px; height: 160px; }
  .student-stats { padding: 8px 10px; }
  .student-stats h2 { font-size: 13px; }
  .student-stats .student-stat { padding: 4px 0; }
  .student-stat strong { font-size: 22px; }
  .student-stat span { font-size: 11px; }
  .student-stats .streak-stat { padding: 5px; margin: 5px 0; }
  .streak-stat span small { margin-top: 1px; font-size: 10px; }
  .key { height: 38px; }
  .keyboard-panel { padding: 8px 16px 10px; }
}
@media (max-width: 720px) {
  .speech-bubble { padding: 10px; border-width: 2px; border-radius: 16px; margin-bottom: 0; }
  .speech-bubble::before, .speech-bubble::after { display: none; }
  .companion .speech-bubble h2, .companion.has-milestone .speech-bubble h2 { font-size: 21px; }
  .companion .speech-bubble p { font-size: 12px; }
  .student-stats { display: block; }
  .student-stats .student-stat { padding: 4px 0; }
  .student-stats .streak-stat { padding: 5px; }
  .student-stat span { margin: 0; }
  .companion { min-height: 0; }
  .confetti { inset: 0; }
}
@media (prefers-reduced-motion: reduce) { .confetti i, .companion.celebrating img { animation: none; } }
@media (min-width: 1000px) {
  .student-page[data-scene=game] .site-footer { display: none; }
  .game-layout { min-height: calc(100svh - 60px); }
  .student-stats .student-stat { line-height: 1.1; padding: 5px 0; }
  .student-stat strong { font-size: 24px; }
}
@media (min-width: 1000px) and (max-height: 900px) {
  .game-layout { min-height: calc(100svh - 48px); }
  .student-stats .student-stat { padding: 3px 0; line-height: 1.05; }
  .student-stat strong { font-size: 20px; }
  .qr-frame, .qr-frame img { width: 150px; height: 150px; }
  .student-stats h2 { margin-bottom: 2px; }
  .student-stats .streak-stat { padding: 4px; margin: 4px 0; }
  .keyboard-caption { line-height: 1.2; }
}

.confetti i { top: var(--y); opacity: 1; width: 12px; height: 18px; animation-duration: 2.8s; }
@keyframes confetti-fall { 0% { opacity: 1; transform: rotate(0deg); } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(var(--drift), 320px) rotate(var(--spin)); } }

/* The child's final result includes every level and all session statistics. */
.finish-screen { max-width: 1200px; grid-template-areas: "intro qr" "results qr" "actions qr" "warning warning"; gap: 18px 28px; align-items: start; margin-top: 24px; }
.finish-intro { grid-area: intro; }
.finish-intro h1 { font-size: 38px; }
.finish-intro h1 span { margin-top: 8px; font-size: 36px; line-height: 1.15; }
.finish-intro img { width: 170px; height: 185px; }
.finish-qr { grid-area: qr; }
.finish-actions { grid-area: actions; }
.restart-warning { grid-area: warning; }
.finish-results { grid-area: results; min-width: 0; }
.finish-results h2 { font: 800 18px/1.3 Nunito, sans-serif; margin: 0 0 10px; }
.finish-levels { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 10px; margin-bottom: 18px; }
.finish-level { display: flex; align-items: baseline; gap: 10px; padding: 14px 16px; border-radius: 12px; background: #e8f0df; border: 1px solid #b9c6ab; }
.finish-level[data-level="2"] { background: #fff0c1; border-color: #dbc784; }
.finish-level[data-level="3"] { background: #dfedf7; border-color: #b3c8db; }
.finish-level[data-level="4"] { background: #f4e4ed; border-color: #d2b8ca; }
.finish-level strong { font: 600 36px/1 Fredoka, Nunito, sans-serif; }
.finish-level span { font-size: 17px; font-weight: 800; }
.finish-metrics { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; margin: 0; }
.finish-metric { padding: 12px; border: 1px solid #d5cbbc; border-radius: 12px; background: #fffdf8; }
.finish-metric dt { font-size: 13px; font-weight: 800; color: var(--ink-soft); margin-bottom: 6px; }
.finish-metric dd { font: 800 21px/1.2 Nunito, sans-serif; margin: 0; overflow-wrap: anywhere; }
.finish-metric.streak { background: #eee6ff; border-color: #b7a0dc; }
.finish-metric.streak dd { color: #6842a4; }
@media (min-width: 1000px) { .finish-screen { margin-top: 32px; } }
@media (min-width: 1000px) and (max-height: 900px) {
  .finish-screen { margin-top: 16px; padding: 22px; gap: 12px 24px; }
  .finish-intro img { width: 140px; height: 150px; }
  .finish-intro h1, .finish-intro h1 span { font-size: 32px; }
  .finish-levels { margin-bottom: 14px; }
  .finish-level { padding: 10px 12px; }
  .finish-level strong { font-size: 30px; }
  .finish-metric { padding: 10px; }
  .finish-metric dd { font-size: 20px; }
}
@media (max-width: 720px) {
  .finish-screen { grid-template-columns: 1fr; grid-template-areas: "intro" "results" "qr" "actions" "warning"; margin-top: 18px; gap: 18px; padding: 20px; }
  .finish-intro img { width: 75px; height: 90px; }
  .finish-intro h1 { font-size: 31px; }
  .finish-intro h1 span { font-size: 27px; }
  .finish-intro p { font-size: 14px; }
  .finish-levels { grid-template-columns: 1fr 1fr; gap: 8px; }
  .finish-level { flex-direction: column; gap: 4px; padding: 10px; }
  .finish-level strong { font-size: 32px; }
  .finish-level span { font-size: 14px; }
  .finish-metrics { grid-template-columns: 1fr 1fr; gap: 8px; }
  .finish-metric { padding: 10px; }
  .finish-metric dt { font-size: 12px; }
  .finish-metric dd { font-size: 19px; }
  .finish-qr .qr-card { display: flex; flex-direction: column; text-align: center; max-width: none; }
  .finish-qr .qr-copy { display: block; }
}

/* Secret hacker mode: unlocked on the welcome mascot, applied only in play. */
#sillu-secret { display: block; width: 100%; padding: 0; border: 0; background: transparent; box-shadow: none; cursor: pointer; touch-action: manipulation; }
#sillu-secret:focus-visible { outline: 3px solid #167b62; outline-offset: 6px; border-radius: 24px; }
#secret-countdown { min-height: 28px; font-size: 16px; color: #116348; }
#matrix-rain { display: none; }
.student-page.hacker-mode { --ink: #d7ffe2; --ink-soft: #9bc8ac; --paper: #071b12; background: #020b07; color: var(--ink); }
.hacker-mode #matrix-rain { display: block; position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: -1; }
#matrix-rain > span { position: absolute; left: var(--left); top: 0; white-space: pre; font: var(--size)/1.55 ui-monospace, monospace; color: #42ee7f; opacity: var(--opacity); text-shadow: 0 0 6px #28e66b66; mask-image: linear-gradient(transparent, #000 55%); animation: code-rain var(--duration) var(--delay) linear infinite; }
#matrix-rain b { color: #c1ffd3; font-weight: 500; text-shadow: 0 0 9px #70ffab; }
@keyframes code-rain { from { transform: translate3d(0,-100%,0); } to { transform: translate3d(0,100vh,0); } }
.hacker-mode .practice-card, .hacker-mode .qr-card, .hacker-mode .keyboard-panel, .hacker-mode .student-stats > div, .hacker-mode .speech-bubble, .hacker-mode .finish-screen { background: #071b12f5; border-color: #37704c; box-shadow: 0 0 24px #00ff6610; }
.hacker-mode .companion { background: transparent; }
.hacker-mode .speech-bubble::after { border-top-color: #071b12; }
.hacker-mode .speech-bubble::before { border-top-color: #37704c; }
.hacker-mode .companion .speech-bubble h2, .hacker-mode .qr-card h2, .hacker-mode .student-stat strong, .hacker-mode .finish-metric dd { color: #9effbb; }
.hacker-mode .typing-prompt, .hacker-mode .typing-input { font: 500 clamp(18px, 2vw, 28px)/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; font-variant-ligatures: none; white-space: pre-wrap; overflow-wrap: anywhere; }
.hacker-mode .typing-prompt { min-height: 100px; color: #d5ffe2; }
.hacker-mode .typing-input { height: 112px; min-height: 112px; color: #e1ffe9; caret-color: #7aff9c; background: #020d08; border-color: #458d60; }
.hacker-mode .typing-input:focus { box-shadow: 0 0 0 3px #39df7544; }
.hacker-mode .typing-prompt .typed-correct { color: #68e890; }
.hacker-mode .typing-prompt .typed-wrong { background: #742138; color: #fff; }
.hacker-mode .typing-prompt .current-char { background: #92ffb4; color: #052210; border-color: #edfff2; }
.hacker-mode .key, .hacker-mode kbd, .hacker-mode .finish-level, .hacker-mode .finish-metric, .hacker-mode .streak-stat, .hacker-mode .restart-warning { background: #102b1d; border-color: #45815a; color: #d7ffe2; }
.hacker-mode .key.active { background: #9effbb; color: #052210; }
.hacker-mode .keyboard-caption, .hacker-mode .finish-metric dt, .hacker-mode .site-footer, .hacker-mode .qr-status { color: #a1c9af; }
.hacker-mode .key { height: 30px; font-size: 16px; }
.hacker-mode .qr-frame { background: white; }
.hacker-mode .primary-button { background: #9effbb; color: #052210; border-color: #45815a; }
@media (max-width:720px) {
  .welcome-copy { display: block; }
  #sillu-secret, #sillu-secret img { height: 150px; }
  #sillu-secret img { width: 140px; }
  .welcome-copy > p:not(#secret-countdown) { display: none; }
  .hacker-mode .key { font-size: 11px; height: 27px; min-width: 0; }
}
@media (prefers-reduced-motion:reduce) { #matrix-rain > span { animation: none; top: 0; transform: none; } }
.task-code-form { border: 1px solid #a9b7a7; border-radius: 12px; padding: 10px; background: var(--paper); }
.task-code-form label { display: block; font-size: 13px; font-weight: 800; margin-bottom: 6px; }
.task-code-form > div { display: flex; gap: 6px; }
.task-code-form input { min-width: 0; width: 100%; font: 700 15px monospace; padding: 6px; text-transform: uppercase; border: 1px solid #6f7d6c; border-radius: 6px; }
.task-code-form button { min-width: 44px; min-height: 36px; padding: 5px 8px; font-size: 13px; }
.task-code-form p { font-size: 12px; margin: 6px 0 0; overflow-wrap: anywhere; }
.task-code-form p:empty { display: none; }
.teacher-text-active .typing-prompt { font-size: clamp(22px, 2.3vw, 30px); line-height: 1.5; }
.teacher-text-active .typing-input, .dictation-active .typing-input { font-size: 24px; min-height: 110px; height: 110px; }
.dictation-player { padding: 14px 0; }
.dictation-player > button { min-height: 48px; }
.dictation-player p { font-size: 14px; min-height: 22px; }
.audio-wave { height: 64px; display: flex; align-items: center; gap: 5px; margin: 10px 0; }
.audio-wave i { background: #16786a; width: 6px; height: 12px; border-radius: 5px; }
.audio-wave i:nth-child(3n) { height: 30px; }
.audio-wave i:nth-child(4n) { height: 46px; }
.playing .audio-wave i { animation: audio-wave .8s ease-in-out infinite alternate; }
.playing .audio-wave i:nth-child(2n) { animation-delay: -.4s; }
.playing .audio-wave i:nth-child(3n) { animation-delay: -.2s; }
@keyframes audio-wave { to { transform: scaleY(.35); } }
#dictation-submit { margin-top: 12px; }
.feedback-hidden .streak-stat, .feedback-hidden #stat-mistakes, .feedback-hidden #stat-mistakes + span { display: none; }
.feedback-hidden .confetti { display: none; }
.dictation-active .keyboard-panel { display: none; }
.hacker-mode .audio-wave i { background: #7cff9f; }
@media (prefers-reduced-motion:reduce) { .playing .audio-wave i { animation: none; } }
@media (max-width:720px) { .task-code-form label { font-size: 11px; } .task-code-form input { font-size: 12px; } .task-code-form > div { flex-wrap: wrap; } }
.hacker-mode .small-button { background: #133d26; color: #d7ffe2; border-color: #45815a; }
.hacker-mode .task-code-form input { background: #020d08; color: #d7ffe2; }
.hacker-mode .task-code-form input::placeholder { color: #a1c9af; }
@media (min-width:1000px) {
  .game-side .qr-frame, .game-side .qr-frame img { width: 160px; height: 160px; }
  .game-side .student-stats > div { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 6px; padding: 6px; }
  .game-side .student-stat { min-width: 0; display: flex; flex-direction: column; align-items: start; gap: 4px; }
  .game-side .student-stat strong { font-size: 20px; }
  .game-side .student-stat span { font-size: 10px; }
  .game-side .streak-stat { grid-column: 1/-1; flex-direction: row; align-items: center; margin: 0; }
  .hacker-mode .keyboard, .hacker-mode .key-row { gap: 4px; }
  .hacker-mode .keyboard-panel { padding: 10px 18px; }
  .hacker-mode .keyboard-caption { margin-bottom: 8px; font-size: 13px; }
  .feedback-hidden .game-side .streak-stat { display: none; }
}
@media (min-width:1000px) and (max-height:900px) {
  .game-side .qr-frame, .game-side .qr-frame img { width: 140px; height: 140px; }
  .game-side { gap: 7px; }
  .game-side .student-stats { padding: 4px; }
  .hacker-mode .key { height: 22px; font-size: 14px; border-bottom-width: 2px; }
  .hacker-mode .keyboard, .hacker-mode .key-row { gap: 3px; }
  .hacker-mode .typing-prompt { min-height: 70px; font-size: 24px; }
  .hacker-mode .typing-input { min-height: 80px; height: 80px; font-size: 24px; }
  .hacker-mode .companion img { height: 200px; }
}
@media (max-width:720px) { .hacker-mode .companion img { display: block; width: 140px; max-width: 100%; height: 160px; } }
@media (min-width:1000px) and (max-height:900px) {
  .hacker-mode .key { height: 18px; font-size: 12px; }
  .hacker-mode .keyboard, .hacker-mode .key-row { gap: 2px; }
  .hacker-mode .keyboard-panel { padding: 6px 16px; }
  .hacker-mode .keyboard-caption { margin-bottom: 4px; font-size: 12px; }
}

/* The twentieth mascot click opens a short terminal-style reveal. */
.hacker-opening { overflow: hidden; }
.hacker-intro { position: fixed; inset: 0; z-index: 10000; background: #000; color: #77f59c; display: flex; align-items: flex-start; padding: clamp(90px, 22vh, 220px) clamp(28px, 12vw, 180px); outline: none; opacity: 1; animation: terminal-arrive .35s ease-out; transition: opacity .5s ease; }
.hacker-intro p { margin: 0; font: 400 clamp(26px, 4vw, 48px)/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .04em; text-shadow: 0 0 12px #39df7544; }
.hacker-intro.leaving { opacity: 0; }
.terminal-cursor { display: inline-block; margin-left: .15em; animation: terminal-cursor 1.2s step-end infinite; }
@keyframes terminal-arrive { from { opacity: 0; } to { opacity: 1; } }
@keyframes terminal-cursor { 50% { opacity: 0; } }
.hacker-mode .start-card { background: #071b12f5; border-color: #37704c; box-shadow: 0 0 30px #00ff6612; }
.hacker-mode .start-card input[type=text] { background: #020d08; color: #d7ffe2; border-color: #45815a; }
.hacker-mode .start-card input[type=text]::placeholder { color: #9bc8ac; }
.hacker-mode .start-levels, .hacker-mode .level-option { border-color: #37704c; }
.hacker-mode .level-option { background: #102b1d; color: #d7ffe2; }
.hacker-mode .level-option:has(input:checked) { background: #1d4a2c; border-color: #9effbb; }
.hacker-mode #secret-countdown { color: #9effbb; }
@media (prefers-reduced-motion:reduce) { .hacker-intro, .terminal-cursor { animation: none; transition: none; } }

/* Secret countdown belongs to Sillu's comic speech bubble. */
.secret-mascot { position: relative; }
#secret-countdown.secret-bubble { position: absolute; z-index: 2; top: 0; right: 0; max-width: min(78%, 290px); min-height: 0; margin: 0; padding: 14px 18px; border: 3px solid #30233e; border-radius: 26px; background: #fffaf1; color: #30233e; font: 800 19px/1.3 Nunito, sans-serif; text-align: center; box-shadow: 0 5px 0 #30233e18; pointer-events: none; }
.secret-bubble::before, .secret-bubble::after { content: ''; position: absolute; bottom: -23px; left: 8%; border-left: 0; border-top: 23px solid #30233e; border-right: 23px solid transparent; }
.secret-bubble::after { bottom: -16px; left: calc(8% + 3px); border-top: 18px solid #fffaf1; border-right-width: 17px; }
.hacker-mode #secret-countdown.secret-bubble { background: #071b12; color: #9effbb; border-color: #45815a; }
.hacker-mode .secret-bubble::before { border-top-color: #45815a; }
.hacker-mode .secret-bubble::after { border-top-color: #071b12; }

/* Real EE key positions; small legends show Shift (top left) and AltGr (right). */
.keyboard .key { position: relative; height: 44px; font-size: 19px; border-radius: 7px; border-bottom-width: 3px; }
.keyboard .key-base { font: inherit; line-height: 1; }
.keyboard .key-shift, .keyboard .key-altgr { position: absolute; font: 700 11px/1 ui-monospace, monospace; }
.keyboard .key-shift { top: 3px; left: 5px; }
.keyboard .key-altgr { bottom: 4px; right: 5px; }
.keyboard .key.modifier, .keyboard .key.shift { flex: 1.5; font-size: 13px; }
.keyboard .key.space { flex: 6; max-width: 60%; font-size: 16px; }
.keyboard .key[data-layer=shift] .key-shift, .keyboard .key[data-layer=altgr] .key-altgr { font-size: 15px; text-decoration: underline; text-underline-offset: 2px; }
.keyboard .key.next-step { outline: 2px dashed #b65b24; outline-offset: 1px; }
.hacker-mode .keyboard .key.next-step { outline-color: #9effbb; }
@media (min-width:1000px) and (max-height:900px) {
  .keyboard .key { height: 31px; font-size: 15px; }
  .keyboard .key-shift, .keyboard .key-altgr { font-size: 9px; }
  .keyboard .key[data-layer=shift] .key-shift, .keyboard .key[data-layer=altgr] .key-altgr { font-size: 12px; }
  .keyboard .key.modifier, .keyboard .key.shift { font-size: 11px; }
}
@media (max-width:720px) {
  #secret-countdown.secret-bubble { top: -8px; right: 0; max-width: 48%; padding: 9px 11px; font-size: 13px; border-width: 2px; border-radius: 18px; }
  .secret-bubble::before { bottom: -19px; border-top-width: 19px; border-right-width: 19px; }
  .secret-bubble::after { bottom: -14px; border-top-width: 15px; border-right-width: 14px; }
  .keyboard .key { height: 36px; font-size: 11px; border-width: 1px; border-bottom-width: 2px; }
  .keyboard .key-shift, .keyboard .key-altgr { font-size: 8px; }
  .keyboard .key-shift { left: 2px; top: 2px; }
  .keyboard .key-altgr { right: 2px; bottom: 2px; }
  .keyboard .key.modifier, .keyboard .key.shift { font-size: 8px; }
  .keyboard .key[data-layer=shift] .key-shift, .keyboard .key[data-layer=altgr] .key-altgr { font-size: 10px; }
}
@media (min-width:1000px) and (max-height:900px) {
  .keyboard .key { height: 26px; font-size: 14px; }
  .keyboard .key-shift { top: 2px; }
  .keyboard .key-altgr { bottom: 2px; }
}

/* Longer translated button labels retain their full width. */
.task-code-form button { flex-shrink: 0; }
.task-code-form input { flex: 1; width: 0; }

/* Reserve the keyboard's row inside the actual browser viewport. Only reading
   and control panels scroll; the decorative companion shrinks to fit. */
@media (min-width: 1000px) {
  .game-layout {
    height: calc(100dvh - 60px);
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }
  .game-main, .game-side, .companion {
    min-height: 0;
    max-height: 100%;
  }
  .game-main { overflow-y: auto; padding: 5px; margin: -5px; }
  .companion {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: visible;
  }
  .companion .speech-bubble { flex: 0 0 auto; max-width: 100%; }
  .companion > img { flex: 0 1 auto; min-height: 0; object-fit: contain; }
  .game-side {
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
  }
  .game-side::-webkit-scrollbar { display: none; width: 0; height: 0; }
}
@media (min-width: 1000px) and (max-height: 900px) {
  .game-layout { height: calc(100dvh - 48px); }
}
@media (min-width: 1000px) and (max-height: 740px) {
  .companion img { height: clamp(100px, calc(100dvh - 460px), 235px); }
  .speech-bubble { padding: 8px; margin-bottom: 14px; }
}
