:root {
  color-scheme: dark;
  --bg: #06101c;
  --bg-2: #091827;
  --card: rgba(10, 24, 39, .78);
  --card-strong: rgba(12, 28, 45, .94);
  --line: rgba(148, 163, 184, .16);
  --line-strong: rgba(148, 163, 184, .28);
  --text: #f8fafc;
  --muted: #8fa1b8;
  --cyan: #35e4c3;
  --cyan-2: #22c9ad;
  --cyan-soft: rgba(53, 228, 195, .12);
  --blue: #60a5fa;
  --danger: #fb7185;
  --warning: #fbbf24;
  --radius: 22px;
  --shadow: 0 24px 80px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 0%, rgba(25, 90, 122, .18), transparent 38%),
    radial-gradient(circle at 100% 20%, rgba(20, 184, 166, .08), transparent 30%),
    linear-gradient(160deg, #050c16 0%, #07121e 55%, #06101c 100%);
}
button, input, textarea, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.bg-orb {
  position: fixed;
  width: 460px;
  height: 460px;
  border-radius: 999px;
  filter: blur(90px);
  opacity: .11;
  pointer-events: none;
  z-index: 0;
}
.bg-orb-a { background: #0ea5e9; top: -180px; right: 12vw; }
.bg-orb-b { background: #2dd4bf; bottom: -240px; left: -120px; }

.site-header {
  position: relative;
  z-index: 10;
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1500px;
  margin: 0 auto;
  padding: 0 30px;
  border-bottom: 1px solid rgba(148,163,184,.08);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  border: 0;
  background: transparent;
  padding: 0;
  font-size: 22px;
  cursor: pointer;
  letter-spacing: -.04em;
}
.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: linear-gradient(145deg, var(--cyan), #38bdf8);
  color: #04201b;
  font-weight: 900;
  box-shadow: 0 8px 28px rgba(53, 228, 195, .25);
}
.header-chip {
  border: 1px solid var(--line);
  background: rgba(8, 20, 33, .55);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
}

main { position: relative; z-index: 1; }
.view { display: none; }
.view.active { display: block; }

.hero-shell {
  max-width: 1380px;
  min-height: calc(100vh - 230px);
  margin: 0 auto;
  padding: 80px 32px 40px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 72px;
}
.hero-copy { max-width: 650px; }
.eyebrow {
  display: inline-block;
  font: 700 12px/1 JetBrains Mono, monospace;
  letter-spacing: .14em;
  color: var(--cyan);
  margin-bottom: 18px;
}
.hero-copy h1, .section-heading h2 {
  margin: 0;
  letter-spacing: -.055em;
  line-height: 1.02;
}
.hero-copy h1 { font-size: clamp(46px, 5.4vw, 79px); }
.hero-copy p {
  color: #a8b7ca;
  max-width: 560px;
  line-height: 1.65;
  font-size: 18px;
  margin: 24px 0 34px;
}
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.btn {
  border: 1px solid transparent;
  border-radius: 13px;
  padding: 10px 16px;
  min-height: 42px;
  font-weight: 750;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease, opacity .15s ease;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:disabled { opacity: .42; cursor: not-allowed; }
.btn-xl { min-height: 52px; padding: 13px 21px; border-radius: 15px; }
.btn-primary {
  background: linear-gradient(145deg, #43e8ca, #25cbb1);
  color: #041b17;
  box-shadow: 0 10px 32px rgba(53, 228, 195, .15);
}
.btn-primary:hover:not(:disabled) { background: linear-gradient(145deg, #6ff1d7, #36d8bc); }
.btn-secondary, .btn-ghost {
  background: rgba(255,255,255,.045);
  border-color: var(--line);
  color: #e8eef6;
}
.btn-secondary:hover:not(:disabled), .btn-ghost:hover:not(:disabled) { background: rgba(255,255,255,.08); border-color: var(--line-strong); }

.glass-card {
  border: 1px solid var(--line);
  background: linear-gradient(155deg, rgba(14, 31, 49, .82), rgba(7, 18, 31, .78));
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.hero-card { border-radius: 27px; overflow: hidden; transform: perspective(1200px) rotateY(-3deg) rotateX(1deg); }
.mini-window-top {
  height: 58px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding: 0 20px;
  background: rgba(3, 10, 18, .45);
}
.mini-window-top > span { width: 9px; height: 9px; border-radius: 50%; background: #334155; }
.mini-window-top > span:first-child { background: #fb7185; }
.mini-window-top > span:nth-child(2) { background: #fbbf24; }
.mini-window-top > span:nth-child(3) { background: #4ade80; }
.mini-window-top strong { margin-left: auto; font: 600 11px JetBrains Mono, monospace; color: var(--muted); }
.mini-game { display: grid; grid-template-columns: 1fr 190px; min-height: 360px; }
.mini-canvas {
  position: relative;
  margin: 18px;
  border-radius: 16px;
  background: #f8fafc;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.mini-drawing { font-size: 84px; filter: grayscale(.2); transform: rotate(-8deg); }
.mini-word {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  color: #334155;
  font: 700 14px JetBrains Mono, monospace;
  white-space: nowrap;
}
.mini-sidebar { border-left: 1px solid var(--line); padding: 18px 14px; background: rgba(3, 10, 18, .25); }
.mini-player { display: grid; grid-template-columns: 24px 1fr auto; align-items: center; gap: 7px; padding: 10px 5px; border-bottom: 1px solid rgba(148,163,184,.08); font-size: 12px; }
.mini-player b { color: var(--cyan); }
.mini-player em { color: var(--muted); font-style: normal; }
.mini-chat { margin-top: 10px; background: var(--cyan-soft); border-radius: 9px; padding: 9px; font-size: 10px; color: #bff9ed; }
.mini-chat.muted { color: var(--muted); background: rgba(255,255,255,.035); }

.feature-strip {
  max-width: 1380px;
  margin: 0 auto 60px;
  padding: 0 32px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.feature-strip article {
  display: flex;
  gap: 13px;
  align-items: center;
  padding: 17px 19px;
  border: 1px solid rgba(148,163,184,.10);
  border-radius: 17px;
  background: rgba(255,255,255,.025);
}
.feature-strip article > span { font-size: 22px; }
.feature-strip strong, .feature-strip small { display: block; }
.feature-strip strong { font-size: 13px; }
.feature-strip small { color: var(--muted); margin-top: 4px; }

.panel-shell { max-width: 1050px; margin: 0 auto; padding: 56px 28px 80px; }
.panel-shell.narrow { max-width: 900px; }
.section-heading { display: flex; align-items: flex-start; gap: 17px; margin-bottom: 26px; }
.section-heading.centered { max-width: 530px; width: 100%; }
.section-heading h2 { font-size: clamp(34px, 5vw, 52px); }
.back-btn {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.035);
  cursor: pointer;
  font-size: 20px;
}

.settings-grid {
  border-radius: var(--radius);
  padding: 26px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.field { display: flex; flex-direction: column; gap: 8px; }
.field > span { color: #c7d2df; font-weight: 700; font-size: 12px; }
.field input, .field textarea, .field select {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(1, 8, 15, .48);
  color: var(--text);
  border-radius: 12px;
  min-height: 46px;
  padding: 10px 12px;
}
.field textarea { min-height: 150px; resize: vertical; line-height: 1.6; }
.field input::placeholder, .field textarea::placeholder { color: #5f7187; }
.field.compact select { min-height: 40px; }
.wide { grid-column: 1 / -1; }
.custom-list-box {
  border: 1px dashed rgba(53, 228, 195, .28);
  background: rgba(53, 228, 195, .045);
  border-radius: 16px;
  padding: 18px;
}
.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #b4c0cf;
  font-size: 13px;
}
.check-row input { width: 17px; height: 17px; accent-color: var(--cyan); }
.form-actions { display: flex; justify-content: flex-end; padding-top: 4px; }

.join-shell {
  min-height: calc(100vh - 100px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px;
}
.join-card { width: min(100%, 520px); padding: 28px; border-radius: var(--radius); display: grid; gap: 18px; }
#join-code { font: 800 30px JetBrains Mono, monospace; letter-spacing: .16em; text-align: center; }

.room-view { padding: 18px 22px 30px; }
.room-topbar {
  max-width: 1650px;
  margin: 0 auto 14px;
  min-height: 62px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 8px 4px;
}
.tiny-label { display: block; color: var(--muted); font: 700 9px/1.1 JetBrains Mono, monospace; letter-spacing: .12em; margin-bottom: 5px; }
.room-code { border: 0; padding: 0; background: transparent; color: var(--cyan); font: 800 20px JetBrains Mono, monospace; letter-spacing: .11em; cursor: pointer; }
.room-status-wrap { justify-self: center; color: var(--muted); font-size: 12px; display: flex; gap: 8px; align-items: center; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #64748b; box-shadow: 0 0 0 4px rgba(100,116,139,.12); }
.status-dot.online { background: #34d399; box-shadow: 0 0 0 4px rgba(52,211,153,.12); }
.status-dot.warn { background: #fbbf24; box-shadow: 0 0 0 4px rgba(251,191,36,.12); }
.timers { display: flex; gap: 9px; }
.timers > div {
  min-width: 86px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 7px 10px;
  background: rgba(255,255,255,.025);
}
.timers span { display: block; color: var(--muted); font-size: 9px; margin-bottom: 3px; }
.timers strong { font: 700 14px JetBrains Mono, monospace; }

.room-layout {
  max-width: 1650px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 14px;
  align-items: stretch;
}
.game-stage { border-radius: 21px; padding: 15px; min-height: calc(100vh - 122px); display: flex; flex-direction: column; }
.stage-head { min-height: 54px; display: flex; align-items: center; justify-content: space-between; padding: 0 5px 10px; }
#word-display { font-size: 18px; letter-spacing: .01em; }
.round-badge { border: 1px solid var(--line); background: rgba(255,255,255,.04); color: var(--muted); border-radius: 999px; padding: 7px 11px; font-size: 11px; font-weight: 700; }
.canvas-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 470px;
  background: #f8fafc;
  border-radius: 17px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .1);
}
#draw-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.canvas-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #334155;
  background: rgba(248,250,252,.93);
  text-align: center;
  gap: 7px;
}
.canvas-overlay[hidden] { display: none; }
.canvas-overlay .overlay-icon { font-size: 42px; margin-bottom: 5px; }
.canvas-overlay span { color: #64748b; font-size: 13px; }
.draw-toolbar {
  min-height: 54px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 3px 0;
  opacity: .45;
  pointer-events: none;
}
.draw-toolbar.enabled { opacity: 1; pointer-events: auto; }
.tool-group { display: flex; gap: 6px; }
.color-dot {
  width: 27px;
  height: 27px;
  padding: 0;
  border-radius: 999px;
  border: 3px solid transparent;
  background: var(--dot);
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
}
.color-dot.selected { border-color: #fff; box-shadow: 0 0 0 2px var(--cyan); }
.tool-btn {
  min-height: 31px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255,255,255,.035);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  padding: 6px 9px;
  cursor: pointer;
}
.tool-btn.selected { color: #06110e; background: var(--cyan); border-color: var(--cyan); }
.tool-btn.danger-soft { color: #fecdd3; }
.tool-separator { width: 1px; height: 25px; background: var(--line); margin: 0 2px; }
.guess-bar { display: flex; gap: 8px; padding-top: 9px; }
.guess-bar input {
  flex: 1;
  border: 1px solid var(--line);
  background: rgba(1,8,15,.5);
  color: var(--text);
  border-radius: 12px;
  min-height: 43px;
  padding: 10px 13px;
}
.guess-bar input:disabled { opacity: .45; }

.room-sidebar { display: flex; flex-direction: column; gap: 12px; min-height: calc(100vh - 122px); }
.side-card { border-radius: 17px; padding: 14px; }
.side-card.grow { display: flex; flex-direction: column; flex: 1; min-height: 220px; }
.side-title { display: flex; align-items: center; justify-content: space-between; color: #dbe5ef; font-weight: 800; font-size: 12px; margin-bottom: 11px; }
.side-title > span:last-child { color: var(--muted); font: 600 10px JetBrains Mono, monospace; }
.teacher-badge { color: var(--cyan) !important; border: 1px solid rgba(53,228,195,.25); background: var(--cyan-soft); border-radius: 999px; padding: 4px 7px; }
.control-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-bottom: 12px; }
.control-grid .btn { font-size: 11px; padding: 8px 9px; }
.player-list { display: grid; gap: 6px; max-height: 250px; overflow: auto; padding-right: 2px; }
.player-row {
  display: grid;
  grid-template-columns: 31px minmax(0,1fr) auto;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(148,163,184,.09);
  background: rgba(255,255,255,.025);
  border-radius: 11px;
  padding: 8px;
}
.player-row.offline { opacity: .53; }
.player-avatar { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; background: rgba(96,165,250,.10); color: #9ec5ff; font-weight: 800; font-size: 11px; }
.player-main { min-width: 0; }
.player-main strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.player-main small { display: block; color: var(--muted); margin-top: 3px; font-size: 9px; }
.player-actions { display: flex; gap: 4px; }
.player-action {
  width: 27px;
  height: 27px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.03);
  cursor: pointer;
  font-size: 11px;
}
.player-action:hover { border-color: var(--line-strong); background: rgba(255,255,255,.07); }
.player-action.kick { color: #fecdd3; }
.icon-text { border: 0; background: transparent; color: var(--muted); font-size: 9px; cursor: pointer; }
.chat-list { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 7px; min-height: 120px; max-height: 360px; padding-right: 2px; }
.chat-message { border-radius: 10px; padding: 8px 9px; background: rgba(255,255,255,.03); border: 1px solid rgba(148,163,184,.07); font-size: 10px; line-height: 1.45; }
.chat-message b { color: #cbd5e1; margin-right: 4px; }
.chat-message.correct { color: #b8f7e9; background: rgba(53,228,195,.08); border-color: rgba(53,228,195,.14); }
.chat-message.system { color: var(--muted); font-style: italic; }

.guest-mode .host-only { display: none !important; }
.host-mode #guess-form { opacity: .48; pointer-events: none; }

.toast-stack { position: fixed; z-index: 50; right: 20px; bottom: 20px; display: grid; gap: 9px; max-width: min(380px, calc(100vw - 40px)); }
.toast { border: 1px solid var(--line); background: rgba(9, 23, 37, .94); backdrop-filter: blur(16px); box-shadow: 0 20px 50px rgba(0,0,0,.35); border-radius: 13px; padding: 12px 14px; color: #dbe5ef; font-size: 12px; animation: toast-in .2s ease both; }
.toast.error { border-color: rgba(251,113,133,.35); }
.toast.success { border-color: rgba(53,228,195,.35); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

.modal-backdrop { position: fixed; z-index: 60; inset: 0; background: rgba(1, 7, 13, .78); backdrop-filter: blur(11px); display: grid; place-items: center; padding: 20px; }
.modal-backdrop[hidden] { display: none; }
.finish-card { width: min(100%, 480px); border-radius: 24px; padding: 30px; text-align: center; }
.finish-icon { font-size: 52px; }
.finish-card h2 { font-size: 32px; margin: 10px 0 4px; letter-spacing: -.04em; }
.finish-card p { color: var(--muted); margin: 0 0 18px; }
.final-ranking { display: grid; gap: 7px; text-align: left; margin-bottom: 22px; }
.rank-row { display: grid; grid-template-columns: 30px 1fr auto; gap: 9px; align-items: center; border: 1px solid var(--line); background: rgba(255,255,255,.025); border-radius: 12px; padding: 10px 12px; }
.rank-row b:first-child { color: var(--cyan); }
.rank-row strong { font: 700 12px JetBrains Mono, monospace; }

@media (max-width: 1100px) {
  .hero-shell { grid-template-columns: 1fr; gap: 35px; padding-top: 56px; }
  .hero-copy { max-width: 780px; }
  .hero-card { transform: none; }
  .room-layout { grid-template-columns: 1fr; }
  .room-sidebar { min-height: unset; display: grid; grid-template-columns: repeat(2, 1fr); }
  .room-sidebar .grow { grid-column: 1 / -1; }
  .game-stage { min-height: 720px; }
}

@media (max-width: 760px) {
  .site-header { padding: 0 17px; height: 64px; }
  .header-chip { display: none; }
  .hero-shell { padding: 44px 19px 26px; min-height: unset; }
  .hero-copy h1 { font-size: clamp(42px, 13vw, 62px); }
  .hero-copy p { font-size: 16px; }
  .hero-actions { display: grid; }
  .hero-actions .btn { width: 100%; }
  .mini-game { grid-template-columns: 1fr; }
  .mini-sidebar { display: none; }
  .mini-canvas { min-height: 270px; }
  .feature-strip { grid-template-columns: 1fr; padding: 0 19px; }
  .panel-shell { padding: 35px 17px 60px; }
  .settings-grid { grid-template-columns: 1fr; padding: 18px; }
  .wide { grid-column: auto; }
  .section-heading h2 { font-size: 34px; }
  .join-shell { justify-content: flex-start; padding-top: 50px; }
  .room-view { padding: 8px 9px 18px; }
  .room-topbar { grid-template-columns: 1fr auto; }
  .room-status-wrap { display: none; }
  .timers > div { min-width: 72px; }
  .room-layout { gap: 9px; }
  .game-stage { min-height: 650px; padding: 9px; }
  .canvas-wrap { min-height: 410px; }
  .room-sidebar { grid-template-columns: 1fr; }
  .room-sidebar .grow { grid-column: auto; }
  .draw-toolbar { gap: 6px; }
  .tool-separator { display: none; }
  .guess-bar .btn { padding-inline: 12px; }
}
