/* A quiet classroom desk: a clear board, one control scale, little decoration. */
:root { --paper:#fdfaf2; --ink:#493f3b; --muted:#776b61; --line:#eddfcd; --orange:#ee8056; }
body { background:var(--paper); }
.header { padding-top:20px; padding-bottom:20px; border-bottom:1px solid var(--line); }
.brand-icon { transform:none; box-shadow:none; border-radius:14px; background:#ee8056; }
.header-actions #musicButton, .header-actions #rulesButton { background:#fff; border:1px solid #e8d6bf; color:#715a48; box-shadow:none; border-radius:14px; }
.header-actions #musicButton:hover, .header-actions #rulesButton:hover { background:#fff0df; }
.header-actions #musicButton[aria-pressed="false"] { background:#f3eee6; }
.home { gap:60px; }
.hero-art { transform:none; }
.hero-caption { display:none; }
.eyebrow { color:#65846c; letter-spacing:0; }
.entry-card, .panel, .mini-panel { border:1px solid var(--line); border-radius:22px; box-shadow:none; }
.entry-card { padding:32px; }
.primary, .secondary, .practice, .hint-button, .tool, .exit-button { border-radius:14px; box-shadow:none; }
.primary { background:#ed6a19; }
.primary:hover { background:#e35e10; }
footer { border-top:1px solid var(--line); display:flex; justify-content:space-between; gap:16px; color:#776b61; font-size:15px; }
footer span { letter-spacing:0; }
.teacher-credit { font-weight:700; }
.game-top { margin-bottom:18px; }
.game-top h2 { font-size:32px; }
.game-layout { grid-template-columns:minmax(0,1fr) 252px; gap:20px; align-items:start; }
.board-panel { overflow:hidden; border-radius:22px; }
.board-heading { padding:15px 18px 0; border:0; border-radius:0; font-size:18px; }
.board-heading strong:before { display:none; }
.board-tools { display:block; position:static; margin:0; padding:12px 16px 14px; border:0; border-bottom:1px solid var(--line); border-radius:0; background:#fff; box-shadow:none; }
.rotation-caption { display:flex; gap:7px; margin-bottom:10px; font-size:16px; }
.rotation-caption small { font-size:14px; color:#8b7969; }
.tool-buttons { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:8px; }
.board-tools .tool, .board-tools .rotate-tool, .board-tools #rotateRight {
 display:flex; align-items:center; justify-content:center; gap:5px; width:100%; height:52px; min-height:52px; margin:0; padding:6px;
 border:1px solid #ead4b7; border-radius:14px; background:#fff1d9; color:#7a5638; font-size:17px; line-height:1.15; box-shadow:none; white-space:nowrap;
}
.board-tools .tool:hover { background:#ffe6ba; }
.board-tools .tool:disabled { opacity:.4; }
.rotate-tool svg { width:22px; height:22px; flex-shrink:0; }
.board-wrap { border-radius:0 0 16px 16px; background:#fff; }
.board { background:#fff; }
#rotationGuide line { stroke:#cf7a44; stroke-width:2; stroke-dasharray:4 4; vector-effect:non-scaling-stroke; }
#rotationGuide circle { fill:#cf7a44; }
#rotationHandle { cursor:grab; touch-action:none; outline:none; }
#rotationHandle:active { cursor:grabbing; }
#rotationHandle circle { fill:#ee9757; stroke:#fff; stroke-width:3; vector-effect:non-scaling-stroke; }
#rotationHandle .rotation-hit { fill:transparent; stroke:none; pointer-events:all; }
#rotationHandle:focus-visible circle:not(.rotation-hit) { stroke:#b7693f; stroke-width:5; }
.side-panel { gap:12px; }
.side-panel .mini-panel { padding:18px; background:#fff; }
.side-panel h3 { font-size:21px; margin:0 0 12px; }
.side-panel p { font-size:16px; line-height:1.65; }
.progress-box { padding:18px; border:1px solid var(--line); border-radius:22px; background:#fff; text-align:left; }
.progress-box>div { width:100%; }
.piece-stickers { margin-top:9px; gap:7px; }
.piece-stickers span { width:20px; height:5px; border-radius:3px; font-size:0; background:#efe5d7; }
.piece-stickers span.filled { background:#83b695; box-shadow:none; transform:none; }
.side-panel button, .game-top button { display:flex; align-items:center; justify-content:center; gap:10px; height:52px; min-height:52px; padding:8px 14px; margin-top:0; font-size:19px; }
.side-panel button { width:100%; }
.side-panel .hint-button { background:#fff2c9; color:#7a5638; border:1px solid #ead4b7; }
.side-panel .exit-button { background:transparent; color:#7a6859; border:1px solid #ead4b7; }
#hintCount { font-size:16px; }
.game-bottom { margin-top:18px; font-size:17px; color:#7a6859; }
.game-bottom span { font-size:14px; }
.connection { font-size:13px; }
.finish-overlay { border-radius:14px; background:#fffefb; box-shadow:0 6px 24px #182d4020; }
.success-mascot { display:none; }
.round-recap { background:#fff; border:1px solid var(--line); border-radius:14px; animation:none; }
.puzzle-card { border:1px solid #e8dac4; border-radius:14px; background:#fff; box-shadow:none; }
.puzzle-card:hover { border-color:#e3a66d; box-shadow:0 3px 12px #253d4f12; transform:none; }
.puzzle-preview, .puzzle-card:nth-child(n) .puzzle-preview { background:#edf5e9; border-radius:9px; }
.category { border-radius:9px; }
.category.active { background:#76a287; border-color:#76a287; }
.game-layout:fullscreen, .game-layout.expanded-board { width:100%; height:100dvh; padding:16px; margin:0; background:#fdfaf2; overflow:auto; align-items:stretch; }
.game-layout.expanded-board { position:fixed; inset:0; z-index:100; }
.game-layout:fullscreen .board-panel, .expanded-board .board-panel { display:grid; grid-template-rows:auto auto minmax(0,1fr) auto; min-height:0; }
.game-layout:fullscreen .board-wrap, .expanded-board .board-wrap { min-height:0; display:block; }
.game-layout:fullscreen .board, .expanded-board .board { width:100%; height:100%; }
.game-layout:fullscreen .side-panel, .expanded-board .side-panel { overflow:auto; }
@media(max-width:900px) {
 .game-layout { grid-template-columns:minmax(0,1fr); }
 .side-panel { display:grid; grid-template-columns:1fr 1fr; align-items:start; }
 .side-panel .progress-box { grid-column:1/-1; }
 .side-panel .ranking-panel, .side-panel .practice-note { grid-column:1/-1; }
 .game-layout:fullscreen, .game-layout.expanded-board { grid-template-columns:minmax(0,1fr) 210px; }
 .game-layout:fullscreen .side-panel, .expanded-board .side-panel { display:flex; }
 .home { gap:28px; }
}
@media(max-width:600px) {
 .header { padding:16px; }
 .entry-card { padding:24px; }
 .game-top h2 { font-size:26px; }
 .board-heading { padding:12px 12px 0; font-size:17px; }
 .board-tools { padding:10px; }
 .rotation-caption small { margin-left:0; width:100%; }
 .tool-buttons { gap:5px; }
 .board-tools .tool, .board-tools .rotate-tool, .board-tools #rotateRight { flex-direction:column; gap:2px; font-size:13px; padding:4px 1px; }
 .rotate-tool svg { width:19px; height:19px; }
 .side-panel { gap:10px; }
 .side-panel .mini-panel { padding:14px; }
 .game-layout:fullscreen, .game-layout.expanded-board { display:block; padding:8px; }
 .game-layout:fullscreen .board-panel, .expanded-board .board-panel { height:calc(100dvh - 16px); }
 .game-layout:fullscreen .side-panel, .expanded-board .side-panel { display:grid; margin-top:12px; }
 footer { padding:20px 16px; font-size:14px; }
}

/* Bright classroom colors, with layout rules that never shrink the game canvas. */
.header { flex-wrap:wrap; row-gap:12px; }
.brand { flex-shrink:0; }
.header-actions { margin-left:auto; flex-shrink:0; }
.curriculum { font-size:15px; }
.brand-accent { color:#ee8056; }
.header-actions #musicButton { background:#fff0dc; border-color:#eddbc2; color:#835f3f; }
.header-actions #rulesButton { background:#f2eafb; border-color:#e1d3f0; color:#756083; }
.hero-art { background:transparent; }
.hero-art img {
  mix-blend-mode:darken; border-radius:0;
  -webkit-mask-image:radial-gradient(ellipse at center,#000 55%,transparent 73%);
  mask-image:radial-gradient(ellipse at center,#000 55%,transparent 73%);
}
.entry-card { box-shadow:0 5px 0 #ecdfc54d; background:#fffefa; }
footer { flex-wrap:wrap; align-items:center; gap:8px 24px; line-height:1.7; }
footer span { white-space:normal; word-break:keep-all; }
.button-icon { display:block; width:22px; height:22px; flex:0 0 22px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.board-heading { background:#fff9e8; padding-bottom:12px; }
.board-tools { background:#fffefb; }
.board-tools #rotateLeft, .board-tools #rotateRight { background:#fff0da; color:#8e5c34; border-color:#edd4b0; }
.board-tools #flipPiece { background:#eaf5ed; color:#50765b; border-color:#cfe4d3; }
.board-tools #resetPieces { background:#f4ecfb; color:#7c658c; border-color:#e4d5ed; }
.board-tools #fullscreen { background:#eaf3fc; color:#537591; border-color:#d0e1ef; }
.board { width:100%; height:auto; aspect-ratio:600/660; }
.board-wrap { min-width:0; }
.game-layout>* { min-width:0; }
.game-top { flex-wrap:wrap; gap:12px; }
.game-top>div:first-child { min-width:0; }
.game-top h2 { word-break:keep-all; overflow-wrap:anywhere; }
.side-panel .hint-button { background:#fff0bf; border-color:#ecd79c; color:#8b6a28; }
.side-panel .submit { background:#ed6a19; }
.side-panel .submit:hover { background:#e35e10; }
.side-panel #submitButton { display:flex; align-items:center; justify-content:center; text-align:center; font-weight:600; }
#submitButton .submit-label { line-height:1.2; white-space:nowrap; }
.side-panel .exit-button { background:#fff8ef; }
.side-panel .mini-panel, .progress-box { background:#fffefa; }
.puzzle-card:nth-child(3n+2) .puzzle-preview { background:#fff1df; }
.puzzle-card:nth-child(3n) .puzzle-preview { background:#f1ebfa; }
.game-layout:fullscreen .board, .expanded-board .board { aspect-ratio:auto; }
@media(max-width:1100px) { .curriculum { width:auto; padding-left:0; border:0; } }
@media(max-width:760px) {
 .header { padding:16px; }
 .header .curriculum { display:block; order:3; width:100%; font-size:14px; color:#8a7c6e; }
 .header-actions { gap:8px; }
 .game-layout { grid-template-columns:minmax(0,1fr); }
}
@media(max-width:600px) {
 .tool-buttons { gap:5px; }
 .board-tools .tool, .board-tools .rotate-tool, .board-tools #rotateRight { font-size:14px; height:56px; min-height:56px; white-space:normal; word-break:keep-all; }
 .button-icon { width:20px; height:20px; flex-basis:20px; }
 .board-tools .rotate-tool span { max-width:3em; }
 .side-panel { display:flex; flex-direction:column; }
 .side-panel>* { width:100%; }
 .side-panel .mini-panel { padding:16px; }
 footer { justify-content:center; text-align:center; }
 footer span { width:100%; }
.hero-art { margin-left:auto; margin-right:auto; }
}

/* Legible labels on bright fills, including the less frequent game screens. */
.primary, .primary:hover, .side-panel .submit { color:#fff; font-weight:600; }
.category.active { background:#d9eddd; border-color:#7fa58a; color:#345840; }
.lobby button, .results button, .answer-dialog button, .bank-empty button {
 min-height:52px; font-size:19px; padding:10px 18px; line-height:1.3;
 display:inline-flex; align-items:center; justify-content:center; gap:8px;
}
.lobby .copy { font-size:17px; padding:10px 14px; }
.recap-player { min-width:0; overflow-wrap:anywhere; }
.results h1, .result-player { overflow-wrap:anywhere; }
.result-table { table-layout:fixed; }
.result-table th, .result-table td { overflow-wrap:anywhere; }
.result-table th:nth-child(1) { width:18%; }
.result-table th:nth-child(2) { width:32%; }
.result-table th:nth-child(3) { width:32%; }
.result-table th:nth-child(4) { width:18%; }
.result-table .rank-change { white-space:normal; }
.bank-empty { text-align:center; padding:28px 16px; }
.bank-empty p { margin:0 0 16px; line-height:1.7; }
@media(max-width:600px) {
 .room-ticket { flex-wrap:wrap; gap:14px; text-align:center; }
 .lobby-bottom { align-items:stretch; }
 .lobby-bottom button { width:100%; margin:0; }
 .result-panel { padding:12px; }
 .result-table, .result-table tbody { display:block; }
 .result-table thead { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }
 .result-table tbody { display:grid; gap:12px; }
 .result-table tr { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:8px 12px; padding:16px; border:1px solid var(--line); border-radius:16px; }
 .result-table td { min-width:0; padding:0; border:0; font-size:18px; }
 .result-player { grid-column:1/-1; grid-row:1; line-height:1.6; }
 .result-rank { display:flex; align-items:center; flex-wrap:wrap; gap:6px; }
 .result-table .result-total { grid-column:2; grid-row:2; font-size:22px; }
 .result-total::before { content:attr(data-label); display:block; color:var(--muted); font-size:14px; font-weight:normal; }
 .result-rounds { grid-column:1/-1; grid-row:3; padding-top:10px!important; border-top:1px solid var(--line)!important; }
 .result-rounds::before { content:attr(data-label); display:block; color:var(--muted); font-size:15px; margin-bottom:5px; }
 .result-rounds .round-score { font-size:18px; margin:0; line-height:1.6; }
 .results h1 { font-size:30px; }
 .results .primary, .results .exit-button { width:100%; margin:8px 0; }
 .dialog-actions { flex-direction:column; align-items:stretch; }
}

/* Both choices use the same shape, size and visual weight. */
#leaveDialog .dialog-actions { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; width:100%; margin-top:24px; }
#leaveDialog .dialog-actions button {
 display:flex; align-items:center; justify-content:center;
 width:100%; min-width:0; height:52px; min-height:52px; margin:0; padding:10px 16px;
 border:1px solid #e6ceb2; border-radius:14px; background:#fff8ee; color:#72583e;
 font-size:19px; font-weight:800; line-height:1.3; text-align:center; white-space:nowrap; box-shadow:none;
}
#leaveDialog .dialog-actions button:hover { background:#ffedda; border-color:#d6b58e; }
@media(max-width:420px) { #leaveDialog .dialog-actions { grid-template-columns:minmax(0,1fr); } }
/* One clear line per friend, with a separate total and round reward. */
.round-recap { padding:22px; background:#fffefa; }
.recap-title { align-items:center; flex-wrap:wrap; }
.recap-title h3 { font-size:28px; color:#493f3b; }
.recap-close { min-height:44px; padding:8px 18px; font-size:18px; }
.my-round-result { display:flex; flex-wrap:wrap; align-items:center; gap:8px 24px; padding:14px 18px; margin:16px 0; border-radius:14px; background:#fff0d5; font-size:20px; }
.my-round-result strong { font-size:27px; color:#a74d1b; }
.recap-heading { margin:20px 0 12px; font-size:21px; }
.recap-ranks { display:grid; grid-template-columns:minmax(0,1fr); list-style:none; padding:0; margin:0; gap:8px; }
.recap-player { display:grid; grid-template-columns:66px minmax(0,1fr) 108px; gap:16px; align-items:center; min-width:0; padding:14px 18px; border:1px solid #e7ded0; border-radius:14px; background:#fff; }
.recap-player.me { border:2px solid #e2a95a; padding:13px 17px; background:#fff7e6; }
.recap-rank { display:flex; flex-direction:column; align-items:center; justify-content:center; min-height:62px; border-radius:12px; background:#f3eee7; color:#654c3c; }
.recap-rank>strong { font-size:30px; line-height:1.2; }
.recap-rank>strong>span { font-size:19px; margin-left:3px; }
.recap-rank>small { font-size:14px; line-height:1.2; }
.recap-person { min-width:0; }
.recap-name { display:flex; flex-wrap:wrap; align-items:center; gap:6px 10px; font-size:22px; line-height:1.5; }
.recap-name>strong { min-width:0; overflow-wrap:anywhere; }
.me-badge { display:inline-flex; align-items:center; justify-content:center; padding:1px 8px; border-radius:8px; background:#f6d999; color:#66491f; font-size:15px; font-weight:700; white-space:nowrap; }
.recap-person .rank-change { margin-top:4px; font-size:17px; line-height:1.5; white-space:normal; word-break:keep-all; color:#74675c; }
.recap-person .rank-change.up { color:#a75425; }
.recap-person .rank-change.down { color:#486c91; }
.recap-score { display:flex; flex-direction:column; align-items:flex-end; gap:4px; }
.recap-score>strong { font-size:30px; line-height:1.25; color:#493f3b; white-space:nowrap; }
.recap-score>strong>span { font-size:19px; margin-left:3px; }
.round-gain { font-size:17px; color:#926127; white-space:nowrap; }
.recap-note { font-size:17px; line-height:1.6; }
.ranking-panel .score-row { display:grid; grid-template-columns:38px minmax(0,1fr) auto; gap:8px; align-items:center; padding:12px 0; }
.ranking-panel .medal { display:flex; flex-direction:column; align-items:center; font-size:19px; font-weight:700; line-height:1.4; }
.ranking-panel .medal small { font-size:12px; }
.ranking-panel .name { min-width:0; font-size:18px; line-height:1.5; overflow-wrap:anywhere; }
.ranking-panel .points { font-size:21px; white-space:nowrap; }
@media(max-width:600px) {
 .board-tools .tool, .board-tools .rotate-tool, .board-tools #rotateRight { flex-direction:row; }
 .board-tools .rotate-tool span { max-width:none; }
 .round-recap { padding:14px; }
 .recap-title h3 { font-size:24px; }
 .my-round-result { padding:12px; font-size:18px; gap:4px 16px; }
 .my-round-result>span { display:block; }
 .my-round-result strong { font-size:24px; }
 .recap-heading { font-size:20px; }
 .recap-player { grid-template-columns:46px minmax(0,1fr) 74px; gap:9px; padding:12px 8px; }
 .recap-player.me { padding:11px 7px; }
 .recap-rank { min-height:54px; border-radius:10px; }
 .recap-rank>strong { font-size:25px; }
 .recap-rank>strong>span { font-size:16px; margin-left:1px; }
 .recap-name { font-size:19px; gap:4px; }
 .recap-score>strong { font-size:26px; }
 .recap-score>strong>span { font-size:17px; }
 .round-gain { font-size:15px; }
 .recap-person .rank-change { font-size:15px; }
}
@media(max-width:380px) {
 .recap-player { grid-template-columns:44px minmax(0,1fr); }
 .recap-person { grid-column:2; }
 .recap-score { grid-column:2; flex-direction:row; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:4px 12px; }
}
/* A brief result card: no board or previous-round panel competes for attention. */
.round-pause { min-height:calc(100dvh - 210px); display:grid; place-items:center; padding:16px 0; }
.finish-overlay.round-summary { position:static; inset:auto; width:min(100%,520px); min-width:0; display:block; padding:24px; border:1px solid #eadbc6; border-radius:22px; background:#fffefa; text-align:center; box-shadow:none; }
.summary-round { color:#827363; font-size:17px; }
.round-summary h2 { margin:8px 0; font-size:28px; line-height:1.4; word-break:keep-all; }
.round-summary .summary-reward { margin:8px 0 20px; color:#77593c; font-size:20px; line-height:1.5; }
.summary-reward strong { color:#a45123; }
.round-summary h3 { font-size:19px; margin:0 0 10px; }
.summary-ranks { list-style:none; margin:0; padding:0; display:grid; gap:7px; text-align:left; }
.summary-ranks li { display:grid; grid-template-columns:48px minmax(0,1fr) 62px; align-items:center; gap:12px; padding:10px 12px; min-height:58px; border:1px solid #e9e0d3; border-radius:12px; background:#fff; }
.summary-ranks li.me { background:#fff0d2; border-color:#dda556; }
.summary-rank { display:flex; flex-direction:column; align-items:center; font-size:23px; line-height:1.3; }
.summary-rank small { font-size:12px; }
.summary-name { min-width:0; overflow-wrap:anywhere; font-size:20px; font-weight:600; line-height:1.45; }
.summary-total { font-size:25px; white-space:nowrap; text-align:right; }
.round-summary .summary-next { font-size:18px; line-height:1.5; margin:18px 0 0; color:#6f624e; }
.summary-next strong { display:inline-block; min-width:1ch; color:#b65822; font-size:23px; }
.round-summary .connection { margin-top:8px; font-size:12px; }
@media(max-width:600px) {
 .round-pause { min-height:0; padding:0; }
 .finish-overlay.round-summary { padding:20px 14px; }
 .round-summary h2 { font-size:24px; }
 .round-summary .summary-reward { font-size:18px; }
 .summary-ranks li { grid-template-columns:40px minmax(0,1fr) 53px; gap:8px; padding:9px 8px; }
 .summary-name { font-size:18px; }
 .summary-total { font-size:23px; }
 .summary-rank { font-size:21px; }
 .round-summary .summary-next { font-size:17px; }
}

/* Keep orange action labels consistent and avoid synthetic bold on Jua. */
.entry-card #createButton, .primary, .primary:hover, .side-panel #submitButton {
 font-family:"Jua","Noto Sans KR",sans-serif; font-size:19px; font-weight:600; line-height:1.3;
}
.results h1 { font-size:32px; line-height:1.5; }
.results h1 em { font-size:inherit; font-weight:inherit; }
@media(max-width:600px) { .results h1 { font-size:28px; } }
/* Shared type and control scale across home, bank, play, results and dialogs. */
:root { --font-ui:"Jua","Noto Sans KR",sans-serif; --text-body:18px; --text-action:19px; --text-compact:16px; --text-note:14px; --title-size:32px; --control-height:52px; font-family:var(--font-ui); }
body { font-family:var(--font-ui); font-size:var(--text-body); }
button, input, select, h1, h2, h3, .brand, .puzzle-name { font-family:var(--font-ui); }
h1, .home h1, .lobby h1, .bank h1, .results h1 { font-size:var(--title-size); font-weight:700; line-height:1.45; }
h2, .entry-card h2, dialog h2, .finish-overlay h2, .round-summary h2 { font-size:24px; font-weight:700; line-height:1.45; }
h3, .side-panel h3, .round-summary h3 { font-size:20px; font-weight:700; line-height:1.4; }
.game-top h2 { font-size:28px; }
.brand-name { font-size:22px; font-weight:700; }
.entry-card p, .intro p, .lobby-heading p, .bank-heading p, .results>p, .side-panel p, .game-bottom, .finish-overlay p { font-size:var(--text-body); line-height:1.7; }
.entry-card label, .search-label, .puzzle-name, input { font-size:var(--text-body); }
.puzzle-name { font-weight:600; line-height:1.5; }
.puzzle-status, .small-note, .waiting-note, .rotation-caption, .board-heading, .summary-round { font-size:var(--text-compact); }
.connection, .rotation-caption small, .game-bottom span, footer { font-size:var(--text-note); }
.primary, .secondary, .practice, .hint-button, .exit-button, .copy,
.entry-card #createButton, .side-panel #submitButton, .lobby button, .results button,
.answer-dialog button, #leaveDialog .dialog-actions button, .finish-overlay button {
 font-family:var(--font-ui); font-size:var(--text-action); font-weight:600; line-height:1.3;
 min-height:var(--control-height); height:var(--control-height); min-width:0;
 display:inline-flex; align-items:center; justify-content:center; gap:8px; padding:8px 14px; border-radius:14px;
}
.entry-card input, .join-row input, .search-label input { min-height:var(--control-height); height:var(--control-height); font-size:var(--text-body); }
.header-actions #musicButton, .header-actions #rulesButton {
 font-family:var(--font-ui); font-size:var(--text-compact); font-weight:600; line-height:1.3;
 height:var(--control-height); min-height:var(--control-height); min-width:0; padding:8px 12px;
}
.board-tools .tool, .board-tools .rotate-tool, .board-tools #rotateLeft, .board-tools #rotateRight, .board-tools #flipPiece, .board-tools #resetPieces, .board-tools #fullscreen {
 font-family:var(--font-ui); font-size:var(--text-compact); font-weight:600; line-height:1.25;
 min-height:var(--control-height); height:var(--control-height); padding:4px; gap:0;
 white-space:normal; word-break:keep-all; flex-direction:row;
}
.category { font-family:var(--font-ui); font-size:var(--text-compact); font-weight:600; min-height:44px; padding:8px 14px; line-height:1.3; }
#hintCount { font-size:var(--text-compact); }
#leaveDialog .dialog-actions button { width:100%; }
.summary-name, .round-summary .summary-reward, .round-summary .summary-next { font-size:var(--text-body); }
.summary-rank, .summary-total, .summary-next strong { font-size:24px; }
.result-table th, .result-table td, .result-table .round-score { font-size:var(--text-body); }
@media(max-width:600px) {
 :root { --title-size:28px; }
 .game-top h2 { font-size:24px; }
 .brand-name { font-size:20px; }
 .header-actions { gap:8px; }
 .board-tools .tool span { max-width:100%; }
 .finish-overlay .primary, .finish-overlay .secondary { font-size:var(--text-action); }
}
@media(max-width:680px) {
 .home .intro { display:grid; grid-template-columns:minmax(0,1fr) 108px; grid-template-areas:"title art" "copy copy"; align-items:center; gap:12px 8px; }
 .home .intro h1 { grid-area:title; max-width:none; margin:0; }
 .home .intro p { grid-area:copy; max-width:none; margin:0; }
 .home .hero-art { grid-area:art; position:static; width:108px; height:116px; max-width:108px; margin:0; }
 .home .hero-art img { width:100%; height:100%; object-fit:contain; }
}

/* Keep all five tools readable on the narrowest phones. */
@media (max-width: 380px) {
  .board-tools #rotateLeft, .board-tools #rotateRight,
  .board-tools #flipPiece, .board-tools #resetPieces,
  .board-tools #fullscreen { font-size: 14px; padding-inline: 0; }
}


/* One mascot and one feedback card vocabulary for every outcome. */
.feedback-mascot { display:block; width:80px; height:80px; object-fit:contain; margin:0 auto 12px; flex-shrink:0; mix-blend-mode:multiply; }
.feedback-card, #answerDialog.feedback-card { box-sizing:border-box; padding:24px; border:1px solid #eadbc6; border-radius:22px; background:#fffefa; text-align:center; color:var(--ink); }
.feedback-card h2, #answerDialog h2 { margin:8px 0 12px; font-size:24px; line-height:1.45; font-weight:700; text-align:center; white-space:pre-line; }
.feedback-card p, #answerDialog p { font-size:18px; line-height:1.7; text-align:center; margin:12px 0 18px; }
#answerDialog { width:min(520px,calc(100% - 32px)); max-height:calc(100dvh - 32px); overflow-y:auto; }
#answerDialog .primary { width:100%; min-width:0; margin-top:0; }
.board-wrap:has(#solvedOverlay:not(:empty)) #board { display:none; }
#solvedOverlay:not(:empty) { width:100%; }
#solvedOverlay .finish-overlay { position:static; inset:auto; display:flex; gap:8px; width:100%; max-height:none; box-shadow:none; }
#solvedOverlay .finish-overlay button { width:100%; margin:0; flex-shrink:0; }
/* A short fullscreen board must keep the completed puzzle's actions reachable. */
.game-layout:fullscreen .board-wrap:has(#solvedOverlay:not(:empty)),
.game-layout.expanded-board .board-wrap:has(#solvedOverlay:not(:empty)) {
  overflow-y:auto;
  overscroll-behavior:contain;
  scrollbar-gutter:stable;
}
.solve-receipt { font-size:18px; line-height:1.5; padding:12px 16px; width:100%; box-sizing:border-box; }
.solve-receipt b { font-size:24px; }
.player-avatar { display:inline-grid; place-items:center; width:28px; height:28px; vertical-align:middle; font-family:"Jua","Noto Sans KR",sans-serif; font-size:20px; line-height:1; background:#fff1d4; border-radius:9px; flex-shrink:0; }
.avatar .player-avatar { width:44px; height:44px; font-size:28px; }
.result-mascot { margin-bottom:12px; }
/* Give the three-second ranking its own screen, including on short phones. */
body:has(.round-pause) > .header,
body:has(.round-pause) > footer { display:none; }
body:has(.round-pause) #app { width:100%; max-width:none; margin:0; padding:0; }
.round-pause { min-height:100dvh; padding:12px; }
.summary-intro-text { min-width:0; }
.summary-name { display:grid; grid-template-columns:28px minmax(0,1fr); align-items:center; gap:6px; }
.summary-player-name { min-width:0; overflow-wrap:anywhere; }
.round-summary .connection:not(.offline) { display:none; }
@media(max-width:600px) {
 .round-pause { padding:8px; }
 .finish-overlay.round-summary { padding:12px; }
 .summary-intro { display:flex; align-items:center; gap:10px; margin-bottom:10px; }
 .summary-intro .feedback-mascot { width:64px; height:64px; margin:0; }
 .summary-intro-text { flex:1; text-align:left; }
 .summary-intro-text h2 { text-align:left; margin:4px 0; line-height:1.35; }
 .summary-intro-text .summary-reward { text-align:left; margin:4px 0 0; line-height:1.4; }
 .round-summary h3 { margin:0 0 6px; }
 .summary-ranks { gap:4px; }
 .summary-ranks li { grid-template-columns:34px minmax(0,1fr) 44px; gap:6px; padding:6px; min-height:52px; }
 .summary-name { grid-template-columns:24px minmax(0,1fr); gap:4px; font-size:18px; line-height:1.35; }
 .summary-rank, .summary-total { font-size:20px; }
 .round-summary .summary-next { margin:8px 0 0; line-height:1.4; }
}
@media(min-width:601px) and (max-height:650px) {
 .round-pause { padding:10px; }
 .finish-overlay.round-summary { width:min(100%,850px); padding:16px; display:grid; grid-template-columns:minmax(0,.8fr) minmax(0,1.2fr); align-items:center; gap:8px 20px; }
 .summary-intro .feedback-mascot { margin-bottom:6px; }
 .summary-intro-text .summary-reward { margin:8px 0 0; }
 .summary-ranks { gap:4px; }
 .summary-ranks li { min-height:52px; padding:6px 8px; gap:8px; }
 .summary-name { font-size:18px; line-height:1.35; }
 .round-summary .summary-next { grid-column:1/-1; margin:0; }
 .round-summary .connection { grid-column:1/-1; }
}
@media(max-width:600px) {
 .feedback-card, #answerDialog.feedback-card { padding:20px 14px; }
 .feedback-card h2, #answerDialog h2 { font-size:24px; }
 .feedback-card p, #answerDialog p { font-size:18px; }
 .summary-name .player-avatar { width:24px; height:24px; font-size:18px; }
}
/* Short landscape play: give the puzzle the full height, with controls beside it. */
:is(.game-layout:fullscreen, .game-layout.expanded-board) .progress-box { width:100%; min-width:0; }
:is(.game-layout:fullscreen, .game-layout.expanded-board) .progress-box>div { min-width:0; }



/* Classroom feedback: outcomes use the same centered native dialog. */
#correctDialog { width:min(520px,calc(100% - 32px)); max-height:calc(100dvh - 32px); overflow-y:auto; }
#correctDialog button { width:100%; min-width:0; margin:0; }
#correctDialog button + button { margin-top:10px; }
#correctDialog .solve-receipt { display:grid; gap:6px; }
.brand-icon { display:flex; align-items:center; justify-content:center; flex:0 0 36px; padding:7px; line-height:1; }
.brand-icon svg { display:block; width:100%; height:100%; overflow:visible; }
.brand-icon polygon { fill:#fffaf1; stroke:#ee8056; stroke-width:0.12; stroke-linejoin:round; }
.side-panel .exit-button, #confirmLeave { background:#845034; color:#fff; border:1px solid #845034; }
.side-panel .exit-button:hover, #confirmLeave:hover { background:#683b24; border-color:#683b24; }
.board-heading .board-instructions { display:block; margin:6px 0 0; font-size:16px; line-height:1.5; font-weight:400; color:var(--muted); }
.board-instructions small { display:block; font-size:14px; margin-top:2px; }
.board-tools { justify-content:center; }
.teacher-credit { margin-left:auto; text-align:right; }

:root { font-synthesis:none; }
#answerDialog .answer-icon { display:grid; place-items:center; width:80px; height:80px; margin:0 auto 12px; font-size:60px; line-height:1; font-family:"Apple Color Emoji","Segoe UI Emoji","Noto Color Emoji",sans-serif; }

/* Classroom follow-up: larger title, blended illustration and readable rules. */
.home .intro h1 { font-size:clamp(42px,5vw,60px); line-height:1.2; }
.home .intro h1 em { font-size:inherit; }
.feedback-mascot { filter:brightness(1.04); mix-blend-mode:multiply; }
.board-instructions .snap-instructions { color:inherit; font:inherit; }

/* Ranking changes remain visible after the movement, including reduced motion. */
.summary-ranks li { position:relative; }
.summary-ranks li[data-rank-changed="true"] { border-color:#e69355; }
.summary-ranks .summary-rank { transform-origin:center; }

/* Keep the instructions in their previous reading font. */
#rulesDialog, #rulesDialog :is(h1,h2,h3,button) { font-family:"Noto Sans KR",sans-serif; }

.header-actions #rulesButton:hover { background:#f2eafb; border-color:#e1d3f0; color:#756083; }

/* Give the larger portrait board the phone's available width. */
@media(max-width:600px) {
  main:has(.game-layout) { padding-left:8px; padding-right:8px; }
  .board-heading { padding:12px; }
  .board-heading .board-instructions { font-size:14px; }
  .board-instructions .snap-instructions { font:inherit; }
  .board-tools { padding:8px; }
  .tool-buttons { grid-template-columns:repeat(5,minmax(0,1fr)); }
}

.winner-announcement { min-height:55vh; display:grid; align-content:center; justify-items:center; gap:24px; text-align:center; padding:32px 16px; }
.winner-announcement h1 { font-size:clamp(30px,5vw,52px); margin:0; color:#80502f; }
.winner-drum { font-size:clamp(50px,9vw,90px); animation:drum-bounce .3s ease-in-out infinite alternate; }
.winner-announcement p { font-size:24px; color:var(--muted); }
@keyframes drum-bounce { to { transform:translateY(-8px) rotate(5deg); } }
@media(prefers-reduced-motion:reduce) { .winner-drum { animation:none; } }

/* Focused play uses only the viewport: tools, board, and essential actions. */
body:has(.expanded-board) { overflow:hidden; }
:is(.game-layout:fullscreen, .game-layout.expanded-board) {
  box-sizing:border-box; width:100%; height:100dvh; padding:6px;
  display:grid; grid-template-columns:minmax(0,1fr); grid-template-rows:minmax(0,1fr) auto;
  gap:6px; overflow:hidden;
}
:is(.game-layout:fullscreen, .game-layout.expanded-board) .board-panel {
  display:grid; grid-template-columns:minmax(0,1fr); grid-template-rows:auto minmax(0,1fr);
  height:auto; min-height:0; overflow:hidden;
}
:is(.game-layout:fullscreen, .game-layout.expanded-board) .board-heading,
:is(.game-layout:fullscreen, .game-layout.expanded-board) .feedback { display:none; }
:is(.game-layout:fullscreen, .game-layout.expanded-board) .board-tools { padding:5px; margin:0; position:static; }
:is(.game-layout:fullscreen, .game-layout.expanded-board) .board-wrap { min-height:0; height:100%; overflow:hidden; }
:is(.game-layout:fullscreen, .game-layout.expanded-board) .board { width:100%; height:100%; min-width:0; aspect-ratio:auto; touch-action:none; }
:is(.game-layout:fullscreen, .game-layout.expanded-board) .side-panel { display:flex; flex-direction:column; gap:6px; margin:0; overflow:hidden; }
:is(.game-layout:fullscreen, .game-layout.expanded-board) .side-panel > :not(.submit):not(.mini-panel:has(#hintButton)) { display:none; }
:is(.game-layout:fullscreen, .game-layout.expanded-board) .mini-panel:has(#hintButton) { display:contents; }
:is(.game-layout:fullscreen, .game-layout.expanded-board) .mini-panel:has(#hintButton) > :not(#hintButton) { display:none; }
:is(.game-layout:fullscreen, .game-layout.expanded-board) .side-panel button { flex:1; height:44px; min-height:44px; font-size:16px; }

/* Keep the locked hint visible above submit in focused play. */
:is(.game-layout:fullscreen, .game-layout.expanded-board) #hintButton[hidden] { display:flex; }
#hintCount[hidden] { display:none; }
