:root {
  color-scheme: light;
  font-family: Pretendard,"Apple SD Gothic Neo","Malgun Gothic",system-ui,sans-serif;
  color: #10192d;
  --ink: #10192d;
  --gold: #ffcb10;
  --line: #cbd5e1;
  --surface: #f7f9fc;
  --slate: #475569;
  --danger: #ad192d;
}
* { box-sizing: border-box }
[hidden] { display: none !important }
html,body,.shell,.game-grid,.viewport,.scene { width: 100%; height: 100%; margin: 0 }
html,body { overflow: hidden; background: #d2eaff }
.shell,.game-grid,.viewport { position: relative }
.scene { position: absolute; inset: 0; overflow: hidden; touch-action: none }
.scene canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab }
.scene canvas:active { cursor: grabbing }
button,input,select,textarea { font: inherit }
button,select { cursor: pointer }
button { touch-action: manipulation }
button:disabled { opacity: .42; cursor: not-allowed }
button:focus-visible,select:focus-visible,a:focus-visible { outline: 3px solid #1674e3; outline-offset: 2px }
.icon { display: inline-block; width: 1.12em; height: 1.12em; vertical-align: -.16em; flex: none }
button { color: var(--ink) }
.intro {
  position: fixed; inset: 0; z-index: 10; display: flex; align-items: safe center; justify-content: safe center; overflow: auto;
  padding: 20px; background: radial-gradient(ellipse at center, #0f172a0c, #0f172a65)
}
.entry-card {
  --school-green: #174e42;
  --entry-y: 22px;
  --entry-x: 24px;
  width: min(760px,100%); flex: none; margin: auto; padding: var(--entry-y) var(--entry-x);
  border: 3px solid #103e35; border-radius: 24px; background: white; box-shadow: 0 20px 55px #081e2540
}
.entry-head {
  display: flex; align-items: center; gap: 15px;
  margin: calc(-1 * var(--entry-y)) calc(-1 * var(--entry-x)) 15px;
  padding: 17px var(--entry-x); border-radius: 20px 20px 0 0; border-bottom: 4px solid #eac258;
  background:
    linear-gradient(118deg, transparent 76%, #fff1 76% 79%, transparent 79% 82%, #fff1 82% 85%, transparent 85%),
    linear-gradient(100deg, #133f37, #1b6655);
  color: white
}
.school-seal { display: block; flex: none; width: 64px; height: 64px; object-fit: contain }
.school-title { min-width: 0; display: grid; gap: 4px }
.school-title p { font-size: 14px; font-weight: 650; line-height: 1.3; color: #def2e9 }
.brand-icon {
  width: 44px; height: 44px; margin-left: auto; flex: none; display: grid; place-items: center;
  background: #fff1b9; border: 2px solid #ecc969; border-radius: 50%; color: #8f5c09; font-size: 26px; line-height: 1
}
.brand-icon .icon { display: block; width: 25px; height: 25px }
h1,h2,h3,h4,p,fieldset { margin: 0 }
.entry-head h1 { font-size: 30px; font-weight: 900; line-height: 1.13; letter-spacing: -.055em }
.entry-intro { margin: 6px 0 18px; color: var(--slate); font-size: 14px; line-height: 1.5 }
.tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 5px; gap: 6px; border-radius: 14px; background: #f1f5f9 }
.tab { padding: 10px; min-height: 40px; border: 0; border-radius: 10px; background: transparent; color: #617087; font-size: 15px; font-weight: 800 }
.tab[aria-selected=true] { color: var(--ink); background: white; box-shadow: 0 2px 6px #18274125 }
.entry-card .tabs { background: #edf3f0 }
.entry-card .tab[aria-selected=true] { color: var(--school-green); box-shadow: 0 2px 5px #194b4024 }
.entry-card .field input:focus { outline-color: var(--school-green) }
.entry-card .choice-buttons button[aria-pressed=true] { background: #eef6f1; border-color: var(--school-green); color: #173f35 }
.entry-student { display: grid; grid-template-columns: 1fr 1.35fr; grid-template-areas: "inputs avatar" "enter avatar" "error error"; align-items: start; gap: 0 20px; margin-top: 25px }
.entry-student>.fields { grid-area: inputs; display: grid; gap: 9px }
.entry-student>.primary { grid-area: enter; align-self: end; margin-top: 19px }
.field,.mode-field legend { color: #334155; font-size: 14px; font-weight: 800 }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0 }
.field input,.field textarea,.field select {
  width: 100%; min-width: 0; border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px;
  background: white; color: var(--ink); font-size: 16px; font-weight: 650
}
.field input:focus,.field textarea:focus,.field select:focus { outline: 2px solid #3689ed; outline-offset: -2px }
.field input::placeholder,.field textarea::placeholder { color: #697582 }
.entry-card .field { font-size: 13px; gap: 5px }
.entry-card .field input { padding: 11px 14px; font-size: 17px; min-height: 48px; font-weight: 700 }
.code-input { text-transform: uppercase }
.form-error { grid-area: error; color: var(--danger); font-size: 14px; margin-top: 12px; font-weight: 700 }
.primary,.secondary,.icon-button,.teacher-body .text-btn,.close-teacher {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  border: 2px solid var(--ink); border-radius: 10px; padding: 8px 12px; background: white; font-size: 14px; font-weight: 800; box-shadow: 0 3px var(--ink)
}
.primary { background: var(--gold) }
.primary:active:enabled,.secondary:active:enabled,.teacher-tab:active,.close-teacher:active { transform: translateY(2px); box-shadow: 0 1px var(--ink) }
.entry-card .primary { width: 100%; padding: 14px 10px; min-height: 62px; border-width: 3px; border-radius: 14px; box-shadow: 0 5px var(--ink); color: #0c101a; font-size: 19px; font-weight: 900 }
.avatar-box { grid-area: avatar; display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--surface); border: 2px solid #e1e8f0; border-radius: 16px; min-width: 0 }
.avatar-preview { width: 96px; height: 120px; flex: none; overflow: hidden; border-radius: 12px; background: linear-gradient(#dcf2ff,#fff9bf) }
.avatar-preview svg,.avatar-preview canvas { width: 100%; height: 100%; display: block }
.avatar-options { flex: 1; min-width: 0; display: grid; gap: 7px }
.choice-row { display: grid; grid-template-columns: 40px minmax(0,1fr); align-items: center; gap: 8px }
.choice-label { color: #334155; font-size: 12px; font-weight: 800; white-space:nowrap }
.choice-buttons,.swatches { display: flex; flex-wrap: wrap; align-items: center; gap: 4px }
.swatches { gap: 7px }
.swatch { display: inline-block; width: 25px; height: 25px; flex: none; padding: 0; border: 2px solid white; border-radius: 50%; background: var(--swatch); box-shadow: 0 0 0 2px var(--line) }
.swatch[aria-pressed=true] { box-shadow: 0 0 0 3px var(--ink); transform: scale(1.08) }
.choice-buttons button { border: 2px solid var(--line); border-radius: 9px; padding: 4px 7px; background: white; color: #334155; font-size: 12px; line-height: 1.25; font-weight: 800; white-space: nowrap }
.choice-buttons button[aria-pressed=true] { background: #fff7bc; border-color: var(--ink); color: var(--ink) }
.entry-teacher { width: min(400px,100%); margin: 20px auto 0; display: grid; gap: 13px }
.entry-teacher .field { display: block }
.entry-teacher input { margin-top: 5px }
.entry-teacher small,.mode-field legend small { color: #63748c; font-size: 12px; font-weight: 600 }
.mode-field { border: 0; padding: 0; min-width: 0 }
.mode-field legend { margin-bottom: 6px; padding: 0; font-size: 13px }
.mode-field>div { display: grid; grid-template-columns: 1fr 1fr; gap: 8px }
.mode-field label { position: relative; cursor: pointer }
.mode-field label input { position: absolute; opacity: 0 }
.mode-field label span { display: grid; gap: 2px; text-align: center; padding: 8px 3px; border: 2px solid var(--line); border-radius: 12px; font-size: 15px; font-weight: 900 }
.mode-field label input:focus-visible+span { outline: 3px solid #1674e3 }
.mode-field label input:checked+span { background: #fff7bd; border-color: var(--ink); box-shadow: 0 3px var(--ink) }
.entry-actions { display: grid; justify-items: center; gap: 7px }
.entry-actions .recover { padding: 5px 9px; border: 0; box-shadow: none; color: var(--slate); background: transparent; font-size: 12px }
.entry-actions .recover:hover,.entry-links button:hover { text-decoration: underline }
.entry-foot { margin-top: 25px; padding-top: 8px; border-top: 1px solid #dce8df }
.entry-card:has(.entry-teacher) .entry-foot { margin-top: 17px }
.entry-links { display: flex; align-items: center; justify-content: center; gap: 7px; margin-top: 9px; color: #8997a8; font-size: 12px }
.entry-links button { padding: 3px 4px; border: none; background: transparent; color: #596980; font-weight: 700 }
.entry-links .icon { width: 13px; height: 13px }

.shell:not(.in-room) :is(.topbar,#stage-roster,#stage-reactions,.view-bottom,#emote-toggle,#move-stick) { display: none }
.topbar { position: fixed; z-index: 4; top: max(10px,env(safe-area-inset-top)); left: max(10px,env(safe-area-inset-left)); right: 10px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; pointer-events: none }
.topbar>* { pointer-events: auto }
.chip,.view-bottom span { border: 0; color: white; background: #10192dd9; border-radius: 30px; padding: 8px 14px; font-size: 14px; line-height: 1.4; font-weight: 850; backdrop-filter: blur(4px) }
.chip:empty,.view-bottom span:empty { display: none }
.chip .icon { width: 17px; height: 17px }
#connection:not(:empty) { background: #174e42eb }
#hud-mode { background: #ad530b } #hud-demo { background: #7c35ee } #hud-leave { background: #822222 } #screen-mode { background: #344257; padding-right: 8px } #screen-mode option { background: white; color: var(--ink) }
#hud-menu,#emote-toggle { display: none }
#stage-roster { position: fixed; z-index: 2; top: 58px; bottom: 34px; left: 10px; width: 196px; display: flex; flex-direction: column; gap: 8px; pointer-events: none }
.roster-group { min-height: 0; flex: 3; border: 2px solid #bddbff; border-radius: 14px; background: #eff6ffeb; overflow: hidden; display: flex; flex-direction: column; pointer-events: auto; backdrop-filter: blur(4px) }
.roster-group.out { flex: 2; background: #fff2f2ea; border-color: #fec9c9 }
.roster-group.score { background: #fff9c5ed; border-color: #fed87d }
.roster-group h3 { display: flex; align-items: center; justify-content: space-between; margin: 0; padding: 8px 10px 6px; font-size: 14px; color: #1958bf }
.roster-group.out h3 { color: #b62229 }.roster-group.score h3 { color: #8d5009 }
.roster-group h3 b { background: white; border-radius: 99px; padding: 1px 9px; font-size: 12px }
.roster-list { display: flex; flex-direction: column; align-content: start; gap: 3px; min-height: 0; overflow: auto; padding: 0 6px 6px }
.roster-list>* { display: flex; align-items: center; gap: 6px; flex: none; padding: 3px 7px; border-radius: 8px; background: #ffffffce; color: #1e293b; font-size: 13px; font-weight: 750 }
.roster-list .own { box-shadow: inset 0 0 0 2px var(--gold) }
.roster-list>small { margin: 0; justify-content: center; background: transparent; font-size: 12px; font-weight: 650; color: #64748b }
.roster-list div>b { margin-left:auto; padding:1px 6px; border-radius:6px; background:#a7560c; color:white; font-size:12px }
.roster-list i { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 0 1px #33415555 }
.roster-list small,.roster-list em { margin-left: auto; color: var(--slate); font-style: normal; font-size: 11px }
.view-bottom { position: fixed; z-index: 2; left: 50%; bottom: 170px; transform: translateX(-50%); max-width: 92vw; pointer-events: none; text-align: center }
.view-bottom span { display: inline-block; width: max-content; max-width: 91vw; font-size: 13px; padding: 7px 13px; text-wrap: balance }
.room-notice { position: fixed; z-index: 3; top: 61px; left: 50%; transform: translateX(-50%); max-width: min(75vw,740px); padding: 9px 14px; border: 2px solid var(--ink); border-radius: 12px; background: #fff8d7; font-weight: 800; text-align: center; overflow-wrap: anywhere }
.dock-summary { position: fixed; z-index: 3; left: 50%; bottom: 91px; transform: translateX(-50%); display: flex; align-items: center; gap: 9px; width: max-content; max-width: min(760px,94vw); border: 3px solid var(--ink); border-radius: 16px; background: white; box-shadow: 0 5px var(--ink); padding: 10px 12px; pointer-events: none }
.dock-meta { display: contents }
#dock-phase { order: 0; padding: 4px 9px; border: 2px solid var(--ink); border-radius: 9px; background: var(--gold); font-size: 15px; font-weight: 900; white-space: nowrap }
#dock-question { order: 1; font-size: 18px; font-weight: 800; line-height: 1.35; overflow-wrap: anywhere }
#timer,#board-timer { order: 2; flex: none; padding: 3px 8px; border-radius: 9px; background: #159953; color: white; font-size: 20px; font-weight: 900; font-variant-numeric: tabular-nums }
#dock-track,#timer:empty,#board-timer:empty,.shell[data-phase=lobby] .dock-summary { display: none }
.action-box { position: fixed; z-index: 3; left: 50%; bottom: 15px; transform: translateX(-50%); display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 8px; width: max-content; max-width: calc(100% - 24px) }
.shell[data-role=teacher] .action-box { padding: 8px 10px; border: 2px solid var(--ink); border-radius: 15px; background: #fffefaed; box-shadow: 0 4px var(--ink); backdrop-filter: blur(4px) }
#dock-status { color: var(--slate); font-weight: 750; font-size: 13px }
.shell[data-role=student] #dock-status,.action-box:has(.dock-actions:empty):not(.shell[data-role=teacher] *) { display: none }
.dock-actions,.button-grid,.bank-actions,.grading-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 7px }
.dock-actions [data-action=menu] { background: var(--gold) }
.shell[data-role=student] .action-box { left: auto; right: 14px; bottom: 96px; transform: none }
.shell[data-role=student] .dock-actions button { border: 3px solid var(--ink); padding: 11px 15px; border-radius: 17px; box-shadow: 0 5px var(--ink); font-size: 16px }
.shell[data-role=student] .dock-actions [data-action=board] { background: var(--gold) }
#stage-reactions { position: fixed; z-index: 3; bottom: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; justify-content: center; max-width: 96vw }
#stage-reactions button,.reaction-buttons button { display: grid; align-content: center; justify-items: center; gap: 1px; width: 58px; height: 62px; background: white; border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 4px var(--ink); font-size: 12px; font-weight: 800; padding: 1px }
#stage-reactions button span,.reaction-buttons button span { font-size: 24px; line-height: 1.12 }
#stage-reactions small { font-size: 12px }
#stage-reactions button:active,.reaction-buttons button:active { transform: translateY(3px); box-shadow: 0 1px var(--ink) }
.shell[data-role=teacher] #stage-reactions { right: 10px; left: auto; transform: none; display: grid; grid-template-columns: repeat(4,44px); gap: 5px }
.shell[data-role=teacher] #stage-reactions button { width: 44px; height: 44px; border-width: 2px; border-radius: 10px; font-size: 0 }
.shell[data-role=teacher] #stage-reactions small { display: none }
.shell[data-role=teacher] #stage-reactions span { font-size: 20px }
#move-stick { display: none }
.winner { position: absolute; inset: 0; display: grid; align-content: center; justify-items: center; pointer-events: none; color: #fff; text-shadow: 0 2px 6px #24160a; background: #0d152a54 }
.winner .icon { height: 54px; width: 54px; color: var(--gold) }
.winner strong { font-size: clamp(2rem,7vw,5rem); color: #ffdc58 }.winner small { font-size: 19px; font-weight: 800 }
#toast:not(:empty) { position: fixed; z-index: 15; left: 50%; top: 62px; transform: translateX(-50%); width: max-content; max-width: 90vw; padding: 11px 18px; border: 3px solid var(--ink); border-radius: 16px; background: white; color: var(--ink); font-size: 17px; font-weight: 850; text-align: center; box-shadow: 0 5px var(--ink); pointer-events: none }

dialog { width: min(460px,calc(100% - 28px)); max-height: calc(100dvh - 26px); padding: 20px; color: var(--ink); background: white; border: 3px solid var(--ink); border-radius: 22px; box-shadow: 0 8px var(--ink),0 18px 58px #0004; overscroll-behavior: contain }
dialog::backdrop { background: #0f172a88; backdrop-filter: blur(2px) }
dialog ol { padding-left: 23px; color: var(--slate); line-height: 1.6; font-size: 15px }
#help-dialog .primary { width: 100% }
.dialog-head,.work-top { display: flex; align-items: center; justify-content: space-between; gap: 10px }
.dialog-head h2,.work-top h2 { font-size: 20px; letter-spacing: -.025em }
.dialog-head .icon-button,.grading-actions .icon-button { font-size: 18px; padding: 3px 8px; border-radius: 8px }
.teacher-dialog { padding: 0; width: min(1080px,calc(100% - 30px)); height: min(640px,calc(100% - 30px)); background: var(--surface); overflow: hidden }
.teacher-dialog[open] { display: flex; flex-direction: column }
.teacher-dialog>.dialog-head,.board-dialog>.dialog-head,.grade-dialog .work-top { background: var(--ink); color: white; padding: 9px 14px }
.teacher-dialog>.dialog-head { flex: none; min-height: 50px }
.teacher-dialog>.dialog-head h2 { margin-right: auto; font-weight: 900; font-size: 17px }
#teacher-info { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 5px; font-weight: 800; font-size: 12px }
#teacher-info:not(:has(*)):not(:empty),#teacher-info>*,.teacher-badge { background: #344156; color: white; border-radius: 999px; padding: 5px 10px }
.close-teacher { border: 0; box-shadow: none; background: var(--gold); border-radius: 10px; padding: 8px 12px }
.teacher-layout { flex: 1; display: grid; grid-template-columns: 210px 1fr; min-height: 0 }
.teacher-tabs { display: flex; flex-direction: column; gap: 6px; background: #eef2f7; border-right: 2px solid #e1e7ef; padding: 10px; overflow: auto }
.teacher-tab { text-align: left; display: flex; align-items: center; gap: 10px; padding: 9px 10px; min-height: 53px; background: transparent; color: #334155; border: 2px solid transparent; border-radius: 14px; font-size: 15px; font-weight: 850 }
.teacher-tab:hover { background: #fff }
.teacher-tab[aria-pressed=true] { border-color: var(--ink); background: white; color: var(--ink); box-shadow: 0 3px var(--ink) }
.teacher-tab>b,.teacher-tab .tab-icon { font-size: 24px; width: 30px; text-align: center; flex: none }
.teacher-tab>span:not(.tab-icon) { display: grid; gap: 3px }
.teacher-tab small { color: #66758c; font-size: 12px; font-weight: 650 }
.teacher-body { height: 100%; min-width: 0; overflow: auto; overscroll-behavior: contain; padding: 17px 22px; color: var(--ink) }
.teacher-page-head { margin: 0 0 16px }
.teacher-page-head h3 { font-size: 22px; font-weight: 900; letter-spacing: -.035em }
.teacher-page-head p,.hint { color: var(--slate); margin: 4px 0 0; font-size: 14px; line-height: 1.5 }
.stack,.question-fields { display: grid; gap: 12px }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px }.entry-student>.fields { grid-template-columns: 1fr }
.teacher-body textarea { resize: vertical; min-height: 72px }
.teacher-body .primary { padding: 10px 12px }
.teacher-body #question-form>.primary { font-size: 17px; background: #d5f8e1 }
.teacher-body .share { display: flex; align-items: center; justify-content: flex-start; gap: 25px; min-height: 275px; padding: 12px 0 }
.teacher-body .share canvas { width: min(218px,34%) !important; height: auto !important; aspect-ratio: 1; flex: none; border: 3px solid var(--ink); border-radius: 15px; background: white }
.share>div { flex: 1; min-width: 0; display: grid; justify-items: start; gap: 8px }
.share p { font-size: 14px; font-weight: 800; color: #64748b }
.room-code { color: var(--ink); font-size: clamp(34px,5vw,72px); line-height: 1.12; letter-spacing: .1em; font-weight: 900; overflow-wrap: anywhere }
.share ol { font-weight: 700; margin: 3px 0; font-size: 15px }
.share .invite-link { width: 100%; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 5px 8px; border: 2px solid #e2e8f0; border-radius: 10px; background: white }
.share .invite-link span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; flex: 1; color: var(--slate); font-size: 12px }
.share .invite-link button { flex: none }
.time-options { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 0; border: 0 }
.time-options legend { padding:0; margin-bottom:6px; color:#334155; font-size:14px; font-weight:800 }
.time-options button,.time-options input { border:2px solid var(--line); border-radius:10px; padding:7px 12px; background:white; font-size:15px; font-weight:800 }
.time-options button[aria-pressed=true] { border-color:var(--ink);background:var(--ink);color:white }.time-options input { width:64px; padding:7px 5px }.time-options label {font-size:13px}
.phase { display: flex; align-items: center; gap: 8px; font-weight: 750; font-size: 14px }
.roster { display: flex; align-content: start; flex-wrap: wrap; gap: 5px; margin-top: 7px; overflow: auto; max-height: 170px }
.seat-pill { padding: 5px 8px; border-radius: 9px; background: #e7eef8; color: var(--ink); font-size: 13px;font-weight: 750 }
.seat-pill b { margin-right: 4px; color: #315c9d }
.roster-groups { display: grid; grid-template-columns: 1fr 1fr; margin-top: 12px; gap: 10px }
.roster-groups h3 { font-size: 16px }
.bank-toolbar,.bank-pagination,.check-field { display: flex; align-items: center; flex-wrap: wrap; gap: 9px }
.bank-toolbar { justify-content: space-between; margin-bottom: 10px }.bank-toolbar .tab { min-height: 30px; padding: 5px 10px; font-size: 14px }
.check-field { font-size: 14px; font-weight: 750 }.check-field input{ accent-color: #d59b00 }
.bank-list { display: grid; gap: 6px }
.bank-list article,.teacher-test,.manage { background: white; border: 2px solid #e0e6ef; border-radius: 12px; padding: 9px 11px }
.bank-list article { display: flex; align-items: center; gap: 8px; flex-wrap: wrap }.bank-list article h4 { flex: 1 1 160px; font-size: 15px }
.bank-actions button { font-size: 13px }.bank-used,.history time { color: #487062; font-size: 12px }.bank-pagination { justify-content: center; margin-top: 14px; font-size: 14px }
.teacher-body .button-grid,.teacher-body #notice-form,.teacher-body .manage,.teacher-test,.teacher-body #bank-bulk { margin-top: 16px }
.teacher-body .danger-text { color: var(--danger); background: #fff1f1; margin-top: 12px }
.history,.standings { display: grid; gap: 5px; padding: 0; list-style: none; font-size: 14px; color: var(--slate) }
.history li,.standings li { padding: 5px 8px; background: var(--surface); border-radius: 6px }.standings li { display:flex; gap:10px }.standings strong { margin-left:auto }
#grade-dialog { width: min(1180px,calc(100% - 26px)); height: min(720px,calc(100% - 26px)); padding: 0; background: var(--surface) }
.grade-dialog .work-top { position: sticky; top: 0; z-index: 1; flex-wrap: wrap }
.grade-dialog .work-top h2 { font-size: 17px }.grade-dialog .work-top .phase { margin-top: 2px; color: #ffe59a; font-size: 13px }
.grades { padding: 14px; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill,minmax(164px,1fr)); align-items: start }
.grade-card { display: grid; gap: 7px; background: #fff; border: 3px solid #e1e8f0; border-radius: 14px; padding: 8px; min-width: 0 }
.grade-card h3 { font-size: 14px;overflow-wrap:anywhere }.grade-art { padding: 0; border: 0; background: none; width: 100% }
.grade-card canvas,.grade-card>p { width: 100%; display: block; aspect-ratio: 5/3; border: 2px solid #c9d3e0; background: #fff; border-radius: 7px }
.grade-card>p { display:grid; place-items:center; color: #6a7890;font-size:13px }
.grade-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 5px }.grade-buttons button { font-size: 12px; padding: 4px 5px }
.grade-card:has([data-correct=true][aria-pressed=true]) { border-color: #17a566;background:#ebfff2 }.grade-card:has([data-correct=false][aria-pressed=true]) { border-color: #e95763;background:#fff0f1 }
.grade-buttons [data-correct=true][aria-pressed=true] { background:#bef5d2 }.grade-buttons [data-correct=false][aria-pressed=true] { background:#ffc7cc }
.solution { display: grid; grid-template-columns: auto 1fr; gap: 4px 8px; padding: 8px 12px; background: #fff6c4; border-radius: 8px; font-size: 14px; line-height: 1.45 }
.grade-dialog .solution { margin: 10px 14px 0 }#solution-dialog .solution { margin-top: 14px }
.board-dialog { width: min(980px,calc(100% - 28px)); padding: 0; overflow: auto }
.board-dialog[open] { display: grid }
.board-dialog>.dialog-head { min-height: 48px; gap: 10px; align-items: center }
.board-round { flex:none; color: var(--ink); background: var(--gold); padding: 3px 8px; border-radius: 8px; font-size: 14px; font-weight: 850 }
#board-heading { flex:1; min-width:0; color:white; font-size:17px; line-height:1.35; overflow-wrap:anywhere }
.board-dialog>.dialog-head .icon-button { order:3 }
.board-pane { padding: 15px; display: grid; grid-template-columns: minmax(0,1fr) minmax(175px,26%); gap: 14px; align-items: stretch }
.board-surface { min-width:0; display:grid; place-items:center; border-radius:16px; padding:10px; background:#e2e8f0 }
.board-side { min-width:0; display:flex; flex-direction:column; align-items:stretch; gap:10px }
.board-side>b { font-size:13px; color:#334155 }.board-side #submit-board { width:100%; margin-top:auto }
.draw-board { display: block; width: min(100%,calc(56vh * 1.66667)); height:auto; border: 6px solid var(--slate); border-radius: 11px; background: white; box-shadow: 0 4px #334155; touch-action: none; cursor: crosshair; aspect-ratio: 5/3 }
.board-pane:has([data-paper]) .draw-board { max-width: min(100%,47vh); border-color: #af2768; border-radius: 50%; aspect-ratio: 1; box-shadow: 0 4px #831843 }
.board-tools,#submit-board,#board-feedback { grid-column: 2 }
.board-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; color: var(--slate); font-size: 13px; font-weight: 750 }
.board-tools .swatch { width: 34px; height: 34px }.board-tools .secondary,.pen-size { min-width:35px; min-height:35px; border: 2px solid var(--line); border-radius: 9px; padding: 5px 8px; background: white; color: var(--ink); font-size: 14px; box-shadow: none }
.board-tools .secondary[aria-pressed=true] { background: #fff6bc; border-color: var(--ink) }
#submit-board { align-self: end; padding: 12px 6px; border-width: 3px; font-size: 17px }
#board-feedback { grid-row: auto; font-size: 13px; line-height: 1.4 }
.reaction-buttons { display:grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap:7px; margin-top: 15px }
.reaction-buttons button { width:auto }

/* Mobile HUD follows the chosen display mode so a phone can also use the full desktop HUD. */
.shell[data-phone=true] .topbar { gap: 5px; width: max-content; max-width: calc(100% - 20px); right: auto }
.shell[data-phone=true] .topbar .chip { padding: 6px 10px; font-size: 13px }
.shell[data-phone=true]:not(.hud-expanded) .topbar>:not(#connection,#hud-menu) { display: none }
.shell[data-phone=true] #hud-menu { display: inline-block }
.shell.hud-expanded[data-phone=true] .topbar { padding: 6px; background: #172033ab; border-radius: 13px; backdrop-filter: blur(4px); z-index: 6 }
.shell[data-phone=true] #stage-roster { top: 52px; width: 150px }
.shell[data-phone=true] #stage-reactions { display: none }
.shell[data-phone=true].emotes-expanded #stage-reactions { left: auto; right: 12px; bottom: 82px; transform: none; display: grid; grid-template-columns: repeat(4,46px); gap: 6px; max-width: 90vw; border-radius: 15px; padding: 8px; background: #182338a9; backdrop-filter: blur(4px) }
.shell[data-phone=true].emotes-expanded #stage-reactions button { width: 46px; height: 46px; border-width: 2px; border-radius: 11px; font-size: 0 }
.shell[data-phone=true] #stage-reactions small { display: none }
.shell.in-room[data-phone=true] #emote-toggle { position: fixed; z-index: 4; bottom: 14px; right: 12px; display: grid; place-items: center; width: 57px; height: 57px; background: white; border: 3px solid var(--ink); border-radius: 50%; box-shadow: 0 4px var(--ink); font-size: 27px }
.shell.emotes-expanded[data-phone=true] #emote-toggle { background: var(--gold) }
.shell[data-phone=true] #move-stick { position: fixed; left: 15px; bottom: 15px; z-index: 4; width: 112px; height: 112px; display: grid; place-items: center; border-radius: 50%; border: 3px solid #ffffffc9; background: #ffffff45; backdrop-filter: blur(2px); touch-action: none; user-select: none }
#move-stick span { width: 49px; height: 49px; border: 3px solid var(--ink); border-radius: 50%; background: #fffffff2; box-shadow: 0 3px var(--ink); pointer-events: none }
.shell.hud-expanded[data-phone=true] #move-stick { visibility: hidden }
.shell[data-phone=true] .dock-summary { border-width: 2px; box-shadow: 0 3px var(--ink); padding: 6px 9px; gap: 6px }
.shell[data-phone=true] #dock-phase { font-size: 12px; padding: 3px 6px }.shell[data-phone=true] #dock-question { font-size: 14px }
.shell[data-phone=true] .view-bottom { top: 90px; bottom: auto }
.shell[data-phone=true] .view-bottom span { font-size: 12px; max-width: min(82vw,450px) }
.shell[data-phone=true][data-role=teacher] .action-box { bottom: 12px; max-width: calc(100vw - 215px); padding: 5px; gap: 4px }
.shell[data-phone=true] .dock-actions { gap: 4px }.shell[data-phone=true] .dock-actions button { padding: 5px 7px; font-size: 12px }
@media (orientation:portrait) {
  .shell[data-phone=true] .dock-summary { bottom: 148px; max-width: 94vw }
  .shell[data-phone=true][data-role=student] .action-box { bottom: 218px }
  .shell[data-phone=true][data-role=teacher] .action-box { max-width: calc(100vw - 96px); left: 50%; bottom: 135px }
  .shell[data-phone=true][data-role=teacher]:not([data-phase=lobby]) .dock-summary { bottom: 204px }
}
@media (orientation:landscape) {
  .shell[data-phone=true] .dock-summary { bottom: 15px; max-width: calc(100vw - 290px) }
  .shell[data-phone=true][data-role=teacher] .dock-summary { bottom: 78px }
}
@media (max-width:850px) {
  .teacher-layout { grid-template-columns: 150px minmax(0,1fr) }.teacher-tab { padding: 8px 5px; gap: 6px }
  .teacher-body { padding: 14px }.teacher-body .share { gap: 14px }
}
@media (max-width:680px) {
  .intro { padding: 12px }.entry-card { --entry-y:16px; --entry-x:14px }
  .entry-intro { display: none }.entry-head { gap: 10px; padding-block: 12px; margin-bottom: 10px }
  .school-seal { width: 49px; height: 49px }.school-title p { font-size: 12px }
  .entry-head h1 { font-size: 25px }.brand-icon { width: 34px; height: 34px }.brand-icon .icon { width: 20px; height: 20px }
  .entry-student { grid-template-columns: 1fr; grid-template-areas: "inputs" "avatar" "enter" "error"; margin-top: 13px; gap: 9px }
  .entry-student>.fields { grid-template-columns: 1fr 1fr; gap: 8px }
  .entry-card .field input { min-height: 41px; font-size: 16px; padding: 8px 10px }
  .entry-student>.primary { margin-top: 5px }
  .entry-card .primary { min-height: 49px; padding: 10px 8px; font-size: 17px }
  .avatar-box { gap: 8px; padding: 8px; margin: 0 }
  .avatar-preview { width: 72px; height: 90px }
  .avatar-options { gap: 6px }.choice-row { gap: 5px; grid-template-columns: 33px minmax(0,1fr) }
  .choice-label { font-size: 12px }.choice-buttons { gap: 3px }.choice-buttons button { padding: 3px 5px; font-size: 12px }
  .swatch { width: 21px; height: 21px }.swatches { gap: 6px }
  .entry-foot,.entry-card:has(.entry-teacher) .entry-foot { margin-top: 12px }.entry-teacher { margin-top: 14px }
  .teacher-dialog { width: calc(100% - 14px); height: min(650px,calc(100% - 20px)) }
  .teacher-layout { grid-template-columns: 1fr; grid-template-rows: auto minmax(0,1fr) }
  .teacher-tabs { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 3px; padding: 5px; border-right: 0; border-bottom: 2px solid #e1e7ef }
  .teacher-tab { min-width: 0; min-height: 34px; font-size: 12px; justify-content: center; gap: 3px; padding: 3px; border-radius: 8px; white-space: nowrap }
  .teacher-tab>b,.teacher-tab .tab-icon { width: auto; font-size: 14px }.teacher-tab small { display: none }
  .teacher-dialog>.dialog-head { gap: 5px; padding: 7px }.teacher-dialog>.dialog-head h2 { font-size: 14px; white-space: nowrap }
  #teacher-info { font-size: 11px; gap: 2px }#teacher-info:not(:has(*)):not(:empty),#teacher-info>* { padding: 3px 5px }.close-teacher { font-size: 12px; padding: 6px }
  .teacher-body .share { min-height: 0; gap: 10px }.teacher-body .share canvas { width: min(130px,36%) !important }
  .room-code { font-size: clamp(30px,7vw,44px) }.share ol { padding-left: 14px; font-size: 13px }.teacher-body .share .secondary { font-size: 12px; padding: 5px 7px }
  .grading-actions button { min-height: 30px; font-size: 12px; padding: 5px }.grades { padding: 7px; gap: 6px; grid-template-columns: repeat(auto-fill,minmax(128px,1fr)) }
  .board-dialog { width: 100%; height: 100%; max-height: 100dvh; max-width: 100vw; border: 0; border-radius: 0 }
  .board-dialog[open] { grid-template-rows: auto 1fr }.board-dialog>.dialog-head { min-height: 42px; padding: 6px 8px }
  #board-heading { font-size: 14px }.board-pane { align-content: center; grid-template-columns: 1fr; gap: 12px; padding: 8px; min-height: 0 }
  .board-side { gap:8px }.board-side>b { display:none }.board-surface{padding:4px}.board-pane .draw-board{width:100%}
  .board-pane>* { grid-column: 1; grid-row: auto }.board-tools { justify-content: center }.board-pane .draw-board { grid-row: auto; max-height: none; border-width: 4px }
  #board-feedback { text-align: center }.grade-dialog,.board-dialog { max-width: 100vw }
}
@media (max-height:560px) {
  .intro { padding: 6px 12px }.entry-card { --entry-y:10px; --entry-x:16px }.entry-intro { display: none }.entry-head { margin-bottom: 7px; padding-block: 6px }
  .entry-foot,.entry-card:has(.entry-teacher) .entry-foot { margin-top: 8px }.entry-links { margin-top: 4px }.entry-student,.entry-teacher { margin-top: 13px }
  .entry-card .primary { min-height: 43px; padding: 8px 10px; font-size: 17px }.entry-card .field input { padding: 7px 11px; min-height: 39px; font-size: 16px }
  .entry-teacher { gap: 6px }.teacher-dialog { height: calc(100% - 14px) }
}
@media (max-height:490px) and (orientation:landscape) {
  .entry-head { gap: 8px }.school-seal { width: 36px; height: 36px }.school-title p,.entry-foot { display: none }.entry-head h1 { font-size: 20px }.brand-icon { width: 29px; height: 29px }
  .entry-student>.primary { margin-top: 7px }.avatar-preview { width: 75px; height: 96px }
  .board-dialog { width: 100%; height: 100dvh; max-width: none; max-height: none; border-radius: 0; border: 0 }.board-dialog[open] { grid-template-rows: auto 1fr }
  .board-pane { grid-template-columns: minmax(0,1fr) 175px; gap: 6px 10px; padding: 9px; align-content: center }.board-pane .draw-board { grid-area: 1/1/span 5/2; max-width: 100%; width: min(100%,calc((100dvh - 88px)*1.6666)); max-height: none; border-width: 3px }
  .board-tools,#submit-board,#board-feedback { grid-column: 2 }.board-tools { gap: 5px }#submit-board { padding: 7px }
}
@media (prefers-reduced-motion:reduce) { *,*::before,*::after { scroll-behavior: auto !important; transition-duration: .001ms !important; animation-duration: .001ms !important } }
