/* Klassen-Quest – chunky, glossy game UI */
:root {
  --navy: #1b2447;
  --navy-2: #2a3566;
  --ink: #1b2447;
  --muted: #5d6690;
  --paper: #fffdf8;
  --cream: #fff6e3;
  --line: #e2e6f4;
  --yellow: #ffd23f;
  --orange: #ff9f1c;
  --coral: #ff5d5d;
  --pink: #ff6fb1;
  --purple: #7b61ff;
  --blue: #45b7f0;
  --royal: #4a6cf7;
  --mint: #2fd08a;
  --ok: #22b56a;
  --bad: #f04848;
  --font-display: 'Lilita One', 'Arial Rounded MT Bold', 'Trebuchet MS', system-ui, sans-serif;
  --font-ui: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --pop: cubic-bezier(.3, 1.6, .5, 1);
  --out: cubic-bezier(.16, 1, .3, 1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #9fdcff; color: var(--ink);
  font-family: var(--font-ui); font-weight: 700;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
body { user-select: none; -webkit-user-select: none; }
input, textarea { user-select: text; -webkit-user-select: text; }
button { font: inherit; color: inherit; }
img { -webkit-user-drag: none; }
[hidden] { display: none !important; }

#scene { position: fixed; inset: 0; z-index: 0; }
#scene canvas { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }
#scene.dragging, #scene.dragging canvas { cursor: grabbing !important; }
#scene.hover-seat canvas { cursor: pointer; }

/* ---------- outlined game text ---------- */
.outlined { position: relative; z-index: 0; color: #fff; }
.outlined::before {
  content: attr(data-text); position: absolute; left: 0; top: 0; z-index: -1; width: 100%;
  -webkit-text-stroke: .2em var(--navy); color: var(--navy);
  text-shadow: 0 .12em 0 var(--navy);
}

/* ---------- buttons ---------- */
.btn {
  --c1: #ffe27a; --c2: #ffab1f;
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: .45em;
  font-family: var(--font-display); font-size: 1.12rem; letter-spacing: .02em; line-height: 1.1; color: #fff;
  padding: .72em 1.35em; border: 3px solid var(--navy); border-radius: 18px;
  background: linear-gradient(180deg, var(--c1), var(--c2));
  box-shadow: inset 0 3px 0 rgba(255,255,255,.55), inset 0 -5px 0 rgba(0,0,0,.13), 0 5px 0 var(--navy), 0 10px 18px rgba(27,36,71,.28);
  cursor: pointer; white-space: nowrap;
  transition: transform .14s var(--pop), box-shadow .12s, filter .15s;
}
.btn > span:not(.outlined), .btn > b { text-shadow: 0 2px 0 rgba(27,36,71,.55); }
.btn:hover { transform: translateY(-2px) scale(1.03); filter: brightness(1.05) saturate(1.05); }
.btn:active { transform: translateY(4px) scale(.99); box-shadow: inset 0 3px 0 rgba(255,255,255,.5), inset 0 -3px 0 rgba(0,0,0,.13), 0 1px 0 var(--navy), 0 3px 8px rgba(27,36,71,.28); }
.btn:disabled { filter: grayscale(.8) opacity(.6); pointer-events: none; }
.btn img { width: 1.6em; height: 1.6em; margin: -.3em 0; filter: drop-shadow(0 2px 1px rgba(0,0,0,.2)); }
.btn-blue { --c1: #8ad8ff; --c2: #3a86ff; }
.btn-green { --c1: #94f0a6; --c2: #1fb466; }
.btn-red { --c1: #ff9d9d; --c2: #ec4343; }
.btn-purple { --c1: #bba6ff; --c2: #7550ff; }
.btn-pink { --c1: #ffa6d2; --c2: #f0508f; }
.btn-white { --c1: #ffffff; --c2: #e8edfb; color: var(--navy); }
.btn-white > span:not(.outlined) { text-shadow: none; }
.btn-sm { font-size: .92rem; padding: .5em .85em; border-radius: 13px; box-shadow: inset 0 2px 0 rgba(255,255,255,.55), inset 0 -3px 0 rgba(0,0,0,.12), 0 3px 0 var(--navy), 0 6px 10px rgba(27,36,71,.22); }
.btn-sm:active { transform: translateY(2px); }
.btn-xl { font-size: 1.9rem; padding: .55em 1.5em; border-radius: 24px; border-width: 4px; box-shadow: inset 0 4px 0 rgba(255,255,255,.55), inset 0 -7px 0 rgba(0,0,0,.13), 0 7px 0 var(--navy), 0 16px 30px rgba(27,36,71,.35); }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; border: 0; box-shadow: none; color: var(--muted); font-family: var(--font-ui); font-weight: 900; padding: .5em .7em; cursor: pointer; border-radius: 12px; }
.btn-ghost:hover { background: rgba(27,36,71,.07); color: var(--navy); }

.icon-btn {
  width: 50px; height: 50px; border-radius: 16px; border: 3px solid var(--navy);
  background: linear-gradient(#ffffff, #e6ebfa); color: var(--navy);
  box-shadow: inset 0 2px 0 #fff, inset 0 -4px 0 rgba(27,36,71,.08), 0 4px 0 var(--navy), 0 8px 14px rgba(27,36,71,.25);
  display: grid; place-items: center; cursor: pointer; padding: 0;
  transition: transform .14s var(--pop);
}
.icon-btn svg { width: 25px; height: 25px; }
.icon-btn:hover { transform: translateY(-2px) rotate(-4deg); }
.icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--navy); }
.icon-btn.is-off { color: #9aa2c4; background: linear-gradient(#f2f4fb, #dfe4f4); }
.icon-btn.is-off svg { opacity: .7; }

/* ---------- loader ---------- */
#loader {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; overflow: hidden;
  background: radial-gradient(120% 90% at 50% 30%, #c8ecff 0%, #7cc9ff 45%, #3f76e0 100%);
}
.loader-rays {
  position: absolute; inset: -50%;
  background: repeating-conic-gradient(from 0deg, rgba(255,255,255,.18) 0 9deg, rgba(255,255,255,0) 9deg 18deg);
  animation: spin 60s linear infinite; mask-image: radial-gradient(circle, #000 10%, transparent 60%);
  -webkit-mask-image: radial-gradient(circle, #000 10%, transparent 60%);
}
.loader-clouds i {
  position: absolute; width: 260px; height: 90px; border-radius: 90px; background: #fff; opacity: .85;
  filter: blur(1px); box-shadow: 60px -30px 0 10px #fff, 130px -10px 0 0 #fff;
  animation: drift 26s linear infinite;
}
.loader-clouds i:nth-child(1) { top: 12%; left: -20%; animation-duration: 34s; }
.loader-clouds i:nth-child(2) { top: 70%; left: -30%; animation-duration: 28s; animation-delay: -12s; transform: scale(.7); }
.loader-clouds i:nth-child(3) { top: 30%; left: -25%; animation-duration: 40s; animation-delay: -25s; transform: scale(1.3); opacity: .6; }
.loader-clouds i:nth-child(4) { top: 82%; left: -20%; animation-duration: 36s; animation-delay: -5s; }
.loader-inner { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 24px; text-align: center; }
.loader-logo { width: min(640px, 82vw); filter: drop-shadow(0 14px 18px rgba(20,30,80,.35)); animation: logoIn 1s var(--pop) both, float 3.2s ease-in-out 1s infinite; }
.loader-sub { margin: -8px 0 6px; font-family: var(--font-display); font-size: clamp(1.1rem, 2.4vw, 1.6rem); color: #fff; text-shadow: 0 3px 0 rgba(27,36,71,.45); letter-spacing: .02em; }
.progress { width: min(440px, 72vw); height: 28px; border: 4px solid var(--navy); border-radius: 999px; background: #fff; overflow: hidden; box-shadow: 0 5px 0 var(--navy), 0 12px 24px rgba(0,0,0,.2); }
.progress-fill { height: 100%; width: 4%; border-radius: 999px; transition: width .35s var(--out);
  background: repeating-linear-gradient(-45deg, #ffd23f 0 14px, #ffb01f 14px 28px); background-size: 40px 40px; animation: stripes .9s linear infinite; }
.loader-tip { margin: 0; min-height: 1.4em; color: #fff; font-weight: 800; font-size: 1.05rem; text-shadow: 0 2px 0 rgba(27,36,71,.45); }
.btn-play { animation: popIn .6s var(--pop) both, pulse 1.6s ease-in-out .6s infinite; }
#loader.is-out { animation: loaderOut .9s var(--out) forwards; pointer-events: none; }

/* ---------- top bar ---------- */
#topbar {
  position: fixed; z-index: 30; top: calc(12px + var(--safe-top)); left: 16px; right: 16px;
  display: flex; align-items: center; gap: 14px; pointer-events: none;
  transition: transform .5s var(--out), opacity .4s;
}
#topbar > * { pointer-events: auto; }
.brand { border: 0; background: none; padding: 0; cursor: pointer; transition: transform .2s var(--pop); }
.brand img { height: 66px; display: block; filter: drop-shadow(0 5px 0 rgba(27,36,71,.28)) drop-shadow(0 10px 12px rgba(27,36,71,.2)); }
.brand:hover { transform: rotate(-3deg) scale(1.04); }
.class-chip {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  background: #fff; border: 3px solid var(--navy); border-radius: 999px; padding: 6px 14px 6px 7px;
  box-shadow: 0 4px 0 var(--navy), 0 10px 16px rgba(27,36,71,.2); transition: transform .15s var(--pop);
}
.class-chip:hover { transform: translateY(-2px); }
.class-chip-label { background: var(--navy); color: #fff; border-radius: 999px; padding: 5px 11px; font-size: .72rem; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.class-chip b { font-family: var(--font-display); font-weight: 400; font-size: 1.45rem; line-height: 1; }
.class-chip-count { color: var(--muted); font-weight: 900; font-size: .85rem; }
.class-chip .caret { width: 18px; height: 18px; }
.top-actions { margin-left: auto; display: flex; gap: 10px; }
.ui-hidden#topbar { transform: translateY(-140%); opacity: 0; }

/* ---------- dock ---------- */
#dock {
  position: fixed; z-index: 30; left: 50%; bottom: calc(18px + var(--safe-bottom));
  display: flex; gap: 16px; align-items: flex-end; transform: translateX(-50%);
  transition: transform .55s var(--out), opacity .4s;
}
#dock.ui-hidden { transform: translate(-50%, 170%); opacity: 0; }
.mode-btn {
  position: relative; width: 168px; min-height: 100px; padding: 46px 10px 12px; cursor: pointer; text-align: center;
  border: 4px solid var(--navy); border-radius: 24px; color: #fff; font-family: var(--font-display);
  background: linear-gradient(165deg, var(--c1), var(--c2));
  box-shadow: inset 0 4px 0 rgba(255,255,255,.5), inset 0 -7px 0 rgba(0,0,0,.12), 0 6px 0 var(--navy), 0 16px 26px rgba(27,36,71,.32);
  transition: transform .2s var(--pop), filter .2s;
}
.mode-btn img { position: absolute; left: 50%; top: -38px; width: 88px; height: 88px; transform: translateX(-50%) rotate(-7deg); filter: drop-shadow(0 7px 5px rgba(0,0,0,.25)); transition: transform .3s var(--pop); pointer-events: none; }
.mode-btn .outlined { display: block; font-size: 1.32rem; line-height: 1.05; }
.mode-btn small { display: block; margin-top: 4px; font-family: var(--font-ui); font-weight: 900; font-size: .74rem; color: rgba(255,255,255,.95); text-shadow: 0 1px 0 rgba(27,36,71,.5); }
.mode-btn:hover { transform: translateY(-7px); filter: brightness(1.05); }
.mode-btn:hover img { transform: translateX(-50%) rotate(7deg) scale(1.13); }
.mode-btn:active { transform: translateY(2px); }
.mode-hero { width: 196px; min-height: 112px; }
.mode-hero img { width: 100px; height: 100px; top: -46px; }
.mode-hero::after {
  content: 'NEU'; position: absolute; top: -12px; right: -10px; transform: rotate(12deg);
  background: var(--coral); color: #fff; font-family: var(--font-display); font-size: .9rem; padding: 3px 9px; border-radius: 10px; border: 3px solid var(--navy);
  animation: wobble 2.2s ease-in-out infinite;
}
.mode-btn.is-active { outline: 4px solid #fff; outline-offset: 3px; }

/* ---------- panels ---------- */
.panel {
  position: fixed; z-index: 25; top: calc(96px + var(--safe-top)); bottom: calc(24px + var(--safe-bottom)); width: 356px;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--paper); border: 4px solid var(--navy); border-radius: 26px;
  box-shadow: 0 7px 0 var(--navy), 0 24px 40px rgba(27,36,71,.3);
}
.panel-left { left: 16px; }
.panel-right { right: 16px; }
.panel-head { padding: 14px 16px 12px; background: linear-gradient(180deg, #8ad8ff, #3a86ff); border-bottom: 4px solid var(--navy); color: #fff; }
.panel-head h2 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 1.55rem; letter-spacing: .01em; }
.panel-head p { margin: 2px 0 0; font-size: .85rem; opacity: .95; }
.tabs { display: flex; gap: 6px; padding: 10px 12px 0; }
.tab { flex: 1; border: 3px solid var(--navy); border-radius: 14px 14px 0 0; border-bottom: 0; padding: 8px 6px; cursor: pointer; font-weight: 900; background: #eef1fb; color: var(--muted); }
.tab.is-on { background: #fff; color: var(--navy); }
.panel-body { flex: 1; overflow: auto; padding: 12px; border-top: 3px solid var(--navy); background: #fff; overscroll-behavior: contain; }
.panel-foot { padding: 12px; display: flex; gap: 8px; flex-wrap: wrap; border-top: 3px solid var(--line); background: var(--paper); }
.panel-foot .btn { flex: 1; }
.panel-close { position: absolute; top: 12px; right: 12px; width: 38px; height: 38px; border-radius: 12px; border: 3px solid var(--navy); background: #fff; cursor: pointer; display: grid; place-items: center; box-shadow: 0 3px 0 var(--navy); z-index: 2; padding: 0; }
.panel-close svg { width: 18px; height: 18px; }
.panel.is-in { animation: panelIn .45s var(--pop) both; }

.roster-list { display: flex; flex-direction: column; gap: 7px; }
.roster-item {
  display: grid; grid-template-columns: 46px 1fr auto; align-items: center; gap: 10px;
  padding: 5px 10px 5px 5px; border-radius: 16px; background: #fff; border: 3px solid var(--line);
  cursor: grab; touch-action: none; transition: border-color .15s, transform .15s var(--pop), background .15s;
}
.roster-item:hover { border-color: var(--navy); transform: translateX(3px); }
.roster-item.is-selected { border-color: var(--navy); background: #fff6d6; }
.roster-item.is-unseated { border-style: dashed; border-color: #ffb3b3; background: #fff5f5; }
.roster-item .nm { font-weight: 900; font-size: 1.02rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roster-item .sub { font-size: .78rem; color: var(--muted); font-weight: 800; }
.roster-item .seat-badge { font-size: .72rem; font-weight: 900; color: var(--muted); background: #eef1fb; border-radius: 8px; padding: 3px 7px; }
.avatar-dot { width: 46px; height: 46px; border-radius: 50%; border: 3px solid var(--navy); background: var(--c, #ddd); overflow: hidden; display: grid; place-items: end center; }
.avatar-dot img { width: 112%; height: 112%; object-fit: cover; object-position: top; }
.empty-hint { text-align: center; color: var(--muted); padding: 18px 8px; font-weight: 800; }
.empty-hint img { width: 120px; display: block; margin: 0 auto 8px; }
.section-title { font-family: var(--font-display); font-weight: 400; font-size: 1.1rem; margin: 14px 2px 8px; color: var(--navy); }
.section-title:first-child { margin-top: 2px; }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.seg button { border: 3px solid var(--line); background: #fff; border-radius: 16px; padding: 8px 4px 6px; cursor: pointer; font-weight: 900; font-size: .85rem; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 4px; transition: .15s; }
.seg button svg { width: 54px; height: 36px; }
.seg button.is-on { border-color: var(--navy); color: var(--navy); background: #fff6d6; box-shadow: 0 3px 0 var(--navy); }
.stepper { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; font-weight: 900; }
.stepper .ctl { display: flex; align-items: center; gap: 8px; }
.stepper .ctl b { min-width: 26px; text-align: center; font-family: var(--font-display); font-weight: 400; font-size: 1.3rem; }
.round-btn { width: 36px; height: 36px; border-radius: 12px; border: 3px solid var(--navy); background: #fff; box-shadow: 0 3px 0 var(--navy); cursor: pointer; font-family: var(--font-display); font-size: 1.2rem; line-height: 1; display: grid; place-items: center; padding: 0; }
.round-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--navy); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; font-weight: 900; }
.switch { position: relative; width: 56px; height: 32px; border-radius: 99px; border: 3px solid var(--navy); background: #dfe4f4; cursor: pointer; flex: none; transition: background .2s; padding: 0; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 2px solid var(--navy); transition: transform .25s var(--pop); }
.switch.is-on { background: var(--mint); }
.switch.is-on::after { transform: translateX(24px); }

/* ---------- pupil card editor ---------- */
.pcard-hero {
  --pc: #45b7f0; position: relative; height: 200px; flex: none; overflow: hidden; border-bottom: 4px solid var(--navy);
  background: radial-gradient(120% 100% at 50% 100%, color-mix(in srgb, var(--pc) 45%, #fff) 0%, var(--pc) 70%);
}
.pcard-hero::before { content: ''; position: absolute; inset: -60%; background: repeating-conic-gradient(rgba(255,255,255,.2) 0 10deg, transparent 10deg 20deg); animation: spin 40s linear infinite; }
.pcard-hero .hero-av { position: absolute; left: 50%; bottom: -44px; height: 226px; transform: translateX(-50%); filter: drop-shadow(0 10px 8px rgba(0,0,0,.25)); cursor: pointer; transition: transform .25s var(--pop); }
.pcard-hero .hero-av:hover { transform: translateX(-50%) scale(1.05) rotate(-2deg); }
.pcard-hero .btn { position: absolute; left: 12px; top: 12px; }
.pcard-body { flex: 1; overflow: auto; padding: 14px; background: #fff; overscroll-behavior: contain; }
.field { display: block; margin-bottom: 12px; }
.field > span { display: flex; align-items: center; gap: 6px; font-weight: 900; font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 5px 3px; }
.field input, .field textarea {
  width: 100%; font: 800 1.02rem var(--font-ui); color: var(--ink);
  padding: 10px 12px; border: 3px solid var(--line); border-radius: 14px; background: #fbfcff; transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; min-height: 64px; }
.field input:focus, .field textarea:focus { border-color: var(--royal); outline: none; box-shadow: 0 0 0 4px rgba(74,108,247,.18); background: #fff; }
.field input.big { font: 400 1.6rem var(--font-display); padding: 8px 12px; }
.swatches { display: flex; flex-wrap: wrap; gap: 7px; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px var(--navy); cursor: pointer; padding: 0; transition: transform .15s var(--pop); }
.swatch:hover { transform: scale(1.12); }
.swatch.is-on { transform: scale(1.16); box-shadow: 0 0 0 3px var(--navy), 0 0 0 6px rgba(27,36,71,.15); }
.facts-grid { display: grid; gap: 8px; }
.private-note { position: relative; }
.private-note textarea { filter: blur(6px); }
.private-note textarea:focus, .private-note.is-shown textarea { filter: none; }
.private-note .lock { position: absolute; right: 10px; top: 32px; font-size: .75rem; color: var(--muted); font-weight: 900; pointer-events: none; }
details.fold { border: 3px solid var(--line); border-radius: 16px; padding: 8px 10px; margin-bottom: 12px; background: #fbfcff; }
details.fold summary { cursor: pointer; font-family: var(--font-display); font-size: 1.05rem; list-style: none; display: flex; align-items: center; justify-content: space-between; }
details.fold summary::after { content: '▾'; transition: transform .2s; }
details.fold[open] summary::after { transform: rotate(180deg); }
details.fold[open] summary { margin-bottom: 8px; }

/* ---------- modal ---------- */
#layer-modal { position: fixed; inset: 0; z-index: 60; pointer-events: none; }
.modal-wrap { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; pointer-events: auto; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(18, 24, 60, .5); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); animation: fadeIn .25s both; }
.modal {
  position: relative; width: min(var(--mw, 560px), 94vw); max-height: 90vh; display: flex; flex-direction: column;
  background: var(--paper); border: 4px solid var(--navy); border-radius: 28px; overflow: hidden;
  box-shadow: 0 8px 0 var(--navy), 0 34px 60px rgba(0,0,0,.35); animation: popIn .42s var(--pop) both;
}
.modal-head { position: relative; padding: 16px 64px 14px 22px; background: linear-gradient(180deg, var(--c1, #8ad8ff), var(--c2, #3a86ff)); border-bottom: 4px solid var(--navy); color: #fff; display: flex; align-items: center; gap: 12px; }
.modal-head img { width: 56px; height: 56px; margin: -10px 0; filter: drop-shadow(0 4px 3px rgba(0,0,0,.2)); }
.modal-head h2 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 1.7rem; }
.modal-head p { margin: 2px 0 0; font-size: .9rem; }
.modal-body { padding: 18px 22px; overflow: auto; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; padding: 4px 22px 22px; flex-wrap: wrap; }
.modal-close { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border-radius: 13px; border: 3px solid var(--navy); background: #fff; display: grid; place-items: center; cursor: pointer; box-shadow: 0 3px 0 var(--navy); padding: 0; color: var(--navy); }
.modal-close svg { width: 18px; height: 18px; }
.modal.is-out { animation: popOut .25s ease both; }
.modal-bare { background: none; border: 0; box-shadow: none; overflow: visible; animation: none; }
.modal-bare .modal-body { overflow: visible; padding: 0; }
.modal-backdrop.is-out { animation: fadeOut .25s ease both; }
.modal textarea.names { width: 100%; min-height: 220px; font: 800 1.05rem/1.5 var(--font-ui); padding: 12px; border: 3px solid var(--line); border-radius: 16px; resize: vertical; }
.modal textarea.names:focus { border-color: var(--royal); outline: none; }
.muted { color: var(--muted); font-weight: 800; }
.small { font-size: .85rem; }

.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.choice {
  position: relative; border: 4px solid var(--line); border-radius: 22px; background: #fff; padding: 14px 12px 12px; cursor: pointer; text-align: center;
  transition: transform .2s var(--pop), border-color .15s, box-shadow .15s; display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.choice img { width: 78px; height: 78px; filter: drop-shadow(0 5px 3px rgba(0,0,0,.18)); transition: transform .3s var(--pop); }
.choice b { font-family: var(--font-display); font-weight: 400; font-size: 1.25rem; color: var(--navy); }
.choice small { color: var(--muted); font-weight: 800; font-size: .8rem; line-height: 1.3; }
.choice:hover { transform: translateY(-4px); border-color: var(--navy); }
.choice:hover img { transform: rotate(-8deg) scale(1.1); }
.choice.is-on { border-color: var(--navy); background: #fff6d6; box-shadow: 0 5px 0 var(--navy); }

.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px; }
.avatar-opt { position: relative; aspect-ratio: 1; border-radius: 20px; border: 3px solid var(--line); background: linear-gradient(180deg, #fff, #eef3ff); cursor: pointer; padding: 0; overflow: hidden; transition: transform .2s var(--pop), border-color .15s; }
.avatar-opt img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.avatar-opt span { position: absolute; left: 0; right: 0; bottom: 0; font-size: .66rem; font-weight: 900; background: rgba(255,255,255,.88); padding: 2px 0; }
.avatar-opt:hover { transform: scale(1.07) rotate(-2deg); border-color: var(--navy); }
.avatar-opt.is-on { border-color: var(--navy); box-shadow: 0 0 0 3px var(--yellow); }
.avatar-opt.is-taken::after { content: '✓'; position: absolute; top: 4px; right: 6px; font-size: .8rem; color: var(--muted); }

.class-list { display: flex; flex-direction: column; gap: 8px; }
.class-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 3px solid var(--line); border-radius: 16px; background: #fff; }
.class-row.is-active { border-color: var(--navy); background: #fff6d6; }
.class-row .nm { font-family: var(--font-display); font-size: 1.3rem; flex: 1; }
.class-row .meta { color: var(--muted); font-weight: 800; font-size: .82rem; }

/* ---------- holo profile card ---------- */
.holo-wrap { display: grid; place-items: center; perspective: 1000px; }
.holo {
  --pc: #45b7f0; --rx: 0deg; --ry: 0deg; --mx: 50%; --my: 50%;
  position: relative; width: min(340px, 86vw); border-radius: 28px; border: 5px solid var(--navy); overflow: hidden; background: #fff;
  transform: rotateX(var(--rx)) rotateY(var(--ry)); transition: transform .2s ease-out;
  box-shadow: 0 10px 0 var(--navy), 0 30px 50px rgba(0,0,0,.35); animation: cardIn .7s var(--pop) both;
}
.holo::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; mix-blend-mode: overlay; opacity: .85;
  background: linear-gradient(115deg, transparent 25%, rgba(255,255,255,.7) 42%, rgba(120,210,255,.55) 48%, rgba(255,120,220,.5) 54%, transparent 72%);
  background-size: 260% 260%; background-position: var(--mx) var(--my);
}
.holo-top { position: relative; height: 250px; overflow: hidden; background: radial-gradient(110% 90% at 50% 100%, color-mix(in srgb, var(--pc) 40%, #fff), var(--pc) 75%); }
.holo-top::before { content: ''; position: absolute; inset: -60%; background: repeating-conic-gradient(rgba(255,255,255,.22) 0 8deg, transparent 8deg 16deg); animation: spin 30s linear infinite; }
.holo-top img { position: absolute; left: 50%; bottom: -34px; height: 290px; transform: translateX(-50%); filter: drop-shadow(0 10px 8px rgba(0,0,0,.25)); }
.holo-badge { position: absolute; top: 12px; left: 12px; background: rgba(255,255,255,.92); color: var(--navy); border: 3px solid var(--navy); border-radius: 12px; padding: 3px 9px; font-weight: 900; font-size: .78rem; }
.holo-name { position: relative; margin: -24px 18px 0; text-align: center; background: linear-gradient(180deg, #ffe27a, #ffab1f); border: 4px solid var(--navy); border-radius: 18px; padding: 6px 10px 8px; box-shadow: 0 4px 0 var(--navy); z-index: 1; }
.holo-name .outlined { font-family: var(--font-display); font-size: 2rem; line-height: 1.05; display: block; }
.holo-name small { display: block; font-weight: 900; color: var(--navy); font-size: .82rem; }
.holo-facts { list-style: none; margin: 0; padding: 12px 16px 16px; display: grid; gap: 7px; }
.holo-facts li { display: grid; grid-template-columns: 30px 1fr; gap: 8px; align-items: start; background: #f5f7ff; border-radius: 14px; padding: 7px 10px; }
.holo-facts li i { font-style: normal; font-size: 1.25rem; line-height: 1.2; }
.holo-facts li small { display: block; font-size: .68rem; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.holo-facts li span { font-weight: 900; }
.holo-actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 28; pointer-events: none; }
#hud > * { pointer-events: auto; }
.scoreboard { position: absolute; top: calc(14px + var(--safe-top)); left: 50%; transform: translateX(-50%); display: flex; align-items: stretch; filter: drop-shadow(0 6px 0 var(--navy)) drop-shadow(0 14px 16px rgba(0,0,0,.2)); animation: dropIn .6s var(--pop) both; }
.team { display: flex; align-items: center; gap: 10px; padding: 6px 16px; border: 4px solid var(--navy); color: #fff; font-family: var(--font-display); }
.team img { width: 44px; height: 44px; margin: -6px 0; }
.team-teacher { border-radius: 22px 0 0 22px; background: linear-gradient(#ffe27a, #ffab1f); border-right: 0; }
.team-class { border-radius: 0 22px 22px 0; background: linear-gradient(#c2adff, #7550ff); border-left: 0; }
.team-name { font-size: 1.05rem; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-score { font-size: 2.3rem; min-width: 1.3em; text-align: center; line-height: 1; }
.team-score.is-bump { animation: bump .5s var(--pop); }
.vs { display: grid; place-items: center; background: var(--navy); color: #ffd23f; font-family: var(--font-display); font-size: 1.1rem; padding: 0 10px; border-top: 4px solid var(--navy); border-bottom: 4px solid var(--navy); }
.round-pill { position: absolute; top: calc(92px + var(--safe-top)); left: 50%; transform: translateX(-50%); background: #fff; border: 3px solid var(--navy); border-radius: 999px; padding: 4px 14px; font-weight: 900; box-shadow: 0 3px 0 var(--navy); white-space: nowrap; }
.hud-left { position: absolute; left: 16px; top: calc(16px + var(--safe-top)); display: flex; gap: 10px; }
.hud-right { position: absolute; right: 16px; top: calc(16px + var(--safe-top)); display: flex; gap: 10px; }
/* sits over the (seat-free) teacher area at the bottom so it never hides a child */
.prompt-card {
  position: absolute; bottom: calc(22px + var(--safe-bottom)); left: 50%; transform: translateX(-50%); width: min(560px, 90vw);
  background: #fff; border: 4px solid var(--navy); border-radius: 26px; padding: 14px 22px 16px; text-align: center;
  box-shadow: 0 6px 0 var(--navy), 0 20px 34px rgba(0,0,0,.25); animation: riseIn .5s var(--pop) both;
}
.prompt-card .kicker { font-weight: 900; font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.prompt-card h3 { margin: 4px 0 0; font-family: var(--font-display); font-weight: 400; font-size: clamp(1.4rem, 3vw, 2.1rem); line-height: 1.15; }
.prompt-card .clue { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 8px; font-size: 1.15rem; font-weight: 900; }
.prompt-card .clue i { font-style: normal; font-size: 1.5rem; }
.prompt-card .clue-label { display: inline-block; background: #eef1fb; border-radius: 10px; padding: 2px 8px; font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.answer-grid { position: absolute; left: 50%; bottom: calc(22px + var(--safe-bottom)); transform: translateX(-50%); display: grid; grid-template-columns: repeat(2, minmax(210px, 1fr)); gap: 14px; width: min(640px, 94vw); }
.answer-grid .btn { font-size: 1.5rem; padding: .55em .8em; animation: popIn .45s var(--pop) both; }
.answer-grid .btn:nth-child(2) { animation-delay: .06s; } .answer-grid .btn:nth-child(3) { animation-delay: .12s; } .answer-grid .btn:nth-child(4) { animation-delay: .18s; }
.answer-grid .btn.is-right { --c1: #94f0a6; --c2: #1fb466; animation: bump .5s var(--pop); }
.answer-grid .btn.is-wrong { --c1: #ff9d9d; --c2: #ec4343; animation: shake .45s; }
.answer-grid .btn.is-dim { filter: grayscale(.7) opacity(.55); }
.hud-bottom { position: absolute; left: 50%; bottom: calc(22px + var(--safe-bottom)); transform: translateX(-50%); display: flex; gap: 12px; align-items: center; }
.tray {
  position: absolute; left: 50%; bottom: calc(16px + var(--safe-bottom)); transform: translateX(-50%); width: min(1100px, calc(100vw - 32px));
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; padding: 12px 14px;
  background: rgba(255,253,248,.94); border: 4px solid var(--navy); border-radius: 26px; box-shadow: 0 6px 0 var(--navy), 0 18px 30px rgba(0,0,0,.25);
  animation: riseIn .5s var(--pop) both;
}
.tray-title { width: 100%; text-align: center; font-weight: 900; color: var(--muted); font-size: .85rem; margin-bottom: 2px; }
.name-card {
  --c1: #8ad8ff; --c2: #3a86ff;
  display: inline-flex; align-items: center; gap: 7px; padding: 4px 13px 4px 4px; border-radius: 999px; border: 3px solid var(--navy);
  background: linear-gradient(180deg, var(--c1), var(--c2)); color: #fff; font-family: var(--font-display); font-size: 1.12rem;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.5), 0 3px 0 var(--navy); cursor: grab; touch-action: none; animation: popIn .4s var(--pop) both;
  transition: transform .15s var(--pop), opacity .2s;
}
.name-card span { text-shadow: 0 2px 0 rgba(27,36,71,.5); }
.name-card img { width: 34px; height: 34px; border-radius: 50%; background: #fff; border: 2px solid var(--navy); object-fit: cover; object-position: top; }
.name-card:hover { transform: translateY(-3px) rotate(-2deg); }
.name-card.is-dragging { opacity: .3; }
.name-card.is-placed { display: none; }
#drag-ghost { position: fixed; z-index: 95; left: 0; top: 0; pointer-events: none; transform: translate(-50%, -60%) rotate(-5deg) scale(1.12); filter: drop-shadow(0 12px 10px rgba(0,0,0,.3)); }
.timer {
  position: absolute; right: 22px; top: calc(96px + var(--safe-top)); width: 84px; height: 84px; border-radius: 50%;
  background: #fff; border: 4px solid var(--navy); box-shadow: 0 5px 0 var(--navy); display: grid; place-items: center;
}
.timer svg { position: absolute; inset: 4px; width: calc(100% - 8px); height: calc(100% - 8px); transform: rotate(-90deg); }
.timer circle { fill: none; stroke-width: 9; }
.timer .track { stroke: #eef1fb; }
.timer .bar { stroke: var(--mint); stroke-linecap: round; transition: stroke .3s; }
.timer b { position: relative; font-family: var(--font-display); font-weight: 400; font-size: 1.8rem; }
.timer.is-low .bar { stroke: var(--coral); }
.timer.is-low { animation: bump .5s var(--pop) infinite; }

.mascot { position: absolute; left: 10px; bottom: calc(8px + var(--safe-bottom)); width: 150px; animation: bob 3s ease-in-out infinite; pointer-events: none; filter: drop-shadow(0 10px 8px rgba(0,0,0,.25)); }
.bubble {
  position: absolute; left: 150px; bottom: calc(118px + var(--safe-bottom)); max-width: min(330px, 60vw);
  background: #fff; border: 4px solid var(--navy); border-radius: 22px; padding: 11px 15px; font-weight: 900; font-size: 1.02rem; line-height: 1.3;
  box-shadow: 0 5px 0 var(--navy), 0 14px 20px rgba(0,0,0,.2); animation: popIn .4s var(--pop) both; pointer-events: none;
}
.bubble::after { content: ''; position: absolute; left: -16px; bottom: 14px; border: 11px solid transparent; border-right: 14px solid var(--navy); }
.bubble::before { content: ''; position: absolute; left: -9px; bottom: 17px; border: 8px solid transparent; border-right: 10px solid #fff; z-index: 1; }

/* results */
.results { text-align: center; }
.results .trophy { width: 150px; filter: drop-shadow(0 12px 10px rgba(0,0,0,.25)); animation: trophy 1.2s var(--pop) both; }
.stars { display: flex; justify-content: center; gap: 6px; margin: 4px 0 10px; }
.stars img { width: 64px; height: 64px; filter: grayscale(1) opacity(.35); }
.stars img.is-on { filter: drop-shadow(0 6px 4px rgba(0,0,0,.2)); animation: starPop .6s var(--pop) both; }
.stars img:nth-child(2) { width: 80px; height: 80px; margin-top: -12px; }
.big-score { font-family: var(--font-display); font-size: 3.2rem; line-height: 1; }
.versus-result { display: flex; justify-content: center; gap: 14px; margin: 12px 0; }
.versus-result > div { flex: 1; max-width: 190px; border: 4px solid var(--navy); border-radius: 20px; padding: 10px; color: #fff; font-family: var(--font-display); }
.versus-result .t { background: linear-gradient(#ffe27a, #ffab1f); }
.versus-result .k { background: linear-gradient(#c2adff, #7550ff); }
.versus-result b { display: block; font-size: 2.4rem; line-height: 1; }
.versus-result .win { transform: scale(1.06) rotate(-2deg); box-shadow: 0 0 0 4px #fff, 0 0 0 8px var(--yellow); }
.learn-list { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 8px; }
.learn-list .name-card { cursor: default; font-size: .95rem; animation: none; }

/* ---------- banner & toasts ---------- */
#layer-banner { position: fixed; inset: 0; z-index: 55; pointer-events: none; display: grid; place-items: center; overflow: hidden; }
.banner { position: relative; z-index: 0; text-align: center; font-family: var(--font-display); color: #fff; line-height: .95; }
.banner-rays { z-index: -1; }
#mascot-layer { position: fixed; inset: 0; z-index: 29; pointer-events: none; }
#mascot-layer.is-top .mascot { top: calc(70px + var(--safe-top)); bottom: auto; width: 112px; }
#mascot-layer.is-top .bubble { top: calc(92px + var(--safe-top)); bottom: auto; left: 128px; }
.pick-card { position: absolute; right: 28px; top: 50%; transform: translateY(-50%); pointer-events: auto; }
.pick-card .holo { width: min(300px, 40vw); }
.hud-controls { position: absolute; left: 50%; bottom: calc(22px + var(--safe-bottom)); transform: translateX(-50%); display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: center; background: rgba(255,253,248,.92); border: 4px solid var(--navy); border-radius: 26px; padding: 12px 16px; box-shadow: 0 6px 0 var(--navy), 0 18px 30px rgba(0,0,0,.25); animation: riseIn .5s var(--pop) both; }
.hud-controls .toggle-row { padding: 0; gap: 8px; font-size: .92rem; }
.hud-controls .count { font-weight: 900; color: var(--muted); font-size: .9rem; }
body.is-game .brand, body.is-game .class-chip, body.is-game #btn-cam { display: none; }
.desk-tools { display: flex; gap: 8px; align-items: center; margin: 8px 0; padding: 8px 10px; background: #fff6d6; border: 3px solid var(--navy); border-radius: 16px; font-weight: 900; }
.desk-tools span { flex: 1; }
.hint { font-size: .8rem; color: var(--muted); font-weight: 800; margin: 4px 2px 10px; }
.warn { background: #fff1f1; border: 3px dashed #ffb3b3; border-radius: 14px; padding: 8px 10px; font-weight: 800; font-size: .85rem; color: #b33; margin-bottom: 10px; }
.quality-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.quality-grid button { border: 3px solid var(--line); background: #fff; border-radius: 12px; padding: 7px 2px; font-weight: 900; font-size: .8rem; cursor: pointer; color: var(--muted); }
.quality-grid button.is-on { border-color: var(--navy); color: var(--navy); background: #fff6d6; }
.privacy-note { display: flex; gap: 10px; align-items: flex-start; background: #eefbf4; border: 3px solid #bfeccf; border-radius: 16px; padding: 10px 12px; font-size: .86rem; font-weight: 800; color: #2a6a45; margin-top: 12px; }
.banner .outlined { display: block; font-size: clamp(3rem, 9.5vw, 8rem); letter-spacing: .01em; }
.banner .outlined::before { -webkit-text-stroke: .16em var(--navy); text-shadow: 0 .1em 0 var(--navy), 0 .3em .4em rgba(0,0,0,.25); }
.banner small { display: inline-block; margin-top: .6em; font-size: clamp(1rem, 2.4vw, 1.6rem); background: var(--navy); padding: .3em .9em; border-radius: 999px; }
.banner.good .outlined { color: #9dffb5; }
.banner.bad .outlined { color: #ffb0b0; }
.banner.gold .outlined { color: #ffe066; }
.banner-rays { position: absolute; width: 150vmax; height: 150vmax; left: 50%; top: 50%; margin: -75vmax 0 0 -75vmax; background: repeating-conic-gradient(rgba(255,230,120,.28) 0 7deg, transparent 7deg 14deg); mask-image: radial-gradient(circle, #000 0, transparent 55%); -webkit-mask-image: radial-gradient(circle, #000 0, transparent 55%); animation: spin 14s linear infinite; }

#layer-toast { position: fixed; z-index: 70; left: 50%; bottom: calc(150px + var(--safe-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: var(--navy); color: #fff; font-weight: 900; padding: 10px 18px; border-radius: 999px; box-shadow: 0 8px 18px rgba(0,0,0,.3); animation: toastIn .4s var(--pop) both; max-width: 86vw; text-align: center; }
.toast.is-out { animation: toastOut .3s ease both; }
.toast.good { background: var(--ok); }
.toast.bad { background: var(--bad); }

.tooltip-3d { position: fixed; z-index: 40; pointer-events: none; transform: translate(-50%, -130%); background: var(--navy); color: #fff; padding: 5px 11px; border-radius: 10px; font-weight: 900; font-size: .85rem; white-space: nowrap; }
.noscript { position: fixed; inset: 0; display: grid; place-items: center; font-size: 1.4rem; }

/* ---------- animations ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes drift { from { transform: translateX(0); } to { transform: translateX(150vw); } }
@keyframes float { 0%, 100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-12px) rotate(1deg); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
@keyframes logoIn { from { transform: scale(.3) rotate(-10deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes stripes { to { background-position: 40px 0; } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes wobble { 0%, 100% { transform: rotate(12deg); } 50% { transform: rotate(-4deg) scale(1.1); } }
@keyframes popIn { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes popOut { to { transform: scale(.85); opacity: 0; } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes loaderOut { to { opacity: 0; transform: scale(1.08); filter: blur(6px); } }
@keyframes panelIn { from { transform: translateY(24px) scale(.96); opacity: 0; } }
@keyframes dropIn { from { transform: translate(-50%, -40px) scale(.8); opacity: 0; } }
@keyframes riseIn { from { transform: translate(-50%, 60px); opacity: 0; } }
@keyframes cardIn { from { transform: rotateY(-100deg) scale(.6); opacity: 0; } }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.3); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-10px) rotate(-2deg); } 40% { transform: translateX(9px) rotate(2deg); } 60% { transform: translateX(-6px); } 80% { transform: translateX(4px); } }
@keyframes toastIn { from { transform: translateY(20px) scale(.8); opacity: 0; } }
@keyframes toastOut { to { transform: translateY(-10px); opacity: 0; } }
@keyframes trophy { 0% { transform: scale(0) rotate(-30deg); } 70% { transform: scale(1.15) rotate(6deg); } 100% { transform: none; } }
@keyframes starPop { 0% { transform: scale(0) rotate(-90deg); } 100% { transform: none; } }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .mode-btn { width: 140px; }
  .mode-hero { width: 160px; }
  .mode-btn small { display: none; }
  .panel { width: 320px; }
}
@media (max-width: 760px) {
  .brand img { height: 48px; }
  .icon-btn { width: 42px; height: 42px; border-radius: 13px; }
  .icon-btn svg { width: 21px; height: 21px; }
  #btn-cam, #btn-full { display: none; }
  #topbar { gap: 8px; left: 10px; right: 10px; }
  .top-actions { gap: 6px; }
  .class-chip { padding: 5px 10px; min-width: 0; }
  .class-chip-label, .class-chip-count { display: none; }
  .class-chip b { font-size: 1.15rem; white-space: nowrap; }
  #dock { gap: 8px; width: calc(100vw - 16px); justify-content: center; }
  .mode-btn { width: auto; flex: 1; min-height: 76px; padding: 34px 4px 8px; border-radius: 18px; }
  .mode-btn img { width: 62px; height: 62px; top: -26px; }
  .mode-hero img { width: 68px; height: 68px; top: -30px; }
  .mode-btn .outlined { font-size: .92rem; }
  .mode-hero::after { display: none; }
  .panel { left: 8px; right: 8px; width: auto; top: auto; bottom: 8px; height: 58vh; }
  .answer-grid { grid-template-columns: 1fr 1fr; }
  .answer-grid .btn { font-size: 1.1rem; }
  .mascot, .bubble { display: none; }
  .team-name { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
