:root {
  font-family: 'Avenir Next', Arial, sans-serif;
  color: #27313d;
  background: #f7f5f0;
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input { font: inherit; }
button { cursor: pointer; }
a { color: #874941; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid #c08360; outline-offset: 2px; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: 'Iowan Old Style', Georgia, serif; font-weight: 700; line-height: 1.15; }
h1 { font-size: clamp(31px, 3.2vw, 43px); margin-bottom: 8px; }
h2 { font-size: 26px; margin-bottom: 5px; }
h3 { font-size: 21px; }
p { line-height: 1.5; color: #5c6570; }
.topbar { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 0 clamp(20px, 4vw, 60px); border-bottom: 1px solid #d4cec4; background: #fffefa; color: #5c6570; font-size: 13px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: #27313d; text-decoration: none; font: 700 25px 'Iowan Old Style', Georgia, serif; }
.brand:first-letter { color: #874941; }
.context-label { margin: 0 0 12px; color: #874941; font-size: 13px; font-weight: 700; }
.admin-layout { max-width: 1370px; margin: auto; padding: 36px clamp(20px, 4vw, 60px) 60px; }
.admin-heading { display: flex; justify-content: space-between; align-items: start; gap: 20px; padding-bottom: 23px; border-bottom: 1px solid #d4cec4; }
.admin-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 18px; }
.admin-heading h1 { margin: 0 0 6px; }
.admin-heading .page-intro { margin: 0; font-size: 15px; }
.account-line { margin: 8px 0 0; color: #77756f; font-size: 12px; }
.admin-grid { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: clamp(28px, 3vw, 48px); margin-top: 25px; }
.side-panel { align-self: start; padding-right: 23px; border-right: 1px solid #d4cec4; }
.panel-head, .detail-head { display: flex; justify-content: space-between; align-items: center; gap: 18px; }
.panel-head h2 { margin: 0; font-size: 21px; }
.panel-head span { color: #77756f; font-size: 13px; }
.class-list { display: grid; gap: 0; margin: 10px 0 24px; border-top: 1px solid #d4cec4; border-bottom: 1px solid #d4cec4; }
.class-list .subtle { margin: 14px 0; }
.class-link { width: 100%; padding: 12px 10px; border: 0; border-bottom: 1px solid #e5e0d8; background: transparent; color: #27313d; text-align: left; }
.class-link:last-child { border-bottom: 0; }
.class-link.active { padding-left: 7px; border-left: 3px solid #874941; background: #eee9e1; }
.class-link:hover { background: #eee9e1; }
.class-link strong, .class-link small { display: block; }
.class-link strong { font-size: 15px; }
.class-link small { margin-top: 3px; color: #77756f; font-size: 12px; }
.stack { display: grid; gap: 8px; }
.stack h3 { margin-bottom: 5px; }
.stack label, .access-card label, .qr-settings label { font-size: 13px; font-weight: 700; }
input[type='email'], input[type='password'], input[type='url'], input[type='number'], input[type='text'] { width: 100%; min-height: 43px; padding: 9px 11px; border: 1px solid #aaa59d; border-radius: 3px; background: #fffefa; color: #27313d; }
.primary, .secondary, .quiet, .qr-button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 9px 15px; border-radius: 3px; font-size: 14px; font-weight: 700; }
.primary { margin-top: 8px; border: 1px solid #874941; background: #874941; color: #fffefa; }
.primary:hover { background: #6c3832; }
.secondary { border: 1px solid #9f9489; background: transparent; color: #27313d; }
.secondary:hover { background: #eee9e1; }
.quiet, .qr-button { min-height: 34px; padding: 4px 0; border: 0; border-radius: 0; background: transparent; color: #874941; }
.quiet:hover, .qr-button:hover { text-decoration: underline; }
.link-button { text-decoration: none; }
.detail-panel { min-width: 0; min-height: 450px; }
.empty-state { padding: 36px 0; }
.empty-state h2 { font-size: 25px; }
.empty-state p { max-width: 350px; }
.detail-head { padding-bottom: 17px; }
.detail-head h2 { margin: 0; font-size: 32px; }
.detail-head p { margin: 4px 0 0; font-size: 13px; }
.game-choice { display: grid; gap: 9px; margin: 8px 0 3px; padding: 10px 11px 12px; border: 1px solid #d4cec4; }
.game-choice legend { padding: 0 4px; font-size: 12px; font-weight: 700; line-height: 1.25; }
.game-choice label, .room-form label { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; }
.game-choice input, .room-form input { width: 17px; height: 17px; margin: 0; accent-color: #874941; }
.room-form { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 20px; padding: 17px 0; border-top: 1px solid #d4cec4; border-bottom: 1px solid #d4cec4; }
.room-form > div { flex: 1 1 200px; }
.room-form strong, .room-form small { display: block; }
.room-form strong { font-size: 14px; }
.room-form small { margin-top: 3px; color: #77756f; font-size: 12px; }
.room-form .secondary { min-height: 36px; }
.qr-settings { display: grid; grid-template-columns: 145px minmax(0, 1fr); align-items: center; gap: 4px 14px; padding: 18px 0; border-bottom: 1px solid #d4cec4; }
.qr-settings small { grid-column: 2; color: #77756f; font-size: 11px; }
.summary-cards { display: flex; gap: 0; padding: 16px 0; border-bottom: 1px solid #d4cec4; }
.summary-cards article { flex: 1; min-width: 0; padding: 0 18px; border-right: 1px solid #d4cec4; }
.summary-cards article:first-child { padding-left: 0; }
.summary-cards article:last-child { border: 0; }
.summary-cards strong { display: block; font: 700 25px 'Iowan Old Style', Georgia, serif; color: #874941; }
.summary-cards span { display: block; margin-top: 2px; color: #5c6570; font-size: 12px; }
.table-scroll { overflow-x: auto; margin-top: 18px; }
table { width: 100%; min-width: 670px; border-collapse: collapse; }
th, td { padding: 11px 8px; border-bottom: 1px solid #ded8cf; text-align: left; vertical-align: middle; }
th { color: #686b6d; font-size: 11px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; }
td { background: #fffefa; font-size: 13px; }
tbody tr:nth-child(even) td { background: #f2eee7; }
td strong, td small { display: block; }
td small { margin-top: 3px; color: #77756f; font-size: 11px; }
.wrong-cell { white-space: nowrap; font-size: 12px; }
.wrong-cell div + div { margin-top: 3px; }
.pips { display: inline-flex; gap: 3px; margin-right: 7px; }
.pips i { width: 11px; height: 11px; background: #ded8cf; }
.pips i.done { background: #874941; }
.table-note { margin: 12px 0 5px; color: #77756f; font-size: 12px; }
.teacher-panel { margin-top: 35px; padding-top: 16px; border-top: 1px solid #d4cec4; }
.teacher-panel summary { color: #27313d; font-size: 13px; font-weight: 700; cursor: pointer; }
.teacher-panel .context-label { margin-bottom: 5px; }
.teacher-panel > .subtle { margin-top: 12px; }
.teacher-table td:first-child { overflow-wrap: anywhere; }
.teacher-table .quiet { white-space: nowrap; }
.create-teacher { margin-top: 22px; }
.password-dialog { width: min(92vw, 510px); max-height: 90vh; padding: 26px; border: 1px solid #9f9489; border-radius: 3px; background: #fffefa; color: #27313d; }
.password-dialog::backdrop { background: #1b243c99; }
.password-dialog > p { overflow-wrap: anywhere; }
.password-dialog form { display: grid; gap: 9px; }
.password-dialog label { font-size: 13px; font-weight: 700; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 10px; }
.dialog-actions .primary { margin: 0; }
.inline-form { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.inline-form label { flex: 1; min-width: 200px; font-size: 12px; }
.inline-form input { margin-top: 5px; }
.message { min-height: 1.5em; color: #426b50; font-size: 13px; }
.message.error { color: #9b4137; }
.subtle { color: #77756f; font-size: 13px; }
.login-layout { min-height: calc(100vh - 68px); display: grid; place-items: center; padding: 30px 20px; }
.access-card { width: min(100%, 530px); padding: 25px 0; border-top: 3px solid #874941; }
.access-card h1 { font-size: clamp(31px, 4vw, 43px); }
.access-card p { font-size: 15px; }
.access-card form { display: grid; gap: 9px; margin-top: 22px; }
.access-card .primary { justify-self: start; }
.scan-steps { margin: 22px 0; padding: 15px 0 15px 24px; border-top: 1px solid #d4cec4; border-bottom: 1px solid #d4cec4; }
.scan-steps li { padding: 5px 0; color: #27313d; font-size: 14px; }
.qr-dialog { width: min(90vw, 350px); max-width: 90vw; padding: 25px; border: 1px solid #9f9489; border-radius: 3px; background: #fffefa; text-align: center; box-shadow: 0 20px 50px #1b243c40; }
.qr-dialog::backdrop { background: #1b243c99; }
.qr-dialog h2 { font-size: 24px; }
.qr-image svg { width: 235px; max-width: 100%; }
.qr-sheet { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 24px; }
.qr-sheet article { padding: 12px; border: 1px dashed #aaa; text-align: center; break-inside: avoid; }
.qr-sheet h3 { font-size: 18px; }
.qr-sheet svg { width: 170px; max-width: 100%; }
.qr-sheet p { font-size: 11px; }
.qr-page + .qr-page { margin-top: 24px; }
.qr-page-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.qr-page-head h2 { font-size: 20px; }
.qr-page-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 850px) {
  .admin-grid { grid-template-columns: 1fr; gap: 22px; }
  .side-panel { padding: 0 0 20px; border-right: 0; border-bottom: 1px solid #d4cec4; }
  .class-list { display: flex; flex-wrap: wrap; gap: 8px; border: 0; margin-bottom: 15px; }
  .class-link { width: auto; border: 1px solid #d4cec4; padding: 8px 10px; }
  .class-link.active { padding-left: 7px; }
  .stack { grid-template-columns: minmax(0, 1fr) 120px; align-items: end; }
  .stack h3, .stack .game-choice, .stack .primary { grid-column: 1 / -1; }
}
@media (max-width: 570px) {
  .topbar > span { display: none; }
  .admin-layout { padding: 25px 18px 45px; }
  .admin-heading { align-items: start; }
  .admin-actions { justify-content: flex-end; }
  .admin-heading .quiet { white-space: nowrap; }
  .stack { grid-template-columns: 1fr; }
  .detail-head { align-items: start; flex-direction: column; }
  .qr-settings { grid-template-columns: 1fr; }
  .qr-settings small { grid-column: 1; }
  .summary-cards { flex-wrap: wrap; gap: 10px 0; }
  .summary-cards article { flex: 1 1 33%; padding: 0 8px; }
  .qr-sheet { grid-template-columns: repeat(2, 1fr); }
  .qr-page-grid { grid-template-columns: repeat(2, 1fr); }
}
@page { size: A4; margin: 12mm; }
@media print {
  :root { background: white; }
  body.printing-qr { background: white; }
  .printing-qr .topbar, .printing-qr .admin-heading, .printing-qr .side-panel, .printing-qr .detail-head, .printing-qr .room-form, .printing-qr .qr-settings, .printing-qr .summary-cards, .printing-qr .table-scroll, .printing-qr .table-note, .printing-qr #refresh, .printing-qr .teacher-panel, .printing-qr #message { display: none !important; }
  .printing-qr .admin-layout, .printing-qr .detail-panel { padding: 0; border: 0; max-width: none; min-height: 0; }
  .printing-qr .admin-grid { display: block; }
  .printing-qr .qr-sheet { display: block !important; margin: 0; }
  .printing-qr .qr-page { margin: 0; break-after: page; page-break-after: always; }
  .printing-qr .qr-page:last-child { break-after: auto; page-break-after: auto; }
  .printing-qr .qr-page-head { height: 12mm; margin: 0 0 5mm; border-bottom: 1px solid #777; }
  .printing-qr .qr-page-head h2 { margin: 0; font-size: 16pt; }
  .printing-qr .qr-page-head span { font-size: 9pt; }
  .printing-qr .qr-page-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4mm 5mm; }
  .printing-qr .qr-sheet article { display: flex; height: 56mm; flex-direction: column; align-items: center; justify-content: space-between; break-inside: avoid; border: 1px solid #888; padding: 3mm; }
  .printing-qr .qr-sheet h3 { margin: 0; font-size: 13pt; }
  .printing-qr .qr-sheet svg { display: block; width: 33mm; height: 33mm; }
  .printing-qr .qr-sheet p { margin: 0; font-size: 8pt; }
}
