:root { --bg:#f3f1ec; --card:#fff; --ink:#1f2328; --muted:#6b6f76; --pri:#2f6fdd; --pri-ink:#fff; --line:#dedad2; --err:#c0392b; --ok:#2e8b57; }
* { box-sizing: border-box; }
html, body { margin:0; height:100%; background:var(--bg); color:var(--ink); font:15px/1.4 "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.hidden { display:none !important; }
.screen { position:fixed; inset:0; overflow:auto; }
.muted { color:var(--muted); } .small { font-size:12px; } .err { color:var(--err); min-height:1.2em; }
.btn { border:1px solid var(--line); background:#fff; color:var(--ink); padding:8px 14px; border-radius:10px; font:inherit; cursor:pointer; text-decoration:none; display:inline-flex; align-items:center; gap:6px; }
.btn:hover { filter:brightness(0.97); } .btn:disabled { opacity:.5; cursor:default; }
.btn.primary { background:var(--pri); color:var(--pri-ink); border-color:var(--pri); }
.btn.ghost { background:transparent; }
.btn.small { padding:5px 10px; font-size:13px; }
.btn.big { width:100%; padding:12px; font-size:17px; margin-top:12px; justify-content:center; }
input, textarea, select { width:100%; font:inherit; padding:8px 10px; border:1px solid var(--line); border-radius:8px; background:#fff; color:var(--ink); }
textarea { resize:vertical; }
label { display:block; margin:10px 0 4px; font-weight:600; font-size:13px; }
label input, label textarea, label select { margin-top:4px; font-weight:400; }
.lbl { font-weight:600; font-size:13px; margin:12px 0 6px; }

/* вхід */
.login { max-width:560px; margin:6vh auto; padding:22px; }
.card { background:var(--card); border-radius:16px; box-shadow:0 6px 24px rgba(0,0,0,.08); }
.login h1 { margin:0 0 4px; font-size:24px; }
.pick { display:flex; flex-wrap:wrap; gap:6px; }
.pick button { width:42px; height:42px; font-size:24px; border-radius:10px; border:2px solid transparent; background:#f4f2ee; cursor:pointer; }
.pick button.sel { border-color:var(--pri); background:#e7efff; }
.colors button { width:34px; height:34px; border-radius:50%; }

/* герой */
.hero { display:flex; gap:14px; align-items:flex-start; }
.hero canvas { width:210px; height:300px; flex:0 0 210px; border-radius:14px; background:linear-gradient(180deg,#ffd8ad,#fff4e8); }
.look { flex:1; min-width:0; }
.look-tabs { display:grid; grid-template-columns:repeat(4,1fr); gap:4px; margin-bottom:6px; }
.look-tab { min-height:46px; padding:3px 2px; border:1px solid var(--line); background:#faf9f6; border-radius:10px; cursor:pointer; font:inherit; font-size:12px; font-weight:700; line-height:1.2; white-space:pre-line; }
.look-tab.sel { background:var(--pri); color:#fff; border-color:var(--pri); }
.look-row { display:flex; flex-direction:column; align-items:flex-start; gap:3px; margin:7px 0; }
.look-k { font-size:12px; font-weight:700; color:var(--muted); }
.look-opts { display:flex; flex-wrap:wrap; gap:6px; }
.look-sw { width:32px; height:32px; border-radius:50%; border:3px solid transparent; cursor:pointer; box-shadow:0 0 0 1px rgba(0,0,0,.18) inset; padding:0; }
.look-sw.sel { border-color:var(--pri); box-shadow:0 0 0 2px #fff inset; }
.look-opt { border:1px solid var(--line); background:#faf9f6; padding:4px 11px; min-height:32px; border-radius:16px; cursor:pointer; font:inherit; font-size:13px; }
.look-opt.sel { background:var(--pri); color:#fff; border-color:var(--pri); }
.look-tools { display:flex; flex-wrap:wrap; gap:6px; margin-top:10px; padding-top:8px; border-top:1px solid var(--line); }
.look-tool { background:#fff; font-weight:700; }
.modal { position:fixed; inset:0; background:rgba(20,16,30,.45); z-index:50; display:flex; align-items:center; justify-content:center; padding:12px; }
.modal-card { width:min(560px,100%); padding:16px; max-height:92vh; overflow:auto; }
.modal-card h3 { margin:0 0 10px; }
@media (max-width:560px) { .hero { flex-direction:column; align-items:center; } .hero canvas { width:200px; height:240px; flex-basis:auto; } .look { width:100%; } }

/* лобі */
.lobby { max-width:900px; margin:0 auto; padding:16px; }
.lobby-head { display:flex; align-items:center; justify-content:space-between; gap:10px; }
.lobby-head h2 { margin:6px 0; }
.actions { display:flex; flex-wrap:wrap; gap:8px; margin:8px 0 14px; }
.rooms { display:grid; grid-template-columns:repeat(auto-fill, minmax(230px, 1fr)); gap:12px; }
.room { padding:14px; display:flex; flex-direction:column; gap:6px; }
.room h3 { margin:0; font-size:16px; }
.room .meta { color:var(--muted); font-size:13px; }
.room .row { display:flex; gap:6px; margin-top:auto; flex-wrap:wrap; }
.badge { display:inline-block; font-size:11px; padding:2px 7px; border-radius:20px; background:#eef3ff; color:#2f4f9d; }
.badge.demo { background:#fff1d6; color:#8a5a00; }

/* гра */
#scr-game { overflow:hidden; background:#222; }
#cv, #cv3 { position:absolute; inset:0; width:100%; height:100%; touch-action:none; display:block; }
.topbar { position:absolute; top:0; left:0; right:0; display:flex; align-items:center; gap:8px; padding:8px; background:linear-gradient(rgba(0,0,0,.55), rgba(0,0,0,0)); z-index:5; }
.topbar .title { color:#fff; font-weight:700; flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; text-shadow:0 1px 2px #000; }
.topbar .online { color:#fff; font-size:13px; text-shadow:0 1px 2px #000; }
.question { position:absolute; left:50%; transform:translateX(-50%); top:50px; max-width:min(92vw, 640px); background:rgba(20,30,40,.88); color:#fff; padding:8px 14px; border-radius:12px; font-weight:700; text-align:center; z-index:4; }
.popup { position:absolute; left:50%; transform:translateX(-50%); bottom:58px; width:min(94vw, 560px); max-height:42vh; overflow:auto; background:#fffdf7; color:#222; border-radius:14px; padding:12px 14px; box-shadow:0 8px 28px rgba(0,0,0,.35); z-index:6; }
.popup h4 { margin:0 0 6px; } .popup p { margin:0; white-space:pre-wrap; }
.popup.good { background:#e3f8ea; } .popup.bad { background:#ffe9e6; } .popup.final { background:#fff4cf; text-align:center; font-size:18px; }
.toast { position:absolute; top:52px; right:10px; max-width:min(80vw, 380px); background:#203a60; color:#fff; padding:8px 12px; border-radius:10px; z-index:7; font-size:14px; }
.busy { position:absolute; top:96px; left:50%; transform:translateX(-50%); background:#5b3fd1; color:#fff; padding:7px 14px; border-radius:20px; z-index:7; animation:pulse 1s infinite alternate; }
@keyframes pulse { from { opacity:.65 } to { opacity:1 } }
.emotes { position:absolute; right:8px; bottom:10px; display:flex; gap:4px; z-index:5; }
.emotes button { width:38px; height:38px; border-radius:50%; border:none; background:rgba(255,255,255,.85); font-size:19px; cursor:pointer; }
.hint-move { position:absolute; left:8px; bottom:14px; color:#fff; font-size:12px; opacity:.8; text-shadow:0 1px 2px #000; z-index:4; pointer-events:none; }

/* сортування */
.question .carry { font-size:14px; font-weight:800; color:#ffd966; margin-top:2px; }
.sect { margin:16px 0 8px; font-size:17px; }
.rooms + .sect { margin-top:20px; }
.room.level { border-top:4px solid #f2a33a; }
.badge.level { background:#fff1d6; color:#8a5a00; font-weight:700; }
.badge.mode { background:#eef7ee; color:#256b3c; }
.cat-row { border-top:1px solid var(--line); padding:6px 0; display:flex; flex-direction:column; gap:6px; align-items:flex-start; }
.cat-row .two { width:100%; }
.sw-row { display:flex; gap:6px; }
.sw { width:28px; height:28px; border-radius:50%; border:3px solid transparent; cursor:pointer; padding:0; box-shadow:0 0 0 1px rgba(0,0,0,.2) inset; }
.sw.sel { border-color:#222; box-shadow:0 0 0 2px #fff inset; }
.colorpick { width:56px; height:36px; padding:2px; }

/* редактор */
.editor { position:absolute; top:0; right:0; bottom:0; width:min(440px, 100vw); background:#fbfaf7; z-index:10; display:flex; flex-direction:column; box-shadow:-6px 0 24px rgba(0,0,0,.3); }
.ed-head { display:flex; align-items:center; justify-content:space-between; padding:8px; border-bottom:1px solid var(--line); }
.tabs { display:flex; gap:4px; }
.tab { border:none; background:transparent; padding:8px 10px; border-radius:8px; font:inherit; cursor:pointer; }
.tab.active { background:#e7efff; color:#1d4fb0; font-weight:700; }
.ed-body { flex:1; overflow:auto; padding:10px 12px 0; }
.pane { padding-bottom:12px; }
.row { display:flex; gap:8px; flex-wrap:wrap; margin:8px 0; }
.row.sticky { position:sticky; bottom:0; background:#fbfaf7; padding:8px 0; margin:0; border-top:1px solid var(--line); }
.ai-log { display:flex; flex-direction:column; gap:8px; margin-bottom:8px; }
.msg { padding:8px 10px; border-radius:10px; font-size:14px; white-space:pre-wrap; }
.msg.me { background:#e7efff; align-self:flex-end; max-width:90%; }
.msg.ai { background:#efeaff; max-width:95%; }
.msg.err { background:#ffe9e6; }
.ai-quota { font-size:12px; color:var(--muted); margin-bottom:4px; }
.stage-box { border:1px solid var(--line); border-radius:12px; padding:8px 10px; margin:10px 0; background:#fff; }
.stage-box h4 { margin:2px 0 4px; display:flex; justify-content:space-between; align-items:center; }
.ans-row { display:flex; gap:6px; align-items:center; margin:4px 0; }
.ans-row input[type=radio] { width:auto; }
.two { display:grid; grid-template-columns:70px 1fr; gap:8px; }

/* керування викладача, масштаб, заморозка */
.frozen-plate { position:absolute; top:50%; left:50%; transform:translate(-50%,-50%); z-index:8; background:rgba(20,40,80,.92); color:#fff; padding:14px 22px; border-radius:16px; font-size:20px; font-weight:800; text-align:center; box-shadow:0 8px 30px rgba(0,0,0,.45); pointer-events:none; max-width:90vw; }
.zoom { position:absolute; right:8px; bottom:56px; display:flex; flex-direction:column; gap:4px; z-index:5; }
.zoom button { width:38px; height:38px; border-radius:50%; border:none; background:rgba(255,255,255,.85); font-size:20px; font-weight:800; cursor:pointer; line-height:1; }
.ctl-actions { display:grid; grid-template-columns:1fr 1fr; gap:6px; margin:8px 0 10px; }
.ctl-actions .btn { justify-content:center; }
.ctl-row { border:1px solid var(--line); border-radius:10px; padding:6px 8px; margin:6px 0; background:#fff; display:flex; align-items:center; gap:6px; }
.ctl-row.fz { background:#e8f1ff; border-color:#9bbcf0; }
.ctl-row .who { flex:1; min-width:0; }
.ctl-row .who b { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.ctl-row .st { font-size:12px; color:var(--muted); }
.ctl-dot { width:14px; height:14px; border-radius:50%; flex:0 0 14px; box-shadow:0 0 0 1px rgba(0,0,0,.25) inset; }
@media (max-width: 600px) {
  .editor { top:auto; height:72vh; width:100vw; border-radius:16px 16px 0 0; }
  .hint-move { display:none; }
  .question { top:46px; font-size:14px; }
}

/* пари і вікторина */
.question .qtext { font-size: 16px; margin-top: 3px; }
.question .res-ok { font-size: 17px; font-weight: 800; color: #7ff0a0; margin-top: 3px; }
.question .res-bad { font-size: 15px; font-weight: 800; color: #ffb3a8; margin-top: 3px; }
.question .qhint { font-size: 13px; font-weight: 600; color: #ffe9a8; margin-top: 3px; }
.ctl-check { display: flex; align-items: center; gap: 6px; margin: 6px 0 10px; font-size: 13px; }
.ctl-check input { width: auto; }
.ctl-score { display: flex; justify-content: space-between; border: 1px solid var(--line); border-radius: 8px; padding: 4px 9px; margin: 4px 0; background: #fff; }
.half-box { border: 1px dashed var(--line); border-radius: 10px; padding: 6px 8px; margin: 6px 0; }
.ans-row b { width: 18px; text-align: center; }
.ctl-actions .btn[disabled] { opacity: .45; cursor: default; }

/* вихід, пульт класу, блокування */
.cls-panel { position:fixed; z-index:30; }
.cls-panel select { width:auto; max-width:170px; padding:4px 6px; font-size:13px; }
.cls-panel .ctl-row { flex-wrap:wrap; }
.cls-panel .ctl-row .who { flex:1 1 120px; }
.cls-panel .cls-acts { display:flex; gap:4px; flex-wrap:wrap; align-items:center; }
.cls-group { border:1px solid var(--line); border-radius:10px; padding:8px; background:#fff; margin:6px 0; display:flex; gap:6px; flex-wrap:wrap; align-items:center; }
.cls-lock { display:flex; align-items:center; gap:8px; padding:8px 10px; border-radius:10px; background:#fff4cf; font-weight:700; margin:6px 0; }
.cls-lock input { width:auto; }
.cls-dot { width:10px; height:10px; border-radius:50%; background:#2e8b57; flex:0 0 10px; }
.lock-plate { max-width:520px; margin:10vh auto; padding:28px 22px; text-align:center; background:#fff4cf; border-radius:18px; box-shadow:0 6px 24px rgba(0,0,0,.1); }
.lock-plate .big { font-size:54px; }
.lock-plate h3 { margin:8px 0; font-size:22px; }
@media (max-width: 600px) { .topbar .tx { display:none; } .topbar { gap:5px; } .cls-panel { top:auto; height:72vh; width:100vw; border-radius:16px 16px 0 0; } }

.card .people { font-size:13px; color:#2e6b8a; margin:4px 0; }
.cls-room { border:1px solid var(--line); border-radius:10px; padding:6px 8px; margin:8px 0; background:#fafcff; }
.cls-rhead { display:flex; justify-content:space-between; align-items:center; gap:6px; padding:2px 0 4px; flex-wrap:wrap; }
.cls-name { cursor:pointer; }
.cls-name:hover { text-decoration:underline; }
.cls-group.col { flex-direction:column; align-items:flex-start; }
.btn.danger { background:#d9534f; color:#fff; }
