:root {
  color-scheme: light;
  --chalk: #efebd4;
  --plaster: #e6d8b2;
  --paper: #f5edd8;
  --ink: #283029;
  --green: #284b3e;
  --green-dark: #203a31;
  --wood: #724438;
  --line: #aca28a;
  --serif: "STKaiti", KaiTi, "Songti SC", SimSun, serif;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 280px; line-height: 1.6; }
button, input { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #c38b50; outline-offset: 3px; }
h1, h2, p { margin: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.entrance {
  position: fixed; z-index: 3; inset: 0; overflow: auto; display: grid; min-height: 100dvh; padding: clamp(1rem, 4vw, 4.6rem);
  background:
    repeating-linear-gradient(98deg, #4c382006 0 1px, transparent 1px 7px),
    linear-gradient(to bottom, transparent 63%, #315142 63% 88%, #807669 88% 100%),
    radial-gradient(ellipse at 34% 20%, #f5e7bf 0%, #e3d4a8 66%, #c8b38c 100%);
}
.entrance-inner { display: grid; grid-template-columns: minmax(0, .95fr) minmax(0, 1fr); align-items: center; gap: clamp(1.5rem, 6vw, 5rem); width: min(100%, 66rem); margin: auto; }
.entrance-copy { grid-area: 1 / 1; padding-block: 1rem 2rem; }
.school { color: #635b46; font-size: .92rem; font-weight: 700; }
.entrance h1 { font: 800 clamp(2.4rem, 5.1vw, 4.6rem)/1.13 var(--serif); margin: .65rem 0 1.45rem; letter-spacing: -.055em; }
.login-form { position: absolute; z-index: 1; left: 50%; bottom: 13%; width: min(91%, 20rem); transform: translateX(-50%); padding: .7rem .75rem; border: 1px solid #b59c72; background: #f0e3c0; box-shadow: .15rem .28rem .45rem #2b21187d; border-radius: .22rem; transition: opacity .18s ease; }
.login-form label { font-weight: 750; display: block; margin-bottom: .25rem; }
.login-form > input { margin-bottom: .48rem; width: 100%; }
.door-open .login-form { opacity: 0; pointer-events: none; }
.login-fields { display: flex; flex-wrap: wrap; gap: .55rem; align-items: stretch; }
input { min-height: 2.9rem; min-width: 0; padding: .52rem .7rem; color: var(--ink); background: #fff9ea; border: 1px solid #89795f; border-radius: .23rem; }
.login-fields input { flex: 1 1 6rem; }
.primary, .action, .plain { min-height: 2.85rem; display: inline-flex; align-items: center; justify-content: center; padding: .45rem .85rem; border-radius: .23rem; font-weight: 760; text-decoration: none; text-align: center; }
.primary { background: var(--green-dark); border: 1px solid var(--green-dark); color: #fff7db; }
.primary:hover { background: #345649; }
.primary:disabled { opacity: .5; cursor: default; }
.action { color: var(--green-dark); background: #f9f4e6; border: 1px solid #b7ac90; }
.action:hover { background: #fffbee; border-color: #7c7a60; }
.plain { border: 0; background: transparent; color: var(--green-dark); padding-inline: .25rem; text-decoration: underline; text-underline-offset: .2em; }
.form-status, .room-status { color: #732f25; font-weight: 650; }
.form-status:not(:empty), .room-status:not(:empty) { margin-top: .4rem; }

.doorway { position: relative; justify-self: center; width: min(100%, 29rem); padding-top: 2.1rem; perspective: 72rem; }
.room-plaque { position: absolute; top: -1.1rem; left: 50%; translate: -50%; padding: .18rem .8rem; color: #efe8cf; background: #254838; border: 1px solid #1c3229; box-shadow: 1px 3px 0 #523d2d44; white-space: nowrap; font: 700 1.22rem/1.5 var(--serif); }
.door-frame { width: 100%; aspect-ratio: .97; position: relative; display: flex; perspective: 95rem; background: #281e19; box-shadow: 1.2rem 1.45rem 1.7rem #43372747; border: .7rem solid #5b3a2e; border-bottom-width: .42rem; }
.door-interior { position: absolute; inset: 0; overflow: hidden; background: linear-gradient(#1b3029 0 60%, #716548 60% 100%); }
.door-light { position: absolute; inset: 0; background: conic-gradient(from 101deg at 77% 10%, transparent 0 26deg, #e8cc7b74 27deg 63deg, transparent 64deg); }
.door { position: relative; width: 50%; height: 100%; background: repeating-linear-gradient(93deg, #f5c8960b 0 1px, transparent 1.1px 5px), linear-gradient(115deg,#6c3e32,#8d5542 43%,#6e4136 76%); border: .35rem solid #57372c; box-shadow: inset 0 0 .3rem #36231d; transition: transform .92s cubic-bezier(.18,.72,.23,1); }
.door-left { transform-origin: left center; border-right-width: .13rem; }
.door-right { transform-origin: right center; border-left-width: .13rem; }
.door-glass, .door-panel { display: block; position: absolute; left: 14%; right: 14%; border: .27rem solid #50362c; box-shadow: 0 0 0 2px #b3805b, inset 0 0 .5rem #3f302885; }
.door-glass { top: 10%; height: 42%; background: linear-gradient(135deg, #c2b7931a 0 32%, #f8e7b638 34% 40%, transparent 42% 62%, #e4dab228 64% 69%, transparent 72%), #807b54; }
.door-glass::after { content: ""; position: absolute; inset: 0 47%; background: #53362b; border-inline: .08rem solid #a67852; }
.door-panel { top: 59%; bottom: 8%; background: linear-gradient(125deg, #7d4d3c, #88503c); }
.door-handle { width: .52rem; height: 2.3rem; background: #bf9d64; border-radius: .55rem; box-shadow: 2px 3px 1px #412b24; position: absolute; top: 53%; }
.door-left .door-handle { right: 5%; }
.door-right .door-handle { left: 5%; }
.doorstep { display: block; width: 104%; height: .65rem; margin-left: -2%; background: #543c31; box-shadow: 0 .2rem 0 #a0876c; }
.door-open .door-left { transform: rotateY(-93deg); }
.door-open .door-right { transform: rotateY(93deg); }
.welcome { position: fixed; z-index: 4; inset: 0; display: grid; place-items: center; text-align: center; padding: 1rem; background: #20312988; pointer-events: none; }
.welcome p { color: #fff3d0; font: 800 clamp(2.1rem, 6vw, 4.6rem)/1.25 var(--serif); text-shadow: 0 .16rem .24rem #251b14; animation: welcome-in .36s ease both; }
@keyframes welcome-in { from { opacity: 0; } to { opacity: 1; } }
.entrance-leaving { opacity: 0; pointer-events: none; transition: opacity .3s ease; }

.classroom { width: min(100% - 2.4rem, 80rem); margin: auto; }
.classroom-header { display: flex; justify-content: space-between; flex-wrap: wrap; align-items: center; min-height: 4.8rem; gap: .5rem 1rem; padding-block: .65rem; }
.room-identity p { font: 800 1.65rem/1.3 var(--serif); }
.header-actions, .scene-actions { display: flex; flex-wrap: wrap; gap: .45rem; }
.scene-wrap { border: 1px solid #918167; background: #f6eedb; border-radius: .33rem; overflow: hidden; }
.viewport { position: relative; width: 100%; height: clamp(19rem, 65vh, 40rem); background: #3b4b3c; overflow: hidden; touch-action: pan-y; }
.viewport.ready { cursor: grab; }
.viewport.ready:active { cursor: grabbing; }
#room-canvas { display: block; width: 100%; height: 100%; }
.desk-names { position: absolute; inset: 0; pointer-events: none; }
.desk-name { position: absolute; width: 74px; height: 44px; padding: 0; border: 0; background: none; transform: translate(-50%, -50%); pointer-events: auto; touch-action: manipulation; }
.desk-name-label { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: .12rem .28rem; color: var(--green-dark); background: #fff3cc; border: 1px solid #a48152; border-radius: .18rem; box-shadow: 0 2px 3px #34241964; font-size: .88rem; line-height: 1.55; font-weight: 760; }
.desk-name:hover .desk-name-label, .desk-name:focus-visible .desk-name-label { background: #fff9e9; border-color: var(--green-dark); }
.scene-fallback { position: absolute; inset: 0; display: grid; align-content: center; justify-items: center; gap: 1rem; padding: 1rem; text-align: center; background: #e1d2aa; }
.fallback-board { max-width: 100%; padding: .9rem 1.35rem; color: var(--chalk); background: #315043; border: .36rem solid #6e4b33; font: 800 clamp(1.6rem, 5vw, 3.2rem)/1.45 var(--serif); }
.view-hint { position: absolute; right: .55rem; bottom: .55rem; border-radius: .2rem; color: var(--chalk); background: #213c33e8; padding: .25rem .52rem; font-size: .86rem; pointer-events: none; }
.scene-controls { display: flex; justify-content: space-between; flex-wrap: wrap; align-items: center; padding: .7rem .85rem; gap: .7rem; }
.seat-state { display: grid; gap: .04rem; }
.seat-state span { color: #5d5b4b; font-size: .9rem; }
.reaction-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .32rem .85rem; margin: 0 .85rem; padding: .62rem 0 .7rem; border-top: 1px solid #d0bf9b; }
.reaction-controls p { color: #5d5b4b; font-size: .9rem; }
.reaction-choices { display: flex; flex-wrap: wrap; gap: .34rem; }
.reaction-choices .action { min-height: 44px; gap: .33em; padding-inline: .65rem; }
.reaction-choices .action[aria-pressed="true"] { color: #fff7df; border-color: var(--green-dark); background: var(--green-dark); }
.desk-name:has(.seat-reaction), .seat-cell:has(.seat-reaction) { z-index: 1; }
.seat-reaction { --spark: #f6ce70; position: absolute; z-index: 1; left: 50%; top: 38%; width: 0; height: 0; pointer-events: none; }
.seat-reaction > span { position: absolute; left: -1em; top: -1em; width: 2em; height: 2em; display: grid; place-content: center; border-radius: 50%; font-size: clamp(1.7rem, 5vw, 2.55rem); background: #fff1cf; border: 2px solid var(--spark); box-shadow: 0 .11rem .2rem #3a261c60; animation: desk-pop .86s both; }
.seat-reaction[data-reaction="punch"] > span { animation-name: desk-punch; }
.seat-reaction[data-reaction="high-five"] { --spark: #87bdac; }
.seat-reaction[data-reaction="confetti"] { --spark: #e0a06e; }
.seat-reaction i { position: absolute; top: -.22rem; left: -.22rem; width: .32rem; height: .64rem; border-radius: .07rem; background: var(--spark); animation: desk-spark .72s .04s both; }
.seat-reaction[data-reaction="confetti"] i:nth-of-type(3n + 1) { background: #b56355; }
.seat-reaction[data-reaction="confetti"] i:nth-of-type(3n + 2) { background: #40938a; }
@keyframes desk-punch {
  0% { opacity: 0; transform: translate(-1.05em, .22em) rotate(-28deg) scale(.55); }
  22% { opacity: 1; transform: translate(.06em, -.1em) rotate(8deg) scale(1.14); }
  42%, 72% { opacity: 1; transform: translateY(-.08em) rotate(-9deg); }
  100% { opacity: 0; transform: translateY(-.3em) scale(.83); }
}
@keyframes desk-pop {
  0% { opacity: 0; transform: translateY(.23em) scale(.65); }
  25% { opacity: 1; transform: translateY(-.13em) scale(1.12); }
  48%, 72% { opacity: 1; transform: translateY(-.08em) scale(1); }
  100% { opacity: 0; transform: translateY(-.3em) scale(.87); }
}
@keyframes desk-spark {
  0% { opacity: 0; transform: rotate(var(--angle)) translateY(-.65rem) scale(.75); }
  40% { opacity: 1; }
  100% { opacity: 0; transform: rotate(var(--angle)) translateY(-3.15rem) scale(.45); }
}
.board-notes, .roll-call { margin-top: .8rem; padding: .75rem .85rem; border: 1px solid #b5a789; border-radius: .25rem; }
.board-notes h2, .roll-call h2 { font: 800 1.35rem/1.3 var(--serif); }
.board-notes h2 { margin-bottom: .45rem; }
.roll-call-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .25rem .8rem; }
#roll-call-count { color: var(--green-dark); font-size: .94rem; font-weight: 730; }
.roll-call-status { color: #5d5b4b; }
.roll-call-status:not(:empty) { margin-top: .28rem; }
.roll-call-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 11.5rem), 1fr)); gap: .4rem; max-height: 13rem; overflow: auto; margin: .55rem 0 0; padding: 0; list-style: none; }
.roll-call-list li { display: grid; gap: .05rem; align-content: center; min-height: 3rem; padding: .38rem .5rem; border: 1px solid #c6b697; border-radius: .2rem; background: #fbf4e2; overflow-wrap: anywhere; }
.roll-call-list li.self { border-color: #98a087; background: #e7ebd3; }
.roll-call-list span { color: #5d5b4b; font-size: .86rem; }
.board-form { display: flex; flex-wrap: wrap; gap: .45rem; align-items: stretch; }
.board-form input { flex: 1 1 15rem; }
.board-notes details { margin-top: .55rem; }
.board-notes summary { color: var(--green-dark); font-weight: 750; cursor: pointer; width: fit-content; min-height: 2.25rem; }
#board-messages { margin: .15rem 0 .2rem; padding: 0; list-style: none; }
#board-messages li { padding: .28rem 0; border-top: 1px solid #c7b995; overflow-wrap: anywhere; }
#board-messages strong { margin-right: .5em; color: var(--green-dark); }
.room-footer { display: flex; justify-content: flex-end; min-height: 3.2rem; }
body:has(dialog[open]) { overflow: hidden; }
dialog { color: var(--ink); background: var(--paper); border: 1px solid #857456; border-radius: .35rem; width: min(100% - 1.1rem, 32rem); max-height: 91dvh; padding: 0; overscroll-behavior: contain; }
dialog::backdrop { background: #1f2d26b5; }
.dialog-content { padding: clamp(.85rem, 3vw, 1.35rem); }
.dialog-heading { display: flex; gap: .7rem; align-items: center; justify-content: space-between; margin-bottom: .35rem; }
.dialog-heading h2 { font: 800 1.65rem/1.3 var(--serif); }
.map-board { margin: .8rem auto .65rem; padding: .18rem .55rem; text-align: center; background: var(--green); color: #f6eed5; font-weight: 760; border-radius: .18rem; }
.seat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) .35rem repeat(2, minmax(0, 1fr)) .35rem repeat(2, minmax(0, 1fr)); gap: .28rem; }
.seat-cell { position: relative; min-height: 44px; min-width: 0; padding: .18rem .22rem; color: var(--ink); background: #fcf5e4; border: 1px solid #a49376; border-radius: .18rem; font-size: .84rem; line-height: 1.2; display: grid; align-content: center; justify-items: center; }
.seat-cell small { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .79rem; }
.seat-cell[data-classmate] { border-color: #9ba082; background: #e7ebd3; }
.seat-cell[data-classmate] small { color: var(--green-dark); font-weight: 760; }
.seat-cell[aria-pressed="true"] { border: 2px solid #515a39; background: #cbd8a6; }
.seat-entry { margin-top: .85rem; display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; }
.seat-entry > p { flex: 1 1 9rem; align-self: center; color: var(--green-dark); font-weight: 720; }
.install-steps { padding-left: 1.3rem; }
.install-steps li { margin-block: .65rem; }
.install-steps strong { display: block; }

@media (max-width: 42rem) {
  .entrance { padding: 1.25rem 1rem; background-position: center; }
  .entrance-inner { grid-template-columns: 1fr; gap: 1rem; width: min(100%, 27rem); }
  .entrance-copy { padding: 0 0 .5rem; }
  .entrance h1 { margin-bottom: .9rem; }
  .doorway { width: min(86%, 18rem); margin-block: .9rem .7rem; }
  .door-frame { aspect-ratio: .80; }
  .classroom { width: calc(100% - 1.05rem); }
  .classroom-header { padding-block: .5rem; }
  .classroom-header .school { font-size: .84rem; }
  .viewport { height: clamp(19rem, 52dvh, 28rem); }
}

@media (display-mode: standalone) {
  #install-open { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .seat-reaction > span, .seat-reaction i { animation: none; }
  .seat-reaction i { display: none; }
}
