:root {
  color-scheme: light;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  --ink: #2d211a;
  --red: #a22d29;
  --green: #305b50;
  --cream: #fff7e7;
  --stationery: #f7e8c8;
  --stationery-line: #cfb68d;
  --stamp: #a22d29;
  --exam-font: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  font-family: system-ui, "PingFang TC", "Microsoft JhengHei", sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  min-height: 100vh;
  margin: 0;
  touch-action: manipulation;
  background-color: #f3d6a5;
  background-image:
    radial-gradient(ellipse at 38% 0%, #fff5dcba 0%, transparent 75%),
    url("data:image/svg+xml,%3Csvg viewBox='0 0 600 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='grain'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.014 .44' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Cpath opacity='.14' filter='url(%23grain)' d='M0 0h600v160H0z'/%3E%3C/svg%3E"),
    repeating-linear-gradient(178deg, #a8754112 0 1px, transparent 1px 9px, #fff3d62b 9px 11px, transparent 11px 21px),
    linear-gradient(135deg, #f8e6bd, #efcd9d);
  background-size: auto, 600px 160px, auto, auto;
}
body.grading-in-progress, body.grading-in-progress * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
button, input { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid #2e6654; outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.desk { max-width: 1330px; margin: auto; padding: 27px 26px 0; }
.intro { display: flex; align-items: center; justify-content: space-between; gap: 17px; }
.eyebrow { margin: 0; color: #513325; font-weight: 800; font-size: .75rem; letter-spacing: .16em; }
.desk-tag { display: inline-block; background: #fff4d1; border: 1px solid #d7b37b; border-radius: 20px; padding: 4px 10px; }
.intro h1 {
  margin: 6px 0; font-weight: 950; font-size: clamp(2rem, 5.5vw, 4.5rem); line-height: 1.12;
  letter-spacing: -.065em; color: #234b3d; text-shadow: 1px 2px #fff8db;
}
.title-highlight {
  display: inline-block; padding: 0 .06em; white-space: nowrap; color: #a22d29;
  background: linear-gradient(177deg, transparent 61%, #ffd56f 62% 91%, transparent 92%);
}
.title-bang { display: inline-block; transform: rotate(9deg); }
.intro p:last-child { margin: 8px 0 0; color: #36241b; font-size: .9rem; }
.clock-card {
  width: 143px; flex: 0 0 auto; padding: 8px 12px;
  border: 2px solid #a75a51; border-radius: 10px;
  background: #cb8175; color: #3f231f; box-shadow: 0 4px 0 #a46158;
}
.clock-label { display: block; margin-bottom: 4px; font: 750 .68rem/1.2 system-ui, sans-serif; letter-spacing: .16em; }
#clock-digits {
  display: block; width: 100%; padding: 5px 8px; border-radius: 4px; background: #402a2a;
  color: #fff0dc; stroke: currentColor; stroke-width: 3.4; stroke-linecap: round; fill: none;
}
#clock-digits .unlit { opacity: .12; }
.clock-card.urgent #clock-digits { color: #ffb5a8; }
#practice-clock { display: block; padding: 5px 0; border-radius: 4px; background: #402a2a; color: #fff0dc; text-align: center; font-size: .95rem; font-weight: 850; }
progress { display: block; width: 100%; height: 3px; margin-top: 5px; appearance: none; border: 0; border-radius: 4px; overflow: hidden; background: #b16c63; }
progress::-webkit-progress-bar { background: #b16c63; }
progress::-webkit-progress-value { background: #683b38; }
progress::-moz-progress-bar { background: #683b38; }
.workspace { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; align-items: start; }
.sheet-pane { min-width: 0; scroll-margin-top: calc(var(--grading-height, 160px) + 10px); }
.sheet-pane { container-type: inline-size; }
.pane-label { display: flex; justify-content: space-between; align-items: center; gap: 5px; padding: 0 1px 6px; color: #342217; }
.pane-label h2, .pane-label span { margin: 0; font-size: .85rem; font-weight: 800; }
.pane-label h2 { border: 1px solid #c0ab96; border-radius: 9px; padding: 5px 12px; background: #ffecad; font-size: 1.04rem; }
#student-sheet h2 { background: #ffded3; border-color: #d49688; }
.pane-label span { font-size: .72rem; }
.paper {
  position: relative; aspect-ratio: 210 / 297; display: flex; flex-direction: column;
  padding: clamp(9px, 4cqw, 22px); background: #fff; color: #151515;
  border: 1px solid #7e5a40; box-shadow: 1px 3px 0 #e4dfd5, 2px 4px 0 #84654c, 4px 7px 12px #512a2654;
  font-family: var(--exam-font);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.reference { box-shadow: 2px 4px 8px #512a264e; }
.exam-heading { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: .82rem; text-align: center; }
.exam-heading th, .exam-heading td { border: 1px solid #464646; padding: 0; }
.exam-heading thead th { padding: 4px 0; letter-spacing: .07em; font-size: .95rem; }
.exam-heading tbody th { font-size: .73rem; padding: 2px 0; line-height: 1.05; overflow-wrap: anywhere; }
.exam-heading tbody td { height: 33px; font-weight: 700; font-size: .76rem; overflow-wrap: anywhere; }
.label-col { width: 6.2%; }
.value-col { width: 11.7%; }
.name-col { width: 22.2%; }
.question-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sheet-group { min-width: 0; padding: 7px 6px 4px 0; }
.sheet-group + .sheet-group { border-left: 1px solid #777; padding: 7px 0 4px 7px; }
.sheet-group h3 { min-height: 2.4em; margin: 0 0 5px; font-size: .87rem; line-height: 1.2; }
.sheet-group ol { padding: 0; margin: 0; list-style: none; }
.sheet-group li { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 2px; align-items: start; min-height: clamp(42px, 12.3cqw, 68px); margin-bottom: 2px; font-size: clamp(.76rem, 3.45cqw, .9rem); line-height: 1.32; }
.answer-slot { display: flex; justify-content: space-between; align-items: baseline; font: .88rem/1.25 var(--exam-font); }
.written-answer { color: #254b88; font: 1.31rem/1 "Marker Felt", "Segoe Print", cursive; transform: rotate(-8deg); }
.true-false-mark { font-weight: 900; -webkit-text-stroke: .85px currentColor; }
.reference .written-answer { color: #b32527; font-weight: 800; transform: none; }
.question-text { overflow-wrap: anywhere; }
.q-number { font-variant-numeric: tabular-nums; }
.options { display: block; margin-top: 3px; }
.paper-page { margin-top: auto; padding-top: 8px; border-top: 1px solid #b2b2b2; text-align: center; font-size: .68rem; }
#ink { position: absolute; z-index: 2; inset: 0; width: 100%; height: 100%; touch-action: none; -webkit-user-select: none; user-select: none; cursor: crosshair; }
#ink.viewport-zoomed { touch-action: pinch-zoom; }
#ink.eraser-active { cursor: cell; }
.start-panel { position: absolute; z-index: 1; inset: clamp(69px, 20cqw, 102px) 0 27px; display: grid; justify-items: center; align-content: start; background: #ffffffeb; text-align: center; font-family: system-ui, sans-serif; padding: clamp(20px, 8cqw, 44px) 10px 10px; }
.start-panel h3 { margin: 0; font-size: 1.27rem; }
.start-panel p { margin: 7px 0 14px; color: #504238; font-size: .9rem; }
.primary { background: var(--green); color: white; border: 1px solid #254638; border-radius: 10px; padding: 9px 11px; font-weight: 800; }
.primary:not(:disabled):hover { background: #365d4e; }
.grading {
  position: sticky; top: 0; z-index: 4; margin: 6px 0 9px; padding: 7px 10px 9px;
  border: 1px solid var(--stationery-line); border-radius: 13px;
  background: #faf0dc; box-shadow: 0 3px 12px #47372130;
}
.grading-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 5px; }
.pen-tools { display: flex; gap: 3px; align-items: center; }
.pen-tools button, .achievement-button, .desk-button {
  min-height: 36px; padding: 4px 7px; border: 1px solid #bda790; border-radius: 7px;
  background: #fffaf0; color: var(--ink); font-size: .78rem; font-weight: 750;
}
.pen-tools button { white-space: nowrap; }
.pen-tools button svg { display: block; width: 27px; height: 27px; }
.pen-tools button[aria-pressed="true"] { background: #ffded5; border-color: #bc7066; }
.grading-count { margin-left: auto; white-space: nowrap; font-size: .95rem; }
.grading-count strong { font-size: 1.12em; }
.achievement-button { background: #fff1bb; white-space: nowrap; }
.lobby-tools { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 13px; }
.mode-buttons { display: flex; flex: 1; gap: 7px; }
.mode-buttons button {
  flex: 0 1 126px; min-width: 0; min-height: 46px; padding: 5px 7px;
  border: 1px solid #b69b71; border-radius: 9px; background: #fff4d7;
  color: #3a2d24; box-shadow: 0 2px 0 #d0b286;
}
.mode-buttons button[data-mode="multi"] { border-color: #bd8f89; background: #ffe3d8; box-shadow: 0 2px 0 #d5a398; }
.mode-buttons button[data-mode="practice"] { border-color: #9eae91; background: #ebf0df; box-shadow: 0 2px 0 #adb99f; }
.mode-buttons button:not(:disabled):hover { filter: brightness(1.04); }
.mode-buttons button[aria-pressed="true"] { outline: 2px solid #7d5b41; outline-offset: -3px; }
.desk-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
.desk-button { background: #fffaf0; }
.achievement-button span { color: #8a5510; }
.grading-body { display: grid; grid-template-columns: minmax(80px, .9fr) minmax(0, 6fr) minmax(100px, 1.55fr); gap: 9px; align-items: center; }
.score-controls { text-align: center; }
.calculator-label { font-size: .72rem; font-weight: 850; }
.score-screen {
  display: grid; place-items: center; min-height: 49px; margin-top: 2px; padding: 3px 5px;
  border: 1px solid #c89182; border-radius: 7px; background: #fffaf0; color: var(--stamp);
  box-shadow: inset 0 2px 2px #b5634320; font: 850 clamp(1.3rem, 3vw, 1.85rem) ui-monospace, monospace;
}
.keypad { display: grid; min-width: 0; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; border: 0; margin: 0; padding: 0; }
.keypad button {
  min-width: 0; height: 44px; padding: 0; border: 1px solid #d2ab7e; border-radius: 7px;
  box-shadow: 0 2px 0 #c9a376; background: #ffe5b7; color: #533823; font-size: 1.18rem; font-weight: 850;
}
.keypad button[data-edit] { background: #f8d7ca; border-color: #d1a096; color: #823e32; box-shadow: 0 2px 0 #c79a87; }
.keypad button[data-edit="clear"] { font-size: .68rem; }
.keypad button:not(:disabled):hover { background: #fff; }
.keypad button[data-score][aria-pressed="true"] { background: #a63d36; border-color: #87322d; color: #fff; box-shadow: 0 2px 0 #87322d; }
.keypad button:not(:disabled):active { transform: translateY(2px); box-shadow: none; }
#submit {
  min-height: 60px; padding-inline: 7px; font-size: 1.13rem; background: #a63d36; border-color: #87322d;
  box-shadow: 0 2px 0 #87322d;
}
#submit:not(:disabled):hover { background: #8e342e; }
.message { margin: 5px 0 0; padding: 4px 6px; border-radius: 4px; background: #fff5de; color: #872824; font-size: .81rem; }
.paper-links { display: none; grid-column: 1; grid-row: 2; flex-wrap: wrap; gap: 3px; }
.paper-links a { padding: 4px; border: 1px solid #c2a77e; border-radius: 5px; background: #fff8e7; color: #483625; font-size: .7rem; font-weight: 750; text-decoration: none; }
dialog { width: min(420px, calc(100% - 30px)); background: var(--cream); color: var(--ink); border: 1px solid #8e8067; border-radius: 8px; padding: 23px; }
dialog::backdrop { background: #302016a6; }
dialog h2 { color: var(--green); margin: 8px 0 0; }
.result-score { margin: 2px 0; color: var(--red); }
.result-score strong { font-size: 3rem; }
#results .result-title {
  display: inline-block; margin: 12px 0 2px; padding: 4px 12px;
  border: 2px solid var(--stamp); border-radius: 6px; background: #ffe9db;
  color: var(--stamp); font-size: clamp(1.55rem, 6vw, 2.1rem); line-height: 1.2;
  box-shadow: 2px 3px 0 #bd73524a; transform: rotate(-2deg);
}
#achievement {
  margin: 12px 0; padding: 10px 12px; border: 1px solid var(--stationery-line);
  border-radius: 10px; background: #fff1d1;
}
#achievement.new-ending { border-color: #b99759; background: #fff0bd; }
#ending-label { color: #804719; font-size: .73rem; font-weight: 850; letter-spacing: .08em; }
#ending-title { margin: 3px 0; color: var(--green); font-size: 1.12rem; }
#ending-detail { margin: 3px 0 0; font-size: .8rem; line-height: 1.4; }
.result-page, .paper-view { max-width: 1080px; padding-bottom: 22px; }
.result-header {
  display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 12px;
  align-items: center; padding: 15px; border: 1px solid #cfb58d; border-radius: 14px; background: #fff8e7;
}
.result-header p:last-child { margin-bottom: 0; }
.result-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
#review {
  padding: 12px; border: 1px solid #ceb58e; border-radius: 12px; background: #fbefd6;
}
#review-title { margin: 0; color: #365548; font-size: 1.18rem; }
#review-note { margin: 4px 0 10px; font-size: .86rem; }
#review-count { margin-left: 4px; padding: 2px 7px; border-radius: 10px; background: #e5eddd; font-size: .8rem; }
#grade-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 145px), 1fr)); gap: 9px; margin: 0; padding: 0; list-style: none; }
.review-card {
  display: grid; align-content: start; justify-items: start; gap: 4px; height: 100%; padding: 7px;
  border: 1px solid #d6bb91; border-radius: 9px; background: #fff9eb; color: var(--ink); text-decoration: none;
}
.review-card:hover { border-color: var(--green); background: #fffdf3; }
.review-card:focus-visible, .back-link:focus-visible { outline: 3px solid #2e6654; outline-offset: 2px; }
.review-card strong { color: #305b50; }
.review-card > span { font-size: .76rem; }
.review-verdict { border-radius: 5px; padding: 2px 5px; background: #f9e4da; color: #863b31; font-size: .73rem; font-weight: 800; }
.review-verdict.correct { background: #e4efde; color: #305b50; }
.review-frame { overflow: hidden; width: 100%; margin: 2px auto 5px; }
.review-page { container-type: inline-size; transform-origin: top left; }
.review-page .paper { box-shadow: none; }
.review-ink { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.paper-view { max-width: 760px; }
.paper-view h1 { margin: 8px 0 4px; color: var(--green); }
.back-link { display: inline-block; padding: 6px 9px; border: 1px solid #c3a67f; border-radius: 8px; background: #fff4db; color: #2c4b3d; font-weight: 800; text-decoration: none; }
@container (max-width: 340px) {
  .sheet-group h3 { font-size: .76rem; }
  .sheet-group li { grid-template-columns: 25px minmax(0, 1fr); font-size: .76rem; line-height: 1.25; }
  .answer-slot { font-size: .78rem; }
  .written-answer { font-size: 1.12rem; }
}
#tutorial, #achievement-dialog {
  border: 1px solid var(--stationery-line);
  background: #fffaed;
}
#tutorial { width: min(510px, calc(100% - 22px)); }
.guide-label { color: #87432e; }
#tutorial-title { font-size: clamp(1.4rem, 5vw, 2rem); }
.tutorial-device-tip { margin: 6px 0 0; color: var(--red); font-size: .82rem; }
.tutorial-steps { display: grid; gap: 6px; padding: 0; counter-reset: tutorial; list-style: none; }
.tutorial-steps li {
  display: grid; grid-template-columns: 27px 1fr; column-gap: 7px; padding: 6px 8px;
  border: 1px solid #dfcda8; border-radius: 8px; background: #fff6e1; line-height: 1.35;
}
.tutorial-steps li::before {
  counter-increment: tutorial; content: counter(tutorial); grid-row: 1 / 3; align-self: center;
  display: grid; place-items: center; height: 26px; border-radius: 50%;
  background: #e1ead7; color: var(--green); font-weight: 850;
}
.tutorial-steps strong { color: var(--green); }
.tutorial-steps span { grid-column: 2; font-size: .84rem; }
.tutorial-modes { font-size: .87rem; line-height: 1.4; }
.tutorial-actions { display: flex; justify-content: flex-end; gap: 8px; align-items: center; }
#tutorial-credit { margin-inline-end: auto; color: var(--green); font-size: .75rem; }
#achievement-dialog { width: min(710px, calc(100% - 22px)); border-top: 5px solid #bb7256; }
.collection-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.collection-controls {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(100px, 145px); gap: 10px; align-items: end;
  margin-top: 12px; padding: 9px; border: 1px solid #dcc8a2; border-radius: 10px; background: #faf0d9;
}
#collection-summary { margin: 0; color: var(--green); font-size: .9rem; font-weight: 800; }
#collection-progress { height: 6px; background: #eddec0; }
#collection-progress::-webkit-progress-bar { background: #eddec0; }
#collection-progress::-webkit-progress-value { background: #d5a545; }
#collection-progress::-moz-progress-bar { background: #d5a545; }
.collection-filter { display: grid; gap: 3px; font-size: .72rem; font-weight: 800; }
#achievement-category {
  appearance: none; width: 100%; min-height: 42px; padding: 5px 31px 5px 11px;
  border: 1px solid #b18b58; border-radius: 10px; color: #463523; font: inherit; font-size: max(16px, 1rem); box-shadow: 0 2px 0 #d5bc90; cursor: pointer;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect width='24' height='24' rx='7' fill='%23f4ddb0'/%3E%3Cpath d='m7 10 5 5 5-5' fill='none' stroke='%2379512e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") right 7px center / 22px no-repeat,
    linear-gradient(#fffdf5, #fff1d4);
}
#achievement-category:focus-visible { outline: 2px solid #2e6654; outline-offset: 2px; }
.achievement-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); gap: 8px; max-height: min(53vh, 520px); overflow: auto; list-style: none; padding: 0 4px 0 0; }
.achievement-list li {
  display: grid; gap: 4px; align-content: start; padding: 9px; border: 1px solid #dfcda8;
  border-left: 4px solid #c8b08c; border-radius: 8px; background: #fff6e3;
}
.achievement-list li.unlocked { border-color: #d6ae52; background: #fff0ad; }
.achievement-list span { font-size: .78rem; }
.achievement-list .ending-code { color: #80583d; font: 750 .73rem/1.2 ui-monospace, monospace; }
.achievement-list strong { color: #314d3f; }
.ending-status { justify-self: start; padding: 2px 6px; border-radius: 5px; background: #eee1c6; font-weight: 750; }
.unlocked .ending-status { color: #694707; background: #f7d778; }
@media (max-width: 1050px) {
  .desk { padding-inline: 15px; }
}
@media (max-width: 680px) {
  .desk { padding: 14px 10px 0; }
  .intro { gap: 6px; }
  .desk-tag { font-size: .64rem; letter-spacing: .06em; padding: 3px 7px; }
  .intro h1 { font-size: clamp(1.65rem, 7vw, 2.7rem); }
  .intro p:last-child { font-size: .73rem; }
  .clock-card { width: 91px; padding: 5px 6px; }
  .clock-label { letter-spacing: .06em; }
  #clock-digits { padding: 4px; }
  .workspace, .result-header { grid-template-columns: minmax(0, 1fr); }
  #grade-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #tutorial { padding: 14px; }
  #tutorial-title { margin-top: 4px; }
  .tutorial-steps { margin-block: 7px; }
  #student-sheet { grid-row: 1; }
  .start-panel { align-content: start; padding-top: 20px; }
  .grading { padding-inline: 6px; }
  .grading-top { gap: 4px; }
  .pen-tools button, .achievement-button { padding-inline: 4px; }
  .grading-count { font-size: .9rem; }
  .grading-body { grid-template-columns: minmax(0, 1fr) 88px minmax(93px, auto); gap: 4px; }
  .keypad { grid-column: 1 / -1; grid-row: 1; }
  .score-controls { grid-column: 2; grid-row: 2; display: flex; gap: 3px; align-items: center; justify-content: space-between; }
  .score-screen { margin-top: 0; min-width: 54px; min-height: 44px; }
  .calculator-label { max-width: 2.2em; line-height: 1.12; }
  #submit { grid-column: 3; grid-row: 2; min-height: 53px; }
  .lobby-tools { flex-wrap: wrap; gap: 5px; }
  .mode-buttons { flex-basis: 100%; }
  .mode-buttons button { flex: 1; min-height: 44px; font-size: .88rem; }
  .desk-actions { margin-left: auto; }
  .desk-actions button { min-height: 29px; }
  .paper-links { display: flex; }
}
@media (max-width: 360px) {
  .grading-top { flex-wrap: wrap; }
  .pen-tools button { padding-inline: 3px; font-size: .68rem; }
  .pen-tools button svg { width: 24px; height: 24px; }
  .grading-count { font-size: .82rem; }
  .start-panel { padding-top: 10px; }
}
@container (max-width: 390px) {
  .question-columns { grid-template-columns: minmax(0, 1.32fr) minmax(0, 1fr); }
  .sheet-group li { min-height: clamp(33px, 11cqw, 46px); align-content: start; row-gap: 0; }
  .question-text { display: contents; }
  .options { grid-column: 1 / -1; margin-top: 1px; padding-left: 4px; font-size: .92em; }
}
@container (max-width: 310px) {
  .paper { padding: 7px 8px; }
  .sheet-group { padding: 5px 3px 2px 0; }
  .sheet-group + .sheet-group { padding: 5px 0 2px 4px; }
  .sheet-group li { grid-template-columns: 22px minmax(0, 1fr); line-height: 1.15; }
  .sheet-group h3 { min-height: 0; margin-bottom: 3px; }
  .options { font-size: .9em; }
  .paper-page { padding-top: 5px; }
}
@media (max-height: 620px) and (max-width: 680px) {
  #tutorial { padding: 11px; }
  .tutorial-steps { gap: 4px; }
  .tutorial-steps li { padding: 4px 6px; }
  .tutorial-steps span { font-size: .78rem; }
  .start-panel { inset-block-start: 4px; padding-top: 4px; }
  .start-panel h3 { font-size: .98rem; }
  .start-panel p { margin: 3px 0 6px; font-size: .79rem; }
  #start { min-height: 36px; padding: 5px 9px; }
}

.layout-buttons { display: flex; gap: 6px; margin-top: 8px; }
.layout-buttons button[aria-pressed="true"] {
  background: #e1ead7; color: #234b3d; border-color: #638172;
}
.answer-key-strip, .short-mode-label { display: none; }
.phone-layout { max-width: 560px; padding-top: 8px; }
.grading-in-progress .phone-layout:not(.viewport-zoomed) { touch-action: pan-x pan-y; }
.grading-in-progress .phone-layout { -webkit-tap-highlight-color: transparent; }
.grading-in-progress .phone-layout ::selection { background: transparent; }
.phone-layout .intro h1 { font-size: clamp(1.55rem, 6.5vw, 2.2rem); }
.phone-layout .intro p:last-child { display: none; }
.phone-layout .clock-card { width: 77px; padding: 3px 5px; }
.phone-layout .clock-label { margin-bottom: 2px; font-size: .6rem; }
.phone-layout #clock-digits { padding: 3px; }
.phone-layout #practice-clock { padding: 3px 0; font-size: .8rem; }
.phone-layout .lobby-tools { justify-content: flex-start; margin-top: 6px; gap: 4px; }
.phone-layout .mode-buttons { flex: 0 0 auto; gap: 3px; }
.phone-layout .mode-buttons button { flex: 0 0 auto; min-height: 26px; padding: 2px 5px; font-size: .72rem; }
.phone-layout .full-mode-label { display: none; }
.phone-layout .short-mode-label { display: inline; }
.phone-layout .desk-actions { gap: 4px; margin-left: 0; }
.phone-layout .desk-actions button { min-height: 26px; padding-block: 2px; font-size: .72rem; }
.phone-layout .grading { margin-block: 4px 5px; padding-block: 4px 6px; }
.phone-layout .grading-top { gap: 3px; margin-bottom: 2px; }
.phone-layout .pen-tools { gap: 2px; }
.phone-layout .grading-top button {
  min-width: 24px; min-height: 24px; padding: 1px 4px;
  font-size: .68rem; white-space: nowrap;
}
.phone-layout .pen-tools button svg { width: 17px; height: 17px; }
.phone-layout .grading-count { font-size: .72rem; }
.phone-layout .grading-count strong { font-size: 1.05em; }
.phone-layout .workspace { grid-template-columns: minmax(0, 1fr); gap: 6px; }
.phone-layout #student-sheet {
  grid-row: 2; height: var(--phone-paper-height, auto);
  overflow: clip; overflow-clip-margin: 4px;
}
.phone-layout #student-sheet .paper {
  transform: scale(var(--phone-paper-scale, 1));
  transform-origin: top center;
}
.paper.compact-student-paper { aspect-ratio: auto; }
.compact-student-paper .label-col { width: 8%; }
.compact-student-paper .value-col { width: 10%; }
.compact-student-paper .name-col { width: 20%; }
.compact-student-paper .exam-heading thead th { padding-block: 3px; font-size: .84rem; }
.compact-student-paper .exam-heading tbody th { padding: 0; font-size: .6rem; }
.compact-student-paper .exam-heading tbody td { height: 24px; font-size: .68rem; }
.compact-student-paper .sheet-group h3 { min-height: 0; }
.compact-student-paper .sheet-group li { min-height: 0; padding-block: 2px; }
.compact-student-paper .paper-page { margin-top: 6px; }
.phone-layout #student-sheet .pane-label, .phone-layout .paper-links, .phone-layout #key-sheet .pane-label { display: none; }
@media (min-height: 501px) {
  .phone-layout #key-sheet:has([aria-expanded="false"]) {
    position: sticky; top: var(--grading-height, 150px); z-index: 3;
  }
  .phone-layout .workspace:has(#key-sheet [aria-expanded="false"]) #student-sheet {
    scroll-margin-top: calc(var(--grading-height, 150px) + 75px);
  }
}
.phone-layout .grading-body { grid-template-columns: minmax(0, 1fr) auto; gap: 4px; }
.phone-layout .keypad { grid-column: 1 / -1; grid-row: 1; }
.phone-layout .keypad button { height: 27px; font-size: .9rem; }
.phone-layout .keypad button[data-edit] { font-size: .72rem; }
.phone-layout .score-controls { grid-column: 1; grid-row: 2; display: flex; align-items: center; justify-content: flex-start; gap: 4px; }
.phone-layout .calculator-label { max-width: none; font-size: .65rem; line-height: 1.12; }
.phone-layout .score-screen { min-width: 38px; min-height: 24px; margin: 0; padding: 1px 4px; font-size: 1rem; }
.phone-layout #submit { grid-column: 2; grid-row: 2; min-height: 31px; padding: 3px 10px; font-size: .84rem; }

.paper.answer-paper {
  aspect-ratio: auto; padding: 5px 7px; border: 1px solid var(--stationery-line);
  border-radius: 10px; background: #faf0dc; box-shadow: 0 3px 10px #47372128;
}
.answer-paper :is(.exam-heading, .paper-page) { display: none; }
.answer-paper:has(#toggle-key-prompts[aria-expanded="false"]) #answer-key { display: none; }
.answer-paper .answer-key-strip { display: block; font-family: system-ui, sans-serif; }
.answer-key-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2px; font-size: .65rem; }
#toggle-key-prompts { min-height: 19px; padding: 0 4px; font-size: .6rem; }
#quick-answers {
  display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 3px;
  list-style: none; margin: 0; padding: 0;
}
#quick-answers li {
  display: grid; justify-items: center; align-content: center; min-height: 31px;
  border: 1px solid #d2ab7e; border-radius: 5px; background: #fff8e7; line-height: 1.15;
}
#quick-answers li span { font-size: .66rem; }
#quick-answers li strong { color: var(--red); font-size: .95rem; }
.answer-paper #answer-key { margin-top: 6px; }
.answer-paper .sheet-group h3 { min-height: 0; }
.answer-paper .sheet-group li {
  min-height: 0; padding: 5px 0; margin: 0; border-top: 1px solid #e8e0d3;
}
.answer-paper .question-text { display: block; }
