:root {
  color-scheme: light;
  --paper: #f7f5ee; --card: #fffdf6; --ink: #171d2d; --muted: #505563; --rule: #c9c6ba;
  --red: #ab193c; --blue: #234ea1; --dark: #192235; --cream: #fff8df; --green: #15704e;
  --sans: "Inter", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  --number: "Barlow Condensed", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  font-family: var(--sans); color: var(--ink); background: var(--paper); -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100svh; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
[hidden] { display: none !important; }
button, input, a { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button, .secondary { cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid var(--blue); outline-offset: 4px; }
button { color: inherit; }
h1, h2, h3, p, dl, dd, figure { margin: 0; }
.shell { width: min(1080px, 100%); margin: 0 auto; padding: 0 clamp(18px, 5vw, 54px) 40px; }
.masthead { min-height: 72px; border-bottom: 2px solid var(--ink); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.brand { display: flex; align-items: center; gap: 7px; font-family: var(--number); font-size: 22px; letter-spacing: -.055em; line-height: 1; white-space: nowrap; }
.brand > span:last-child { font: 800 17px var(--sans); letter-spacing: -.045em; }
.brand-mark { height: 22px; display: flex; align-items: center; gap: 2px; transform: skew(-12deg); margin-right: 4px; }
.brand-mark i { width: 4px; background: var(--red); height: 40%; }
.brand-mark i:nth-child(2), .brand-mark i:nth-child(4) { height: 74%; }
.brand-mark i:nth-child(3) { height: 100%; }
.text-button { border: 0; background: transparent; min-height: 44px; display: inline-flex; gap: 7px; align-items: center; font-size: 14px; font-weight: 700; padding: 4px; }
.info-icon { border: 1.5px solid currentColor; border-radius: 50%; width: 16px; height: 16px; display: grid; place-content: center; font: bold 12px Georgia, serif; }
.home { display: grid; grid-template-columns: 1.12fr 1fr; grid-template-areas: "cover headline" "cover action"; column-gap: clamp(34px, 5.4vw, 76px); padding: clamp(42px, 7.2vw, 88px) 0; align-items: start; }
.home-title { grid-area: headline; align-self: end; }
.school-line { display: flex; gap: 10px; align-items: center; font-size: 14px; font-weight: 800; color: var(--muted); letter-spacing: -.035em; }
.school-colors { width: 24px; height: 10px; transform: skew(-18deg); background: linear-gradient(90deg, var(--red) 0 45%, transparent 45% 55%, var(--blue) 55%); }
.home h1 { margin: 17px 0 19px; font-weight: 900; font-size: clamp(48px, 5.4vw, 76px); letter-spacing: -.083em; line-height: 1.05; }
.home h1 em { color: var(--red); font-style: normal; }
.cover { grid-area: cover; position: relative; isolation: isolate; align-self: stretch; min-height: 410px; }
.cover::after { content: ""; position: absolute; inset: 7px -7px -7px 7px; background: var(--red); z-index: -1; }
.cover img { width: 100%; height: 100%; position: absolute; object-fit: cover; object-position: 48% center; border: 1px solid #3c3430; display: block; }
.home-action { grid-area: action; }
.home-lead { color: #353c49; font-size: 17px; line-height: 1.55; letter-spacing: -.035em; word-break: keep-all; }
.stats { display: grid; grid-template-columns: 1fr 1fr 1.25fr; margin: 23px 0; border-block: 1px solid var(--rule); padding: 13px 0; }
.stats > div + div { padding-left: 14px; border-left: 1px solid var(--rule); }
.stats dt, .grade-score > span, .grade-block > span { font-size: 13px; font-weight: 650; color: var(--muted); }
.stats dd { display: flex; gap: 4px; align-items: baseline; font: 780 29px/1.3 var(--number); letter-spacing: -.055em; }
.stats small { font: 700 14px var(--sans); }
.primary, .secondary { min-height: 52px; width: 100%; padding: 12px 18px; border-radius: 5px; display: inline-flex; align-items: center; justify-content: center; gap: 11px; font-weight: 800; text-align: center; text-decoration: none; color: var(--ink); }
.primary { background: var(--red); border: 1px solid var(--red); color: #fff; }
.primary:active:not(:disabled) { background: #831032; }
.primary:disabled { opacity: .56; }
.secondary { background: transparent; border: 1px solid var(--rule); }
.secondary:active { background: #eae8df; }
.play-icon { width: 0; height: 0; border-left: 11px solid currentColor; border-block: 7px solid transparent; }
.notice { min-height: 0; font-size: 14px; color: var(--red); line-height: 1.45; word-break: keep-all; }
.notice:not(:empty) { margin-top: 8px; }
.score-hud { font-size: 13px; font-weight: 650; display: flex; align-items: baseline; gap: 3px; }
.score-hud strong { color: var(--red); font: 800 24px var(--number); margin-left: 4px; }
.game, .result { width: min(100%, 590px); margin: clamp(24px, 6vh, 65px) auto; }
.round-heading, .answer-heading, .play-footer, .dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.round-heading h1, .result h1 { font-size: clamp(25px, 4.2vw, 39px); letter-spacing: -.065em; font-weight: 850; }
.round-heading p { font-size: 14px; color: var(--muted); white-space: nowrap; }
.round-heading strong { color: var(--red); font: 800 22px var(--number); }
.progress { display: flex; gap: 4px; margin: 15px 0 22px; }
.progress i { flex: 1; height: 5px; background: #dfddd4; border-radius: 1px; }
.progress i[data-state="active"] { background: var(--red); }
.progress i[data-state="correct"] { background: var(--blue); }
.progress i[data-state="done"] { background: #848690; }
.player { color: var(--cream); position: relative; background: var(--dark); border-radius: 8px; overflow: hidden; padding: 18px 22px 0; box-shadow: 0 4px 0 #a6abc0; }
.player-top { display: flex; align-items: center; gap: 7px; color: #e3e7f1; font-size: 13px; }
.player-light { width: 8px; height: 8px; border-radius: 50%; background: #9ba5b9; }
.player-light.on { background: #ff6d7b; box-shadow: 0 0 9px #ff7d8850; }
.time { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.time b { font: 740 22px var(--number); color: var(--cream); font-variant-numeric: tabular-nums; }
.time b.urgent { color: #ffa9a7; }
.player-center { min-height: 60px; padding-top: 14px; display: flex; align-items: center; justify-content: center; gap: 10px; }
.player-center h2 { font-size: clamp(23px, 4vw, 31px); letter-spacing: -.06em; }
.count { font: 850 38px/1 var(--number); color: #ffadb4; }
#wave { display: block; width: 100%; height: clamp(45px, 8vh, 80px); margin: 2px 0 14px; }
.hints { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; }
.hints span { border-top: 2px solid #4e5a71; color: #bcc4d4; font-size: 13px; text-align: center; font-weight: 600; padding: 9px 0 12px; }
.hints span.current { color: #fff1d7; border-color: #ff9da8; }
.hints span.done { border-color: #ccc5b6; }
#answer-form { margin-top: 26px; }
.answer-heading { margin-bottom: 9px; }
.answer-heading label { font-weight: 800; font-size: 16px; }
#available { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.answer-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.answer-row input { min-width: 0; width: 100%; border: 1.5px solid #9395a1; border-radius: 5px; background: var(--card); color: var(--ink); font-size: max(16px, 1rem); padding: 12px; }
.answer-row input:focus { border-color: var(--blue); outline: 2px solid #234ea12a; }
.answer-row .primary { min-width: 76px; }
.play-footer { align-items: flex-start; min-height: 45px; }
.play-footer .text-button { margin-left: auto; flex: none; }
.skip-icon { width: 10px; height: 10px; border-right: 2px solid currentColor; }
.skip-icon::before { content: ""; display: block; border-left: 7px solid currentColor; border-block: 5px solid transparent; }
.last-round { margin-top: 9px; font-size: 14px; font-weight: 650; text-align: center; color: var(--muted); }
.play-recovery { margin-top: 15px; color: var(--red); font-size: 14px; }
.play-recovery button { margin-top: 8px; min-height: 44px; }
.result h1 { margin: 10px 0 20px; }
.grade-card { position: relative; display: grid; grid-template-columns: minmax(96px, 38%) 1fr; align-items: stretch; border: 1.5px solid var(--ink); background: var(--card); margin-bottom: 20px; box-shadow: 4px 4px 0 #d2cfc2; }
.grade-block { padding: 20px 9px; background: var(--red); text-align: center; display: flex; flex-direction: column; justify-content: center; }
.grade-block > span { color: #ffe3e8; }
.grade-block strong { font: italic 900 clamp(62px, 12vw, 100px)/1 var(--number); color: white; letter-spacing: -.075em; padding-right: 6px; }
.grade-score { align-self: center; padding: 22px clamp(14px, 4vw, 26px); }
.grade-score b { font: 850 clamp(31px, 7vw, 54px) var(--number); letter-spacing: -.075em; }
.grade-score small { font-size: 13px; color: var(--muted); white-space: nowrap; }
.hits { color: var(--muted); font-size: 14px; margin-top: 5px; }
.result > .secondary, #save-sheet .secondary { margin-top: 8px; }
.save-icon { width: 15px; height: 15px; position: relative; border: 2px solid currentColor; border-top: 0; height: 7px; margin-top: 7px; }
.save-icon::before { content: "↓"; font-size: 17px; position: absolute; bottom: 1px; left: 0; line-height: 1; }
.review { margin-top: 22px; border-block: 1px solid var(--rule); }
.review summary { padding: 13px 0; font-weight: 750; cursor: pointer; }
.review ol { padding: 0; margin: 0; list-style: none; }
.review li { display: grid; grid-template-columns: 24px 1fr auto; align-items: center; padding: 10px 0; gap: 6px; border-top: 1px solid #dedbd1; }
.review li span:first-child { font: 650 14px var(--number); color: var(--muted); }
.review strong { font-size: 15px; }
.review small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-top: 2px; }
.review li b { color: var(--red); }
dialog { color: var(--ink); border: 1.5px solid var(--ink); border-radius: 10px; background: var(--paper); padding: 18px 20px 22px; width: min(calc(100% - 26px), 460px); max-height: 87svh; overflow: auto; }
dialog::backdrop { background: #11182791; }
.dialog-head { margin-bottom: 12px; }
.dialog-head h2 { font-size: 23px; letter-spacing: -.06em; }
.close { background: transparent; border: 0; font-size: 27px; min-width: 44px; min-height: 44px; }
dialog p, .rules-list { font-size: 15px; line-height: 1.55; word-break: keep-all; }
.rules-list { padding-left: 21px; }
.rules-list li { margin-top: 7px; }
dialog h3 { font-size: 16px; margin: 18px 0 8px; }
.grade-table { display: grid; grid-template-columns: auto 1fr auto 1fr; column-gap: 9px; }
.grade-table dt, .grade-table dd { padding: 6px 0; border-top: 1px solid var(--rule); font-size: 13px; }
.grade-table dt { font-weight: 850; color: var(--red); }
#save-preview { width: auto; max-width: 100%; max-height: 40svh; display: block; margin: 0 auto 14px; border: 1px solid var(--rule); -webkit-touch-callout: default; }
#save-help { margin: 0 0 12px; }
#confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 3; }
#confetti i { position: absolute; width: 8px; height: 14px; top: -25px; animation: fall var(--duration) ease-in var(--delay) both; }
@keyframes fall { from { transform: translate3d(0,-3vh,0) rotate(0); } to { transform: translate3d(var(--drift),105vh,0) rotate(var(--turn)); } }
@media (max-width: 680px) {
  .shell { max-width: 490px; }
  .masthead { min-height: 58px; }
  .brand { font-size: 20px; }
  .home { display: flex; flex-direction: column; gap: 0; padding: 22px 0 5px; }
  .home-title, .home-action, .cover { width: 100%; }
  .home h1 { margin: 10px 0 17px; font-size: clamp(37px, 8.7vw, 48px); line-height: 1.12; }
  .home h1 br { display: none; }
  .home h1 em::before { content: " "; }
  .cover { min-height: 0; height: auto; aspect-ratio: 1.85; margin-bottom: 22px; width: calc(100% - 4px); }
  .cover::after { inset: 4px -4px -4px 4px; }
  .school-line { font-size: 13px; }
  .wide-break { display: none; }
  .home-lead { font-size: 16px; }
  .stats { margin: 14px 0 16px; padding: 9px 0; }
  .stats dd { font-size: 26px; }
  .game, .result { margin: 24px auto 10px; }
  .player { padding: 14px 15px 0; }
  .progress { margin: 12px 0 17px; }
}
@media (max-height: 560px) {
  .game { margin-top: 10px; }
  .progress { margin: 5px 0 9px; }
  .player-center { min-height: 37px; padding: 2px; }
  #wave { height: 30px; margin-bottom: 4px; }
  #answer-form { margin-top: 13px; }
}
@media (prefers-reduced-motion: reduce) { #confetti i { animation: none; } }
