:root,
html[data-theme="dark"] {
  --bg: #07131f;
  --bg-deep: #0b1c2c;
  --bg-glow: radial-gradient(1200px 600px at 10% -10%, rgba(13, 148, 136, 0.28), transparent 55%),
    radial-gradient(900px 500px at 90% 0%, rgba(201, 162, 39, 0.14), transparent 50%),
    linear-gradient(165deg, #07131f 0%, #0d2137 48%, #071018 100%);
  --panel: rgba(14, 32, 48, 0.82);
  --panel-soft: rgba(18, 40, 58, 0.72);
  --input-bg: rgba(6, 16, 28, 0.65);
  --ink: #f3f7fb;
  --muted: #9db0c3;
  --accent: #7c6bff;
  --accent-ink: #1a1338;
  --accent-2: #ff8a5b;
  --danger: #ff6b7a;
  --ok: #3ddc97;
  --line: rgba(255, 255, 255, 0.12);
  --panel-solid: #12283a;
  --shadow-md: 0 12px 30px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.4);
  --font-display: "Syne", "Segoe UI", sans-serif;
  --font: "Manrope", "Segoe UI", sans-serif;
  /* Цифры: у Syne они широкие и «размазанные» — счётчики набираем Manrope. */
  --font-nums: "Manrope", "Segoe UI", sans-serif;

  --ui-scale: 1;
  /* Текст масштабируем мягче раскладки: на узком экране интерфейс сжимается,
     а шрифт остаётся читаемым (не меньше 13–14 px). */
  --fs: 1;
  --space: calc(16px * var(--ui-scale));
  --space-sm: calc(10px * var(--ui-scale));
  --radius: calc(14px * var(--ui-scale));
  --text: calc(16px * var(--fs));
  --text-sm: calc(13px * var(--fs));
  --text-md: calc(15px * var(--fs));
  --text-lg: calc(22px * var(--fs));
  --hud-w: calc(280px * var(--ui-scale));
  --tile-gap: calc(14px * var(--ui-scale));
  --header-h: calc(56px * var(--ui-scale));
  --control-h: calc(42px * var(--ui-scale));
  --brand-title: calc(22px * var(--ui-scale));
  --brand-ico: calc(44px * var(--ui-scale));
  --theme-label: calc(11px * var(--ui-scale));
  --avatar-size: calc(88px * var(--ui-scale));
  --ship-max: calc(420px * var(--ui-scale));
  --drawer-w: min(92vw, calc(680px * var(--ui-scale)));
  --wheel-preview: calc(260px * var(--ui-scale));
}

html[data-theme="light"] {
  --bg: #eef4f7;
  --bg-deep: #dde8ef;
  --bg-glow: radial-gradient(1000px 520px at 8% -8%, rgba(20, 184, 166, 0.18), transparent 55%),
    radial-gradient(800px 420px at 100% 0%, rgba(201, 162, 39, 0.12), transparent 45%),
    linear-gradient(165deg, #f7fbfc 0%, #e7f0f5 55%, #d9e6ef 100%);
  --panel: rgba(255, 255, 255, 0.78);
  --panel-soft: rgba(255, 255, 255, 0.9);
  --input-bg: #ffffff;
  --ink: #102033;
  --muted: #5b6f82;
  --accent: #4c3fd4;
  --accent-ink: #f4f1ff;
  --accent-2: #e25b32;
  --danger: #dc2626;
  --ok: #059669;
  --line: rgba(16, 32, 51, 0.12);
  --panel-solid: #ffffff;
  --shadow-md: 0 12px 28px rgba(16, 40, 60, 0.1);
  --shadow-lg: 0 24px 50px rgba(16, 40, 60, 0.14);
}

* { box-sizing: border-box; }

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Одна прокрутка на весь сайт: окно, а не блоки внутри блоков. */
html, body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  background: var(--bg-glow);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--text);
  line-height: 1.4;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
}

/* Игра и доска — на весь экран без прокрутки страницы. */
body.in-play,
body.board-open {
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  width: 100%;
  flex: 1 0 auto;
  max-width: none;
  margin: 0;
  padding: var(--space);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.top {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: calc(8px * var(--ui-scale));
  min-height: calc(48px * var(--ui-scale));
  height: auto;
  flex-wrap: nowrap;
  padding: calc(8px * var(--ui-scale)) calc(12px * var(--ui-scale));
  border-radius: calc(14px * var(--ui-scale));
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  border: 1px solid var(--line);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.top-left {
  display: flex;
  align-items: center;
  gap: calc(8px * var(--ui-scale));
  flex-wrap: nowrap;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: calc(8px * var(--ui-scale));
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
  color: var(--muted);
}

.theme-switch-label {
  font-size: var(--theme-label);
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 1.3;
}

.theme-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.theme-switch-track {
  width: calc(44px * var(--ui-scale));
  height: calc(24px * var(--ui-scale));
  border-radius: 999px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  position: relative;
  display: inline-block;
  transition: background .2s ease;
}

.theme-switch-thumb {
  position: absolute;
  top: calc(2px * var(--ui-scale));
  left: calc(2px * var(--ui-scale));
  width: calc(18px * var(--ui-scale));
  height: calc(18px * var(--ui-scale));
  border-radius: 50%;
  background: var(--accent-2);
  transition: transform .2s ease;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}

.theme-switch input:checked + .theme-switch-track {
  background: color-mix(in srgb, var(--accent) 35%, var(--panel));
}

.theme-switch input:checked + .theme-switch-track .theme-switch-thumb {
  transform: translateX(calc(20px * var(--ui-scale)));
  background: var(--accent);
}

.brand-btn {
  display: inline-flex;
  align-items: center;
  gap: calc(8px * var(--ui-scale));
  margin: 0;
  padding: calc(4px * var(--ui-scale)) calc(8px * var(--ui-scale)) calc(6px * var(--ui-scale));
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  cursor: pointer;
  border-radius: calc(10px * var(--ui-scale));
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  overflow: visible;
  height: auto;
}

.brand-title {
  font-family: "Manrope", "Segoe UI", sans-serif !important;
  font-weight: 700 !important;
  font-size: var(--brand-title) !important;
  line-height: 1.25 !important;
  letter-spacing: 0 !important;
  font-stretch: 100% !important;
  font-synthesis: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-block;
  max-width: min(56vw, 460px);
  padding-bottom: 0;
  transform: none !important;
  scale: none !important;
  text-rendering: geometricPrecision;
}

.brand-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--line);
}

.brand-btn .brand-ico {
  display: block;
  width: var(--brand-ico);
  height: var(--brand-ico);
  object-fit: contain;
  flex-shrink: 0;
}

.btn-danger {
  background: linear-gradient(180deg, #ff7b88, #e44555) !important;
  color: #fff !important;
  border: none !important;
  font-weight: 700;
}

.btn-danger.small {
  padding: calc(6px * var(--ui-scale)) calc(10px * var(--ui-scale));
  font-size: var(--text-sm);
}

.observer-placeholder {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--muted);
  padding: var(--space);
  text-align: center;
}

.bank-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space);
  margin-bottom: var(--space-sm);
}

.bank-header-row .ghost {
  margin-top: 0;
  flex: 0 0 auto;
}

.bank-header-row h2 { margin: 0 0 4px; }
.exam-add {
  display: grid;
  gap: 8px;
  max-width: 36rem;
  margin-top: 8px;
}
.exam-add textarea,
.exam-add input { width: 100%; }
.bank-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: var(--space);
  padding: 12px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.bank-toolbar label {
  margin: 0;
  min-width: calc(140px * var(--ui-scale));
  display: flex;
  flex-direction: column;
  gap: calc(4px * var(--ui-scale));
  font-size: var(--text-sm);
  font-weight: 700;
}

.bank-search-btn {
  align-self: flex-end;
  margin-top: 0;
  margin-bottom: 0;
  min-height: var(--control-h);
  font-size: var(--text-sm);
}

.bank-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(calc(300px * var(--ui-scale)), 0.75fr);
  gap: var(--space);
  min-height: 0;
  flex: 1;
  align-items: start;
}

.bank-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: none;
  overflow: visible;
  padding-right: 0;
}

.bank-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  margin: 0;
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 6px 0 rgba(16, 32, 51, 0.04);
  color: var(--ink);
  font-size: var(--text);
  cursor: pointer;
}

html[data-theme="light"] .bank-item {
  background: #ffffff;
  border-color: rgba(16, 32, 51, 0.1);
}

html[data-theme="dark"] .bank-item {
  background: var(--panel-soft);
  box-shadow: none;
}

.bank-item input[type="checkbox"] {
  width: calc(28px * var(--ui-scale));
  height: calc(28px * var(--ui-scale));
  min-width: calc(28px * var(--ui-scale));
  min-height: calc(28px * var(--ui-scale));
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}
.bank-meta {
  color: var(--accent-2);
  white-space: nowrap;
  font-size: var(--text-md);
  font-weight: 700;
  padding-top: calc(2px * var(--ui-scale));
}

.bank-item .q-text {
  font-size: calc(17px * var(--fs));
  line-height: 1.4;
  font-weight: 500;
}

.q-play {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 8px;
  padding: 4px 10px 4px 6px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--ink);
  font: 700 12px/1 var(--font);
  letter-spacing: 0.04em;
  vertical-align: middle;
  cursor: pointer;
}
.q-play:hover { background: color-mix(in srgb, var(--accent) 30%, transparent); }
.q-play-ico {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  position: relative;
  flex: none;
}
.q-play-ico::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 5px;
  border-left: 8px solid #fff;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}
.q-play.playing .q-play-ico { animation: q-play-pulse 0.9s ease-in-out infinite; }
.q-play.playing .q-play-ico::before {
  left: 6px;
  top: 6px;
  width: 8px;
  height: 8px;
  border: 0;
  background: #fff;
  border-radius: 1px;
}
@keyframes q-play-pulse { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 30%, transparent); } }

#bank-stats {
  font-size: var(--text-md);
  margin: 0 0 calc(10px * var(--ui-scale));
}

#question-edit-modal .modal-card {
  font-size: calc(17px * var(--fs));
}

#question-edit-modal h2 {
  font-size: calc(23px * var(--fs));
}

#question-edit-modal label {
  font-size: var(--text);
}

#question-edit-modal textarea,
#question-edit-modal input,
#question-edit-modal select {
  font-size: calc(17px * var(--fs));
}

#edit-prompt {
  min-height: 6.5em;
  line-height: 1.45;
}

.bank-side h3 { margin: 0 0 8px; }
.bank-side {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 16px;
  overflow: visible;
  max-height: none;
  box-shadow: 0 8px 0 rgba(16, 32, 51, 0.04);
  position: sticky;
  top: calc(var(--space) * 2);
}

html[data-theme="light"] .bank-side {
  background: #ffffff;
  border-color: rgba(16, 32, 51, 0.1);
}

html[data-theme="dark"] .bank-side {
  background: var(--panel-soft);
  box-shadow: none;
}

.bank-side .players li {
  background: #f8fafc;
  border-color: rgba(16, 32, 51, 0.1);
  box-shadow: 0 1px 2px rgba(16, 40, 60, 0.04);
}

html[data-theme="dark"] .bank-side .players li {
  background: var(--panel);
  border-color: var(--line);
  box-shadow: none;
}

@media (max-width: 900px) {
  .bank-layout { grid-template-columns: 1fr; }
}

.check-row {
  display: flex !important;
  align-items: center;
  gap: 10px;
  color: var(--ink) !important;
  font-size: var(--text) !important;
}

.check-row input {
  width: auto !important;
  margin: 0 !important;
}

.join-toast {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 80;
  max-width: min(360px, calc(100vw - 24px));
}

.join-toast[hidden] { display: none !important; }

.join-toast-card {
  position: relative;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid color-mix(in srgb, var(--accent-2) 55%, var(--line));
  border-radius: 18px;
  padding: 18px 18px 16px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px);
  animation: toast-in 0.25s ease;
}

.join-toast-pulse {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, rgba(255, 180, 84, 0.35), transparent 55%);
  pointer-events: none;
  animation: pulse-glow 1.4s ease-in-out infinite;
}

.join-toast h3 {
  margin: 0 0 6px;
  position: relative;
}

.join-toast-label {
  position: relative;
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.join-toast-name {
  position: relative;
  margin: 2px 0 14px;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--ink);
}

.join-toast-actions {
  position: relative;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-allow {
  margin: 0 !important;
  flex: 1;
  min-width: 120px;
  background: linear-gradient(180deg, #5ef0d8, #2bb8aa) !important;
  color: #06241f !important;
  border: none !important;
  font-weight: 800;
  border-radius: 12px !important;
  padding: 12px 16px !important;
}

.btn-deny {
  margin: 0 !important;
  flex: 1;
  min-width: 110px;
  background: linear-gradient(180deg, #ff8a96, #e44555) !important;
  color: #fff !important;
  border: none !important;
  font-weight: 800;
  border-radius: 12px !important;
  padding: 12px 16px !important;
}

@keyframes toast-in {
  from { transform: translateY(-12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes pulse-glow {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

.bank-item {
  cursor: pointer;
}

.top-right {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: nowrap;
  flex-shrink: 0;
}

@media (max-width: 720px) {
  .top-right {
    flex-shrink: 1;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .top-right::-webkit-scrollbar { display: none; }

  .top-right > * { flex: 0 0 auto; }
}

.pill {
  font-size: var(--text-sm);
  padding: calc(4px * var(--ui-scale)) calc(10px * var(--ui-scale));
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line);
  color: var(--muted);
}

.pill.ok { color: var(--ok); }
.pill.bad { color: var(--danger); }

.admin-btn {
  margin: 0;
  padding: calc(8px * var(--ui-scale)) calc(14px * var(--ui-scale));
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
  font-size: var(--text-sm);
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
}

.admin-btn:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}

.admin-btn.on {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}

.screen {
  display: flex;
  flex-direction: column;
  flex: 1 0 auto;
  min-height: 0;
  min-width: 0;
  overflow: visible;
}

.screen[hidden] { display: none !important; }

.hub-screen {
  gap: var(--space-sm);
  align-items: stretch;
}

.hub-lead {
  margin: 0;
  flex: 0 0 auto;
  color: var(--muted);
  font-size: var(--text-sm);
}

.games-grid {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(calc(220px * var(--ui-scale)), calc(260px * var(--ui-scale))));
  gap: var(--tile-gap);
  align-content: start;
  justify-content: center;
  width: 100%;
  max-width: calc(1120px * var(--ui-scale));
  margin: 0 auto;
  min-height: 0;
  padding: calc(8px * var(--ui-scale)) calc(4px * var(--ui-scale)) var(--space);
}

.game-tile {
  position: relative;
  aspect-ratio: 16 / 10;
  width: 100%;
  max-width: calc(260px * var(--ui-scale));
  justify-self: center;
  border: 1px solid var(--line);
  border-radius: calc(18px * var(--ui-scale));
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  margin: 0;
  text-align: left;
  color: #fff;
  font: inherit;
  box-shadow: var(--shadow-md);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.game-tile:hover {
  transform: translateY(calc(-4px * var(--ui-scale)));
  box-shadow: var(--shadow-lg);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}

.game-tile:focus-visible {
  outline: calc(3px * var(--ui-scale)) solid var(--accent);
  outline-offset: 2px;
}

.game-tile .art {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
}

.game-tile .art-thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border: 0;
  transition: transform 0.35s ease;
}

.game-tile .art-glow {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(180deg, transparent 42%, rgba(0, 0, 0, 0.55) 100%),
    radial-gradient(ellipse at 70% 20%, rgba(255, 255, 255, 0.18), transparent 55%);
}

.game-tile:hover .art-thumb {
  transform: scale(1.05);
}

.game-tile .title {
  position: absolute;
  left: calc(12px * var(--ui-scale));
  bottom: calc(12px * var(--ui-scale));
  right: calc(12px * var(--ui-scale));
  z-index: 2;
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(13px, calc(16px * var(--fs)), 20px);
  font-weight: 800;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.55);
  line-height: 1.15;
}

.game-tile .badge-soon {
  position: absolute;
  top: calc(8px * var(--ui-scale));
  right: calc(8px * var(--ui-scale));
  font-size: calc(10px * var(--fs));
  font-weight: 700;
  padding: calc(3px * var(--ui-scale)) calc(7px * var(--ui-scale));
  border-radius: calc(6px * var(--ui-scale));
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
}

.game-tile.playable .badge-soon { display: none; }

.art-jump {
  background: linear-gradient(180deg, #6ec8ff 0%, #9ad8ff 55%, #7ec8a0 55%, #5aaa58 100%);
}
.art-jump::before,
.art-jump::after {
  content: "";
  position: absolute;
  width: 28%;
  height: 14%;
  background: #4caf50;
  border-radius: 4px;
  border-bottom: 4px solid #2e7d32;
}
.art-jump::before { left: 18%; top: 42%; }
.art-jump::after { right: 22%; top: 28%; width: 22%; }

.art-brawl { background: linear-gradient(180deg, #9ad0ff, #e8f4ff 40%, #fff 40%); }
.art-snow { background: linear-gradient(180deg, #0b1b3a, #1a335f 50%, #dfe9f7 50%); }
.art-farm { background: linear-gradient(180deg, #87ceeb 0%, #87ceeb 45%, #7cb342 45%, #558b2f 100%); }
.art-blast { background: radial-gradient(circle at 50% 40%, #fff 0 8%, transparent 9%), linear-gradient(135deg, #4fc3f7, #0288d1); }
.art-tag { background: #9e9e9e; }
.art-mine { background: linear-gradient(160deg, #5d4037, #3e2723 40%, #795548); }
.art-jungle { background: linear-gradient(180deg, #81c784, #2e7d32); }
.art-knock { background: linear-gradient(180deg, #7e57c2, #311b92 60%, #ef5350 60%); }
.art-fish { background: linear-gradient(180deg, #4fc3f7 0%, #0288d1 55%, #795548 55%); }
.art-flag { background: linear-gradient(90deg, #cfd8dc 50%, #eceff1 50%); }
.art-desert { background: linear-gradient(180deg, #ffe082, #ffb300 40%, #8d6e63 40%); }
.art-clash { background: linear-gradient(135deg, #66bb6a, #ec407a); }

.blob {
  position: absolute;
  width: calc(18px * var(--ui-scale));
  height: calc(18px * var(--ui-scale));
  border-radius: 50% 50% 45% 45%;
  background: #ef5350;
  box-shadow: inset -3px -3px 0 rgba(0, 0, 0, 0.15);
}
.blob::after {
  content: "";
  position: absolute;
  width: 18%;
  height: 18%;
  background: #222;
  border-radius: 50%;
  left: 28%;
  top: 32%;
  box-shadow: 140% 0 #222;
}

h1, h2, h3 { margin: 0 0 calc(8px * var(--ui-scale)); }
h2 { font-size: var(--text-lg); }
h3 { font-size: calc(1.05 * var(--text)); }
.muted { color: var(--muted); }
.small { font-size: var(--text-sm); }
.hint { color: var(--muted); font-size: var(--text-sm); }
.error { color: var(--danger); margin-top: var(--space-sm); }
code {
  background: rgba(0, 0, 0, 0.25);
  padding: 2px 6px;
  border-radius: 4px;
}

label {
  display: block;
  margin: var(--space-sm) 0;
  font-size: var(--text-sm);
  color: var(--muted);
}

input, select, button, textarea {
  font: inherit;
}

input, select, textarea {
  display: block;
  width: 100%;
  max-width: 100%;
  margin-top: calc(6px * var(--ui-scale));
  padding: calc(12px * var(--ui-scale)) calc(14px * var(--ui-scale));
  border-radius: calc(10px * var(--ui-scale));
  border: 1px solid var(--line);
  background: var(--input-bg);
  color: var(--ink);
  font-size: var(--text);
}

select option {
  background: #ffffff;
  color: #102033;
}

textarea {
  font-family: Consolas, "Courier New", monospace;
  font-size: var(--text-sm);
  resize: vertical;
  min-height: calc(160px * var(--ui-scale));
}

input.code {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: calc(20px * var(--fs));
  font-weight: 700;
}

button {
  margin-top: var(--space-sm);
  padding: calc(12px * var(--ui-scale)) calc(18px * var(--ui-scale));
  border-radius: calc(10px * var(--ui-scale));
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.12);
  color: var(--ink);
  cursor: pointer;
  font-size: var(--text);
}

button.primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 92%, white), var(--accent));
  color: var(--accent-ink);
  border: none;
  font-weight: 700;
  border-radius: 12px;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 28%, transparent);
}

button.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 12px;
}
button.small {
  padding: calc(8px * var(--ui-scale)) calc(12px * var(--ui-scale));
  font-size: var(--text-sm);
}
button:disabled { opacity: 0.5; cursor: not-allowed; }

.panel {
  margin: var(--space) 0;
  padding: calc(14px * var(--ui-scale));
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-md);
}

.groups-panel.panel {
  margin: 0;
}

.code-big {
  display: inline-block;
  padding: 2px calc(10px * var(--ui-scale));
  border-radius: calc(8px * var(--ui-scale));
  background: rgba(0, 0, 0, 0.35);
  letter-spacing: 0.18em;
  color: var(--accent-2);
}

.players {
  list-style: none;
  padding: 0;
  margin: var(--space) 0;
}

.players li {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: calc(10px * var(--ui-scale)) calc(12px * var(--ui-scale));
  border-radius: calc(10px * var(--ui-scale));
  background: rgba(0, 0, 0, 0.25);
  margin-bottom: calc(8px * var(--ui-scale));
  border: 1px solid var(--line);
}

.dot {
  width: calc(12px * var(--ui-scale));
  height: calc(12px * var(--ui-scale));
  border-radius: 50%;
  flex: 0 0 auto;
}

.badge {
  margin-left: auto;
  font-size: calc(11px * var(--fs));
  color: var(--accent-2);
}

/* Игровой экран на всё доступное место */
.game-screen {
  display: grid !important;
  grid-template-columns: minmax(calc(180px * var(--ui-scale)), var(--hud-w)) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: var(--space-sm);
  padding: 0;
  overflow: hidden;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
}

.game-screen[hidden] {
  display: none !important;
}

.lobby-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-sm);
  margin-top: var(--space);
}

.btn-start-lg {
  font-size: calc(20px * var(--fs));
  padding: calc(16px * var(--ui-scale)) calc(22px * var(--ui-scale));
  width: 100%;
  max-width: calc(420px * var(--ui-scale));
}

.btn-leave-sm {
  font-size: calc(12px * var(--fs));
  padding: calc(6px * var(--ui-scale)) calc(12px * var(--ui-scale));
  width: auto;
  align-self: flex-start;
  opacity: 0.85;
}

.shared-timer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-sm);
  padding: calc(10px * var(--ui-scale)) calc(12px * var(--ui-scale));
  border-radius: calc(10px * var(--ui-scale));
  background: rgba(61, 214, 198, 0.18);
  border: 1px solid rgba(61, 214, 198, 0.45);
  font-size: var(--text-sm);
}

.shared-timer strong {
  font-size: calc(22px * var(--fs));
  color: var(--accent);
}

.spectate-caption {
  position: absolute;
  left: 8px;
  bottom: 8px;
  z-index: 3;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: var(--text-sm);
}

#spectate-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #0b1f3a;
  image-rendering: auto;
}

.observer-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  padding: var(--space);
  color: var(--muted);
}

.hud {
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: calc(14px * var(--ui-scale));
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.controls-hint {
  margin: 0 0 var(--space-sm);
  padding: calc(8px * var(--ui-scale)) calc(10px * var(--ui-scale));
  border-radius: calc(8px * var(--ui-scale));
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.35;
}

.hud-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: calc(8px * var(--ui-scale));
  color: var(--muted);
  font-size: var(--text-sm);
}

.hud-row strong {
  color: var(--ink);
  font-size: calc(18px * var(--fs));
}

.board {
  margin: 0;
  padding-left: calc(18px * var(--ui-scale));
  color: var(--muted);
  font-size: var(--text-sm);
}

.board .you { color: var(--accent); font-weight: 700; }

.host-panel {
  margin-top: var(--space);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--line);
}

.host-panel input { margin-bottom: calc(6px * var(--ui-scale)); }

#game-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: #0b1f3a;
  min-width: 0;
  min-height: 0;
  height: 100%;
  width: 100%;
}

#phaser-root {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: transparent;
}

#phaser-root canvas {
  display: block;
  margin: 0 auto;
}

.touch {
  display: none;
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  z-index: 2;
}

#touch-left { left: 0; }
#touch-right { right: 0; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 10, 30, 0.72);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: var(--space);
  overflow: auto;
}

.modal[hidden] { display: none !important; }

.modal-card {
  position: relative;
  width: min(calc(440px * var(--ui-scale)), 100%);
  max-height: min(90dvh, 100%);
  overflow: auto;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: calc(18px * var(--ui-scale));
  padding: calc(22px * var(--ui-scale));
  box-shadow: var(--shadow-lg);
}

.modal-card h2 {
  font-family: var(--font-display);
  margin-top: 0;
}

#admin-ended-modal .modal-card {
  text-align: center;
}

#admin-ended-modal .modal-card .primary {
  display: inline-block;
  margin-top: var(--space-sm);
}

.order-fieldset {
  margin: var(--space-sm) 0 0;
  border: 1px solid var(--line);
  border-radius: calc(8px * var(--ui-scale));
  padding: calc(10px * var(--ui-scale));
}

.order-fieldset legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: var(--text-sm);
}

.order-list {
  list-style: none;
  margin: var(--space-sm) 0;
  padding: 0;
  max-height: min(55dvh, 420px);
  overflow: auto;
  display: grid;
  gap: 8px;
}

.order-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
  cursor: grab;
  user-select: none;
}

.order-list li.dragging {
  opacity: 0.55;
  border-color: var(--accent);
}

.order-list .ord-handle {
  color: var(--muted);
  font-weight: 700;
  min-width: 1.5em;
}

.order-list .ord-text {
  flex: 1;
  font-size: var(--text-sm);
  line-height: 1.35;
}

.modal-card.wide {
  width: min(calc(560px * var(--ui-scale)), 100%);
}

.modal-close {
  position: absolute;
  top: calc(8px * var(--ui-scale));
  right: calc(10px * var(--ui-scale));
  margin: 0;
  border: none;
  background: transparent;
  font-size: calc(24px * var(--fs));
  line-height: 1;
  color: var(--muted);
  padding: 4px 8px;
}

.quiz-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: var(--text-sm);
  color: var(--accent);
}

.choices {
  display: grid;
  gap: var(--space-sm);
  margin-top: var(--space);
}

.choices button {
  margin: 0;
  text-align: left;
  background: rgba(0, 0, 0, 0.28);
}

.feedback { margin-top: calc(14px * var(--ui-scale)); font-weight: 700; }
.feedback.ok { color: var(--ok); }
.feedback.bad { color: var(--danger); }

/* Узкие окна: игра сверху на максимум, hud компактно снизу */
@media (max-width: 820px) {
  .game-screen {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
    overflow: hidden;
  }
  .hud {
    order: 2;
    max-height: 28dvh;
  }
  #game-wrap {
    order: 1;
    min-height: 0;
    height: 100%;
  }
  .touch { display: block; }
}

@media (max-width: 520px) {
  .games-grid {
    grid-template-columns: minmax(0, 280px);
    justify-content: center;
  }
  .game-tile {
    max-width: none;
  }
}

/* —— Lobby invite —— */
.lobby-invite {
  margin-top: var(--space-sm);
  padding: calc(12px * var(--ui-scale));
  display: grid;
  gap: 8px;
}
.lobby-invite-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.lobby-invite-row input {
  flex: 1;
  min-width: 0;
  font-size: var(--text-sm);
}
.lobby-invite-row button {
  flex: 0 0 auto;
  margin: 0;
  white-space: nowrap;
}

/* —— Additive mobile hub / game shell (desktop rules unchanged above) —— */
@media (max-width: 820px) {
  :root {
    --ui-scale: 0.92;
  }
  body {
    padding-left: max(8px, env(safe-area-inset-left));
    padding-right: max(8px, env(safe-area-inset-right));
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
  .topbar {
    gap: 8px;
    flex-wrap: wrap;
  }
  .hub-lead {
    font-size: 0.9rem;
  }
  .games-grid {
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    gap: 10px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  .game-tile {
    max-width: none;
    border-radius: 14px;
  }
  .game-tile:hover {
    transform: none;
  }
  .lobby-invite-row {
    flex-direction: column;
  }
  .lobby-invite-row button {
    width: 100%;
  }
  #phaser-root,
  #oss-game-frame {
    touch-action: manipulation;
    -webkit-overflow-scrolling: touch;
  }
  .game-screen {
    padding-bottom: env(safe-area-inset-bottom);
  }
  .modal-card {
    width: min(96vw, 520px);
    max-height: min(90dvh, 720px);
    overflow: auto;
  }
  .join-toast {
    top: max(10px, env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
    left: max(10px, env(safe-area-inset-left));
    max-width: none;
  }
}

@media (max-width: 480px) {
  .games-grid {
    grid-template-columns: 1fr 1fr;
  }
  .hud {
    font-size: 0.85rem;
  }
}

/* ��� ����� � ������ �������� ��� */
.mail-badge {
  display: inline-block;
  min-width: 1.15em;
  margin-left: 0.35em;
  padding: 0 0.3em;
  border-radius: 999px;
  background: #e0453b;
  color: #fff;
  font-size: 0.72em;
  line-height: 1.5;
  text-align: center;
  vertical-align: middle;
}

.mail-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 12px 0;
}

.mail-letter {
  padding: 12px 14px;
  border: 1px solid rgba(127, 127, 127, 0.28);
  border-radius: 12px;
}

.mail-letter.unread {
  border-color: #3d8bfd;
  box-shadow: inset 3px 0 0 #3d8bfd;
}

.mail-letter-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.mail-letter p {
  margin: 6px 0 10px;
}

.profile-plan-box {
  margin: 18px 0 10px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-soft);
}

/* ——— Профиль и почта: карточка по центру, без «сырого» текста ——— */
.profile-screen,
.lab-screen {
  justify-content: flex-start;
  padding-top: calc(10px * var(--ui-scale));
}

.profile-shell {
  width: min(calc(760px * var(--ui-scale)), 100%);
  margin: 0 auto calc(20px * var(--ui-scale));
  padding: calc(22px * var(--ui-scale)) calc(24px * var(--ui-scale));
  border-radius: calc(24px * var(--ui-scale));
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 10px 0 rgba(16, 32, 51, 0.05), 0 22px 40px rgba(16, 32, 51, 0.08);
  color: var(--ink);
}

.profile-head {
  display: flex;
  align-items: center;
  gap: calc(14px * var(--ui-scale));
  padding-bottom: calc(14px * var(--ui-scale));
  margin-bottom: calc(14px * var(--ui-scale));
  border-bottom: 1px solid var(--line);
}

.profile-head h2 {
  margin: 0 0 2px;
  font-size: calc(26px * var(--fs));
}

.profile-head p {
  margin: 0;
  font-size: var(--text-sm);
}

.profile-avatar {
  display: grid;
  place-items: center;
  width: calc(56px * var(--ui-scale));
  height: calc(56px * var(--ui-scale));
  flex: 0 0 auto;
  border-radius: 18px;
  font-size: calc(28px * var(--fs));
  background: linear-gradient(150deg, #e8f1ff, #d7f3ea);
  box-shadow: inset 0 -3px 0 rgba(16, 32, 51, 0.06);
}

.profile-facts {
  display: grid;
  gap: 2px;
  margin: 0 0 calc(6px * var(--ui-scale));
}

.profile-facts > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: calc(9px * var(--ui-scale)) 0;
  border-bottom: 1px dashed var(--line);
}

.profile-facts > div:last-child {
  border-bottom: 0;
}

.profile-facts dt {
  flex: 0 0 auto;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--muted);
}

.profile-facts dd {
  margin: 0;
  text-align: right;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.profile-seats-row {
  display: flex;
  align-items: center;
  gap: calc(14px * var(--ui-scale));
  margin: calc(10px * var(--ui-scale)) 0 calc(6px * var(--ui-scale));
}

.profile-seats-row input[type="range"] {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 0;
  height: calc(28px * var(--ui-scale));
  /* Дорожка — фон самого ползунка во всю ширину: ручка ходит от края до края,
     поэтому на максимуме её правый край совпадает с правым краем строки. */
  background: linear-gradient(
      color-mix(in srgb, var(--accent) 24%, var(--line)),
      color-mix(in srgb, var(--accent) 24%, var(--line))
    ) center / 100% 8px no-repeat;
  accent-color: var(--accent);
  -webkit-appearance: none;
  appearance: none;
}

.profile-seats-row input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: transparent;
}

.profile-seats-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -7px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(16, 24, 40, 0.25);
  cursor: pointer;
}

.profile-seats-row input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: transparent;
}

.profile-seats-row input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(16, 24, 40, 0.25);
  cursor: pointer;
}

.profile-seats-row input[type="number"] {
  flex: 0 0 auto;
  width: calc(88px * var(--ui-scale));
  margin: 0;
  text-align: center;
  font-size: calc(18px * var(--fs));
  font-weight: 700;
}

.profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: calc(8px * var(--ui-scale));
  margin-top: calc(4px * var(--ui-scale));
}

.profile-actions button {
  margin: 0;
}

/* ——— Продление: крупная кнопка + свёрнутые настройки мест ——— */
.profile-renew {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: calc(12px * var(--ui-scale));
}

.profile-renew-title {
  margin: 0 0 calc(4px * var(--ui-scale));
  font-weight: 800;
  font-size: calc(17px * var(--fs));
}

.profile-renew .profile-price-line {
  margin: 0;
}

.profile-renew #profile-pay {
  margin: 0;
  white-space: nowrap;
}

.profile-plan-toggle {
  display: flex;
  align-items: center;
  gap: calc(8px * var(--ui-scale));
  width: 100%;
  margin-top: calc(14px * var(--ui-scale));
  padding: calc(10px * var(--ui-scale)) calc(12px * var(--ui-scale));
  border: 1px dashed var(--line);
  border-radius: calc(12px * var(--ui-scale));
  background: transparent;
  color: var(--muted);
  font-size: calc(14px * var(--fs));
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.profile-plan-toggle:hover {
  color: var(--ink);
  border-color: var(--accent);
}

.profile-plan-toggle .chev {
  display: inline-block;
  transition: transform 0.18s ease;
}

.profile-plan-toggle.open .chev {
  transform: rotate(180deg);
}

.profile-plan-extra {
  padding-top: calc(12px * var(--ui-scale));
  animation: profile-extra-in 0.18s ease;
}

.profile-plan-extra .ghost {
  margin-top: calc(6px * var(--ui-scale));
}

/* Пояснение тарифа «онлайн-школа»: что даёт и что значит «одновременно». */
.profile-plan-note {
  margin-top: calc(10px * var(--ui-scale));
  padding: calc(12px * var(--ui-scale)) calc(14px * var(--ui-scale));
  border-radius: calc(14px * var(--ui-scale));
  background: color-mix(in srgb, var(--accent) 8%, var(--panel-solid));
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line));
}
.profile-plan-note p {
  margin: 0 0 calc(8px * var(--ui-scale));
  font-size: calc(14px * var(--fs));
  line-height: 1.45;
  color: var(--ink);
}
.profile-plan-note p:last-child { margin-bottom: 0; }
.profile-plan-note b { color: var(--ink); }

@keyframes profile-extra-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 620px) {
  .profile-shell {
    padding: calc(16px * var(--ui-scale));
  }
  .profile-facts > div {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }
  .profile-facts dd {
    text-align: left;
  }
}

.profile-plan-box h3 {
  margin: 0 0 4px;
  font-size: var(--text-md);
}

.profile-seats-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 10px 0 6px;
  font-weight: 700;
  font-size: var(--text-sm);
}

.profile-seats-label input {
  width: 100%;
  max-width: 140px;
}

.profile-price-line {
  margin: 0 0 8px;
  font-size: var(--text-md);
}

.profile-price-line b {
  font-size: calc(18px * var(--fs));
  color: var(--accent-2);
}

.profile-logout-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.profile-logout-row .ghost {
  margin-top: 0;
}

/* Удаление кабинета: спрятано в details, чтобы не пугать в обычном профиле. */
.profile-delete {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(127, 127, 127, 0.22);
}

.profile-delete > summary {
  cursor: pointer;
  font-size: calc(14px * var(--fs));
  color: var(--muted);
  list-style-position: inside;
}

.profile-delete > summary:hover { color: var(--danger); }

.profile-delete-form {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.profile-delete-form .muted { margin: 0; }

.profile-delete-confirm {
  display: flex !important;
  align-items: flex-start;
  gap: 8px;
  font-size: calc(13.5px * var(--fs));
}

.profile-delete-confirm input { margin-top: 3px; }

.profile-delete-form .ghost {
  margin-top: 0;
  justify-self: start;
}

.profile-delete-form .ghost:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Короткое уведомление поверх страницы: видно с любой прокрутки. */
.notice-float {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 90;
  max-width: min(520px, calc(100vw - 32px));
  margin: 0;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--panel-solid);
  color: var(--ink);
  border: 1px solid rgba(127, 127, 127, 0.32);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  font-size: calc(14px * var(--fs));
  line-height: 1.4;
  text-align: center;
}

.cabinet-kind {
  margin: 8px 0;
  padding: 8px 10px;
  border: 1px solid rgba(127, 127, 127, 0.28);
  border-radius: 10px;
}

.cabinet-kind legend {
  padding: 0 4px;
  font-size: 0.85em;
  opacity: 0.75;
}

/* ===== Cookie: аккуратная карточка в левом нижнем углу; на телефоне — снизу во всю ширину ===== */
.cookie-card {
  position: fixed; left: 16px; bottom: 16px; z-index: 9000;
  width: min(480px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto;
  padding: 18px 18px 16px; border-radius: 18px;
  background: var(--panel-solid, #12283a); color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  font-size: 14px; line-height: 1.5;
  display: grid; gap: 12px;
  animation: cookie-in 0.22s ease-out;
}
.cookie-card[hidden] { display: none; }
@keyframes cookie-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .cookie-card { animation: none; } }
.cookie-title { margin: 0 0 4px; font-size: 1.02rem; font-weight: 800; letter-spacing: -0.01em; }
.cookie-text { margin: 0; color: var(--muted); }
.cookie-text a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.cookie-prefs fieldset { margin: 0; padding: 0; border: 0; display: grid; gap: 8px; }
.cookie-sub { padding: 0; margin-bottom: 2px; font-weight: 700; font-size: 0.9rem; }
.cookie-cat {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); cursor: pointer;
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}
.cookie-cat.is-locked { cursor: default; }
.cookie-cat-text { display: grid; gap: 2px; }
.cookie-cat-text small { color: var(--muted); font-size: 0.82rem; line-height: 1.4; }
.cookie-badge { margin-left: 6px; padding: 1px 7px; border-radius: 999px; font-style: normal; font-weight: 600; font-size: 0.72rem; background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--ink); white-space: nowrap; }
.cookie-switch { position: relative; flex: 0 0 auto; width: 42px; height: 24px; margin-top: 2px; }
.cookie-switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.cookie-switch input:disabled { cursor: not-allowed; }
.cookie-switch i {
  position: absolute; inset: 0; border-radius: 999px; background: color-mix(in srgb, var(--muted) 45%, transparent);
  transition: background 0.15s;
}
.cookie-switch i::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 0.15s;
}
.cookie-switch input:checked + i { background: var(--accent); }
.cookie-switch input:checked + i::after { transform: translateX(18px); }
.cookie-switch input:disabled + i { opacity: 0.6; }
.cookie-switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.cookie-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; align-items: center; }
.cookie-btn {
  width: auto; margin: 0; min-height: 38px; padding: 8px 13px; border-radius: 12px;
  font: inherit; font-weight: 700; font-size: 0.88rem; cursor: pointer; white-space: nowrap;
}
.cookie-btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.cookie-btn-ghost:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.cookie-btn-main {
  border: 0; color: #fff;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 88%, white), var(--accent));
  box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 28%, transparent);
}
.cookie-btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }
.cookie-btn[hidden] { display: none; }
/* «Только необходимые» и «Принять все» — равнозначны по виду и размеру: без навязывания. */
.cookie-actions [data-cookie="necessary"] { order: 2; }
.cookie-actions [data-cookie="settings"] { order: 1; margin-right: auto; }
.cookie-actions [data-cookie="all"], .cookie-actions [data-cookie="save"] { order: 3; }
/* Открыто окно (вход в игру, регистрация) — карточка уходит под него. */
body:has(.modal:not([hidden])) .cookie-card { z-index: 10; }
.site-footer .cookie-settings-link { background: none; border: 0; padding: 0; margin: 0; width: auto; color: inherit; font: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; opacity: 0.85; }
@media (max-width: 560px) {
  .cookie-card { left: 8px; right: 8px; bottom: 8px; width: auto; padding: 14px; border-radius: 16px; font-size: 13.5px; }
  .cookie-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .cookie-actions [data-cookie="settings"] { grid-column: 1 / -1; margin: 0; }
  .cookie-btn { white-space: normal; }
}

/* Счётчик онлайн-мест рядом с «Главная» */
.seats-online {
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  font-size: 13px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  white-space: nowrap;
}
.seats-online b { margin-left: 4px; }

/* Смена пароля в профиле */
.profile-password { margin: 18px 0 6px; }
.profile-password summary { cursor: pointer; font-weight: 600; }
.profile-password-form { display: grid; gap: 10px; max-width: 360px; margin-top: 10px; }
.profile-password-form label { display: grid; gap: 4px; font-size: 14px; }
.profile-password-form input { padding: 8px 10px; border-radius: 10px; border: 1px solid #c9d2e0; font: inherit; }
.profile-password-form button { justify-self: start; }

.profile-ref-refund-note { margin: 6px 0 0; color: var(--muted, #6b7280); }
.profile-ref-list tr.profile-ref-refunded td { color: var(--muted, #6b7280); text-decoration: line-through; text-decoration-thickness: 1px; }
.profile-ref-list tr.profile-ref-refunded td:last-child { text-decoration: none; }

/* «Общий каталог» — взять из общей базы в свою копию */
.modal-card.bank-global-card { width: min(920px, 94vw); max-width: 94vw; }
.bank-global-card input[type="checkbox"] { width: auto; margin: 0; }
.bg-tools, .bg-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 10px 0; }
.bg-tools input[type="search"], .bg-tools #bg-search { flex: 1 1 260px; }
.bg-actions .spacer { flex: 1; }
.bg-topics { display: flex; flex-wrap: wrap; gap: 6px; max-height: 96px; overflow: auto; }
.bg-topics .chip { border: 1px solid rgba(127,127,127,.35); background: transparent; border-radius: 999px; padding: 4px 10px; cursor: pointer; font-size: 13px; color: inherit; }
.bg-topics .chip.on { background: var(--accent, #6c5ce7); color: #fff; border-color: transparent; }
.bg-topics .chip small { opacity: .7; }
.bg-list { max-height: 46vh; overflow: auto; border: 1px solid rgba(127,127,127,.2); border-radius: 10px; margin-top: 8px; }
.bg-row { display: grid; grid-template-columns: auto 1fr auto auto; gap: 10px; align-items: center; padding: 8px 12px; border-bottom: 1px solid rgba(127,127,127,.12); cursor: pointer; }
.bg-row.have { opacity: .6; cursor: default; }
.bg-prompt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge-have { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: rgba(46, 204, 113, .18); color: #1e9c57; white-space: nowrap; }
.col-gap { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.bank-global-card .check-inline { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; font-size: 14px; white-space: nowrap; width: auto; margin: 0; }
.col-owner { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: rgba(108, 92, 231, .14); color: #5b4bd6; }
#collections-owner-filter-wrap { display: flex; gap: 6px; align-items: center; margin: 4px 0 8px; }

/* Онлайн-школа: «Как вас зовут?», «Кто в сети», преподаватели в профиле */
.seats-online[role="button"] { cursor: pointer; }
.school-online-pop { position: fixed; top: 72px; right: 24px; z-index: 1200; min-width: 280px; max-width: 360px; padding: 12px 14px; border-radius: 14px; background: var(--card, #fff); color: inherit; box-shadow: 0 12px 40px rgba(20, 20, 60, .22); }
.school-online-pop h4 { margin: 0 0 8px; }
.team-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.team-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 6px 8px; border-radius: 10px; }
.team-row.me { background: rgba(108, 92, 231, .08); }
.team-row small { order: 5; flex-basis: 100%; padding-left: 18px; }
.team-tools { margin-left: auto; display: inline-flex; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #b8bcc8; flex: none; }
.dot.on { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .2); }
.profile-team { margin: 18px 0; padding: 16px; border-radius: 14px; border: 1px solid rgba(127, 127, 127, .2); }
.profile-team-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.profile-team-head h3 { margin: 0 0 4px; }
.school-who-card { width: min(520px, 94vw); }
.school-who-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.school-who-pick { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; border: 1px solid rgba(127, 127, 127, .3); background: transparent; color: inherit; cursor: pointer; text-align: left; font-size: 15px; }
.school-who-pick:hover, .school-who-pick.on { border-color: var(--accent, #6c5ce7); background: rgba(108, 92, 231, .08); }
.school-who-new { display: flex; flex-direction: column; gap: 10px; padding-top: 10px; border-top: 1px dashed rgba(127, 127, 127, .3); }
