:root {
  color-scheme: light;
  --ink: #10231a;
  --muted: #637068;
  --green: #166534;
  --green-dark: #0f4b27;
  --green-soft: #eaf6ed;
  --cream: #fbfaf4;
  --paper: #ffffff;
  --amber: #f59e0b;
  --red: #c2413b;
  --red-soft: #fff0ee;
  --line: #dce5de;
  --shadow: 0 18px 60px rgba(25, 57, 38, 0.12);
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: #fbfaf4;
}

body {
  margin: 0;
  width: 100%;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 12%, rgba(245,158,11,.13), transparent 24rem),
    radial-gradient(circle at 94% 88%, rgba(22,101,52,.12), transparent 28rem),
    var(--cream);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  overflow-x: hidden;
}

button, select, input, textarea { font: inherit; }
button { cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid rgba(245,158,11,.55); outline-offset: 3px; }
body.modal-open { overflow: hidden; }

.shell { width: min(1100px, calc(100% - 32px)); margin: 0 auto; }
.topbar { min-height: 98px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 11px; font-size: 1.22rem; font-weight: 800; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; color: white; background: var(--green); border-radius: 13px 13px 13px 4px; font-family: Georgia, serif; font-size: 1.35rem; }
.header-side { display: flex; align-items: center; gap: 22px; }
.programs-link { text-decoration: none; white-space: nowrap; }
.header-action { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 40px; padding: 0 11px; border: 1px solid #bdd5c4; border-radius: 12px; color: var(--green-dark); background: #eef8ef; font-size: .9rem; font-weight: 800; white-space: nowrap; }
.header-action:hover { background: #dff0e2; }
.sound-action { min-width: 42px; padding: 0 8px; font-size: 1.25rem; }
.school-emblem { display: block; width: 154px; height: 77px; object-fit: contain; }
.top-stat { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px 18px; color: var(--muted); font-size: .95rem; }
.top-stat span { white-space: nowrap; }
.top-stat strong { color: var(--ink); margin-left: 5px; }
.combo-stat { display: inline-flex; align-items: center; gap: 4px; padding: 5px 9px; border: 1px solid #ffdc63; border-radius: 99px; color: #fff8d3; background: linear-gradient(135deg, #f28b1c, #d9461a); box-shadow: 0 0 0 3px rgba(247,166,28,.16), 0 0 15px rgba(245,132,24,.55); font-weight: 900; animation: combo-fire 1.2s ease-in-out infinite alternate; }
.combo-stat strong { margin-left: 0; color: white; font-variant-numeric: tabular-nums; }
.combo-stat.is-boosting { animation: combo-fire 1.2s ease-in-out infinite alternate, combo-stat-boost .65s cubic-bezier(.18,1.6,.4,1); }
@keyframes combo-fire { from { box-shadow: 0 0 0 3px rgba(247,166,28,.14), 0 0 11px rgba(245,132,24,.42); filter: saturate(.94); } to { box-shadow: 0 0 0 5px rgba(255,206,49,.24), 0 0 22px rgba(245,99,20,.78); filter: saturate(1.25); } }
@keyframes combo-stat-boost { 0% { transform: scale(1); } 48% { transform: scale(1.34) rotate(-3deg); } 100% { transform: scale(1); } }
.view { min-height: calc(100vh - 98px); }

.setup-view { display: grid; grid-template-columns: .88fr 1.12fr; gap: clamp(36px, 7vw, 92px); align-items: center; padding: 42px 0 72px; }
.eyebrow { margin: 0 0 12px; color: var(--green); font-size: .8rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.intro h1 { margin: 0; font: 700 clamp(2.6rem, 5.2vw, 4.9rem)/.99 Georgia, serif; letter-spacing: -.045em; overflow-wrap: normal; word-break: normal; hyphens: none; }
.intro > p:last-child { max-width: 33rem; margin: 24px 0 0; color: var(--muted); font-size: 1.08rem; line-height: 1.65; }

.setup-card, .question-card, .weak-card { background: rgba(255,255,255,.92); border: 1px solid rgba(255,255,255,.8); box-shadow: var(--shadow); }
.setup-card { padding: clamp(24px, 4vw, 42px); border-radius: 28px; }
.player-entry { position: relative; margin-bottom: 28px; padding: 20px; border: 1px solid #b7d5bd; border-radius: 20px; background: linear-gradient(135deg, #effaf0, #fff8e8); }
.player-entry-icon { position: absolute; right: 17px; top: 15px; font-size: 1.6rem; }
.player-entry .field { max-width: 330px; }
.player-entry .field > span { color: var(--green-dark); font-size: .95rem; }
.player-entry input { width: 100%; min-height: 50px; padding: 0 14px; border: 1px solid #a6c8af; border-radius: 12px; color: var(--ink); background: white; font-size: 1.05rem; }
.player-entry > p { margin: 9px 0 0; color: var(--muted); font-size: .79rem; line-height: 1.45; }
.player-entry .player-entry-status { min-height: 0; color: var(--red); font-weight: 700; }
.player-entry .player-entry-status.is-ok { color: var(--green-dark); }
.player-auth { display: grid; gap: 12px; margin-top: 15px; padding-top: 15px; border-top: 1px solid #c9dfca; }
.player-auth-hint { margin: 0; color: var(--green-dark); font-size: .9rem; font-weight: 700; line-height: 1.45; }
.player-auth .field { max-width: 100%; }
.player-auth-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.player-auth-actions .secondary-button { min-height: 46px; }
.player-auth-actions .quiet-button { min-height: 46px; }
.player-recovery { display: grid; gap: 11px; margin-top: 5px; padding: 14px; border: 1px solid #c9dfca; border-radius: 14px; background: rgba(255,255,255,.65); }
.player-recovery p { margin: 0; color: var(--muted); font-size: .83rem; line-height: 1.45; }
.player-recovery button { justify-self: start; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
fieldset + fieldset, fieldset + .settings-grid, .settings-grid + fieldset { margin-top: 30px; }
legend { width: 100%; margin: 0 0 14px; font-weight: 750; font-size: 1rem; }
legend span { display: inline-grid; place-items: center; width: 26px; height: 26px; margin-right: 8px; color: var(--green); background: var(--green-soft); border-radius: 50%; font-size: .8rem; }
.grade-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.grade-option input, .repeat-option input, .mode-option input { position: absolute; opacity: 0; pointer-events: none; }
.grade-option span, .repeat-option span { display: grid; place-items: center; min-height: 45px; border: 1px solid var(--line); border-radius: 12px; background: white; font-weight: 700; transition: .18s ease; }
.grade-option input:checked + span, .repeat-option input:checked + span { color: white; border-color: var(--green); background: var(--green); transform: translateY(-1px); box-shadow: 0 7px 18px rgba(22,101,52,.18); }
.grade-option input:disabled + span { color: #a7b0aa; background: #f3f5f3; cursor: not-allowed; text-decoration: line-through; }
.field-hint { margin: 10px 0 0; color: var(--muted); font-size: .82rem; }
.mode-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.mode-option > span { display: grid; align-content: center; min-height: 92px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: white; transition: .18s ease; }
.mode-option strong, .mode-option small { display: block; }
.mode-option strong { font-size: .92rem; line-height: 1.2; }
.mode-option small { margin-top: 6px; color: var(--muted); font-size: .73rem; line-height: 1.35; }
.mode-option input:checked + span { color: var(--green-dark); border-color: var(--green); background: var(--green-soft); box-shadow: 0 7px 18px rgba(22,101,52,.12); }
.mode-option input:focus-visible + span { outline: 3px solid rgba(245,158,11,.55); outline-offset: 3px; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: grid; gap: 8px; }
.field > span { color: var(--muted); font-size: .82rem; font-weight: 700; }
select { width: 100%; min-height: 48px; padding: 0 38px 0 13px; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 12px; }
.repeat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.empty-notice { margin-top: 24px; padding: 16px; display: grid; gap: 4px; border-radius: 14px; color: var(--green-dark); background: var(--green-soft); }
.empty-notice span { color: var(--muted); font-size: .9rem; }
.primary-button, .secondary-button, .quiet-button { border: 0; border-radius: 14px; font-weight: 800; }
.primary-button { width: 100%; min-height: 54px; margin-top: 28px; color: white; background: var(--green); box-shadow: 0 10px 24px rgba(22,101,52,.2); }
.primary-button:hover { background: var(--green-dark); transform: translateY(-1px); }
.primary-button:disabled { cursor: not-allowed; opacity: .48; transform: none; }
.secondary-button { min-height: 54px; padding: 0 24px; color: var(--green); background: var(--green-soft); }
.quiet-button { padding: 10px 15px; color: var(--muted); background: transparent; border: 1px solid var(--line); }
.admin-open-button { width: 100%; min-height: 46px; margin-top: 10px; border: 0; color: var(--green); background: transparent; font-weight: 750; }
.admin-open-button:hover { color: var(--green-dark); text-decoration: underline; text-underline-offset: 4px; }

.quiz-view { max-width: 820px; margin: 0 auto; padding: 46px 0 72px; }
.quiz-head { display: flex; align-items: end; justify-content: space-between; gap: 24px; }
.quiz-head h2, .result-view h2 { margin: 0; font: 700 clamp(2rem, 4vw, 3.1rem)/1.08 Georgia, serif; }
.quiz-player { margin: 9px 0 0; color: var(--green); font-size: .9rem; font-weight: 800; }
.progress-card { margin: 28px 0 18px; padding: 17px 20px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.66); }
.progress-copy { display: flex; justify-content: space-between; gap: 16px; color: var(--muted); font-size: .9rem; }
.progress-copy strong { color: var(--ink); }
.progress-track { height: 9px; margin-top: 12px; overflow: hidden; background: #dfe8e1; border-radius: 99px; }
.progress-fill { width: 0; height: 100%; background: linear-gradient(90deg, var(--green), #38a169); border-radius: inherit; transition: width .35s ease; }
.question-card { padding: clamp(24px, 5vw, 48px); border-radius: 28px; }
.question-meta { display: flex; justify-content: space-between; align-items: center; min-height: 48px; color: var(--muted); font-size: .92rem; }
.question-tools { display: inline-flex; align-items: center; gap: 11px; }
.timer { display: grid; place-items: center; width: 46px; height: 46px; border: 2px solid var(--amber); border-radius: 50%; color: var(--ink); font-size: 1.05rem; font-weight: 850; font-variant-numeric: tabular-nums; }
.timer[hidden] { display: none; }
.timer.is-low { color: var(--red); border-color: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(.94); } }
.answer-grid { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 22px; }
.answer-button { min-height: 86px; padding: 14px; border: 2px solid var(--line); border-radius: 18px; color: var(--ink); background: white; font-size: clamp(1.25rem, 3vw, 1.65rem); font-weight: 750; transition: .16s ease; }
.answer-button { overflow-wrap: anywhere; -webkit-appearance: none; appearance: none; }
.answer-button:hover:not(:disabled) { border-color: #8bb397; transform: translateY(-2px); box-shadow: 0 8px 20px rgba(25,57,38,.08); }
.answer-button.correct { color: var(--green-dark); border-color: #3a9b5d; background: var(--green-soft); box-shadow: 0 0 0 3px rgba(58,155,93,.1); }
.answer-button.wrong { color: var(--red); border-color: #dd6b62; background: var(--red-soft); }
.answer-button.pop, .answer-entry-card.pop { animation: answer-pop .65s cubic-bezier(.2,1.8,.5,1); }
.answer-button.shake, .answer-entry-card.shake { animation: answer-shake .55s ease-out; }
@keyframes answer-pop { 0% { transform: scale(1); } 35% { transform: scale(1.13) rotate(-2deg); } 65% { transform: scale(.96) rotate(1deg); } 100% { transform: scale(1); } }
@keyframes answer-shake { 10%, 50% { transform: translateX(-9px) rotate(-2deg); } 30%, 70% { transform: translateX(9px) rotate(2deg); } 100% { transform: none; } }
.answer-burst { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; pointer-events: none; overflow: visible; }
.answer-burst strong { position: relative; z-index: 2; max-width: min(86vw, 560px); padding: 9px 16px; border: 3px solid currentColor; border-radius: 16px; background: #fff9df; box-shadow: 0 8px 0 rgba(60,50,18,.14), 0 14px 28px rgba(60,50,18,.16); font-size: clamp(1.05rem, 4vw, 1.5rem); font-weight: 950; letter-spacing: .03em; line-height: 1.12; text-align: center; animation: burst-label var(--burst-duration, 1.8s) ease-out both; }
.answer-burst--correct { color: #18764a; }
.answer-burst--wrong { color: #ae3434; }
.answer-burst--wrong strong { background: #fff0ed; }
.answer-burst i { position: absolute; left: 50%; top: 50%; width: 13px; height: 24px; border-radius: 50% 50% 45% 45%; background: #ffcb36; transform: translate(-50%, -50%); animation: burst-piece var(--burst-duration, 1.6s) ease-out both; }
.answer-burst--wrong i { width: 18px; height: 18px; border-radius: 50%; background: #fa8069; }
.answer-burst i:nth-of-type(2n) { background: #46b8e6; }
.answer-burst i:nth-of-type(3n) { background: #8acc5a; }
.answer-burst--wrong i:nth-of-type(2n) { background: #f7b26b; }
.answer-burst--wrong i:nth-of-type(3n) { background: #e76161; }
.answer-burst i:nth-of-type(1) { --dx: -115px; --dy: -75px; --turn: -65deg; }
.answer-burst i:nth-of-type(2) { --dx: -48px; --dy: -110px; --turn: -28deg; }
.answer-burst i:nth-of-type(3) { --dx: 50px; --dy: -108px; --turn: 30deg; }
.answer-burst i:nth-of-type(4) { --dx: 115px; --dy: -70px; --turn: 68deg; }
.answer-burst i:nth-of-type(5) { --dx: 112px; --dy: 74px; --turn: 120deg; }
.answer-burst i:nth-of-type(6) { --dx: 46px; --dy: 110px; --turn: 160deg; }
.answer-burst i:nth-of-type(7) { --dx: -48px; --dy: 110px; --turn: 205deg; }
.answer-burst i:nth-of-type(8) { --dx: -112px; --dy: 72px; --turn: 245deg; }
@keyframes burst-label { 0% { opacity: 0; transform: scale(.25) rotate(-12deg); } 28% { opacity: 1; transform: scale(1.22) rotate(4deg); } 48% { transform: scale(.94) rotate(-2deg); } 70% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(1.08); } }
@keyframes burst-piece { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.2); } 20% { opacity: 1; } 100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(var(--turn)) scale(.6); } }
.combo-burst { position: absolute; z-index: 5; top: 8px; left: 50%; display: grid; justify-items: center; gap: 2px; padding: 8px 16px; border: 3px solid #fff2a6; border-radius: 16px; color: #fffce0; background: linear-gradient(135deg, #f3a714, #df5a17); box-shadow: 0 0 0 5px rgba(250,206,48,.2), 0 10px 24px rgba(112,45,4,.3); pointer-events: none; transform: translateX(-50%); animation: combo-flare 1.8s ease-out both; white-space: nowrap; }
.combo-burst strong { font-size: clamp(1.05rem, 4.2vw, 1.45rem); font-weight: 950; letter-spacing: .04em; text-shadow: 0 2px 0 rgba(102,38,3,.4); }
.combo-burst small { font-size: .7rem; font-weight: 850; }
@keyframes combo-flare { 0% { opacity: 0; transform: translate(-50%, 22px) scale(.45) rotate(-7deg); } 20% { opacity: 1; transform: translate(-50%, 0) scale(1.16) rotate(3deg); } 43% { transform: translate(-50%, -5px) scale(.96); } 76% { opacity: 1; transform: translate(-50%, -12px) scale(1); } 100% { opacity: 0; transform: translate(-50%, -26px) scale(1.08); } }
.answer-button:disabled { cursor: default; }
.answer-entry-card { min-height: 150px; padding: 16px; display: grid; align-content: center; gap: 12px; border: 2px solid var(--line); border-radius: 18px; background: white; transition: .16s ease; }
.answer-entry-card.correct { border-color: #3a9b5d; background: var(--green-soft); box-shadow: 0 0 0 3px rgba(58,155,93,.1); }
.answer-entry-card.wrong { border-color: #dd6b62; background: var(--red-soft); }
.inline-word-field { position: relative; display: grid; gap: 8px; padding: 12px 4px; border: 2px dashed #9abd9e; border-radius: 13px; cursor: text; }
.inline-word-field:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px rgba(58,155,93,.13); }
.masked-word { display: block; max-width: 100%; overflow-x: auto; text-align: center; color: var(--ink); font-size: clamp(1.05rem, 3.7vw, 1.8rem); font-weight: 800; letter-spacing: .02em; white-space: nowrap; }
.letter-gap { display: inline-block; min-width: .72em; margin: 0 .03em; color: var(--green); border-bottom: 3px solid var(--green); line-height: 1; text-align: center; }
.letter-gap.is-filled { background: #e8f7e6; border-radius: 5px 5px 0 0; }
.letter-capture-input { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; opacity: .01; color: transparent; caret-color: transparent; cursor: text; font-size: 16px; }
.answer-entry-label { color: var(--muted); text-align: center; font-size: .78rem; font-weight: 750; }
.answer-entry-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.answer-entry-input { min-width: 0; width: 100%; min-height: 48px; padding: 0 12px; border: 1px solid #b8cdbd; border-radius: 12px; color: var(--ink); background: white; font-size: 1.05rem; font-weight: 700; }
.check-answer-button { min-height: 48px; padding: 0 14px; border: 0; border-radius: 12px; color: white; background: var(--green); font-weight: 800; }
.check-answer-button:disabled, .answer-entry-input:disabled { cursor: default; opacity: .72; }
.feedback { min-height: 28px; margin-top: 22px; text-align: center; font-size: 1.02rem; font-weight: 750; }
.feedback.good { color: var(--green); }
.feedback.bad { color: var(--red); }
.next-button { max-width: 310px; display: block; margin: 18px auto 0; }

.result-view { max-width: 820px; margin: 0 auto; padding: 58px 0 84px; text-align: center; }
.result-badge { display: inline-block; margin-bottom: 14px; padding: 7px 12px; border-radius: 99px; color: var(--green-dark); background: var(--green-soft); font-size: .78rem; font-weight: 850; letter-spacing: .09em; text-transform: uppercase; }
.result-view > p { max-width: 610px; margin: 16px auto 0; color: var(--muted); line-height: 1.6; }
.result-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin: 34px 0 18px; }
.result-stats div { padding: 22px 12px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.7); }
.personal-card, .ranking-preview { margin: 18px 0; padding: 23px; border: 1px solid #cde3cf; border-radius: 22px; background: #f1f9ef; text-align: left; }
.personal-card-head { display: flex; align-items: center; gap: 13px; }
.profile-avatar { display: grid; flex: 0 0 auto; place-items: center; width: 54px; height: 54px; overflow: hidden; border: 2px solid #fff; border-radius: 50%; color: #775000; background: #fff1bb; box-shadow: 0 2px 0 rgba(4,58,29,.08); font-size: 1.4rem; font-weight: 850; }
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.personal-card-head small { color: var(--green); font-size: .78rem; font-weight: 800; }
.personal-card h3 { margin: 3px 0 0; font: 700 1.4rem Georgia, serif; }
.personal-level-title { margin: 5px 0 0; color: #8b5b00; font-size: .78rem; font-weight: 800; }
.personal-card-head > strong { margin-left: auto; color: #8b5b00; font: 800 1.1rem system-ui, sans-serif; white-space: nowrap; }
.personal-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-top: 18px; }
.personal-stats > div { padding: 14px 10px; border-radius: 14px; background: white; text-align: center; }
.personal-stats strong, .personal-stats span { display: block; }
.personal-stats strong { color: var(--green-dark); font-size: 1.35rem; font-weight: 850; }
.personal-stats span { margin-top: 3px; color: var(--muted); font-size: .72rem; }
.profile-save-status { margin: 13px 0 0; color: var(--muted); font-size: .84rem; }
.profile-save-status.is-error { color: var(--red); font-weight: 750; }
.personal-card #retrySaveButton { margin-top: 10px; }
.avatar-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 13px; }
.avatar-reminder { margin: 0; color: #775000; font-size: .82rem; font-weight: 750; }
.ranking-preview { background: white; }
.ranking-preview-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.ranking-preview h3 { margin: 0; font-size: 1.08rem; }
.ranking-list { display: grid; gap: 8px; margin: 15px 0 0; padding: 0; list-style: none; }
.ranking-list li { display: grid; grid-template-columns: 36px 34px minmax(0, 1fr) auto auto; align-items: center; gap: 10px; min-width: 0; padding: 12px 14px; border-radius: 13px; background: #f5f8f4; }
.ranking-list li.is-me { background: #e4f4e8; box-shadow: inset 0 0 0 1px #9dc7a8; }
.ranking-place { color: var(--green-dark); font-size: 1.15rem; font-weight: 850; }
.ranking-avatar { display: grid; place-items: center; width: 34px; height: 34px; overflow: hidden; border-radius: 50%; background: #dff1e2; color: var(--green-dark); font-size: .78rem; font-weight: 850; object-fit: cover; }
.ranking-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 800; }
.ranking-accuracy { color: var(--green-dark); font-weight: 850; white-space: nowrap; }
.ranking-skill { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.ranking-modal { position: relative; width: min(760px, 100%); max-height: calc(100dvh - 36px); overflow: auto; padding: clamp(24px, 5vw, 42px); border-radius: 26px; background: white; box-shadow: 0 28px 90px rgba(3,20,10,.3); }
.ranking-modal h2 { margin: 0; font: 700 clamp(2rem, 5vw, 3rem) Georgia, serif; }
.ranking-explain { max-width: 610px; margin: 13px 0 0; color: var(--muted); font-size: .88rem; line-height: 1.5; }
.ranking-status { min-height: 20px; margin: 14px 0 0; color: var(--muted); font-size: .85rem; }
.profile-modal { position: relative; width: min(760px, 100%); max-height: calc(100dvh - 36px); overflow: auto; padding: clamp(24px, 5vw, 42px); border-radius: 26px; background: white; box-shadow: 0 28px 90px rgba(3,20,10,.3); }
.profile-modal h2 { margin: 0; padding-right: 44px; font: 700 clamp(2rem, 5vw, 3rem) Georgia, serif; }
.profile-guest > p:not(.eyebrow) { max-width: 540px; margin: 14px 0 0; color: var(--muted); line-height: 1.55; }
.profile-guest .primary-button { margin-top: 22px; }
.profile-heading { display: flex; align-items: center; gap: 18px; }
.profile-modal-avatar { display: grid; flex: 0 0 auto; place-items: center; width: 94px; height: 94px; overflow: hidden; border: 4px solid #d3ead8; border-radius: 50%; color: var(--green-dark); background: #e8f5e9; font-size: 2.1rem; font-weight: 850; }
.profile-modal-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-level-title, .profile-rank { margin: 6px 0 0; color: var(--muted); line-height: 1.4; }
.profile-level-title { color: var(--green-dark); font-weight: 800; }
.profile-rank { font-size: .88rem; }
.profile-actions { margin-top: 20px; }
.profile-full-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 20px; }
.profile-full-stats > div { padding: 14px 12px; border: 1px solid #dce9df; border-radius: 15px; background: #f5f9f5; text-align: center; }
.profile-full-stats strong, .profile-full-stats span { display: block; }
.profile-full-stats strong { color: var(--green-dark); font: 800 clamp(1.2rem, 4vw, 1.65rem)/1.15 Georgia, serif; font-variant-numeric: tabular-nums; }
.profile-full-stats span { margin-top: 5px; color: var(--muted); font-size: .74rem; line-height: 1.25; }
.start-overlay { position: fixed; z-index: 1200; inset: 0; display: grid; place-items: center; padding: 25px; color: white; background: radial-gradient(circle at 50% 40%, #238445, #093d22); text-align: center; }
.start-overlay-inner { display: grid; place-items: center; gap: 14px; }
.start-overlay-inner > span { font-size: clamp(1.35rem, 5vw, 2rem); font-weight: 800; }
.start-overlay-inner b { display: grid; place-items: center; width: 180px; height: 180px; border: 7px solid #fbbf24; border-radius: 50%; color: #fff8d9; background: rgba(255,255,255,.1); font: 800 6rem Georgia, serif; box-shadow: 0 0 0 18px rgba(255,255,255,.08); animation: countdown-pulse .68s ease-out both; }
.start-overlay-inner small { font-size: .95rem; }
@keyframes countdown-pulse { from { transform: scale(.65); opacity: .45; } to { transform: scale(1); opacity: 1; } }
.score-celebration { position: fixed; z-index: 1210; inset: 0; display: grid; place-items: center; padding: 22px; color: #fffdf1; background: radial-gradient(circle at 50% 42%, rgba(63,157,68,.95), rgba(8,49,29,.98)); text-align: center; }
.score-celebration-card { position: relative; display: grid; justify-items: center; width: min(420px, 100%); padding: 28px clamp(22px, 7vw, 44px) 24px; overflow: hidden; border: 5px solid #f8c940; border-radius: 30px; background: linear-gradient(155deg, #2a904f, #126036 63%, #0b482a); box-shadow: inset 0 0 0 4px rgba(255,255,255,.16), 0 22px 55px rgba(0,0,0,.36); }
.score-celebration-card > span { position: relative; z-index: 1; color: #ffe488; font-size: .82rem; font-weight: 950; letter-spacing: .13em; }
.score-celebration-card > strong { position: relative; z-index: 1; margin: 7px 0 0; color: #fff8c9; font: 950 clamp(3.6rem, 17vw, 5.4rem)/1 Georgia, serif; letter-spacing: -.06em; -webkit-text-stroke: 2px #814e09; text-shadow: 0 5px 0 #814e09, 0 11px 0 rgba(4,38,18,.38); font-variant-numeric: tabular-nums; }
.score-celebration-card > p { position: relative; z-index: 1; margin: 6px 0 0; font-size: .94rem; font-weight: 800; }
.score-celebration-card > small { position: relative; z-index: 1; margin-top: 15px; padding: 7px 12px; border-radius: 99px; color: #e8ffe8; background: rgba(0,0,0,.2); font-size: .8rem; font-weight: 750; }
.celebration-combo-bonus { margin-top: 9px !important; color: #fff1aa !important; background: rgba(235,123,18,.38) !important; box-shadow: 0 0 15px rgba(255,192,42,.28); }
.celebration-level-up { position: relative; z-index: 2; max-width: 310px; margin: 13px 0 -2px !important; padding: 10px 15px !important; border: 2px solid #ffe16f; border-radius: 16px !important; color: #fff7c7 !important; background: linear-gradient(135deg, rgba(255,181,32,.62), rgba(210,105,13,.65)) !important; font: 900 clamp(.88rem, 3.8vw, 1.05rem)/1.3 Georgia, serif !important; box-shadow: 0 0 0 5px rgba(255,225,111,.12), 0 0 24px rgba(255,194,51,.5); }
.celebration-level-up.is-shown { animation: level-up-pop .7s cubic-bezier(.16,1.4,.38,1) both; }
.celebration-tip { max-width: 280px; margin-top: 16px; color: #fff1b5 !important; background: transparent !important; font-size: .74rem !important; line-height: 1.35; }
.celebration-close { position: absolute; z-index: 3; top: 10px; right: 10px; display: grid; place-items: center; width: 36px; height: 36px; border: 2px solid rgba(255,255,255,.4); border-radius: 50%; color: white; background: rgba(0,0,0,.18); font: 900 1.45rem/1 system-ui, sans-serif; }
.celebration-close:focus-visible { outline: 3px solid white; outline-offset: 3px; }
.score-confetti { position: absolute; inset: 12px 8px auto; display: flex; justify-content: space-around; color: #ffdc47; font-size: 1.55rem; letter-spacing: .23em; transform: translateY(-20px); opacity: 0; }
.score-trophy { position: relative; z-index: 1; width: 104px; height: 82px; margin: 3px 0 8px; filter: drop-shadow(0 7px 0 rgba(54,35,4,.28)); }
.score-trophy::before { content: ""; position: absolute; left: 23px; top: 2px; width: 58px; height: 52px; border: 5px solid #f6ca3f; border-radius: 8px 8px 27px 27px; background: linear-gradient(90deg, #e5a826, #fff3a5 49%, #d99617); box-shadow: inset 6px 0 rgba(255,255,255,.25); }
.score-trophy::after { content: ""; position: absolute; left: 34px; bottom: 0; width: 36px; height: 21px; border-radius: 5px 5px 10px 10px; background: #efb22a; box-shadow: 0 -16px 0 -6px #f5c23d; }
.score-trophy i, .score-trophy i::before { position: absolute; box-sizing: border-box; border: 5px solid #f4c440; border-radius: 50%; content: ""; }
.score-trophy i { left: 6px; top: 11px; width: 30px; height: 31px; border-right: 0; }
.score-trophy i::before { left: 62px; top: -5px; width: 30px; height: 31px; border-left: 0; }
.score-trophy b { position: absolute; z-index: 2; left: 42px; top: 15px; color: #8b5108; font-size: 1.25rem; text-shadow: 0 1px #fff1a3; }
.score-celebration.is-running .score-celebration-card { animation: score-card-pop .5s cubic-bezier(.16,1.5,.42,1) both; }
.score-celebration.is-running .score-confetti { animation: score-confetti-fall 3.9s ease-out both; }
.score-celebration.is-running .score-trophy { animation: score-trophy-shine 1.1s ease-in-out .25s 3; }
@keyframes score-card-pop { from { opacity: 0; transform: scale(.54) rotate(-5deg); } to { opacity: 1; transform: scale(1) rotate(0); } }
@keyframes score-confetti-fall { 18% { opacity: 1; } 100% { opacity: 0; transform: translateY(115px) rotate(12deg); } }
@keyframes score-trophy-shine { 0%, 100% { transform: rotate(-3deg) scale(1); } 50% { transform: rotate(4deg) scale(1.1); } }
@keyframes level-up-pop { 0% { opacity: 0; transform: scale(.55) rotate(-4deg); } 55% { opacity: 1; transform: scale(1.08) rotate(1deg); } 100% { opacity: 1; transform: scale(1) rotate(0); } }
.result-stats strong { display: block; font: 700 2rem/1 Georgia, serif; }
.result-stats span { display: block; margin-top: 8px; color: var(--muted); font-size: .82rem; }
#resultLevel, #personalLevel { font-size: clamp(.78rem, 2vw, 1.12rem); letter-spacing: -.035em; white-space: nowrap; }
.parent-summary { margin: 0 0 18px; padding: 22px 24px; border: 1px solid #efc56a; border-radius: 20px; background: #fff8e7; text-align: left; }
.parent-summary > span { display: block; color: #86600c; font-size: .76rem; font-weight: 850; letter-spacing: .09em; text-transform: uppercase; }
.parent-summary > strong { display: block; margin-top: 8px; font: 700 1.9rem/1.1 Georgia, serif; overflow-wrap: normal; word-break: normal; }
.parent-summary > p { margin: 8px 0 0; color: var(--muted); line-height: 1.5; }
.parent-summary.is-perfect { border-color: #9bc9a8; background: var(--green-soft); }
.parent-summary.is-perfect > span { color: var(--green-dark); }
.weak-card { padding: 25px; border-radius: 22px; text-align: left; }
.weak-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.weak-head h3 { margin: 0; font-size: 1.05rem; }
.weak-head span { color: var(--muted); font-size: .8rem; }
.weak-list { display: grid; gap: 8px; margin: 18px 0 0; padding: 0; list-style: none; counter-reset: weak; }
.weak-list li { counter-increment: weak; display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 12px; border-radius: 12px; background: #f6f8f6; }
.weak-list li::before { content: counter(weak); display: grid; place-items: center; width: 26px; height: 26px; color: var(--green); background: white; border-radius: 50%; font-size: .75rem; font-weight: 800; }
.weak-word-info { min-width: 0; }
.weak-word-info strong, .weak-word-info small { display: block; }
.weak-word-info strong { overflow-wrap: anywhere; }
.weak-word-info small { margin-top: 3px; color: var(--muted); line-height: 1.35; }
.weak-list li > span { color: var(--muted); font-size: .82rem; white-space: nowrap; }
.weak-list li > span b { color: var(--ink); font-size: .95rem; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.result-actions .primary-button { margin: 0; }

.modal-backdrop { position: fixed; z-index: 1000; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(9, 28, 17, .67); overflow: auto; overscroll-behavior: contain; }
.admin-modal { position: relative; width: min(760px, 100%); max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px); overflow: auto; padding: clamp(24px, 5vw, 44px); border: 1px solid rgba(255,255,255,.8); border-radius: 28px; background: var(--paper); box-shadow: 0 28px 90px rgba(3, 20, 10, .34); }
.admin-modal h2 { margin: 0; font: 700 clamp(2rem, 5vw, 3rem)/1.08 Georgia, serif; }
.modal-close { position: absolute; z-index: 2; top: 16px; right: 16px; display: grid; place-items: center; width: 42px; height: 42px; border: 0; border-radius: 50%; color: var(--muted); background: #f1f5f2; font-size: 1.75rem; line-height: 1; }
.admin-lead { margin: 14px 52px 0 0; color: var(--muted); line-height: 1.55; }
.admin-login-form { max-width: 430px; margin-top: 26px; }
.admin-login-form input, .admin-fields textarea, .variant-row input { width: 100%; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: white; }
.admin-login-form input, .variant-row input { min-height: 48px; padding: 0 13px; }
.admin-login-form .primary-button { margin-top: 14px; }
.admin-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 54px; }
.admin-mode-actions { display: flex; gap: 8px; margin-top: 22px; }
.admin-mode-actions .quiet-button.is-active { color: white; border-color: var(--green); background: var(--green); }
.admin-fields { display: grid; grid-template-columns: 140px 1fr; gap: 16px; margin-top: 28px; align-items: start; }
.admin-fields textarea, .admin-fields input, .manage-edit-card input { min-height: 48px; padding: 0 13px; }
.admin-fields textarea { min-height: 172px; padding: 12px 13px; resize: vertical; line-height: 1.5; }
.admin-status { min-height: 24px; margin: 16px 0 0; color: var(--muted); font-size: .9rem; line-height: 1.45; }
.admin-status.is-error { color: var(--red); font-weight: 700; }
.admin-status.is-success { color: var(--green); font-weight: 700; }
.speller-credit { margin: 16px 0 0; font-size: .78rem; }
.speller-credit a { color: var(--muted); }
.review-heading { display: flex; justify-content: space-between; gap: 20px; margin-top: 28px; }
.review-heading h3 { margin: 0; font-size: 1.2rem; }
.review-heading p { margin: 6px 0 0; color: var(--muted); font-size: .9rem; }
.review-list { display: grid; gap: 14px; margin-top: 18px; }
.review-card { padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: #f8faf8; }
.review-card-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.review-card-title strong { font-size: 1.2rem; overflow-wrap: anywhere; }
.review-card-title span { color: var(--muted); font-size: .75rem; }
.variant-list { display: grid; gap: 9px; }
.variant-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.replace-button { min-height: 48px; padding: 0 14px; border: 1px solid #b8cdbd; border-radius: 12px; color: var(--green-dark); background: white; font-weight: 750; }
.replace-button:hover { border-color: var(--green); background: var(--green-soft); }
.replace-button:disabled { cursor: wait; opacity: .55; }
.word-warning { margin: 10px 0 0; padding: 9px 11px; border-radius: 10px; color: #7c4b00; background: #fff4d8; font-size: .8rem; line-height: 1.4; }
.admin-modal button[aria-busy="true"] { cursor: wait; }
.manage-edit-card { display: grid; gap: 16px; margin-top: 18px; }
.manage-edit-card .variant-list { margin-top: 0; }
.manage-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; margin-top: 16px; }
.manage-actions .primary-button { margin: 0; }
.delete-button { min-height: 54px; padding: 0 20px; border: 1px solid #dd6b62; border-radius: 14px; color: var(--red); background: var(--red-soft); font-weight: 800; }
.delete-button:hover { border-color: var(--red); background: #ffe1de; }

[hidden] { display: none !important; }

@media (max-width: 760px) {
  .shell { width: min(calc(100% - 22px), 620px); padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
  .topbar { min-height: 82px; gap: 10px; }
  .brand { font-size: 1.05rem; }
  .brand-mark { width: 36px; height: 36px; }
  .school-emblem { width: 108px; height: 58px; }
  .header-side { gap: 10px; }
  .header-action span { display: none; }
  .header-action { min-width: 38px; padding: 0 7px; }
  .top-stat { gap: 10px; font-size: .8rem; }
  .view { min-height: calc(100vh - 82px); min-height: calc(100svh - 82px); }
  .setup-view { display: block; padding: 32px 0 48px; }
  .intro h1 { font-size: clamp(1.75rem, 8.5vw, 3.3rem); letter-spacing: -.03em; }
  .intro > p:last-child { margin-top: 18px; }
  .setup-card { margin-top: 34px; }
  .grade-grid { grid-template-columns: repeat(4, 1fr); }
  .settings-grid { grid-template-columns: 1fr; }
  .mode-grid { grid-template-columns: 1fr; }
  .mode-option > span { min-height: 70px; }
  .quiz-view { padding: 30px 0 52px; }
  .answer-grid { grid-template-columns: 1fr; }
  .answer-button { min-height: 68px; }
  .answer-entry-card { min-height: 140px; }
  .result-stats { grid-template-columns: 1fr; }
  .personal-stats { grid-template-columns: repeat(2, 1fr); }
  .result-stats div { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; }
  .result-stats span { margin: 0; }
  .parent-summary { padding: 19px; }
  .parent-summary > strong { font-size: 1.65rem; }
  .weak-list li { grid-template-columns: 30px minmax(0, 1fr); }
  .weak-list li > span { grid-column: 2; white-space: normal; }
  .result-actions { grid-template-columns: 1fr; }
  .modal-backdrop { align-items: end; padding: 10px; }
  .profile-modal { width: 100%; max-height: calc(100vh - 20px); max-height: calc(100dvh - 20px); padding: 26px 18px 22px; border-radius: 24px 24px 16px 16px; }
  .profile-full-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-modal { width: 100%; max-height: calc(100vh - 20px); max-height: calc(100dvh - 20px); padding: 26px 18px 22px; border-radius: 24px 24px 16px 16px; }
  .admin-heading { gap: 12px; padding-right: 42px; }
  .admin-fields { grid-template-columns: 1fr; }
  .admin-mode-actions { flex-direction: column; }
  .admin-grade-field { max-width: none; }
  .review-heading { align-items: flex-start; }
}

@media (max-width: 420px) {
  .brand > span:last-child { display: none; }
  .school-emblem { width: 118px; height: 62px; }
  .header-side { gap: 5px; }
  .programs-link span { display: none; }
  .school-emblem { width: 78px; height: 49px; }
  .header-action { min-width: 35px; }
  .top-stat { font-size: .7rem; }
  .top-stat { flex-direction: column; gap: 2px; }
  .setup-card, .question-card { border-radius: 22px; }
  .grade-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .repeat-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .answer-entry-row { grid-template-columns: 1fr; }
  .weak-head { align-items: flex-start; flex-direction: column; gap: 4px; }
  .admin-heading { display: block; padding-right: 46px; }
  .admin-heading .quiet-button { margin-top: 12px; }
  .review-heading { display: block; }
  .review-heading .quiet-button { margin-top: 10px; }
  .variant-row { grid-template-columns: 1fr; }
  .replace-button { min-height: 43px; }
  .manage-actions { grid-template-columns: 1fr; }
  .ranking-list li { grid-template-columns: 30px 28px minmax(0, 1fr) auto; gap: 7px; padding: 10px; }
  .ranking-avatar { width: 28px; height: 28px; }
  .ranking-skill { grid-column: 3 / 5; }
  .ranking-preview-head { align-items: flex-start; }
  .profile-modal-avatar { width: 76px; height: 76px; font-size: 1.7rem; }
  .profile-heading { gap: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
  .start-overlay-inner b { animation: none; }
  .score-celebration-card { transform: none; }
}
