:root {
  --bg: #121218;
  --bg-elevated: #1a1a22;
  --surface: #1e1e28;
  --surface-2: #252532;
  --surface-glass: rgba(30, 30, 40, 0.72);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f8fafc;
  --text-dim: #94a3b8;
  --text-muted: #64748b;
  --primary: #7c3aed;
  --primary-strong: #6d28d9;
  --accent: #22d3ee;
  --accent-2: #f472b6;
  --success: #4ade80;
  --warning: #fb923c;
  --gradient-primary: linear-gradient(135deg, #f97316 0%, #ef4444 55%, #ec4899 100%);
  --gradient-accent: linear-gradient(135deg, #7c3aed 0%, #ec4899 100%);
  --gradient-cyan: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
  --gold: #fbbf24;
  --radius: 18px;
  --radius-sm: 14px;
  --radius-lg: 22px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 32px rgba(124, 58, 237, 0.38);
  --shadow-cyan: 0 0 28px rgba(34, 211, 238, 0.32);
  --lobby-header-btn-size: 44px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --screen-pad-x: 20px;
  --screen-pad-top: 16px;
  --header-bar-h: 40px;
  --header-title-gap: 12px;
  --header-action-size: 40px;
  --header-action-gap: 8px;
  --game-header-actions-w: calc(var(--header-action-size) * 4 + var(--header-action-gap) * 3);
  --cn-footer-top-h: 48px;
  --cn-footer-action-h: 48px;
  --cn-footer-gap: 8px;
  --cn-game-footer-h: calc(20px + var(--cn-footer-top-h) + var(--cn-footer-gap) + var(--cn-footer-action-h));
  --app-max-w: 480px;
  --app-shell-w: min(100vw, var(--app-max-w));
  --app-shell-left: calc((100vw - var(--app-shell-w)) / 2);
  --app-content-left: calc(var(--app-shell-left) + var(--screen-pad-x));
  --app-content-w: calc(var(--app-shell-w) - 2 * var(--screen-pad-x));
  --app-content-right-inset: calc((100vw - min(100vw, var(--app-max-w))) / 2 + var(--screen-pad-x));
  --page-grid-rows: 20;
  --page-grid-cols: 10;
  --page-grid-row-h: calc(100dvh / var(--page-grid-rows));
  --app-panel-h: calc(100dvh - var(--screen-pad-top) - var(--header-bar-h) - 8px - 16px - var(--safe-bottom));
}

#app:not(.has-session-header) {
  --app-panel-h: calc(100dvh - var(--screen-pad-top) - 16px - var(--safe-bottom));
}

@property --neon-hue-a {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}

@property --neon-hue-b {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}

@property --neon-hue-c {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body::before,
body::after,
#neon-bg-orb-c {
  position: fixed;
  inset: -28%;
  z-index: 0;
  pointer-events: none;
}

#setup-focus-overlay {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  backdrop-filter: grayscale(1) saturate(0.15);
  -webkit-backdrop-filter: grayscale(1) saturate(0.15);
  transition: opacity 3s ease;
  will-change: opacity;
}

body.setup-player-in-team #setup-focus-overlay {
  opacity: 1;
}

body::before,
body::after {
  content: '';
}

body::before {
  --neon-hue-a: 0deg;
  opacity: 0.92;
  background:
    radial-gradient(ellipse 44% 40% at 50% 50%, rgba(124, 58, 237, 0.54) 0%, transparent 68%),
    radial-gradient(ellipse 38% 34% at 50% 50%, rgba(6, 182, 212, 0.4) 0%, transparent 66%),
    radial-gradient(ellipse 34% 30% at 50% 50%, rgba(236, 72, 153, 0.34) 0%, transparent 64%);
  filter: blur(38px) hue-rotate(var(--neon-hue-a));
  animation:
    neon-orb-drift-a 26s ease-in-out infinite,
    neon-hue-shift-a 18s linear infinite;
}

body::after {
  --neon-hue-b: 0deg;
  opacity: 0.82;
  background:
    radial-gradient(ellipse 42% 38% at 50% 50%, rgba(244, 114, 182, 0.44) 0%, transparent 70%),
    radial-gradient(ellipse 36% 32% at 50% 50%, rgba(139, 92, 246, 0.36) 0%, transparent 68%),
    radial-gradient(ellipse 32% 28% at 50% 50%, rgba(34, 211, 238, 0.3) 0%, transparent 65%);
  filter: blur(42px) hue-rotate(var(--neon-hue-b));
  animation:
    neon-orb-drift-b 32s ease-in-out infinite,
    neon-hue-shift-b 22s linear infinite reverse;
}

#neon-bg-orb-c {
  --neon-hue-c: 0deg;
  opacity: 0.78;
  background:
    radial-gradient(ellipse 40% 36% at 50% 50%, rgba(74, 222, 128, 0.38) 0%, transparent 70%),
    radial-gradient(ellipse 36% 34% at 50% 50%, rgba(251, 191, 36, 0.32) 0%, transparent 68%),
    radial-gradient(ellipse 34% 30% at 50% 50%, rgba(59, 130, 246, 0.34) 0%, transparent 66%);
  filter: blur(40px) hue-rotate(var(--neon-hue-c));
  animation:
    neon-orb-drift-c 28s ease-in-out infinite,
    neon-hue-shift-c 20s linear infinite;
}

@keyframes neon-orb-drift-a {
  0% { transform: translate(-30%, -34%) scale(1); }
  20% { transform: translate(34%, -28%) scale(1.08); }
  40% { transform: translate(38%, 36%) scale(0.96); }
  60% { transform: translate(-10%, 40%) scale(1.06); }
  80% { transform: translate(-36%, 6%) scale(1.02); }
  100% { transform: translate(-30%, -34%) scale(1); }
}

@keyframes neon-orb-drift-b {
  0% { transform: translate(32%, 34%) scale(1.04); }
  25% { transform: translate(-34%, 24%) scale(0.94); }
  50% { transform: translate(-28%, -36%) scale(1.1); }
  75% { transform: translate(30%, -20%) scale(1); }
  100% { transform: translate(32%, 34%) scale(1.04); }
}

@keyframes neon-orb-drift-c {
  0% { transform: translate(-34%, 14%) scale(1); }
  20% { transform: translate(-6%, -36%) scale(1.1); }
  40% { transform: translate(28%, -8%) scale(0.96); }
  60% { transform: translate(16%, 38%) scale(1.08); }
  80% { transform: translate(-22%, 32%) scale(1.02); }
  100% { transform: translate(-34%, 14%) scale(1); }
}

@keyframes neon-hue-shift-a {
  to { --neon-hue-a: 360deg; }
}

@keyframes neon-hue-shift-b {
  to { --neon-hue-b: 360deg; }
}

@keyframes neon-hue-shift-c {
  to { --neon-hue-c: 360deg; }
}

@media (prefers-reduced-motion: reduce) {
  #setup-focus-overlay {
    transition: none;
  }

  #session-header[data-screen="screen-setup"],
  #screen-setup .setup-panel-body #setup-player-block,
  #screen-setup .setup-panel-body #setup-teams-block > .block-title,
  #screen-setup .team-card-multi:not(.is-mine) {
    transition: none;
  }

  body::before,
  body::after,
  #neon-bg-orb-c {
    animation: none;
    inset: 0;
    filter: none;
    opacity: 1;
  }

  body::before {
    background:
      radial-gradient(ellipse 90% 60% at 8% -8%, rgba(124, 58, 237, 0.48) 0%, transparent 58%),
      radial-gradient(ellipse 70% 50% at 96% 4%, rgba(236, 72, 153, 0.36) 0%, transparent 54%),
      radial-gradient(ellipse 80% 55% at 50% 102%, rgba(6, 182, 212, 0.32) 0%, transparent 58%),
      radial-gradient(ellipse 55% 40% at 82% 78%, rgba(139, 92, 246, 0.22) 0%, transparent 52%),
      radial-gradient(ellipse 45% 35% at 18% 72%, rgba(244, 114, 182, 0.16) 0%, transparent 50%),
      var(--bg);
  }

  body::after,
  #neon-bg-orb-c {
    display: none;
  }
}

/* Touch / low-end: static background, no GPU blur animations */
@media (hover: none) and (pointer: coarse) {
  body::before,
  body::after,
  #neon-bg-orb-c {
    animation: none;
    inset: 0;
    filter: none;
    opacity: 1;
  }

  body::before {
    background:
      radial-gradient(ellipse 90% 60% at 8% -8%, rgba(124, 58, 237, 0.48) 0%, transparent 58%),
      radial-gradient(ellipse 70% 50% at 96% 4%, rgba(236, 72, 153, 0.36) 0%, transparent 54%),
      radial-gradient(ellipse 80% 55% at 50% 102%, rgba(6, 182, 212, 0.32) 0%, transparent 58%),
      radial-gradient(ellipse 55% 40% at 82% 78%, rgba(139, 92, 246, 0.22) 0%, transparent 52%),
      radial-gradient(ellipse 45% 35% at 18% 72%, rgba(244, 114, 182, 0.16) 0%, transparent 50%),
      var(--bg);
  }

  body::after,
  #neon-bg-orb-c {
    display: none;
  }
}

html.perf-lite body::before,
html.perf-lite body::after,
html.perf-lite #neon-bg-orb-c {
  animation: none !important;
  inset: 0;
  filter: none !important;
  opacity: 1;
}

html.perf-lite body::before {
  background:
    radial-gradient(ellipse 90% 60% at 8% -8%, rgba(124, 58, 237, 0.48) 0%, transparent 58%),
    radial-gradient(ellipse 70% 50% at 96% 4%, rgba(236, 72, 153, 0.36) 0%, transparent 54%),
    radial-gradient(ellipse 80% 55% at 50% 102%, rgba(6, 182, 212, 0.32) 0%, transparent 58%),
    radial-gradient(ellipse 55% 40% at 82% 78%, rgba(139, 92, 246, 0.22) 0%, transparent 52%),
    radial-gradient(ellipse 45% 35% at 18% 72%, rgba(244, 114, 182, 0.16) 0%, transparent 50%),
    var(--bg);
}

html.perf-lite body::after,
html.perf-lite #neon-bg-orb-c {
  display: none;
}

html.perf-lite *,
html.perf-lite *::before,
html.perf-lite *::after {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  z-index: 1;
}

.screen {
  position: relative;
  padding: var(--screen-pad-top) var(--screen-pad-x) calc(120px + var(--safe-bottom));
}

.screen.hidden { display: none; }

.hidden {
  display: none !important;
}

.game-captain-slot.hidden {
  display: flex !important;
  visibility: hidden;
  pointer-events: none;
}

.game-captain-slot.hidden .game-captain-btn {
  visibility: hidden;
  pointer-events: none;
}

.screen-header { margin-bottom: 24px; }

#session-header {
  position: relative;
  z-index: 2;
  padding: var(--screen-pad-top) var(--screen-pad-x) 0;
  margin-bottom: 0;
}

#session-header.hidden {
  display: none;
}

#session-header-btn-pool {
  display: none !important;
}

#session-header .header-action-slot--extra:empty,
#session-header .header-action-slot--info:empty {
  visibility: hidden;
  pointer-events: none;
}

#session-header[data-screen="screen-lobby"] .screen-title-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

#session-header[data-screen="screen-lobby"] .screen-header-actions {
  grid-template-columns: repeat(2, var(--header-action-size));
  gap: var(--header-action-gap);
  width: calc(var(--header-action-size) * 2 + var(--header-action-gap));
}

#session-header[data-screen="screen-lobby"] .screen-header-actions:has(.header-action-slot--info:empty) {
  grid-template-columns: var(--header-action-size);
  width: var(--header-action-size);
}

#session-header[data-screen="screen-lobby"] .header-action-slot--extra,
#session-header[data-screen="screen-lobby"] .header-action-slot--captain {
  display: none !important;
}

#session-header[data-screen="screen-lobby"] .header-action-slot--info {
  grid-column: 1;
}

#session-header[data-screen="screen-lobby"] .header-action-slot--info:empty {
  display: none !important;
}

#session-header[data-screen="screen-lobby"] .header-action-slot--back {
  grid-column: 2;
}

#session-header[data-screen="screen-lobby"] .screen-header-actions:has(.header-action-slot--info:empty) .header-action-slot--back {
  grid-column: 1;
}

#app.has-session-header .screen {
  padding-top: 8px;
}

.setup-screen-error {
  margin: 0 0 16px;
}

.screen-cn-chrome {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
  flex-shrink: 0;
}

#session-header .screen-title-row,
#session-header.screen-header--title-row .screen-title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--game-header-actions-w);
  grid-template-rows: var(--header-bar-h);
  column-gap: var(--header-title-gap);
  align-items: center;
  height: var(--header-bar-h);
  min-height: var(--header-bar-h);
  max-height: var(--header-bar-h);
  padding-right: 0;
  box-sizing: border-box;
}

#session-header #session-header-title:empty,
#session-header #session-header-title.hidden {
  display: none !important;
  min-height: 0;
  margin: 0;
}

#session-header #session-header-title-block {
  grid-column: 1;
  grid-row: 1;
  position: relative;
  width: auto;
  max-width: 100%;
  height: var(--header-bar-h);
  min-height: var(--header-bar-h);
  max-height: var(--header-bar-h);
  min-width: 0;
  overflow: hidden;
  box-sizing: border-box;
}

#session-header .screen-header-actions {
  grid-column: 2;
  grid-row: 1;
  position: static;
  top: auto;
  right: auto;
  justify-self: end;
  align-self: center;
  width: var(--game-header-actions-w);
  height: var(--header-bar-h);
  min-height: var(--header-bar-h);
  max-height: var(--header-bar-h);
  margin: 0;
  z-index: 2;
}

#session-header[data-screen="screen-setup"] #session-header-title-block:has(#setup-room-code-wrap:not(.hidden)) {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
}

#session-header[data-screen="screen-setup"] #session-header-title-block:has(#setup-room-code-wrap:not(.hidden)) #session-header-title {
  display: none !important;
}

#session-header #session-header-title-block:has(#session-room-badge:not(.hidden)) {
  display: flex;
  align-items: center;
}

#session-header[data-screen="screen-games"] #session-header-title-block:has(#session-room-badge:not(.hidden)) #session-header-title {
  display: none !important;
}

#session-header .setup-room-code-wrap,
#session-header .session-room-badge {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  min-height: 0;
}

#session-header .header-room-code-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 5.75rem;
  min-width: 5.75rem;
  max-width: 5.75rem;
  height: var(--header-action-size);
  min-height: var(--header-action-size);
  padding: 0 8px;
  font-size: 17px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.16em;
  margin-right: -0.16em;
  border-radius: 12px;
  text-align: center;
  flex-shrink: 0;
  line-height: 1;
}

#session-header .screen-title-block .subtitle:not(.hidden) {
  display: block;
}

#session-header.screen-header--compact {
  margin-bottom: 8px;
}

#session-header.screen-header--compact #session-header-title {
  margin-bottom: 0;
}

#session-header .games-header-room {
  margin-bottom: 0;
}

#screen-setup.screen {
  padding-top: 8px;
  padding-bottom: calc(16px + var(--safe-bottom));
}

#screen-setup.has-many-teams {
  padding-bottom: calc(16px + var(--safe-bottom));
}

#screen-percent.screen,
#screen-result.screen {
  padding-top: 8px;
  padding-bottom: calc(16px + var(--safe-bottom));
}

#screen-percent:not(.hidden),
#screen-result:not(.hidden) {
  display: flex;
  flex-direction: column;
  height: var(--app-panel-h);
  max-height: var(--app-panel-h);
  min-height: 0;
  overflow: hidden;
  background-color: transparent;
}

.percent-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.percent-panel-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.percent-panel-body .percent-scoreboard {
  flex: 0 1 auto;
  margin: 0 0 12px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

#screen-percent.has-many-teams .percent-panel-body .percent-scoreboard,
#screen-result.has-many-teams .percent-panel-body .percent-scoreboard {
  max-height: 38%;
}

.percent-panel-body .question-card {
  flex-shrink: 0;
  margin-bottom: 12px;
}

.percent-panel-body .percent-answer-block {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 0;
}

.percent-panel-body .result-question-text {
  flex-shrink: 0;
}

.percent-panel-body .result-answer-card {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 0;
}

.percent-panel-body .percent-hint {
  flex-shrink: 0;
  margin: 8px 0 0;
}

.percent-panel-footer,
.cn-panel-footer,
.tw-panel-footer,
.tone-panel-footer {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.percent-panel-footer.hidden,
.cn-panel-footer.hidden,
.tw-panel-footer.hidden,
.tone-panel-footer.hidden {
  display: none;
}

.percent-panel-footer > *,
.cn-panel-footer > *,
.tw-panel-footer > *,
.tone-panel-footer > * {
  width: 100%;
  margin: 0;
}

#screen-codenames.cn-page.screen,
#screen-codenames-captain.cn-page.screen {
  padding-top: 8px;
  padding-bottom: calc(16px + var(--safe-bottom));
}

#screen-codenames.cn-page:not(.hidden),
#screen-codenames-captain.cn-page:not(.hidden) {
  display: flex;
  flex-direction: column;
  height: var(--app-panel-h);
  max-height: var(--app-panel-h);
  min-height: 0;
  overflow: hidden;
  background-color: transparent;
}

.cn-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.cn-panel-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.cn-panel-body .cn-chrome {
  flex-shrink: 0;
  margin-bottom: 10px;
}

.cn-page .cn-chrome .percent-scoreboard {
  margin: 0 0 8px;
}

.cn-page .percent-score-chip.is-active-turn,
.tw-page .percent-score-chip.is-active-turn,
.tone-page .percent-score-chip.is-active-turn,
.sp-page .percent-score-chip.is-active-turn {
  position: relative;
  z-index: 1;
  border: 2px solid color-mix(in srgb, var(--team-color, var(--primary)) 78%, white);
  background: color-mix(in srgb, var(--team-color, var(--primary)) 34%, var(--surface));
  box-shadow:
    inset 5px 0 0 var(--team-color, var(--primary)),
    0 0 0 1px color-mix(in srgb, var(--team-color, var(--primary)) 55%, transparent),
    0 0 32px color-mix(in srgb, var(--team-color, var(--primary)) 45%, transparent);
}

.cn-page .percent-score-chip.is-active-turn .percent-score-name,
.tw-page .percent-score-chip.is-active-turn .percent-score-name,
.tone-page .percent-score-chip.is-active-turn .percent-score-name,
.sp-page .percent-score-chip.is-active-turn .percent-score-name {
  font-weight: 800;
  color: color-mix(in srgb, var(--team-color, var(--primary)) 88%, white);
}

.cn-page .percent-score-chip.is-active-turn .percent-score-value,
.tw-page .percent-score-chip.is-active-turn .percent-score-value,
.tone-page .percent-score-chip.is-active-turn .percent-score-value,
.sp-page .percent-score-chip.is-active-turn .percent-score-value {
  font-size: 20px;
  text-shadow: 0 0 14px color-mix(in srgb, var(--team-color, var(--primary)) 55%, transparent);
}

.cn-page .percent-score-chip.is-active-turn .percent-score-status-badge,
.tw-page .percent-score-chip.is-active-turn .percent-score-status-badge,
.tone-page .percent-score-chip.is-active-turn .percent-score-status-badge,
.sp-page .percent-score-chip.is-active-turn .percent-score-status-badge {
  color: #fff;
  background: var(--team-color, var(--primary));
  border-color: color-mix(in srgb, var(--team-color, var(--primary)) 70%, white);
  box-shadow: 0 0 14px color-mix(in srgb, var(--team-color, var(--primary)) 65%, transparent);
}

.cn-page .percent-score-chip.is-winner {
  border-color: color-mix(in srgb, var(--gold) 58%, transparent);
  background: color-mix(in srgb, var(--gold) 18%, var(--surface-glass));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 0 24px color-mix(in srgb, var(--gold) 35%, transparent);
}

.cn-page .percent-score-chip.is-winner .percent-score-value {
  color: var(--gold);
}

.cn-panel-body .cn-board-card {
  flex: 1;
  min-height: 0;
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow: hidden;
}

.cn-panel-body .cn-grid,
.cn-panel-body .captain-grid {
  width: 100%;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  flex: 0 1 auto;
  align-self: stretch;
  margin-bottom: 0;
}

/* --- Меню игр: гибкая вёрстка (координаты — в «Сетке макета») --- */
#screen-games.screen {
  padding-top: 8px;
  padding-bottom: calc(16px + var(--safe-bottom));
}

#screen-games:not(.hidden) {
  display: flex;
  flex-direction: column;
  height: var(--app-panel-h);
  max-height: var(--app-panel-h);
  min-height: 0;
  overflow: hidden;
  background-color: transparent;
}

.games-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}


.games-panel-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.games-panel-body .block {
  margin-bottom: 16px;
  flex-shrink: 0;
}

.games-panel-body .games-teams-block {
  flex: 0 1 auto;
  max-height: 45%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-bottom: 12px;
  overflow: hidden;
}

.games-panel-body .games-teams-block > .block-title {
  flex-shrink: 0;
}

.games-panel-body .games-teams-block .teams-preview {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.games-panel-body .games-list-block {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
  overflow: hidden;
}

.games-panel-body .games-list-block > .block-title {
  flex-shrink: 0;
}

.games-panel-body .games-list-block .games-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.games-panel-footer.games-screen-badges {
  display: flex;
  align-items: stretch;
  gap: 10px;
  flex-shrink: 0;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  --games-footer-bar-h: 44px;
}

.games-screen-badges {
  display: flex;
  align-items: stretch;
  gap: 10px;
  --games-footer-bar-h: 44px;
}

.games-screen-badges.hidden {
  display: none;
}

.games-screen-badges .games-settings-btn {
  flex-shrink: 0;
  align-self: stretch;
  width: var(--games-footer-bar-h);
  height: auto;
  min-height: var(--games-footer-bar-h);
  border-radius: var(--radius-sm);
}

.games-screen-badges .games-settings-btn.hidden {
  display: none;
}

.games-screen-badges .games-exit-btn {
  flex: 1;
  min-width: 0;
  min-height: var(--games-footer-bar-h);
  margin: 0;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
}

.games-player-block {
  margin-bottom: 14px;
}

.games-player-block.hidden {
  display: none;
}

.games-player-name-row {
  display: flex;
  align-items: stretch;
  margin-bottom: 0;
}

.games-player-name-field {
  flex: 1;
  min-width: 0;
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--team-color, var(--accent)) 35%, var(--border-strong));
  background: color-mix(in srgb, var(--team-color, var(--accent)) 8%, var(--surface-glass));
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  line-height: 1.35;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 0 16px color-mix(in srgb, var(--team-color, var(--accent)) 22%, transparent);
  word-break: break-word;
  overflow-wrap: anywhere;
  user-select: none;
  cursor: default;
  pointer-events: none;
}

#screen-games .screen-header--compact {
  margin-bottom: 8px;
}

#screen-games-settings .screen-header--compact {
  margin-bottom: 12px;
}

#screen-games-settings .screen-header--compact h1 {
  margin-bottom: 0;
}

#screen-games-settings .screen-header--title-row {
  margin-bottom: 8px;
}

#games-settings-admin-btn.hidden {
  display: none;
}

#screen-games .screen-header--compact h1 {
  margin-bottom: 0;
}

#screen-games .screen-title-block {
  flex: 1 1 auto;
  min-width: 0;
  overflow: visible;
}

.games-settings-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: #d1d5db;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}

.games-settings-btn:hover,
.games-settings-btn:focus-visible {
  color: #f3f4f6;
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.22);
}

.games-settings-btn:active {
  transform: scale(0.94);
}

.games-settings-btn.hidden {
  display: none;
}

.games-settings-btn-icon {
  display: block;
  color: currentColor;
}

.games-settings-btn-icon path {
  stroke: currentColor;
}

#games-settings-count-section .segmented {
  margin-top: 0;
}

.games-settings-section {
  margin-bottom: 20px;
}

.games-settings-section:last-child {
  margin-bottom: 0;
}

.games-settings-section-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.games-settings-teams {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#screen-games-settings.screen {
  padding-top: 8px;
  padding-bottom: calc(16px + var(--safe-bottom));
}

#screen-games-settings:not(.hidden) {
  display: flex;
  flex-direction: column;
  height: var(--app-panel-h);
  max-height: var(--app-panel-h);
  min-height: 0;
  overflow: hidden;
}

.games-settings-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.games-settings-panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.games-settings-panel-footer {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.games-settings-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 0;
  padding-top: 0;
}

.games-settings-footer .secondary.full-width {
  width: 100%;
}

#screen-games-settings .games-settings-footer .primary,
#screen-games-settings .games-settings-footer .secondary.full-width {
  width: 100%;
  min-height: 48px;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 700;
  border-radius: 14px;
  cursor: pointer;
  font-family: inherit;
}

#screen-games-settings .games-settings-footer .primary {
  border: none;
}

#screen-games-settings .games-settings-footer .primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.games-settings-team {
  padding: 14px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  background: var(--surface-glass);
  box-shadow: inset 3px 0 0 var(--team-color, var(--primary));
}

.games-settings-team .team-row {
  margin-bottom: 10px;
}

.games-settings-team .palette {
  margin-bottom: 0;
}

.games-settings-team-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.games-settings-captain {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-top: 0;
}

.games-settings-score {
  display: flex;
  align-items: center;
  gap: 8px;
}

.games-settings-captain-label {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  min-width: 64px;
}

.games-settings-score-label {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
}

.games-settings-score-btn {
  appearance: none;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.games-settings-score-btn:active {
  transform: scale(0.96);
}

.games-settings-score-input {
  width: 72px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  -moz-appearance: textfield;
}

.games-settings-score-input::-webkit-outer-spin-button,
.games-settings-score-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

#games-settings-players-section .games-settings-players {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.games-settings-player {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.games-settings-player-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.games-settings-player-main .lobby-player-name,
.games-settings-player-main .lobby-player-name-input {
  flex: 1;
  min-width: 0;
}

.games-settings-player-main .lobby-player-badge {
  flex-shrink: 0;
}

.games-settings-player-teams {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.games-settings-team-pick {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  max-width: 100%;
}

.games-settings-team-pick::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--team-color, var(--primary));
  flex-shrink: 0;
}

.games-settings-team-pick[aria-checked="true"] {
  border-color: color-mix(in srgb, var(--team-color, var(--primary)) 55%, var(--border));
  background: color-mix(in srgb, var(--team-color, var(--primary)) 12%, var(--surface));
  color: var(--text);
}

.games-settings-player .player-kick-btn {
  align-self: flex-start;
}

#screen-setup.is-player-setup #setup-host-panel-btn {
  display: none !important;
}

#screen-setup.is-player-setup #setup-teams-block {
  margin-top: 0;
}

#screen-setup.is-player-setup #setup-teams-block .team-list {
  margin-top: 0;
}

#screen-setup .setup-panel-body .block:first-of-type {
  margin-top: 0;
}

/* --- Выбор команды: гибкая вёрстка (координаты — в «Сетке макета») --- */
#screen-setup:not(.hidden) {
  display: flex;
  flex-direction: column;
  height: var(--app-panel-h);
  max-height: var(--app-panel-h);
  min-height: 0;
  overflow: hidden;
}

.setup-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 10px;
}


.setup-panel-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 0;
  overflow: hidden;
}

.setup-panel-body .block {
  margin-bottom: 16px;
  flex-shrink: 0;
}

.setup-panel-body #setup-teams-block {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
  overflow: hidden;
}

.setup-panel-body #setup-teams-block > .block-title {
  flex-shrink: 0;
}

.setup-panel-body #setup-teams-block .team-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.setup-panel-footer {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.setup-panel-footer > * {
  width: 100%;
  margin: 0;
}

#screen-setup .setup-screen-error {
  flex-shrink: 0;
  width: 100%;
  margin: 0;
  padding: 6px 0 0;
  text-align: center;
  line-height: 1.35;
  font-size: 13px;
}

#screen-setup .setup-screen-error:empty {
  display: none;
  padding: 0;
}

.setup-host-modal-section:last-of-type {
  margin-bottom: 20px;
}

.screen-header h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
  background: linear-gradient(135deg, #fff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  margin: 0;
  color: var(--text-dim);
  font-size: 14px;
}

.back-btn {
  background: var(--surface-glass);
  border: 1px solid var(--border-strong);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 12px;
  font-size: 18px;
  cursor: pointer;
  margin-bottom: 12px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.screen-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--header-title-gap);
}

/* Единая шапка: фиксированная строка 40px + панель кнопок, прижата к правому краю контента */
.screen-header--title-row .screen-title-row {
  position: relative;
  display: block;
  width: 100%;
  height: var(--header-bar-h);
  min-height: var(--header-bar-h);
  max-height: var(--header-bar-h);
  padding-right: calc(var(--game-header-actions-w) + var(--header-title-gap));
  box-sizing: border-box;
  overflow: visible;
}

.screen-header--title-row .screen-title-block {
  position: relative;
  width: 100%;
  height: var(--header-bar-h);
  min-height: var(--header-bar-h);
  max-height: var(--header-bar-h);
  min-width: 0;
  overflow: visible;
  box-sizing: border-box;
}

.screen-header--title-row .screen-title-actions,
.screen-header--title-row .screen-header-actions {
  position: absolute;
  top: 0;
  right: 0;
  width: var(--game-header-actions-w);
  height: var(--header-bar-h);
  min-height: var(--header-bar-h);
  max-height: var(--header-bar-h);
  margin: 0;
}

.header-action-slot--extra {
  grid-column: 1;
}

.header-action-slot--info {
  grid-column: 2;
}

.header-action-slot--captain {
  grid-column: 3;
}

.header-action-slot--back {
  grid-column: 4;
}

.screen-header--title-row .screen-title-block h1 {
  margin: 0;
  height: var(--header-bar-h);
  min-height: var(--header-bar-h);
  max-height: var(--header-bar-h);
  display: flex;
  align-items: center;
  font-size: clamp(1.5rem, 5.5vw, 1.75rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.screen-header--title-row .screen-title-block .subtitle {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#screen-games .screen-header--title-row .screen-title-block {
  display: flex;
  align-items: center;
}

.screen-title-actions {
  flex-shrink: 0;
}

.screen-header-actions {
  display: grid;
  grid-template-columns: repeat(4, var(--header-action-size));
  gap: var(--header-action-gap);
  width: var(--game-header-actions-w);
  height: var(--header-bar-h);
  min-height: var(--header-bar-h);
  max-height: var(--header-bar-h);
  flex: none;
  align-items: center;
  justify-items: center;
}

.header-action-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--header-action-size);
  height: var(--header-action-size);
  min-width: var(--header-action-size);
  min-height: var(--header-action-size);
  flex: 0 0 var(--header-action-size);
}

.header-action-slot:empty {
  visibility: hidden;
  pointer-events: none;
}

.header-action-slot .info-btn,
.header-action-slot .back-btn--inline,
.header-action-slot .cn-new-layout-btn,
.header-action-slot .games-random-btn,
.header-action-slot .game-captain-btn,
.header-action-slot > .back-btn--inline {
  width: var(--header-action-size);
  height: var(--header-action-size);
  border-radius: 12px;
  flex-shrink: 0;
}

@media (max-width: 599px) {
  body {
    overflow-x: clip;
  }

  #session-header:not(.hidden) {
    width: 100%;
    max-width: min(100vw, var(--app-max-w));
    margin-inline: auto;
    box-sizing: border-box;
    overflow-x: clip;
  }

  /* Нижний bar (Процент, Codenames) — в колонке контента #app */
  .footer-bar {
    right: var(--app-content-right-inset);
    left: auto;
    transform: none;
    width: var(--app-content-w);
    max-width: var(--app-content-w);
    box-sizing: border-box;
    padding-left: 0;
    padding-right: 0;
  }
}

@media (max-width: 359px) {
  :root {
    --screen-pad-x: 16px;
    --header-title-gap: 10px;
  }
}

@media (min-width: 600px) {
  :root {
    --screen-pad-x: 20px;
    --header-title-gap: 12px;
  }
}

@media (min-width: 900px) {
  :root {
    --screen-pad-x: 24px;
  }
}

#screen-setup,
#screen-games,
#screen-games-settings,
#screen-percent,
#screen-codenames,
#screen-codenames-captain,
#screen-twowords,
#screen-tooncolor,
#screen-result,
#screen-random {
  width: 100%;
  max-width: none;
  margin-left: 0;
  margin-right: 0;
}

#session-header.screen-header--title-row {
  margin-bottom: 8px;
}

.screen-title-actions > .info-btn,
.screen-title-actions > .back-btn--inline,
.screen-title-actions > .cn-new-layout-btn,
.screen-title-actions > .games-random-btn,
.screen-title-actions .game-captain-btn {
  width: var(--header-action-size);
  height: var(--header-action-size);
  border-radius: 12px;
}

/* legacy: экраны без слотов (админ и т.п.) */

.games-random-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: #d1d5db;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.games-random-btn:hover,
.games-random-btn:focus-visible {
  color: #f3f4f6;
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.22);
}

.games-random-btn:active {
  transform: scale(0.94);
}

.games-random-btn-icon {
  display: block;
  width: 20px;
  height: 20px;
}

.info-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: #d1d5db;
  font-family: inherit;
  font-size: 17px;
  font-weight: 800;
  font-style: normal;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.info-btn:hover,
.info-btn:focus-visible {
  color: #f3f4f6;
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.22);
}

.info-btn:active {
  transform: scale(0.94);
}

.game-info-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.game-info-modal.hidden {
  display: none;
}

.game-info-modal-backdrop {
  position: absolute;
  inset: 0;
  border: none;
  background: rgba(0, 0, 0, 0.62);
  cursor: pointer;
  padding: 0;
}

.game-info-modal-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 380px);
  max-height: min(85dvh, 520px);
  overflow: auto;
  padding: 20px 18px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

.game-info-modal-title {
  margin: 0 0 14px;
  font-size: 20px;
}

.game-info-list {
  margin: 0 0 18px;
  padding-left: 18px;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.55;
}

.game-info-list li + li {
  margin-top: 8px;
}

.game-info-sublist {
  margin: 8px 0 0;
  padding-left: 16px;
  list-style: disc;
}

.game-info-sublist li + li {
  margin-top: 6px;
}

.game-info-list--compact {
  font-size: 13px;
  line-height: 1.45;
}

.game-info-list--compact li + li {
  margin-top: 6px;
}

#cap-info-modal .game-info-modal-panel {
  width: min(100%, 400px);
  max-height: min(90dvh, 640px);
  overflow: auto;
}

#cap-info-modal .game-info-modal-title {
  margin-bottom: 12px;
  font-size: 19px;
}

#cap-info-modal .game-info-list {
  margin-bottom: 16px;
  font-size: 14px;
  line-height: 1.55;
}

.game-captain-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: #d1d5db;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
}

.game-captain-btn:hover,
.game-captain-btn:focus-visible {
  color: #f3f4f6;
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.22);
}

.game-captain-btn:active {
  transform: scale(0.94);
}

.game-captain-btn.is-captain {
  border-color: rgba(250, 204, 21, 0.62);
  background: rgba(250, 204, 21, 0.22);
  color: #fde047;
  cursor: pointer;
  box-shadow:
    0 0 0 1px rgba(250, 204, 21, 0.18),
    0 0 18px rgba(250, 204, 21, 0.24);
}

.game-captain-btn.is-captain:hover,
.game-captain-btn.is-captain:focus-visible {
  color: #fef08a;
  background: rgba(250, 204, 21, 0.3);
  border-color: rgba(250, 204, 21, 0.75);
  box-shadow:
    0 0 0 1px rgba(250, 204, 21, 0.24),
    0 0 22px rgba(250, 204, 21, 0.32);
}

.game-captain-btn.is-captain:disabled {
  cursor: default;
  opacity: 1;
  pointer-events: none;
}

.game-captain-btn.is-pending {
  border-color: rgba(255, 255, 255, 0.24);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08);
}

.game-captain-btn.is-local-inactive {
  opacity: 0.55;
  cursor: default;
  pointer-events: none;
}

.game-captain-btn.is-local-inactive:hover,
.game-captain-btn.is-local-inactive:focus-visible {
  color: #d1d5db;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
  transform: none;
}

.game-captain-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px;
  font-size: 13px;
  font-weight: 700;
  color: #fde68a;
  white-space: nowrap;
  flex-shrink: 0;
}

.game-captain-label-text {
  line-height: 1;
}

.team-captain-label {
  margin-top: 10px;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(250, 204, 21, 0.45);
  background: rgba(250, 204, 21, 0.12);
  color: #fef08a;
}

.games-settings-captain-select {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

.games-settings-captain-select:disabled {
  opacity: 0.6;
}

.captain-request-banner {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: 50%;
  z-index: 300;
  width: min(calc(100% - 24px), 440px);
}

.captain-request-banner.hidden {
  display: none;
}

.captain-request-banner:not(.hidden) {
  display: block;
}

.captain-request-banner-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid rgba(250, 204, 21, 0.35);
  background: color-mix(in srgb, var(--surface) 88%, #000);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.45);
}

.captain-request-banner-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fde68a;
}

.captain-request-banner-text {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
}

.captain-request-banner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.captain-request-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.captain-request-btn:active {
  transform: scale(0.94);
}

.captain-request-btn--accept {
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.35);
  background: rgba(34, 197, 94, 0.12);
}

.captain-request-btn--reject {
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(239, 68, 68, 0.1);
}

.screen-title-block {
  flex: 1;
  min-width: 0;
}

.screen-header--title-row {
  margin-bottom: 8px;
}

.percent-scoreboard {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.percent-panel-body .percent-scoreboard {
  margin-bottom: 12px;
}

.percent-score-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--team-color, var(--accent)) 35%, var(--border-strong));
  background: color-mix(in srgb, var(--team-color, var(--accent)) 8%, var(--surface-glass));
  color: var(--text);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 0 16px color-mix(in srgb, var(--team-color, var(--accent)) 22%, transparent);
  width: 100%;
  box-sizing: border-box;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.percent-score-chip.is-reordering {
  position: relative;
  z-index: 2;
}

.percent-score-chip.is-winner {
  border-color: color-mix(in srgb, var(--team-color, var(--primary)) 48%, var(--border-strong));
  background: color-mix(in srgb, var(--team-color, var(--primary)) 14%, var(--surface-glass));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 0 22px color-mix(in srgb, var(--team-color, var(--primary)) 34%, transparent);
}

#result-scoreboard .percent-score-chip.is-winner {
  border-color: color-mix(in srgb, var(--gold) 52%, var(--border-strong));
  background: color-mix(in srgb, var(--gold) 14%, var(--surface-glass));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 0 0 1px color-mix(in srgb, var(--gold) 28%, transparent),
    0 0 24px rgba(251, 191, 36, 0.28);
}

#result-scoreboard .percent-score-chip.is-winner .percent-score-value {
  color: var(--gold);
}

.percent-score-status {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 88px;
  max-width: min(48%, 168px);
  overflow: hidden;
}

.percent-score-status-main {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.percent-score-status.is-active .percent-score-status-main,
.percent-score-status.is-ready .percent-score-status-main {
  color: #4ade80;
}

.percent-score-status-icon {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.percent-score-status.is-ready .percent-score-status-icon {
  color: #bbf7d0;
  background: rgba(74, 222, 128, 0.2);
  border: 1px solid rgba(74, 222, 128, 0.48);
  box-shadow: 0 0 14px rgba(74, 222, 128, 0.22);
}

.percent-score-status-icon.is-muted {
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.percent-score-status-badge {
  flex-shrink: 0;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: color-mix(in srgb, var(--team-color, var(--text)) 72%, #fff);
  background: color-mix(in srgb, var(--team-color, var(--primary)) 18%, rgba(255, 255, 255, 0.04));
  border: 1px solid color-mix(in srgb, var(--team-color, var(--primary)) 42%, rgba(255, 255, 255, 0.12));
  box-shadow: 0 0 12px color-mix(in srgb, var(--team-color, var(--primary)) 18%, transparent);
  white-space: nowrap;
}

.percent-score-value {
  flex-shrink: 0;
  min-width: 24px;
  text-align: right;
  font-size: 18px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--team-color, var(--text));
  line-height: 1;
}

.percent-score-chip.is-scoring {
  animation: percent-score-win 1.15s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 2;
  position: relative;
}

.percent-score-chip.is-scoring .percent-score-value {
  animation: percent-score-pop 1.15s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes percent-score-win {
  0% {
    transform: scale(1);
    background: color-mix(in srgb, var(--team-color, var(--accent)) 8%, var(--surface-glass));
    border-color: color-mix(in srgb, var(--team-color, var(--accent)) 35%, var(--border-strong));
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.06),
      0 0 16px color-mix(in srgb, var(--team-color, var(--accent)) 22%, transparent);
  }
  22% {
    transform: scale(1.06);
    background: color-mix(in srgb, var(--team-color, var(--primary)) 18%, var(--surface-glass));
    border-color: color-mix(in srgb, var(--team-color, var(--primary)) 52%, var(--border-strong));
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.1),
      0 0 0 2px color-mix(in srgb, var(--team-color, var(--primary)) 32%, transparent),
      0 0 32px color-mix(in srgb, var(--team-color, var(--primary)) 48%, transparent);
  }
  100% {
    transform: scale(1);
    background: color-mix(in srgb, var(--team-color, var(--accent)) 8%, var(--surface-glass));
    border-color: color-mix(in srgb, var(--team-color, var(--accent)) 35%, var(--border-strong));
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.06),
      0 0 16px color-mix(in srgb, var(--team-color, var(--accent)) 22%, transparent);
  }
}

@keyframes percent-score-pop {
  0%, 100% { transform: scale(1); }
  28% { transform: scale(1.45); }
}

#screen-percent.percent-screen-flash,
#screen-result.percent-screen-flash {
  animation: none;
}

body.percent-win-bg-flash {
  animation: percent-win-bg 1.35s ease forwards;
}

body.percent-win-bg-tint {
  background-color: color-mix(in srgb, var(--percent-win-color, var(--primary)) 22%, var(--bg));
  transition: background-color 0.5s ease;
}

@keyframes percent-win-bg {
  0% {
    background-color: var(--bg);
  }
  12% {
    background-color: color-mix(in srgb, var(--percent-win-color, var(--primary)) 35%, var(--bg));
  }
  100% {
    background-color: color-mix(in srgb, var(--percent-win-color, var(--primary)) 22%, var(--bg));
  }
}

.percent-score-name {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.percent-score-name-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.percent-score-name-wrap .percent-score-name {
  flex: 0 1 auto;
  min-width: 0;
}

.percent-score-ready-badge {
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #bae6fd;
  background: rgba(34, 211, 238, 0.14);
  border: 1px solid rgba(34, 211, 238, 0.42);
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.16);
}

.result-answers-layout {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin-top: 20px;
  padding: 6px 2px 4px;
  overflow: visible;
}

.result-answers-layout.is-pending-reveal {
  margin-top: 16px;
}

.result-answers-layout.is-pending-reveal .result-answers-row--winner {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: flex-end;
  gap: clamp(8px, 2.5vw, 16px);
  width: 100%;
  min-height: auto;
}

.result-answers-layout.is-pending-reveal .result-answers-row--others {
  display: none !important;
}

.result-answers-layout.is-pending-reveal .result-answer-item {
  flex: 1 1 0;
  min-width: 0;
  max-width: none;
}

.result-answers-layout.is-pending-reveal .result-answer-pct,
.result-answers-layout.is-pending-reveal .result-answer-pct--uniform {
  font-size: clamp(2.25rem, 8.4vw, 3rem) !important;
  font-weight: 800;
  line-height: 1.1;
}

.result-answers-layout.is-pending-reveal .result-answer-pct::after {
  display: none;
}

.result-answers-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 14px;
  align-items: end;
  justify-items: center;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.result-answers-row--winner {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-end;
  gap: 18px 24px;
  min-height: 7rem;
  overflow: visible;
}

.result-answers-row--others {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-end;
  gap: clamp(10px, 3.5vw, 22px);
  min-height: 6rem;
}

.result-answers-row--winner:empty,
.result-answers-row--others:empty {
  display: none;
}

.result-answer-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: auto;
  max-width: 100%;
  min-width: 0;
  position: relative;
}

.result-answers-row--winner .result-answer-item {
  max-width: min(100%, 280px);
  overflow: visible;
}

.result-answers-row--winner .result-answer-pct {
  position: relative;
  font-size: clamp(5rem, 22vw, 7.5rem);
}

.result-answers-row--winner .result-answer-pct::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -6px;
  transform: translateX(-50%);
  width: 120%;
  height: 24px;
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.62) 0%, rgba(255, 255, 255, 0.18) 42%, rgba(255, 255, 255, 0) 72%);
  pointer-events: none;
  filter: blur(1px);
  z-index: -1;
}

.result-answers-row--winner .result-answer-diff.rank-1 {
  font-size: 1.25rem;
}

.result-answers-row--winner .result-answer-diff.is-exact.rank-1 {
  font-size: 2rem;
}

.result-answers-row--others .result-answer-item {
  flex: 0 1 auto;
}

.result-answers-row--others .result-answer-pct.rank-1 { font-size: clamp(3.5rem, 15.5vw, 5.25rem); }
.result-answers-row--others .result-answer-pct.rank-2 { font-size: clamp(2.625rem, 12vw, 4rem); }
.result-answers-row--others .result-answer-pct.rank-3 { font-size: clamp(2rem, 9.5vw, 2.625rem); }
.result-answers-row--others .result-answer-pct.rank-4 { font-size: clamp(1.625rem, 7.75vw, 1.75rem); }

.result-answers-row--others .result-answer-diff.rank-1 { font-size: 1rem; }
.result-answers-row--others .result-answer-diff.rank-2 { font-size: 0.9375rem; }
.result-answers-row--others .result-answer-diff.rank-3 { font-size: 0.8125rem; }
.result-answers-row--others .result-answer-diff.rank-4 { font-size: 0.75rem; }

.result-answers-row--others .result-answer-diff.is-exact.rank-1 { font-size: 1.5rem; }
.result-answers-row--others .result-answer-diff.is-exact.rank-2 { font-size: 1.3125rem; }
.result-answers-row--others .result-answer-diff.is-exact.rank-3 { font-size: 1.125rem; }
.result-answers-row--others .result-answer-diff.is-exact.rank-4 { font-size: 1rem; }

#screen-result .result-answers-layout {
  gap: 12px;
  margin-top: 14px;
  padding-top: 2px;
}

#screen-result .result-answers-row--others {
  min-height: 4.5rem;
  gap: clamp(8px, 2.5vw, 16px);
}

#screen-result .result-answer-card {
  padding: 18px 16px 20px;
}

.result-answer-diff {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  line-height: 1;
  letter-spacing: -0.01em;
}

.result-answer-diff.rank-1 { font-size: 1.125rem; }
.result-answer-diff.rank-2 { font-size: 1rem; }
.result-answer-diff.rank-3 { font-size: 0.875rem; }
.result-answer-diff.rank-4 { font-size: 0.8125rem; }

.result-answer-diff.is-exact {
  line-height: 1;
  filter: drop-shadow(0 1px 4px rgba(251, 191, 36, 0.45));
}

.result-answer-diff.is-exact.rank-1 { font-size: 1.75rem; }
.result-answer-diff.is-exact.rank-2 { font-size: 1.5rem; }
.result-answer-diff.is-exact.rank-3 { font-size: 1.25rem; }
.result-answer-diff.is-exact.rank-4 { font-size: 1.125rem; }

.result-answers-layout[data-team-count="4"] .result-answers-row--others {
  gap: 16px 12px;
}

.result-answer-pct {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--team-color, var(--text));
  line-height: 1;
  letter-spacing: -0.02em;
  text-shadow: 0 0 20px color-mix(in srgb, var(--team-color, var(--text)) 32%, transparent);
}

.result-answer-pct.rank-1 { font-size: clamp(4rem, 18vw, 6rem); }
.result-answer-pct.rank-2 { font-size: clamp(3rem, 14vw, 4.5rem); }
.result-answer-pct.rank-3 { font-size: clamp(2.25rem, 11vw, 3rem); }
.result-answer-pct.rank-4 { font-size: clamp(1.875rem, 9vw, 2rem); }

.result-answer-pct-wrap {
  position: relative;
  display: inline-block;
  line-height: 1;
  overflow: visible;
}

.result-answer-pct.is-reveal-bounce {
  display: inline-block;
  transform-origin: center bottom;
  animation: result-winner-pct-bounce 2s linear both;
}

.result-answer-pct-wrap.is-spark-reveal::before {
  content: '';
  position: absolute;
  inset: -10% -6%;
  pointer-events: none;
  z-index: 4;
  opacity: 0;
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--team-color, #fbbf24) 72%, #fff) 0%,
    transparent 22%,
    transparent 78%,
    color-mix(in srgb, var(--team-color, #fbbf24) 72%, #fff) 100%
  );
  filter: blur(6px);
  animation: result-winner-edge-flash 0.72s ease-out both;
}

.result-winner-spark-burst {
  position: absolute;
  top: -24%;
  bottom: -24%;
  left: 0;
  right: 0;
  pointer-events: none;
  overflow: visible;
  z-index: 5;
}

.result-winner-spark {
  --spark-dist: clamp(56px, 18vw, 108px);
  --spark-color: var(--team-color, #fbbf24);
  position: absolute;
  top: calc(50% + var(--spark-y, 0px));
  opacity: 0;
  animation-duration: var(--spark-duration, 0.58s);
  animation-timing-function: cubic-bezier(0.2, 0.82, 0.28, 1);
  animation-delay: var(--spark-delay, 0s);
  animation-fill-mode: both;
  pointer-events: none;
}

.result-winner-spark--left {
  left: 0;
  transform: translate(0, -50%);
  animation-name: result-winner-spark-fly-left;
}

.result-winner-spark--right {
  left: 100%;
  transform: translate(-100%, -50%);
  animation-name: result-winner-spark-fly-right;
}

.result-winner-spark--streak {
  width: clamp(16px, 4.5vw, 32px);
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--spark-color) 55%, transparent), var(--spark-color), #fff);
  box-shadow:
    0 0 8px color-mix(in srgb, var(--spark-color) 80%, #fff),
    0 0 16px color-mix(in srgb, var(--spark-color) 45%, transparent);
}

.result-winner-spark--right.result-winner-spark--streak {
  background: linear-gradient(270deg, transparent, color-mix(in srgb, var(--spark-color) 55%, transparent), var(--spark-color), #fff);
}

.result-winner-spark--dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #fff;
  box-shadow:
    0 0 6px #fff,
    0 0 12px var(--spark-color),
    0 0 20px color-mix(in srgb, var(--spark-color) 65%, transparent);
}

.result-winner-spark--flare {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, color-mix(in srgb, var(--spark-color) 85%, #fff) 42%, transparent 72%);
  box-shadow:
    0 0 14px #fff,
    0 0 24px var(--spark-color);
}

.result-winner-spark--v1 { --spark-dist: clamp(62px, 19vw, 114px); }
.result-winner-spark--v2 { --spark-dist: clamp(52px, 16vw, 96px); }
.result-winner-spark--v3 { --spark-dist: clamp(72px, 22vw, 124px); }
.result-winner-spark--v4 { --spark-dist: clamp(46px, 14vw, 88px); }

@keyframes result-winner-edge-flash {
  0% {
    opacity: 0;
    transform: scaleX(0.72);
  }
  18% {
    opacity: 0.85;
    transform: scaleX(1);
  }
  100% {
    opacity: 0;
    transform: scaleX(1.06);
  }
}

@keyframes result-winner-spark-fly-left {
  0% {
    opacity: 0;
    transform: translate(0, -50%) scale(0.4);
  }
  12% {
    opacity: 1;
    transform: translate(-10px, -50%) scale(1.05);
  }
  100% {
    opacity: 0;
    transform: translate(calc(-1 * var(--spark-dist)), -50%) scale(0.55);
  }
}

@keyframes result-winner-spark-fly-right {
  0% {
    opacity: 0;
    transform: translate(-100%, -50%) scale(0.4);
  }
  12% {
    opacity: 1;
    transform: translate(calc(-100% + 10px), -50%) scale(1.05);
  }
  100% {
    opacity: 0;
    transform: translate(calc(-100% + var(--spark-dist)), -50%) scale(0.55);
  }
}

.result-answers-row--winner .result-answer-item.is-winner.is-reveal-bounce .result-answer-diff {
  animation: result-winner-diff-bounce 2s linear both;
}

@keyframes result-winner-pct-bounce {
  0% {
    transform: scale(0.55);
    opacity: 0.72;
  }
  14% {
    transform: scale(1.16);
    opacity: 1;
  }
  28% {
    transform: scale(0.9);
  }
  42% {
    transform: scale(1.1);
  }
  56% {
    transform: scale(0.95);
  }
  70% {
    transform: scale(1.04);
  }
  84% {
    transform: scale(0.98);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes result-winner-diff-bounce {
  0% {
    transform: scale(0.85);
    opacity: 0.4;
  }
  14% {
    transform: scale(1.1);
    opacity: 1;
  }
  28% {
    transform: scale(0.93);
  }
  42% {
    transform: scale(1.06);
  }
  56% {
    transform: scale(0.96);
  }
  70% {
    transform: scale(1.02);
  }
  84% {
    transform: scale(0.99);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .result-answer-pct.is-reveal-bounce,
  .result-answers-row--winner .result-answer-item.is-winner.is-reveal-bounce .result-answer-diff {
    animation: none;
  }

  .result-winner-spark,
  .result-answer-pct-wrap.is-spark-reveal::before {
    animation: none;
    display: none;
  }
}

.result-question-text {
  margin: 0 0 20px;
  padding: 14px 16px;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
  letter-spacing: -0.01em;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 8px 20px rgba(0, 0, 0, 0.22);
}

.back-btn--inline {
  appearance: none;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #d1d5db;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.back-btn--inline:hover,
.back-btn--inline:focus-visible {
  color: #f3f4f6;
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.22);
}

.back-btn--inline:active {
  transform: scale(0.94);
}

.back-btn--inline:disabled {
  opacity: 0.45;
  cursor: wait;
  pointer-events: none;
}

.back-btn--label {
  width: auto;
  min-width: 40px;
  max-width: min(148px, 42vw);
  height: 40px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  line-height: 1.15;
  letter-spacing: -0.01em;
  text-align: center;
  white-space: normal;
}

.back-btn--exit {
  color: #ef4444;
}

.back-btn--exit:hover,
.back-btn--exit:focus-visible {
  color: #f87171;
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.35);
}

.back-btn-icon--exit path {
  stroke: currentColor;
}

.rules-captain-star {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  color: #facc15;
  margin: 0 2px;
}

.rules-captain-star svg {
  display: block;
}

.back-btn-icon {
  display: block;
}

/* Только стрелка «Назад» — жирнее; остальные иконки берут stroke-width из SVG */
#session-back-btn .back-btn-icon path {
  stroke-width: 3.5;
}

#lobby-admin-btn .back-btn-icon path,
#lobby-admin-btn .back-btn-icon rect,
#lobby-skip-btn .back-btn-icon path,
#lobby-skip-btn .back-btn-icon circle {
  stroke-width: 1.75;
}

.header-btn-glyph {
  display: block;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
}

.header-btn-glyph--compact {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.05em;
}

/* Блоки */
.block { margin-bottom: 24px; }
.block-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}

/* Сегментированный переключатель */
.segmented {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  background: var(--surface-glass);
  padding: 6px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.seg-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 16px;
  font-weight: 600;
  padding: 10px 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.seg-btn[aria-checked="true"] {
  background: var(--gradient-accent);
  color: #fff;
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.3);
}

/* Карточки команд */
.team-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.team-card {
  background: var(--surface-glass);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 14px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.team-card[style*="--team-color"] {
  border: 2px solid color-mix(in srgb, var(--team-color, var(--border)) 52%, var(--border));
  background: color-mix(in srgb, var(--team-color, var(--primary)) 9%, var(--surface));
  box-shadow:
    inset 4px 0 0 var(--team-color, var(--primary)),
    0 0 0 1px color-mix(in srgb, var(--team-color, var(--primary)) 18%, transparent);
}

.team-meta-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin-bottom: 4px;
}

.team-color-picker-wrap {
  flex: 1;
  min-width: 0;
}

.team-color-picker {
  position: relative;
}

.team-color-trigger {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.team-color-trigger:hover:not(:disabled),
.team-color-trigger:focus-visible {
  border-color: color-mix(in srgb, var(--text) 22%, var(--border));
  background: color-mix(in srgb, var(--surface-2) 80%, var(--text));
}

.team-color-trigger:disabled {
  opacity: 0.72;
  cursor: default;
}

.team-color-trigger-swatch {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}

.team-color-trigger-label {
  display: none;
}

.team-color-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 80;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.team-color-menu.hidden {
  display: none;
}

.team-color-menu--roster {
  position: absolute;
  inset: 0;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  margin: 0;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-content: stretch;
  border: none;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

.team-color-menu--roster.hidden {
  display: none;
}

.team-color-option {
  appearance: none;
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 0;
  border-radius: 999px;
  padding: 0;
  background: var(--option-color, #666);
  cursor: pointer;
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.team-color-option:hover:not(:disabled) {
  transform: scale(1.06);
}

.team-color-option.is-selected {
  box-shadow:
    0 0 0 2px var(--bg),
    0 0 0 4px var(--text);
}

.team-color-option:disabled {
  opacity: 0.28;
  cursor: not-allowed;
}

.team-color-option:disabled::after {
  content: '';
  position: absolute;
  inset: 28%;
  border-radius: 50%;
  background: var(--bg);
  opacity: 0.45;
}

.team-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 0;
}

.team-card-local {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
}

.team-card-local .team-name {
  width: 100%;
  box-sizing: border-box;
  margin: 0;
}

.team-local-palette {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}

.team-local-palette .team-color-option {
  aspect-ratio: 1;
  height: auto;
  min-height: 0;
  max-height: 34px;
}

#setup-local-count-block .segmented {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

#screen-setup .team-card-local {
  filter: none;
}

.team-swatch {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  flex-shrink: 0;
  background: #444;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  transition: background 0.2s ease;
}

.team-name {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s ease;
}

.team-name:focus { border-color: var(--primary); }
.team-name::placeholder { color: var(--text-muted); }

/* Палитра */
.palette {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
}

.color-dot {
  appearance: none;
  border: 0;
  padding: 0;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s ease;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.color-dot[aria-checked="true"] {
  transform: scale(1.08);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text);
}

.color-dot[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.28;
}

.color-dot[aria-disabled="true"]:not([aria-checked="true"])::after {
  content: '';
  position: absolute;
  inset: 30%;
  border-radius: 50%;
  background: var(--bg);
  opacity: 0.35;
}

/* Нижний бар */
.footer-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, 480px);
  box-sizing: border-box;
  padding: 10px var(--screen-pad-x) calc(10px + var(--safe-bottom));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-strong);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 20;
}

.footer-bar > * {
  pointer-events: auto;
  width: 100%;
  max-width: none;
  margin: 0;
}

#percent-footer-bar {
  flex-direction: column;
  gap: 8px;
}

#percent-footer-bar > * {
  flex: none;
}

#screen-codenames .cn-panel-footer,
#screen-codenames-captain .cn-panel-footer,
#cn-footer-bar,
#cap-hint-form-wrap,
#screen-twowords .tw-panel-footer,
#tw-footer-bar,
#screen-tooncolor .tone-panel-footer,
#tone-footer-bar {
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
  border-top: none;
}

#percent-confirm-btn.is-waiting {
  background: rgba(74, 222, 128, 0.2);
  color: #bbf7d0;
  border: 1px solid rgba(74, 222, 128, 0.52);
  cursor: default;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 0 0 1px rgba(74, 222, 128, 0.16),
    0 0 24px rgba(74, 222, 128, 0.28);
}

#percent-confirm-btn.is-waiting:disabled {
  opacity: 1;
}

.primary, .secondary {
  appearance: none;
  border: 0;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  padding: 14px 18px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
  display: block;
}

.primary {
  background: var(--gradient-primary);
  color: #fff;
  box-shadow: 0 8px 24px rgba(239, 68, 68, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.primary:hover {
  filter: brightness(1.06);
  box-shadow: 0 10px 28px rgba(239, 68, 68, 0.34);
}
.primary:active { transform: translateY(1px) scale(0.99); }
.primary:disabled {
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: not-allowed;
  box-shadow: none;
  border-color: var(--border);
  filter: none;
}

.secondary {
  background: var(--surface-glass);
  color: var(--text);
  border: 1px solid var(--border-strong);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.secondary:hover {
  background: color-mix(in srgb, var(--text) 6%, var(--surface-2));
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border-strong));
}

/* Превью команд + счёт */
.teams-preview {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.teams-preview li {
  margin: 0;
  padding: 0;
}

.teams-preview-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid color-mix(in srgb, var(--team-color, var(--primary)) 38%, var(--border));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--team-color, var(--primary)) 16%, var(--surface));
  box-shadow: inset 3px 0 0 var(--team-color, var(--primary));
  font: inherit;
  font-weight: 600;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.teams-preview-row:hover,
.teams-preview-row:focus-visible {
  background: color-mix(in srgb, var(--team-color, var(--primary)) 22%, var(--surface));
  border-color: color-mix(in srgb, var(--team-color, var(--primary)) 52%, var(--border));
  outline: none;
}

.teams-preview-row:active {
  transform: scale(0.99);
}

.teams-preview-name {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.teams-preview-score {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 1.75rem;
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--team-color, var(--text));
  min-width: 2rem;
  text-align: right;
}

.games-team-modal-panel {
  box-shadow:
    0 16px 48px rgba(0, 0, 0, 0.45),
    inset 3px 0 0 var(--team-color, var(--primary));
}

.games-team-modal-players {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.games-team-modal-players li {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--team-color, var(--primary)) 12%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--team-color, var(--primary)) 28%, var(--border));
  font-size: 15px;
  font-weight: 600;
}

.games-team-modal-players li.is-captain {
  color: #fde68a;
}

.games-team-modal-empty {
  color: var(--text-dim);
  font-weight: 500;
  font-style: italic;
  background: transparent;
  border: 1px dashed var(--border);
}

.top-slide-plate {
  transform: translateX(-50%) translateY(calc(-100% - 24px));
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    transform 0.38s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.32s ease,
    visibility 0.38s;
  will-change: transform, opacity;
}

.top-slide-plate.is-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.top-slide-plate.is-exiting {
  transform: translateX(-50%) translateY(calc(-100% - 24px));
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Карточки игр */
.games-list {
  display: grid;
  gap: 10px;
}

.game-card {
  text-align: left;
  background: var(--surface-glass);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 18px;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

.game-card:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border-strong));
  box-shadow: var(--shadow), var(--shadow-cyan);
}
.game-card:active { transform: scale(0.99); }

.game-card-title {
  font-weight: 700;
  font-size: 17px;
  margin-bottom: 4px;
}

.game-card-desc {
  font-size: 14px;
  color: var(--text-dim);
}

.game-card-presence {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.game-card-presence.hidden {
  display: none;
}

.game-presence-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  background: color-mix(in srgb, var(--team-color, var(--primary)) 20%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--team-color, var(--primary)) 45%, var(--border));
  box-shadow: inset 2px 0 0 var(--team-color, var(--primary));
  max-width: 100%;
}

.game-presence-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.team-activity-badge {
  display: inline-flex;
  align-items: center;
  margin-left: auto;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text);
  background: color-mix(in srgb, var(--team-color, var(--primary)) 22%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--team-color, var(--primary)) 50%, var(--border));
  box-shadow: 0 0 12px color-mix(in srgb, var(--team-color, var(--primary)) 25%, transparent);
  flex-shrink: 0;
}

/* Игра «Угадай процент» */
.question-card {
  position: relative;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  padding: 0;
  margin-bottom: 24px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 12px 32px rgba(0, 0, 0, 0.32),
    0 0 28px rgba(34, 211, 238, 0.1);
}

.question-card-inner {
  position: relative;
  z-index: 1;
  padding: 18px;
}

.question-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.question-card-head .block-title {
  margin: 0;
}

.question-card-timer {
  flex-shrink: 0;
  font-size: 1.625rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  padding: 4px 2px;
  border-radius: 0;
  background: transparent;
  border: none;
  color: var(--timer-text-color, var(--text));
  letter-spacing: -0.03em;
  transition: color 0.35s ease;
  min-width: 2.25rem;
  text-align: right;
}

.question-card-timer.hidden {
  display: none;
}

.question-card.has-timer.is-timer-urgent .question-card-timer {
  text-shadow: 0 0 22px color-mix(in srgb, var(--timer-text-color, #ef4444) 58%, transparent);
}

.question-card-timer-fill {
  position: absolute;
  inset: 0;
  z-index: 0;
  transform: scaleX(var(--timer-fill, 0));
  transform-origin: left center;
  background: color-mix(in srgb, var(--timer-fill-color, rgba(100, 116, 139, 0.22)) 32%, transparent);
  pointer-events: none;
  will-change: transform, background-color;
  transition:
    transform 0.15s linear,
    background-color 0.35s ease;
}

.question-card.has-timer {
  transition: border-color 0.35s ease, box-shadow 0.35s ease;
  border-color: color-mix(in srgb, var(--timer-fill-color, var(--border)) 48%, rgba(255, 255, 255, 0.12));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 12px 32px rgba(0, 0, 0, 0.32),
    0 0 24px color-mix(in srgb, var(--timer-fill-color, rgba(34, 211, 238, 0.2)) 28%, transparent);
}

.question-text {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.01em;
  color: var(--text);
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.06);
}

.percent-own-answer:empty {
  display: none;
}

.percent-own-answer .answer-row {
  margin: 0;
}

.percent-opponents-heading {
  margin-top: 16px;
}

.percent-opponents-heading.hidden {
  display: none;
}

.percent-opponents-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.percent-opponent-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 8px 20px rgba(0, 0, 0, 0.24);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.percent-opponent-chip.is-ready {
  border-color: rgba(74, 222, 128, 0.52);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 0 0 1px rgba(74, 222, 128, 0.28),
    0 0 20px rgba(74, 222, 128, 0.18);
  background: color-mix(in srgb, #4ade80 10%, rgba(255, 255, 255, 0.06));
}

.percent-opponent-name {
  flex: 1;
  font-weight: 600;
  min-width: 0;
}

.percent-opponent-mark {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.percent-opponent-chip.is-ready .percent-opponent-mark {
  color: #bbf7d0;
  background: rgba(74, 222, 128, 0.22);
  border-color: rgba(74, 222, 128, 0.5);
  box-shadow: 0 0 12px rgba(74, 222, 128, 0.24);
}

.answers-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.answer-row {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  padding: 14px 14px 12px;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto auto auto;
  gap: 4px 0;
  align-items: center;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 8px 24px rgba(0, 0, 0, 0.26);
}

#screen-percent .answer-row {
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--team-color, var(--accent)) 35%, var(--border-strong));
  background: color-mix(in srgb, var(--team-color, var(--accent)) 8%, var(--surface-glass));
  padding: 14px 16px 12px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 0 16px color-mix(in srgb, var(--team-color, var(--accent)) 22%, transparent);
}

#screen-percent .answer-row .answer-head {
  min-height: 48px;
  align-items: center;
}

#screen-percent .answer-row .answer-value-wrap {
  flex: 0 0 164px;
  width: 164px;
  height: 48px;
  justify-content: flex-end;
  overflow: visible;
  padding-right: 2px;
}

.answer-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.answer-value-wrap {
  display: flex;
  align-items: center;
  gap: 0;
  margin-left: auto;
  flex-shrink: 0;
}

.answer-value.is-tappable {
  cursor: text;
  -webkit-tap-highlight-color: transparent;
}

.answer-value-wrap.is-editing .answer-value {
  display: none;
}

.answer-value-wrap.is-editing .answer-input {
  display: block;
}

.answer-team-name {
  flex: 1;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
  min-width: 0;
}

#screen-percent .answer-row .answer-value,
#screen-percent .answer-row .answer-input {
  font-size: 44px;
  line-height: 1;
  white-space: nowrap;
  transform: scale(0.5);
  transform-origin: right center;
  transition: transform 0.18s ease, text-shadow 0.18s ease;
}

#screen-percent .answer-row .answer-input {
  width: 100%;
  min-width: 0;
  text-align: right;
}

#screen-percent .answer-row.is-scrubbing .answer-value,
#screen-percent .answer-row .answer-value-wrap.is-editing .answer-input {
  transform: scale(1);
}

#screen-percent .answer-row.is-scrubbing .answer-value {
  text-shadow: 0 0 24px color-mix(in srgb, var(--team-color, var(--text)) 38%, transparent);
}

.answer-value {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 22px;
  color: var(--team-color, var(--text));
  letter-spacing: -0.02em;
  text-shadow: 0 0 16px color-mix(in srgb, var(--team-color, var(--text)) 28%, transparent);
}

#screen-percent .answer-slider-wrap {
  position: relative;
  margin-top: 10px;
  isolation: isolate;
  overflow: visible;
  --slider-track-top: 4px;
  --slider-track-height: 64px;
  --slider-track-center-y: calc(var(--slider-track-top) + var(--slider-track-height) / 2);
}

#screen-percent .answer-slider-fx {
  position: absolute;
  inset: 0 -8px -56px;
  pointer-events: none;
  z-index: 2;
  overflow: visible;
}

#screen-percent .answer-slider-fx-spark {
  position: absolute;
  left: var(--fill, 50%);
  top: var(--slider-track-center-y);
  width: 7px;
  height: 7px;
  border-radius: 50%;
  z-index: 1;
  background: #fff;
  box-shadow:
    0 0 8px #fff,
    0 0 14px color-mix(in srgb, var(--team-color, var(--primary)) 90%, #fff),
    0 0 24px color-mix(in srgb, var(--team-color, var(--primary)) 65%, transparent);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.45);
  transition: opacity 0.3s ease-out;
}

#screen-percent .answer-row.is-scrubbing .answer-slider-fx-spark--1 {
  animation: percent-slider-spark-a 0.78s ease-out infinite;
}

#screen-percent .answer-row.is-scrubbing .answer-slider-fx-spark--2 {
  animation: percent-slider-spark-b 0.86s ease-out infinite 0.08s;
}

#screen-percent .answer-row.is-scrubbing .answer-slider-fx-spark--3 {
  animation: percent-slider-spark-c 0.74s ease-out infinite 0.16s;
}

#screen-percent .answer-row.is-scrubbing .answer-slider-fx-spark--4 {
  animation: percent-slider-spark-d 0.82s ease-out infinite 0.05s;
}

#screen-percent .answer-row.is-scrubbing .answer-slider-fx-spark--5 {
  animation: percent-slider-spark-e 0.9s ease-out infinite 0.14s;
}

#screen-percent .answer-row.is-scrubbing .answer-slider-fx-spark--6 {
  animation: percent-slider-spark-f 0.76s ease-out infinite 0.22s;
}

#screen-percent .answer-row.is-scrubbing .answer-slider-fx-spark--7 {
  animation: percent-slider-spark-g 0.84s ease-out infinite 0.28s;
}

#screen-percent .answer-row.is-scrubbing .answer-slider-fx-spark--8 {
  animation: percent-slider-spark-h 0.7s ease-out infinite 0.04s;
}

#screen-percent .answer-row.is-scrubbing .answer-slider-fx-spark--9 {
  animation: percent-slider-spark-i 0.8s ease-out infinite 0.11s;
}

#screen-percent .answer-row.is-scrubbing .answer-slider-fx-spark--10 {
  animation: percent-slider-spark-j 0.76s ease-out infinite 0.19s;
}

#screen-percent .answer-row.is-scrubbing .answer-slider-fx-spark--11 {
  animation: percent-slider-spark-k 0.88s ease-out infinite 0.24s;
}

#screen-percent .answer-row.is-scrubbing .answer-slider-fx-spark--12 {
  animation: percent-slider-spark-l 0.72s ease-out infinite 0.32s;
}

@keyframes percent-slider-track-glow-pulse {
  0% {
    border-color: color-mix(in srgb, var(--team-color, var(--primary)) 38%, rgba(255, 255, 255, 0.14));
    box-shadow:
      inset 0 2px 8px rgba(0, 0, 0, 0.18),
      0 0 10px color-mix(in srgb, var(--team-color, var(--primary)) 26%, transparent),
      0 0 18px color-mix(in srgb, var(--team-color, var(--primary)) 14%, transparent),
      inset 0 0 8px color-mix(in srgb, var(--team-color, var(--primary)) 8%, transparent);
  }
  100% {
    border-color: color-mix(in srgb, var(--team-color, var(--primary)) 58%, rgba(255, 255, 255, 0.22));
    box-shadow:
      inset 0 2px 8px rgba(0, 0, 0, 0.18),
      0 0 16px color-mix(in srgb, var(--team-color, var(--primary)) 42%, transparent),
      0 0 30px color-mix(in srgb, var(--team-color, var(--primary)) 24%, transparent),
      inset 0 0 14px color-mix(in srgb, var(--team-color, var(--primary)) 14%, transparent);
  }
}

@keyframes percent-slider-spark-a {
  0% { transform: translate(-50%, -50%) scale(0.55); opacity: 0; }
  12% { opacity: 1; }
  100% { transform: translate(calc(-50% - 72px), calc(-50% - 88px)) scale(0.12); opacity: 0; }
}

@keyframes percent-slider-spark-b {
  0% { transform: translate(-50%, -50%) scale(0.55); opacity: 0; }
  12% { opacity: 1; }
  100% { transform: translate(calc(-50% + 68px), calc(-50% - 92px)) scale(0.12); opacity: 0; }
}

@keyframes percent-slider-spark-c {
  0% { transform: translate(-50%, -50%) scale(0.55); opacity: 0; }
  12% { opacity: 1; }
  100% { transform: translate(-50%, calc(-50% - 102px)) scale(0.12); opacity: 0; }
}

@keyframes percent-slider-spark-d {
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
  12% { opacity: 0.95; }
  100% { transform: translate(calc(-50% - 52px), calc(-50% - 64px)) scale(0.1); opacity: 0; }
}

@keyframes percent-slider-spark-e {
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
  12% { opacity: 0.95; }
  100% { transform: translate(calc(-50% + 54px), calc(-50% - 66px)) scale(0.1); opacity: 0; }
}

@keyframes percent-slider-spark-f {
  0% { transform: translate(-50%, -50%) scale(0.6); opacity: 0; }
  12% { opacity: 1; }
  100% { transform: translate(calc(-50% - 34px), calc(-50% - 108px)) scale(0.1); opacity: 0; }
}

@keyframes percent-slider-spark-g {
  0% { transform: translate(-50%, -50%) scale(0.6); opacity: 0; }
  12% { opacity: 1; }
  100% { transform: translate(calc(-50% + 36px), calc(-50% - 104px)) scale(0.1); opacity: 0; }
}

@keyframes percent-slider-spark-h {
  0% { transform: translate(-50%, -50%) scale(0.48); opacity: 0; }
  12% { opacity: 0.9; }
  100% { transform: translate(calc(-50% - 84px), calc(-50% - 42px)) scale(0.08); opacity: 0; }
}

@keyframes percent-slider-spark-i {
  0% { transform: translate(-50%, -50%) scale(0.48); opacity: 0; }
  12% { opacity: 0.9; }
  100% { transform: translate(calc(-50% + 78px), calc(-50% - 38px)) scale(0.08); opacity: 0; }
}

@keyframes percent-slider-spark-j {
  0% { transform: translate(-50%, -50%) scale(0.52); opacity: 0; }
  12% { opacity: 1; }
  100% { transform: translate(calc(-50% - 24px), calc(-50% + 48px)) scale(0.1); opacity: 0; }
}

@keyframes percent-slider-spark-k {
  0% { transform: translate(-50%, -50%) scale(0.52); opacity: 0; }
  12% { opacity: 1; }
  100% { transform: translate(calc(-50% + 26px), calc(-50% + 52px)) scale(0.1); opacity: 0; }
}

@keyframes percent-slider-spark-l {
  0% { transform: translate(-50%, -50%) scale(0.58); opacity: 0; }
  12% { opacity: 1; }
  100% { transform: translate(calc(-50% - 58px), calc(-50% + 62px)) scale(0.08); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  #screen-percent .answer-row.is-scrubbing .answer-slider::-webkit-slider-runnable-track,
  #screen-percent .answer-row.is-scrubbing .answer-slider::-moz-range-track {
    animation: none;
    border-color: color-mix(in srgb, var(--team-color, var(--primary)) 48%, rgba(255, 255, 255, 0.18));
    box-shadow:
      inset 0 2px 8px rgba(0, 0, 0, 0.18),
      0 0 14px color-mix(in srgb, var(--team-color, var(--primary)) 30%, transparent),
      inset 0 0 10px color-mix(in srgb, var(--team-color, var(--primary)) 10%, transparent);
  }

  #screen-percent .answer-row.is-scrubbing .answer-slider-fx-spark {
    animation: none;
    opacity: 0;
  }
}

.answer-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 72px;
  background: transparent;
  margin: 10px 0 0;
  padding: 0;
  cursor: pointer;
  touch-action: pan-y;
}

#screen-percent .answer-slider {
  position: relative;
  z-index: 1;
  margin: 0;
}

.answer-slider::-webkit-slider-runnable-track {
  height: 64px;
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--team-color, var(--primary)) 88%, transparent) 0%,
    color-mix(in srgb, var(--team-color, var(--primary)) 88%, transparent) var(--fill, 50%),
    rgba(255, 255, 255, 0.05) var(--fill, 50%),
    rgba(255, 255, 255, 0.05) 100%);
  border-radius: 16px;
  border: 1px solid color-mix(in srgb, var(--team-color, var(--primary)) 38%, rgba(255, 255, 255, 0.12));
  box-shadow:
    inset 0 2px 8px rgba(0, 0, 0, 0.28),
    0 0 18px color-mix(in srgb, var(--team-color, var(--primary)) 22%, transparent);
}

.answer-slider::-moz-range-track {
  height: 64px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  border: 1px solid color-mix(in srgb, var(--team-color, var(--primary)) 38%, rgba(255, 255, 255, 0.12));
  box-shadow:
    inset 0 2px 8px rgba(0, 0, 0, 0.28),
    0 0 18px color-mix(in srgb, var(--team-color, var(--primary)) 22%, transparent);
}

.answer-slider::-moz-range-progress {
  height: 64px;
  background: var(--team-color, var(--primary));
  border-radius: 16px;
}

#screen-percent .answer-slider::-webkit-slider-runnable-track {
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--team-color, var(--primary)) var(--fill-opacity, 60%), transparent) 0%,
    color-mix(in srgb, var(--team-color, var(--primary)) var(--fill-opacity, 60%), transparent) var(--fill, 50%),
    rgba(255, 255, 255, 0.03) var(--fill, 50%),
    rgba(255, 255, 255, 0.03) 100%);
  border: 1px solid color-mix(in srgb, var(--team-color, var(--primary)) 28%, rgba(255, 255, 255, 0.1));
  box-shadow:
    inset 0 2px 8px rgba(0, 0, 0, 0.18),
    0 0 12px color-mix(in srgb, var(--team-color, var(--primary)) 14%, transparent);
  transition: background 0.12s linear, box-shadow 0.25s ease, border-color 0.25s ease;
}

#screen-percent .answer-row.is-scrubbing .answer-slider::-webkit-slider-runnable-track {
  animation: percent-slider-track-glow-pulse 1s ease-in-out infinite alternate;
}

#screen-percent .answer-slider::-moz-range-track {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid color-mix(in srgb, var(--team-color, var(--primary)) 28%, rgba(255, 255, 255, 0.1));
  box-shadow:
    inset 0 2px 8px rgba(0, 0, 0, 0.18),
    0 0 12px color-mix(in srgb, var(--team-color, var(--primary)) 14%, transparent);
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

#screen-percent .answer-row.is-scrubbing .answer-slider::-moz-range-track {
  animation: percent-slider-track-glow-pulse 1s ease-in-out infinite alternate;
}

#screen-percent .answer-slider::-moz-range-progress {
  background: color-mix(in srgb, var(--team-color, var(--primary)) var(--fill-opacity, 60%), transparent);
  transition: background 0.12s linear;
}

.answer-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 48px;
  height: 64px;
  margin-top: 0;
  border-radius: 16px;
  background: transparent;
  border: none;
  box-shadow: none;
  cursor: pointer;
}

.answer-slider::-moz-range-thumb {
  width: 48px;
  height: 64px;
  border-radius: 16px;
  background: transparent;
  border: none;
  box-shadow: none;
  cursor: pointer;
}

.answer-input {
  display: none;
  background: transparent;
  border: none;
  border-radius: 0;
  color: var(--team-color, var(--text));
  font-size: 22px;
  font-family: inherit;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 0;
  width: 3.5ch;
  min-width: 2.5ch;
  text-align: right;
  outline: none;
  letter-spacing: -0.02em;
  box-shadow: none;
  -moz-appearance: textfield;
}

.answer-input:focus {
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--team-color, var(--primary)) 55%, transparent);
  text-underline-offset: 4px;
}

.answer-input::-webkit-outer-spin-button,
.answer-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Экран результата */
.result-correct-reveal {
  margin-bottom: 8px;
}

.result-correct-reveal.is-animating {
  filter: drop-shadow(0 0 28px rgba(251, 191, 36, 0.42));
}

.result-correct-bar {
  --correct-color: #fbbf24;
  background: linear-gradient(180deg, rgba(251, 191, 36, 0.2) 0%, rgba(251, 191, 36, 0.08) 100%);
  border: 1px solid rgba(253, 224, 71, 0.58);
  margin-bottom: 4px;
  text-align: left;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 0 28px rgba(251, 191, 36, 0.2);
  transition: background 300ms ease, border-color 300ms ease, box-shadow 300ms ease;
}

.result-correct-bar .answer-team-name {
  color: #ffffff;
  font-weight: 800;
  opacity: 1;
  -webkit-text-fill-color: #ffffff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.75);
  letter-spacing: 0.01em;
}

.result-correct-bar .answer-value,
.result-correct-bar-value {
  color: #ffffff;
  font-weight: 900;
  font-size: clamp(48px, 11vw, 60px);
  opacity: 1;
  -webkit-text-fill-color: #ffffff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.75);
  letter-spacing: -0.02em;
}

.result-correct-bar-track {
  width: 100%;
  height: 64px;
  margin-top: 10px;
  border-radius: 16px;
  border: 1px solid rgba(253, 224, 71, 0.42);
  background: rgba(0, 0, 0, 0.22);
  box-shadow:
    inset 0 2px 10px rgba(0, 0, 0, 0.34),
    0 0 16px rgba(251, 191, 36, 0.12);
  overflow: hidden;
  position: relative;
}

.result-correct-bar-track::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 10%;
  bottom: 10%;
  width: 2px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, transparent, rgba(250, 204, 21, 0.85), transparent);
  z-index: 2;
  pointer-events: none;
  box-shadow: 0 0 8px rgba(250, 204, 21, 0.45);
}

.result-correct-bar-track::after {
  content: '50';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 11px;
  font-weight: 800;
  color: rgba(250, 204, 21, 0.55);
  z-index: 2;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

.result-correct-bar-fill {
  height: 100%;
  width: 50%;
  border-radius: 16px;
  background: linear-gradient(90deg, #ea580c 0%, #fbbf24 45%, #fde68a 100%);
  box-shadow: inset 0 -4px 10px rgba(0, 0, 0, 0.18);
  will-change: width;
  transform: translateZ(0);
}

.result-correct-bar.is-rolling {
  background: rgba(251, 191, 36, 0.16);
  border-color: rgba(252, 211, 77, 0.72);
  box-shadow: 0 0 32px rgba(251, 191, 36, 0.28);
}

.result-correct-bar.is-rolling .result-correct-bar-value,
.result-correct-bar.is-rolling .answer-value {
  color: #ffffff;
  opacity: 1;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.65);
}

.result-correct-bar.is-rolling .answer-team-name {
  color: #ffffff;
  opacity: 1;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.65);
}

.result-correct-bar.is-revealed .result-correct-bar-value,
.result-correct-bar.is-revealed .answer-value {
  color: #ffffff;
  opacity: 1;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.65);
}

.result-correct-bar.is-revealed .answer-team-name {
  color: #ffffff;
  opacity: 1;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.65);
}

.result-correct-bar.is-rolling .result-correct-bar-track {
  border-color: rgba(253, 224, 71, 0.95);
  box-shadow:
    inset 0 0 18px rgba(251, 191, 36, 0.35),
    0 0 32px rgba(251, 191, 36, 0.55),
    0 0 56px rgba(245, 158, 11, 0.28);
  animation: result-correct-track-pulse 650ms ease-in-out infinite alternate;
}

.result-correct-bar.is-rolling .result-correct-bar-fill {
  background: linear-gradient(90deg, #c2410c 0%, #f59e0b 28%, #fbbf24 58%, #fef08a 100%);
  animation: result-correct-fill-shimmer 700ms ease-in-out infinite alternate;
  box-shadow:
    inset 0 0 16px rgba(255, 255, 255, 0.28),
    0 0 28px rgba(251, 191, 36, 0.72);
}

.result-correct-bar.is-revealed {
  background: rgba(251, 191, 36, 0.14);
  border-color: #fcd34d;
  box-shadow: 0 0 36px rgba(251, 191, 36, 0.32);
}

.result-correct-bar.is-revealed .result-correct-bar-track {
  border-color: #fde047;
  box-shadow:
    inset 0 0 22px rgba(251, 191, 36, 0.42),
    0 0 36px rgba(251, 191, 36, 0.68),
    0 0 64px rgba(245, 158, 11, 0.35);
}

.result-correct-bar.is-revealed .result-correct-bar-fill {
  background: linear-gradient(90deg, #d97706 0%, #fbbf24 50%, #fef9c3 100%);
  box-shadow:
    inset 0 -4px 10px rgba(0, 0, 0, 0.14),
    inset 0 0 18px rgba(255, 255, 255, 0.22),
    0 0 32px rgba(251, 191, 36, 0.85);
}

@keyframes result-correct-fill-shimmer {
  0% { filter: brightness(1); }
  100% { filter: brightness(1.22); }
}

@keyframes result-correct-track-pulse {
  0% {
    box-shadow:
      inset 0 0 14px rgba(251, 191, 36, 0.28),
      0 0 20px rgba(251, 191, 36, 0.38);
  }
  100% {
    box-shadow:
      inset 0 0 24px rgba(251, 191, 36, 0.48),
      0 0 40px rgba(251, 191, 36, 0.78),
      0 0 72px rgba(245, 158, 11, 0.38);
  }
}

.result-answer-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  padding: 22px 18px 28px;
  margin-bottom: 24px;
  text-align: center;
  overflow: hidden;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 12px 32px rgba(0, 0, 0, 0.3),
    0 0 24px rgba(124, 58, 237, 0.08);
}

.correct-value {
  font-size: 4.75rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.correct-value::after { content: '%'; font-size: 0.55em; margin-left: 4px; color: #fff; }

.results-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

@media (max-width: 479px) {
  .footer-bar {
    padding: 8px 0 calc(8px + var(--safe-bottom));
    gap: 6px;
  }

  .footer-bar .primary,
  .footer-bar .secondary {
    min-height: 48px;
    padding: 12px 14px;
    font-size: 15px;
    border-radius: 12px;
  }

  #screen-result .percent-panel-footer .secondary {
    min-height: 42px;
    padding: 10px 12px;
    font-size: 13px;
  }

  .result-answer-card {
    padding: 18px 14px 22px;
    margin-bottom: 16px;
  }

  .correct-value {
    font-size: 3.75rem;
  }
}

/* ========================================== */
/* Codenames — панель cn-page (как Процент)   */
/* ========================================== */

.cn-page .cn-chrome {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.cn-page .cn-board-card {
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.cn-page .cn-grid,
.cn-page #cap-map-area.captain-grid {
  width: 100%;
  max-width: 100%;
  margin: 0;
}

.cn-page .cap-header-status {
  margin-top: 0;
  width: 100%;
  min-width: 0;
}

.cn-page .cn-hints-widget {
  margin: 0;
  width: 100%;
}

/* Таблицы счёта скрыты в играх кроме Codenames (там — полоска «осталось слов») */
#screen-percent .percent-scoreboard,
#screen-result .percent-scoreboard,
.tw-page .percent-scoreboard,
.tone-page .percent-scoreboard,
.sp-page .percent-scoreboard {
  display: none !important;
}

.cn-page .cn-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.cn-page .cn-panel-body {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cn-page .cn-board-card {
  flex: 0 1 auto;
  min-height: 0;
  justify-content: flex-start;
  padding-top: 2px;
}

.cn-words-bar {
  flex-shrink: 0;
  width: 100%;
}

.cn-words-bar-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 8px;
  width: 100%;
}

.cn-words-chip {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--team-color, var(--primary)) 45%, transparent);
  background: color-mix(in srgb, var(--team-color, var(--primary)) 16%, var(--surface-glass));
}

.cn-words-chip.is-active-turn {
  border-color: color-mix(in srgb, var(--team-color, var(--primary)) 72%, white);
  box-shadow: 0 0 18px color-mix(in srgb, var(--team-color, var(--primary)) 35%, transparent);
}

.cn-words-name-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.cn-words-name {
  font-weight: 700;
  font-size: 14px;
  color: color-mix(in srgb, var(--team-color, var(--primary)) 88%, white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cn-words-turn-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  color: #fff;
  background: var(--team-color, var(--primary));
}

.cn-words-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--team-color, var(--primary));
  flex-shrink: 0;
}

.cn-page .cn-hints-widget {
  flex: 1 1 0;
  min-height: 0;
  margin-top: 0;
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
}

.cn-page .cn-hints-widget .cn-hints-history {
  flex: 1 1 0;
  min-height: 0;
  height: auto;
  max-height: none;
}

.cn-hints-widget--captain {
  padding-bottom: 12px;
}

.cn-hints-widget--captain .captain-hint-form {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 8px;
  margin-top: 10px;
  width: 100%;
  flex-shrink: 0;
}

.cn-hints-widget--captain .captain-hint-input {
  flex: 1;
  min-width: 0;
}

.cn-hints-widget--captain .captain-hint-form--locked {
  opacity: 0.55;
  pointer-events: none;
}

.cn-turn-banner {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(8, 8, 14, 0.58);
  backdrop-filter: blur(6px);
  animation: cn-turn-banner-in 380ms cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.cn-turn-banner.hidden {
  display: none !important;
}

.cn-turn-banner-inner {
  text-align: center;
  padding: 20px 24px;
  border-radius: 18px;
  background: color-mix(in srgb, var(--team-color, var(--primary)) 22%, var(--surface-glass));
  border: 1px solid color-mix(in srgb, var(--team-color, var(--primary)) 45%, transparent);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  max-width: min(92vw, 320px);
}

.cn-turn-banner-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: color-mix(in srgb, var(--team-color, var(--primary)) 88%, white);
}

.cn-turn-banner-subtitle {
  margin-top: 6px;
  font-size: 0.95rem;
  color: var(--text-muted);
}

@keyframes cn-turn-banner-in {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.cn-page.is-turn-intro .cn-board-card {
  filter: brightness(0.72);
}

.cn-page .cn-panel-footer {
  flex-direction: column;
  gap: 8px;
}

.cn-page .cn-panel-footer > * {
  flex: none;
  min-height: 48px;
}

.cn-page .captain-hint-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.game-card-meta {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.game-card-requirement {
  margin-top: 10px;
  font-weight: 500;
}

.game-card-status:empty {
  display: none;
}

.game-card[aria-disabled="true"] {
  opacity: 0.72;
  cursor: default;
}

.game-card[aria-disabled="true"]:active {
  transform: none;
}

.game-card[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.game-card[disabled]:hover {
  border-color: var(--border);
}

/* Статус-бар Codenames */
.cap-header-status {
  display: grid;
  grid-template-columns: minmax(0, auto) auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.cap-header-status--turn-only {
  grid-template-columns: minmax(0, 1fr);
}

.cap-header-status--turn-only .cap-turn-banner {
  width: 100%;
  max-width: 100%;
}

.cap-header-counts {
  flex-shrink: 0;
  gap: 6px;
}

.cap-header-status .cn-count {
  min-width: 34px;
  height: 34px;
  padding: 0 6px;
  font-size: 14px;
  border-radius: 10px;
}

.cap-turn-banner {
  min-width: 0;
  width: 100%;
  font-weight: 700;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid;
  background: rgba(var(--cn-team1-rgb, 225, 29, 72), 0.22);
  color: #fff;
  border-color: rgba(var(--cn-team1-rgb, 225, 29, 72), 0.48);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  box-sizing: border-box;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.cap-turn-banner.team2 {
  background: rgba(var(--cn-team2-rgb, 37, 99, 235), 0.22);
  border-color: rgba(var(--cn-team2-rgb, 37, 99, 235), 0.48);
}

.cap-turn-banner.game-over {
  background: color-mix(in srgb, var(--gold) 42%, transparent);
  color: #fff;
  border-color: color-mix(in srgb, var(--gold) 58%, transparent);
}

#screen-codenames .cap-header-status .cap-turn-banner,
#screen-codenames-captain .cap-header-status .cap-turn-banner {
  color: #fff;
  -webkit-text-stroke: 0.55px #000;
  paint-order: stroke fill;
  text-shadow:
    0 0 1px #000,
    1px 0 0 #000,
    -1px 0 0 #000,
    0 1px 0 #000,
    0 -1px 0 #000;
}

.captain-team-badge {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  min-width: 0;
  max-width: 100%;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: var(--captain-team-color, var(--cn-team1, #E11D48));
  border: 1px solid color-mix(in srgb, #fff 28%, transparent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.captain-team-badge.hidden {
  visibility: hidden;
  pointer-events: none;
}

.cn-new-layout-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: #d1d5db;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
}

.cn-new-layout-btn:hover,
.cn-new-layout-btn:focus-visible {
  color: #f3f4f6;
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.22);
}

.cn-new-layout-btn:active {
  transform: scale(0.94);
}

.cn-new-layout-btn.is-pending,
.cn-new-layout-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.cn-new-layout-btn-icon {
  display: block;
  width: 20px;
  height: 20px;
}

.cn-layout-request-text {
  margin: 0 0 16px;
  font-size: 15px;
  line-height: 1.45;
  color: var(--muted);
  text-align: center;
}

.cn-layout-request-team {
  font-weight: 700;
}

.cn-counts {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.cn-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  border-radius: 10px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: white;
  font-size: 15px;
}

.cn-count.team1 { background: var(--cn-team1, #E11D48); }
.cn-count.team2 { background: var(--cn-team2, #2563EB); }

/* Сетка 5×5 — равные зазоры по горизонтали и вертикали */
.cn-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-template-rows: repeat(5, minmax(0, 1fr));
  gap: 5px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin-bottom: 0;
  align-content: stretch;
}

.cn-cell {
  width: 100%;
  height: 100%;
  min-height: 0;
  min-width: 0;
  aspect-ratio: auto;
  padding: 0;
  border: none;
  background: transparent;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1;
  text-align: center;
  cursor: pointer;
  display: block;
  overflow: visible;
  position: relative;
  font-family: inherit;
  perspective: 720px;
  -webkit-tap-highlight-color: transparent;
  box-sizing: border-box;
}

.cn-cell-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.4, 0.2, 0.2, 1);
  border-radius: 8px;
  z-index: 1;
}

.cn-cell.is-flipped .cn-cell-inner {
  transform: rotateY(180deg);
}

.cn-cell.cn-cell--assassin-flip .cn-cell-inner {
  transition-duration: 0.9s;
  transition-timing-function: cubic-bezier(0.55, 0.08, 0.2, 1);
}

.cn-cell.cn-cell--assassin-flip.is-flipped {
  z-index: 2;
}

.cn-cell.cn-cell-glow--team.cn-cell-glow--animating .cn-cell-inner::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 8px;
  pointer-events: none;
  z-index: 3;
  opacity: 0;
  box-shadow:
    0 0 0 2px rgba(var(--cn-neon-rgb, 225, 29, 72), 1),
    0 0 14px rgba(var(--cn-neon-rgb, 225, 29, 72), 0.98),
    0 0 28px rgba(var(--cn-neon-rgb, 225, 29, 72), 0.82),
    0 0 46px rgba(var(--cn-neon-rgb, 225, 29, 72), 0.52),
    inset 0 0 24px rgba(var(--cn-neon-rgb, 225, 29, 72), 0.32);
  animation: cn-neon-rim 2s ease-in-out forwards;
}

.cn-cell.cn-cell-glow--wrong.cn-cell-glow--animating .cn-cell-inner::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 8px;
  pointer-events: none;
  z-index: 3;
  opacity: 0;
  box-shadow:
    0 0 0 2px rgba(var(--cn-neon-rgb, 255, 42, 42), 1),
    0 0 16px rgba(var(--cn-neon-rgb, 255, 42, 42), 1),
    0 0 32px rgba(var(--cn-neon-rgb, 255, 42, 42), 0.88),
    0 0 52px rgba(var(--cn-neon-rgb, 255, 42, 42), 0.58),
    inset 0 0 26px rgba(var(--cn-neon-rgb, 255, 42, 42), 0.36);
  animation: cn-neon-rim 2s ease-in-out forwards;
}

@keyframes cn-neon-rim {
  0%, 100% {
    opacity: 0;
  }
  12%, 78% {
    opacity: 1;
  }
}

.cn-page .cn-panel {
  position: relative;
}

.cn-panel-red-wash {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  border-radius: var(--radius-lg);
  opacity: 0;
  overflow: hidden;
}

.cn-panel-red-wash.is-running,
.cn-panel-red-wash.is-held {
  opacity: 1;
}

.cn-panel-red-wash::before {
  content: '';
  position: absolute;
  left: var(--cn-assassin-x, 50%);
  top: var(--cn-assassin-y, 50%);
  width: 420%;
  height: 420%;
  transform: translate(-50%, -50%) scale(0.04);
  transform-origin: center center;
  border-radius: 50%;
  opacity: 0;
  filter: blur(4px);
  background: radial-gradient(
    circle at center,
    rgba(255, 70, 70, 0.98) 0%,
    rgba(240, 25, 25, 0.82) 8%,
    rgba(210, 10, 10, 0.62) 18%,
    rgba(170, 0, 0, 0.42) 32%,
    rgba(120, 0, 0, 0.24) 48%,
    rgba(70, 0, 0, 0.1) 64%,
    transparent 78%
  );
}

.cn-panel-red-wash.is-running::before {
  animation: cn-assassin-radial-spread 4s ease-in-out forwards;
}

.cn-panel-red-wash::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0;
  background:
    radial-gradient(
      circle at var(--cn-assassin-x, 50%) var(--cn-assassin-y, 50%),
      rgba(160, 0, 0, 0.45) 0%,
      rgba(100, 0, 0, 0.32) 42%,
      rgba(60, 0, 0, 0.22) 68%,
      rgba(30, 0, 0, 0.12) 100%
    );
}

.cn-panel-red-wash.is-running::after {
  animation: cn-assassin-ambient-fill 4s ease-in-out forwards;
}

.cn-panel-red-wash.is-held::before {
  animation: none;
  transform: translate(-50%, -50%) scale(var(--cn-assassin-max-scale, 1.2));
  opacity: 1;
}

.cn-panel-red-wash.is-held::after {
  animation: none;
  opacity: 1;
}

@keyframes cn-assassin-radial-spread {
  0% {
    transform: translate(-50%, -50%) scale(0.04);
    opacity: 0.15;
  }
  100% {
    transform: translate(-50%, -50%) scale(var(--cn-assassin-max-scale, 1.2));
    opacity: 1;
  }
}

@keyframes cn-assassin-ambient-fill {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

#screen-codenames .cn-panel-body,
#screen-codenames .cn-panel-footer {
  position: relative;
  z-index: 1;
}

#screen-codenames .cn-grid {
  position: relative;
  z-index: 1;
}

@media (prefers-reduced-motion: reduce) {
  .cn-cell.cn-cell-glow--team.cn-cell-glow--animating .cn-cell-inner::after,
  .cn-cell.cn-cell-glow--wrong.cn-cell-glow--animating .cn-cell-inner::after {
    animation: none !important;
    opacity: 0;
  }

  .cn-panel-red-wash.is-running::before,
  .cn-panel-red-wash.is-held::before {
    animation: none !important;
    transform: translate(-50%, -50%) scale(var(--cn-assassin-max-scale, 1.2));
    opacity: 0.9;
  }

  .cn-panel-red-wash.is-running::after,
  .cn-panel-red-wash.is-held::after {
    animation: none !important;
    opacity: 0.85;
  }
}

.cn-cell-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0;
  box-sizing: border-box;
}

.cn-cell-front {
  transform: rotateY(0deg);
  color: #fff;
  background: #374151;
}

.cn-cell-back {
  transform: rotateY(180deg);
  color: #fff;
}

.cn-cell-back.team1 { background: var(--cn-team1, #E11D48); }
.cn-cell-back.team2 { background: var(--cn-team2, #2563EB); }
.cn-cell-back.neutral { background: #C9B58C; }
.cn-cell-back.assassin {
  background: #0a0a0a;
  color: #fff;
  border-color: #fff;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.18),
    0 0 18px rgba(0, 0, 0, 0.65);
}

.cn-cell:not(.is-flipped):active .cn-cell-inner {
  transform: scale(0.96);
}

.cn-cell.is-flipped,
.cn-cell.cn-cell--revealing {
  cursor: default;
  pointer-events: none;
}

.cn-cell.is-flipped.team1 .cn-cell-back,
.cn-cell.revealed.team1 .cn-cell-back { background: var(--cn-team1, #E11D48); }

.cn-cell.is-flipped.team2 .cn-cell-back,
.cn-cell.revealed.team2 .cn-cell-back { background: var(--cn-team2, #2563EB); }

.cn-cell.is-flipped.neutral .cn-cell-back,
.cn-cell.revealed.neutral .cn-cell-back { background: #C9B58C; }

.cn-cell.is-flipped.assassin .cn-cell-back,
.cn-cell.revealed.assassin .cn-cell-back {
  background: #0a0a0a;
  border-color: #fff;
}

#screen-codenames .cn-board-card,
#screen-codenames .cn-grid {
  overflow: visible;
}

/* Неоновое свечение крайних столбцов — не обрезать по бокам панели */
#screen-codenames.cn-page:not(.hidden),
#screen-codenames .cn-shell,
#screen-codenames .cn-panel,
#screen-codenames .cn-panel-body {
  overflow: visible;
}

#screen-codenames .cn-board-card {
  --cn-glow-bleed: 104px;
  box-sizing: border-box;
  width: calc(100% + var(--cn-glow-bleed));
  max-width: calc(100% + var(--cn-glow-bleed));
  margin-inline: calc(var(--cn-glow-bleed) / -2);
  padding-inline: calc(var(--cn-glow-bleed) / 2);
}

/* Внутренний span — всегда в одну строку; JS уменьшает font-size под ширину ячейки */
.cn-cell-text,
.captain-cell-text,
.cn-cell-face .cn-cell-text,
.cn-cell .cn-cell-text,
.cn-cell.is-flipped .cn-cell-text,
.cn-cell:not(.is-flipped) .cn-cell-text,
#screen-codenames .cn-cell .cn-cell-text,
#screen-codenames-captain .captain-cell-text,
#screen-codenames-captain .captain-card-front .captain-cell-text {
  display: inline-block;
  white-space: nowrap;
  transform-origin: center center;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  line-height: inherit;
  position: relative;
  z-index: 1;
  max-width: 100%;
  padding: 0 1px;
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
  -webkit-font-smoothing: antialiased;
  -webkit-text-stroke: 0 transparent;
  /* Классический CSS-контур: 8 направлений, blur=0 (без stroke — он даёт мыло на мелком тексте) */
  text-shadow:
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000,
    1px 1px 0 #000,
    -1px 0 0 #000,
    1px 0 0 #000,
    0 -1px 0 #000,
    0 1px 0 #000;
}

#screen-codenames .cn-cell .cn-cell-text {
  font-weight: 800;
  letter-spacing: 0;
}

#screen-codenames-captain .captain-cell-text,
#screen-codenames-captain .captain-card-front .captain-cell-text {
  font-weight: 800;
  letter-spacing: 0;
}


.cn-captain-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  text-decoration: none;
  color: inherit;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.cn-captain-btn.hidden {
  visibility: hidden;
  pointer-events: none;
}

.cn-captain-btn-spacer {
  visibility: hidden;
  pointer-events: none;
}

.cn-captain-btn-icon {
  font-size: 17px;
  font-weight: 800;
  line-height: 1;
  color: #fff;
  letter-spacing: -0.02em;
}

.cn-captain-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.22);
  transform: scale(1.05);
  text-decoration: none;
}

.cn-captain-btn:active {
  transform: scale(0.94);
}

.cn-captain-btn--local-turn {
  background: color-mix(in srgb, var(--cn-captain-btn-team, #E11D48) 30%, rgba(255, 255, 255, 0.08));
  border-color: color-mix(in srgb, var(--cn-captain-btn-team, #E11D48) 58%, rgba(255, 255, 255, 0.14));
}

.cn-captain-btn--local-turn:hover {
  background: color-mix(in srgb, var(--cn-captain-btn-team, #E11D48) 38%, rgba(255, 255, 255, 0.12));
  border-color: color-mix(in srgb, var(--cn-captain-btn-team, #E11D48) 65%, rgba(255, 255, 255, 0.22));
}

/* Настройка Codenames */
.dict-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--surface);
  padding: 6px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.dict-toggle button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
}

.dict-toggle button[aria-checked="true"] {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border);
}

.cn-seed-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.cn-seed-row input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 22px;
  font-family: inherit;
  font-weight: 700;
  padding: 12px 14px;
  outline: none;
  text-align: center;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}

.cn-seed-row input::-webkit-outer-spin-button,
.cn-seed-row input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.cn-seed-row input:focus { border-color: var(--primary); }

.cn-seed-row .secondary {
  padding: 0 16px;
  font-size: 14px;
  white-space: nowrap;
}

.cn-hint {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

/* Win-overlay */
.cn-winner-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  backdrop-filter: blur(6px);
}

.cn-winner-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 22px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  position: relative;
}

.cn-winner-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-dim);
  font-size: 22px;
  line-height: 1;
  font-weight: 400;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.cn-winner-close:hover,
.cn-winner-close:focus-visible {
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
  border-color: color-mix(in srgb, var(--text) 22%, var(--border));
  outline: none;
}

.cn-winner-card--highlighted {
  border: 2px solid var(--cn-winner-color, var(--gold));
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--cn-winner-color, #f4c542) 42%, transparent),
    0 0 24px color-mix(in srgb, var(--cn-winner-color, #f4c542) 36%, transparent),
    0 0 48px color-mix(in srgb, var(--cn-winner-color, #f4c542) 16%, transparent);
}

.cn-winner-emoji {
  font-size: 48px;
  margin-bottom: 8px;
  line-height: 1;
}

.cn-winner-title {
  font-size: 22px;
  font-weight: 800;
  margin: 0 0 16px;
  letter-spacing: -0.02em;
}

.cn-winner-title-label {
  color: var(--gold);
}

.cn-winner-title-team {
  color: var(--cn-winner-color, var(--text));
}

.cn-winner-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Codenames score modal additions */
.cn-score-bonus {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #f4c542;
  margin: 4px 0 14px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.cn-score-detail {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 16px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
}

.cn-score-detail--results {
  gap: 10px;
  text-align: left;
}

.cn-score-team {
  padding: 10px 10px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
}

.cn-score-team--winner {
  background: rgba(244, 197, 66, 0.08);
  border: 1px solid rgba(244, 197, 66, 0.18);
}

.cn-score-team-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.cn-score-team-title {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.cn-score-team-name {
  min-width: 0;
  font-size: 15px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cn-score-team-ready {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.cn-score-team-ready[hidden] {
  display: none !important;
}

.cn-cap-ready-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
}

.cn-cap-ready-icon {
  position: relative;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
  box-sizing: border-box;
}

.cn-cap-ready-icon--pending {
  border: 2px solid #6b7280;
  background: transparent;
}

.cn-cap-ready-icon--ready {
  border: none;
  background: linear-gradient(145deg, #4ade80 0%, #16a34a 55%, #15803d 100%);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.28),
    0 0 0 1px rgba(21, 128, 61, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.38);
}

.cn-cap-ready-icon--ready::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 47%;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2.5px 2.5px 0;
  transform: translate(-58%, -52%) rotate(45deg);
  filter: drop-shadow(0 0.5px 0 rgba(0, 0, 0, 0.15));
}

.cn-cap-ready-icon--exit {
  border: 2px solid #ef4444;
  background: #ef4444;
}

.cn-cap-ready-icon--exit::before,
.cn-cap-ready-icon--exit::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 2px;
  background: #fff;
  border-radius: 1px;
}

.cn-cap-ready-icon--exit::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.cn-cap-ready-icon--exit::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.cn-score-team-total {
  font-size: 22px;
  font-weight: 800;
  color: #f4c542;
  font-variant-numeric: tabular-nums;
}

.cn-score-breakdown {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cn-score-breakdown li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--text-dim);
}

.cn-score-breakdown strong {
  color: var(--text);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.cn-score-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
}

.cn-score-row > span:nth-child(2) {
  flex: 1;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cn-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

.cn-score-num {
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* Codenames active-team tint */
html, body {
  transition: background-color 280ms ease;
}

body.cn-tinted {
  background:
    radial-gradient(140% 90% at 50% 0%,
      rgba(var(--cn-tint, 255,255,255), 0.28) 0%,
      rgba(var(--cn-tint, 255,255,255), 0.12) 40%,
      rgba(var(--cn-tint, 255,255,255), 0.04) 70%,
      rgba(var(--cn-tint, 255,255,255), 0) 100%),
    var(--bg);
  background-attachment: fixed;
}

/* Two Words active-team tint (по аналогии с Codenames) */
body.tw-tinted {
  background:
    radial-gradient(140% 90% at 50% 0%,
      rgba(var(--tw-tint, 255,255,255), 0.42) 0%,
      rgba(var(--tw-tint, 255,255,255), 0.22) 35%,
      rgba(var(--tw-tint, 255,255,255), 0.08) 65%,
      rgba(var(--tw-tint, 255,255,255), 0) 100%),
    var(--bg);
  background-attachment: fixed;
}

body.tone-tinted {
  background:
    radial-gradient(140% 90% at 50% 0%,
      rgba(var(--tone-tint, 255, 255, 255), 0.38) 0%,
      rgba(var(--tone-tint, 255, 255, 255), 0.18) 38%,
      rgba(var(--tone-tint, 255, 255, 255), 0.06) 68%,
      rgba(var(--tone-tint, 255, 255, 255), 0) 100%),
    var(--bg);
  background-attachment: fixed;
}

#screen-twowords.tw-active-team-tint:not(.hidden) {
  background:
    radial-gradient(120% 80% at 50% 30%,
      rgba(var(--tw-tint, 255,255,255), 0.35) 0%,
      rgba(var(--tw-tint, 255,255,255), 0.14) 45%,
      rgba(var(--tw-tint, 255,255,255), 0.04) 75%,
      transparent 100%);
}

/* ========================================================
   Адаптив: телефон (по умолчанию) → планшет → ландшафт
   ======================================================== */

/* Ячейки доски — как у капитана */
.cn-cell,
.captain-cell {
  font-size: clamp(11px, 2.6vw, 18px);
}

/* Узкие телефоны (<360px) — ужимаем заголовки/кнопки */
@media (max-width: 359px) {
  .cn-cell,
  .captain-cell {
    font-size: 10px;
  }
  .screen-header h1 {
    font-size: 22px;
  }
}

/* Планшеты в портрете и крупные телефоны */
@media (min-width: 600px) {
  :root {
    --app-max-w: 640px;
  }

  #app {
    max-width: 640px;
  }
  .screen-header h1 {
    font-size: 32px;
  }
  .subtitle {
    font-size: 16px;
  }
  .primary, .secondary {
    font-size: 17px;
    padding: 16px 20px;
  }
  .cn-grid,
  .captain-grid {
    gap: 8px;
  }
  .cn-cell,
  .captain-cell {
    font-size: clamp(14px, 2.4vw, 20px);
    border-radius: 10px;
  }
  .cn-cell-inner,
  .captain-card-inner {
    border-radius: 10px;
  }
  .cn-cell-face,
  .captain-card-face {
    border-radius: 10px;
  }
  .cn-captain-btn {
    width: 44px;
    height: 44px;
  }
  .game-card-title {
    font-size: 19px;
  }
  .game-card-desc {
    font-size: 15px;
  }
}

/* Ландшафт: Codenames — chrome сверху, доска слева, footer справа */
@media (min-width: 700px) and (orientation: landscape) {
  #app {
    max-width: 1100px;
  }

  .cn-page .cn-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(240px, 300px);
    grid-template-rows: auto minmax(0, 1fr);
    column-gap: 20px;
    row-gap: 10px;
  }

  .cn-page .cn-panel-body {
    display: contents;
  }

  .cn-page .cn-chrome {
    grid-column: 1 / -1;
    grid-row: 1;
    margin-bottom: 0;
  }

  .cn-page .cn-board-card {
    grid-column: 1;
    grid-row: 2;
    margin: 0;
    min-height: 0;
  }

  .cn-page .cn-board-card .cn-grid,
  .cn-page .cn-board-card .captain-grid {
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 1 / 1;
    height: auto;
  }

  .cn-page .cn-cell,
  .cn-page .captain-card {
    aspect-ratio: auto;
    height: 100%;
    width: 100%;
    min-height: 0;
    padding: 0;
  }

  .cn-page .cn-cell,
  .cn-page .captain-cell {
    font-size: clamp(13px, 1.5vw, 19px);
  }

  .cn-page .cn-panel-footer {
    grid-column: 2;
    grid-row: 2;
    align-self: center;
    margin-top: 0;
    padding-top: 0;
    border-top: none;
    pointer-events: auto;
  }
}

/* Широкие экраны: доска заполняет панель, зазоры равномерные */
@media (min-width: 900px) {
  .cn-page .cn-board-card .cn-grid,
  .cn-page .cn-board-card .captain-grid {
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 1 / 1;
    height: auto;
    margin-inline: auto;
    gap: 7px;
    grid-template-rows: repeat(5, minmax(0, 1fr));
  }

  .cn-page .cn-cell,
  .cn-page .captain-card {
    aspect-ratio: auto;
    height: 100%;
    width: 100%;
    min-height: 0;
    padding: 0;
  }

  .cn-page .cn-cell,
  .cn-page .captain-cell {
    font-size: clamp(13px, 1.25vw, 18px);
  }
}

/* Компактный ландшафт на телефоне */
@media (orientation: landscape) and (max-height: 500px) {
  .cn-page .cn-chrome {
    margin-bottom: 4px;
    gap: 4px;
  }

  #session-header #session-header-title {
    font-size: 17px;
    margin: 0;
  }

  .cn-page .cn-board-card .cn-grid,
  .cn-page .cn-board-card .captain-grid {
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 1 / 1;
    height: auto;
    margin-inline: auto;
  }

  .cn-page .cn-cell,
  .cn-page .captain-card {
    padding: 0;
  }

  .cn-page .cn-cell,
  .cn-page .captain-cell {
    font-size: clamp(10px, 1.3vw, 14px);
  }
}

/* ========================================================
   Адаптив капитанской страницы
   ======================================================== */
.captain-cell {
  font-size: clamp(11px, 2.6vw, 18px);
}

@media (max-width: 359px) {
  .captain-cell {
    font-size: 10px;
  }
}

@media (min-width: 600px) {
  .captain-grid {
    gap: 8px !important;
  }
  .captain-cell {
    font-size: clamp(14px, 2.4vw, 20px);
    border-radius: 10px;
  }
}

/* ========================================================
   Игра «Два слова» (tw-page — как Процент / Codenames)
   ======================================================== */

#screen-twowords.tw-page.screen {
  padding-top: 8px;
  padding-bottom: calc(16px + var(--safe-bottom));
}

#screen-twowords.tw-page:not(.hidden) {
  display: flex;
  flex-direction: column;
  height: var(--app-panel-h);
  max-height: var(--app-panel-h);
  min-height: 0;
  overflow: hidden;
  background-color: transparent;
}

.tw-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.tw-panel-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tw-panel-body .tw-chrome {
  flex-shrink: 0;
  margin-bottom: 10px;
}

.tw-page .tw-chrome .percent-scoreboard {
  margin: 0 0 8px;
}

#screen-twowords.has-many-teams .tw-panel-body .percent-scoreboard {
  flex: 0 1 auto;
  min-height: 0;
  max-height: 38%;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.tw-panel-body .tw-board-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.tw-page .tw-panel-footer {
  flex-direction: column;
  gap: 8px;
  padding-top: 10px;
}

.tw-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 0;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
}

.tw-stage.controls-disabled .tw-timer-row {
  opacity: 1;
}

.tw-stage.controls-disabled .tw-timer {
  pointer-events: none;
}

.tw-hint {
  font-size: 14px;
  color: var(--text-muted, #9ca3af);
  text-align: center;
  max-width: 320px;
  margin: 0 auto;
}

.tw-play-area {
  position: relative;
  flex: 1;
  width: 100%;
  max-width: 100%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  padding: 4px 0;
}

.tw-turn-banner {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 28px 22px;
  text-align: center;
  border-radius: 20px;
  background: color-mix(in srgb, var(--team-color, var(--primary)) 24%, rgba(255, 255, 255, 0.06));
  border: 2px solid color-mix(in srgb, var(--team-color, var(--primary)) 58%, white);
  box-shadow:
    0 10px 36px color-mix(in srgb, var(--team-color, var(--primary)) 38%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  animation: tw-turn-banner-in 420ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tw-turn-banner.hidden {
  display: none;
}

.tw-turn-banner-scores,
.tw-turn-banner-result-rows {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  width: 100%;
  max-width: 320px;
}

.tw-turn-banner-heading {
  margin: 0 0 6px;
  font-size: clamp(22px, 5.5vw, 30px);
  font-weight: 800;
  line-height: 1.1;
  color: #fff;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.4);
}

.tw-turn-banner-result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid color-mix(in srgb, var(--team-color, var(--primary)) 35%, transparent);
}

.tw-turn-banner-result-name {
  font-size: clamp(16px, 4vw, 20px);
  font-weight: 700;
  line-height: 1.2;
  text-align: left;
  color: #fff;
}

.tw-turn-banner-score {
  font-size: clamp(28px, 7vw, 40px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.02em;
  flex-shrink: 0;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.35);
}

.tw-turn-banner-title {
  margin: 0;
  font-size: clamp(28px, 7vw, 44px);
  font-weight: 800;
  line-height: 1.1;
  color: #fff;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.45);
}

.tw-turn-banner-title.hidden {
  display: none;
}

.tw-turn-banner-subtitle {
  margin: 0;
  font-size: clamp(20px, 5vw, 28px);
  font-weight: 700;
  line-height: 1.2;
  word-break: break-word;
  color: var(--team-color, var(--primary));
  text-shadow: 0 2px 18px color-mix(in srgb, var(--team-color, var(--primary)) 45%, transparent);
}

@keyframes tw-turn-banner-in {
  0%   { transform: scale(0.92); opacity: 0; }
  65%  { transform: scale(1.03); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.tw-play-area.is-turn-intro .tw-words {
  visibility: hidden;
  pointer-events: none;
}

#tw-footer-bar.is-turn-intro .tw-decide-buttons {
  visibility: hidden;
  pointer-events: none;
  opacity: 0;
}

.tw-words {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
}

.tw-word {
  width: 100%;
  background: color-mix(in srgb, var(--tw-team, var(--primary)) 32%, rgba(255, 255, 255, 0.06));
  border: 2px solid color-mix(in srgb, var(--tw-team, var(--primary)) 52%, rgba(255, 255, 255, 0.14));
  border-radius: 18px;
  padding: 26px 20px;
  text-align: center;
  font-size: clamp(28px, 7vw, 44px);
  font-weight: 800;
  letter-spacing: 0.01em;
  word-break: break-word;
  text-transform: lowercase;
  color: #fff;
  box-shadow:
    0 8px 28px color-mix(in srgb, var(--tw-team, var(--primary)) 24%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: transform 220ms cubic-bezier(0.34, 1.56, 0.64, 1), border-color 220ms ease, background 220ms ease;
  will-change: transform;
}

.tw-word.is-fresh {
  animation: tw-word-in 380ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes tw-word-in {
  0%   { transform: translateY(8px) scale(0.94); opacity: 0; }
  60%  { transform: translateY(0) scale(1.03); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

.tw-word-plus {
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  color: var(--text-muted, #9ca3af);
  line-height: 1;
  margin: 2px 0;
}

/* Таймер — убывающее кольцо + пауза */
.tw-timer-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 100%;
  min-height: 96px;
  flex-shrink: 0;
}

.tw-timer {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
}

.tw-timer-ring {
  position: relative;
  width: 88px;
  height: 88px;
  flex-shrink: 0;
}

.tw-timer.is-idle .tw-timer-ring-track {
  stroke: rgba(255, 255, 255, 0.14);
}

.tw-timer.is-idle .tw-timer-ring-progress {
  opacity: 0.72;
}

.tw-timer.is-paused .tw-timer-value {
  opacity: 0.88;
}

.tw-timer.is-expiring {
  animation: tw-timer-expire-pulse 2s ease-in-out forwards;
}

.tw-timer.is-expiring .tw-timer-ring {
  animation: tw-timer-ring-expire 2s ease-in-out forwards;
}

.tw-timer.is-expiring .tw-timer-ring-progress {
  animation: tw-timer-ring-stroke-expire 2s ease-in-out forwards;
}

.tw-timer.is-expiring .tw-timer-value {
  animation: tw-timer-value-expire 2s ease-in-out forwards;
}

@keyframes tw-timer-expire-pulse {
  0%, 100% { transform: scale(1); }
  15% { transform: scale(1.1); }
  30% { transform: scale(0.96); }
  45% { transform: scale(1.08); }
  60% { transform: scale(0.98); }
  75% { transform: scale(1.05); }
}

@keyframes tw-timer-ring-expire {
  0%, 100% { filter: drop-shadow(0 0 0 transparent); }
  20% { filter: drop-shadow(0 0 16px rgba(239, 68, 68, 0.75)); }
  40% { filter: drop-shadow(0 0 24px rgba(239, 68, 68, 0.95)); }
  60% { filter: drop-shadow(0 0 14px rgba(249, 115, 22, 0.7)); }
  80% { filter: drop-shadow(0 0 20px rgba(239, 68, 68, 0.85)); }
}

@keyframes tw-timer-ring-stroke-expire {
  0%, 100% { stroke: rgb(239, 68, 68); stroke-width: 5; }
  25% { stroke: rgb(254, 202, 202); stroke-width: 6; }
  50% { stroke: rgb(239, 68, 68); stroke-width: 7; }
  75% { stroke: rgb(249, 115, 22); stroke-width: 6; }
}

@keyframes tw-timer-value-expire {
  0%, 100% { transform: scale(1); color: rgb(239, 68, 68); }
  25% { transform: scale(1.25); color: rgb(254, 202, 202); }
  50% { transform: scale(1.15); color: rgb(239, 68, 68); }
  75% { transform: scale(1.2); color: rgb(252, 165, 165); }
}

.tw-timer-pause-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: #f3f4f6;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
}

.tw-timer-pause-btn:hover:not(:disabled),
.tw-timer-pause-btn:focus-visible {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.28);
}

.tw-timer-pause-btn:active:not(:disabled) {
  transform: scale(0.94);
}

.tw-timer-pause-btn:disabled {
  opacity: 0.38;
  cursor: default;
}

.tw-timer-pause-btn.is-paused {
  color: #fde68a;
  border-color: rgba(250, 204, 21, 0.35);
  background: rgba(250, 204, 21, 0.12);
}

.tw-timer-pause-btn svg {
  display: block;
}

.tw-timer-pause-btn svg.hidden {
  display: none;
}

.tw-stage.controls-disabled .tw-timer-pause-btn {
  pointer-events: none;
  opacity: 0.38;
}

.tw-timer-svg {
  display: block;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.tw-timer-ring-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 5;
}

.tw-timer-ring-progress {
  fill: none;
  stroke: #fff;
  stroke-width: 5;
  stroke-linecap: round;
  transition: stroke 120ms linear;
}

.tw-timer-value {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #fff;
  line-height: 1;
  pointer-events: none;
}

.tw-decide-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  flex-shrink: 0;
  margin: 0;
  padding: 0;
}

.tw-btn-match,
.tw-btn-miss {
  position: relative;
  padding: 36px 18px;
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  overflow: hidden;
  transition: transform 140ms cubic-bezier(0.34, 1.56, 0.64, 1), filter 140ms ease, box-shadow 200ms ease;
  will-change: transform;
}

.tw-btn-match:disabled,
.tw-btn-miss:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
  transform: none;
  filter: none;
}

.tw-btn-match {
  background: #FACC15; /* жёлтая */
  color: #1a1a1a;
  box-shadow: 0 6px 0 rgba(202, 138, 4, 0.55), 0 10px 24px rgba(250, 204, 21, 0.25);
}

.tw-btn-miss {
  background: #EF4444; /* красная */
  color: #fff;
  box-shadow: 0 6px 0 rgba(153, 27, 27, 0.6), 0 10px 24px rgba(239, 68, 68, 0.25);
}

.tw-btn-match:hover { filter: brightness(1.05); transform: translateY(-1px); }
.tw-btn-miss:hover  { filter: brightness(1.05); transform: translateY(-1px); }

.tw-btn-match:active,
.tw-btn-miss:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35), 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Яркая вспышка после нажатия (Совпало — радость) */
.tw-btn-match.is-pop {
  animation: tw-pop 460ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes tw-pop {
  0%   { transform: scale(1); box-shadow: 0 6px 0 rgba(202, 138, 4, 0.55), 0 10px 24px rgba(250, 204, 21, 0.25); }
  18%  { transform: scale(0.94); }
  45%  { transform: scale(1.07); box-shadow: 0 8px 0 rgba(202, 138, 4, 0.55), 0 14px 36px rgba(250, 204, 21, 0.55); }
  70%  { transform: scale(0.99); }
  100% { transform: scale(1); box-shadow: 0 6px 0 rgba(202, 138, 4, 0.55), 0 10px 24px rgba(250, 204, 21, 0.25); }
}

/* Встряхивание кнопки "Ещё +1" + яркий флеш */
.tw-btn-miss.is-shake {
  animation: tw-shake 460ms cubic-bezier(0.36, 0.07, 0.19, 0.97);
}
@keyframes tw-shake {
  0%   { transform: translate3d(0, 0, 0); }
  15%  { transform: translate3d(-6px, 0, 0); box-shadow: 0 6px 0 rgba(153, 27, 27, 0.6), 0 14px 36px rgba(239, 68, 68, 0.55); }
  30%  { transform: translate3d(6px, 0, 0); }
  45%  { transform: translate3d(-5px, 0, 0); }
  60%  { transform: translate3d(5px, 0, 0); }
  75%  { transform: translate3d(-3px, 0, 0); }
  90%  { transform: translate3d(2px, 0, 0); }
  100% { transform: translate3d(0, 0, 0); }
}

/* Планшет и ПК */
@media (min-width: 600px) {
  .tw-words { max-width: 420px; }
  .tw-word { padding: 32px 22px; font-size: clamp(32px, 5vw, 48px); }

  .tw-timer-row {
    min-height: 104px;
    gap: 16px;
  }

  .tw-timer-ring {
    width: 96px;
    height: 96px;
  }

  .tw-timer-value {
    font-size: 30px;
  }

  .tw-timer-pause-btn {
    width: 52px;
    height: 52px;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .tw-word {
    padding: 18px 14px;
    font-size: clamp(22px, 3.5vw, 36px);
    border-radius: 14px;
  }

  .tw-word-plus { font-size: 22px; }

  .tw-timer-row {
    min-height: 84px;
    gap: 10px;
  }

  .tw-timer-ring {
    width: 72px;
    height: 72px;
  }

  .tw-timer-value {
    font-size: 24px;
  }

  .tw-timer-pause-btn {
    width: 44px;
    height: 44px;
  }

  .tw-btn-match, .tw-btn-miss {
    padding: 12px 14px;
    font-size: 14px;
  }
}

/* ========================================================
   Игра «Цвет персонажа» (tone-page)
   ======================================================== */

#screen-tooncolor.tone-page.screen {
  padding-top: 8px;
  padding-bottom: calc(16px + var(--safe-bottom));
}

#screen-tooncolor.tone-page:not(.hidden) {
  display: flex;
  flex-direction: column;
  height: var(--app-panel-h);
  max-height: var(--app-panel-h);
  min-height: 0;
  overflow: hidden;
  background-color: transparent;
}

.tone-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.tone-panel-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tone-panel-body .tone-chrome {
  flex-shrink: 0;
  margin-bottom: 10px;
}

.tone-page .tone-chrome .percent-scoreboard {
  margin: 0 0 8px;
}

#screen-tooncolor.has-many-teams .tone-panel-body .percent-scoreboard {
  flex: 0 1 auto;
  min-height: 0;
  max-height: 38%;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.tone-panel-body .tone-board-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 2px 0;
}

.tone-page .tone-panel-footer {
  flex-direction: column;
  gap: 8px;
  padding-top: 10px;
}

.tone-preview-wrap {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  flex-shrink: 0;
}

.tone-art-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 16px;
  border: 2px solid rgba(255, 255, 255, 0.92);
  box-shadow:
    0 10px 32px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  background: #fff;
  overflow: hidden;
}

.tone-art-fill,
.tone-art-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.tone-art-fill {
  z-index: 0;
  background-color: #808080;
  transition: background-color 80ms linear;
}

.tone-art-overlay {
  z-index: 2;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

.tone-preview-hex {
  align-self: center;
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}

.tone-sliders {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.tone-slider-bank {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(8px, 2.5vw, 14px);
  align-items: stretch;
  justify-content: center;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
}

.tone-slider-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-height: 0;
  height: 100%;
  padding: 10px 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  cursor: default;
}

.tone-slider-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-dim);
}

.tone-slider-shell {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  max-width: 108px;
  min-height: 120px;
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #111318;
  box-shadow:
    0 6px 18px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.tone-slider-track,
.tone-slider-input {
  position: absolute;
  inset: 0;
}

.tone-slider-track--hue {
  background: linear-gradient(to bottom, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
  transform: scaleY(-1);
}

.tone-slider-thumb {
  position: absolute;
  left: 50%;
  z-index: 4;
  width: calc(100% - 10px);
  height: 10px;
  background: #f8fafc;
  border: 2px solid rgba(12, 11, 15, 0.92);
  border-radius: 6px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.tone-slider-input {
  z-index: 5;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  writing-mode: vertical-lr;
  direction: rtl;
}

.tone-slider-input:disabled {
  cursor: not-allowed;
}

.tone-slider-card:has(.tone-slider-input:disabled) {
  opacity: 0.45;
}

.tone-reveal {
  padding: 12px 8px 4px;
}

.tone-reveal-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}

.tone-reveal-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.tone-reveal-caption {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.tone-reveal-swatch {
  width: 100%;
  max-width: 88px;
  aspect-ratio: 1;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}

.tone-reveal-hex {
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
}

.tone-reveal-teams {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tone-reveal-team-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
}

.tone-reveal-team-row.is-best {
  border-color: color-mix(in srgb, var(--team-color, #fff) 55%, rgba(255, 255, 255, 0.2));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--team-color, #fff) 25%, transparent);
}

.tone-reveal-team-row--answer {
  margin-top: 4px;
  opacity: 0.92;
}

.tone-reveal-team-name {
  font-size: 14px;
  font-weight: 700;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tone-reveal-team-swatch {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.85);
}

.tone-reveal-team-pct {
  font-size: 16px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  min-width: 3.5rem;
  text-align: right;
}

.tone-reveal-score {
  font-size: clamp(2rem, 8vw, 2.75rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
  text-shadow: 0 0 20px rgba(251, 191, 36, 0.35);
  line-height: 1;
}

.tone-finished {
  text-align: center;
  padding: 8px 0 4px;
}

.tone-finished-title {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 800;
}

.tone-finished-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.tone-finished-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  font-weight: 600;
}

#screen-tooncolor.tone-controls-locked .tone-sliders,
#screen-tooncolor.tone-controls-locked #tone-submit-btn {
  pointer-events: none;
  opacity: 0.45;
}

/* ========================================================
   Игра «Сапёр» (sp-page)
   ======================================================== */

#screen-sapper.sp-page.screen {
  padding-top: 8px;
  padding-bottom: calc(16px + var(--safe-bottom));
}

#screen-sapper.sp-page:not(.hidden) {
  display: flex;
  flex-direction: column;
  height: var(--app-panel-h);
  max-height: var(--app-panel-h);
  min-height: 0;
  overflow: hidden;
  background-color: transparent;
}

.sp-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sp-panel-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sp-panel-body .sp-chrome {
  flex-shrink: 0;
  margin-bottom: 10px;
}

.sp-page .sp-chrome .percent-scoreboard {
  margin: 0 0 8px;
}

.sp-page .percent-score-chip {
  align-items: flex-start;
}

.sp-page .percent-score-name-wrap {
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  overflow: visible;
}

.sp-page .percent-score-status-badge {
  max-width: 100%;
  white-space: normal;
  text-align: left;
  line-height: 1.25;
}

#screen-sapper.has-many-teams .sp-panel-body .percent-scoreboard {
  flex: 0 1 auto;
  min-height: 0;
  max-height: 38%;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.sp-panel-body .sp-board-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 2px 0;
}

.sp-page .sp-panel-footer {
  flex-direction: column;
  gap: 8px;
  padding-top: 10px;
}

.sp-roles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  flex-shrink: 0;
}

.sp-role-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
}

.sp-role-card--explainer {
  border-color: rgba(251, 191, 36, 0.35);
}

.sp-role-card--guesser {
  border-color: rgba(59, 130, 246, 0.35);
}

.sp-role-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.65;
}

.sp-role-name {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.25;
}

.sp-hint {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  opacity: 0.85;
}

.sp-wait-title {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 800;
}

.sp-wait-text {
  margin: 0;
  font-size: 14px;
  opacity: 0.8;
  line-height: 1.45;
}

.sp-form-title {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 700;
}

.sp-mine-inputs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.sp-mine-inputs input,
.sp-mine-team-block input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font-size: 16px;
}

.sp-mine-team-block {
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sp-mine-team-block:last-child {
  border-bottom: none;
}

.sp-mine-team-title {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 800;
}

.sp-mining-progress {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sp-mining-progress li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
}

.sp-mining-progress li.is-done {
  color: var(--green);
}

.sp-secret {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 16px;
  border-radius: var(--radius-sm);
  border: 2px solid rgba(251, 191, 36, 0.45);
  background: rgba(251, 191, 36, 0.08);
  text-align: center;
}

.sp-secret-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.7;
}

.sp-secret-word {
  font-size: clamp(1.75rem, 7vw, 2.25rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--gold);
}

.sp-miner-strips {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sp-miner-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.08);
}

.sp-miner-strip-label {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
}

.sp-btn-stop {
  flex-shrink: 0;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: none;
  background: linear-gradient(180deg, #ef4444 0%, #b91c1c 100%);
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.sp-btn-stop:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.sp-result-title {
  margin: 0 0 8px;
  font-size: clamp(1.25rem, 5vw, 1.5rem);
  font-weight: 900;
  text-align: center;
}

.sp-result-title.is-boom {
  color: #f87171;
}

.sp-result-title.is-success {
  color: var(--green);
}

.sp-result-detail,
.sp-result-scoring {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  text-align: center;
  opacity: 0.85;
}

.sp-stop-prompt {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.45;
}

.sp-stop-word-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sp-stop-word-btn {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.12);
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}

.sp-stop-word-btn:active {
  transform: scale(0.98);
}

.sp-word-stage {
  display: block;
  width: 100%;
  margin-bottom: 14px;
  flex-shrink: 0;
}

.sp-word-stage.hidden {
  display: none;
}

.sp-word-card {
  display: block;
  width: 100%;
  min-height: 104px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: default;
  perspective: 720px;
}

.sp-word-card.is-actionable {
  cursor: pointer;
}

.sp-word-card.is-actionable:not(:disabled):active {
  transform: scale(0.99);
}

.sp-word-card-inner {
  display: block;
  position: relative;
  width: 100%;
  min-height: 104px;
  transform-style: preserve-3d;
  transition: transform 0.45s ease;
}

.sp-word-card.is-flipped .sp-word-card-inner {
  transform: rotateY(180deg);
}

.sp-word-card-face {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: absolute;
  inset: 0;
  width: 100%;
  padding: 18px 16px;
  border-radius: var(--radius-sm);
  border: 2px solid rgba(251, 191, 36, 0.5);
  background: rgba(251, 191, 36, 0.12);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-sizing: border-box;
}

.sp-word-card-face--back {
  transform: rotateY(180deg);
  border-color: rgba(34, 197, 94, 0.55);
  background: rgba(34, 197, 94, 0.14);
}

.sp-word-card-caption {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.55);
}

.sp-word-card-text {
  width: 100%;
  font-size: clamp(2rem, 9vw, 2.75rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  text-align: center;
  line-height: 1.1;
  word-break: break-word;
  color: #fcd34d;
  text-shadow: 0 0 24px rgba(251, 191, 36, 0.35);
}

.sp-word-card.is-guesser-hidden .sp-word-card-text {
  color: rgba(255, 255, 255, 0.35);
  text-shadow: none;
}

.sp-mine-grid--edit {
  width: 100%;
}

.sp-mine-inputs-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.sp-mine-input-wrap {
  display: block;
  width: 100%;
}

.sp-mine-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(0, 0, 0, 0.32);
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
  text-align: center;
}

.sp-mine-input::placeholder {
  color: rgba(255, 255, 255, 0.35);
  font-weight: 500;
}

.sp-mine-input:focus {
  outline: none;
  border-color: rgba(251, 191, 36, 0.55);
  background: rgba(0, 0, 0, 0.42);
}

.sp-mine-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sp-mine-grid-title {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  opacity: 0.85;
}

.sp-mine-grid-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

@media (max-width: 520px) {
  .sp-mine-grid-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.sp-mine-card {
  aspect-ratio: 3 / 4;
  padding: 0;
  border: none;
  background: transparent;
  cursor: default;
  perspective: 640px;
  min-height: 72px;
}

.sp-mine-card.is-actionable {
  cursor: pointer;
}

.sp-mine-card.is-actionable:not(:disabled):hover {
  filter: brightness(1.08);
}

.sp-mine-card-inner {
  display: block;
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 72px;
  transform-style: preserve-3d;
  transition: transform 0.45s ease;
}

.sp-mine-card.is-flipped .sp-mine-card-inner {
  transform: rotateY(180deg);
}

.sp-mine-card-face {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  inset: 0;
  padding: 8px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  word-break: break-word;
}

.sp-mine-card-face--back {
  transform: rotateY(180deg);
  border-color: rgba(239, 68, 68, 0.55);
  background: rgba(239, 68, 68, 0.16);
  color: #fecaca;
}

.sp-mine-card.is-boom .sp-mine-card-face--back {
  border-color: rgba(239, 68, 68, 0.75);
  background: rgba(239, 68, 68, 0.28);
}

.sp-mine-card-icon {
  font-size: 1.35rem;
  line-height: 1;
}

.sp-mine-card-face input {
  width: 100%;
  padding: 6px 4px;
  border: none;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

.sp-mine-party-submit {
  margin-top: 4px;
}

#screen-sapper .sp-board-card .primary,
#screen-sapper .sp-board-card .sp-mine-card,
#screen-sapper .sp-board-card .sp-word-card {
  pointer-events: auto;
  opacity: 1;
}

#screen-sapper.sp-controls-blocked .sp-panel-footer {
  pointer-events: none;
  opacity: 0.5;
}

/* ========================================================
   Игра «Случайный выбор»
   ======================================================== */

#screen-random:not(.hidden) {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 32px;
  color: #fff;
}

#screen-random .screen-header--compact h1,
#screen-random .rnd-block-title,
#screen-random .rnd-max-label,
#screen-random .rnd-display,
#screen-random .rnd-number-placeholder,
#screen-random .rnd-players-empty,
#screen-random .rnd-lottery-chip,
#screen-random .rnd-slot-cell,
#screen-random #rnd-guest-input,
#screen-random .back-btn--inline {
  color: #fff;
}

#screen-random .rnd-display.is-result {
  color: #fff;
}

#screen-random .rnd-lottery-chip.is-excluded {
  color: rgba(255, 255, 255, 0.52);
}

#screen-random #rnd-guest-input::placeholder {
  color: rgba(255, 255, 255, 0.48);
}

#screen-random .screen-header--compact {
  margin-bottom: 4px;
}

#screen-random .screen-header--compact h1 {
  margin-bottom: 0;
}

.rnd-num-settings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.rnd-num-setting {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.rnd-num-stepper {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.rnd-num-stepper-btn {
  appearance: none;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.rnd-num-stepper-btn:active {
  transform: scale(0.96);
  background: rgba(255, 255, 255, 0.10);
}

.rnd-num-stepper input {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  border-radius: 10px;
  padding: 8px 6px;
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-family: inherit;
  flex: 1;
  min-width: 0;
  width: 100%;
  text-align: center;
  -moz-appearance: textfield;
}

.rnd-num-stepper input::-webkit-outer-spin-button,
.rnd-num-stepper input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.rnd-num-stepper input:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.32);
  background: rgba(255, 255, 255, 0.10);
}

.rnd-slots-wrap {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 10px;
  box-sizing: border-box;
  pointer-events: none;
}

.rnd-slots-wrap.hidden {
  display: none;
}

.rnd-slots-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--rnd-slots-gap, 12px);
  flex-wrap: nowrap;
  width: 100%;
  max-width: 100%;
}

.rnd-slot-window {
  width: var(--rnd-slot-w, 72px);
  height: var(--rnd-slot-cell-h, 64px);
  flex-shrink: 1;
  min-width: 0;
  overflow: hidden;
  border-radius: 12px;
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  border: 2px solid rgba(251, 191, 36, 0.5);
  box-shadow:
    inset 0 12px 20px rgba(0, 0, 0, 0.55),
    inset 0 -12px 20px rgba(0, 0, 0, 0.55),
    0 4px 16px rgba(0, 0, 0, 0.35);
  position: relative;
}

.rnd-slot-window::before,
.rnd-slot-window::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: calc(var(--rnd-slot-cell-h, 64px) * 0.22);
  z-index: 1;
  pointer-events: none;
}

.rnd-slot-window::before {
  top: 0;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.75), transparent);
}

.rnd-slot-window::after {
  bottom: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.75), transparent);
}

.rnd-slot-reel {
  display: flex;
  flex-direction: column;
  will-change: transform;
}

.rnd-slot-cell {
  height: var(--rnd-slot-cell-h, 64px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(22px, 6vw, 34px);
  font-weight: 800;
  color: #fef3c7;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
}

.rnd-number-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(44px, 11vw, 72px);
  font-weight: 900;
  color: var(--text-muted, #9ca3af);
}

.rnd-number-placeholder.hidden {
  display: none;
}

.rnd-block-screen {
  position: relative;
  flex: 1 1 0;
  min-height: 128px;
  overflow: hidden;
  box-sizing: border-box;
}

.rnd-num-display {
  position: relative;
  flex-direction: column;
  font-variant-numeric: tabular-nums;
  text-transform: none;
  padding: 0;
}

.rnd-num-display.is-rolling {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.12);
}

.rnd-num-display.has-result {
  padding: 0;
}


.rnd-block {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 300px;
}

.rnd-block-footer {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: auto;
}

.rnd-block--player .rnd-players {
  max-height: 80px;
  overflow-y: auto;
}

.rnd-block-title {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--text-muted, #9ca3af);
}

/* Дисплеи результата */
.rnd-display {
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 22px 18px;
  text-align: center;
  font-size: clamp(22px, 5.5vw, 34px);
  font-weight: 800;
  line-height: 1.15;
  word-break: break-word;
  text-transform: lowercase;
  color: var(--text-muted, #9ca3af);
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.rnd-word-display {
  padding: 22px 18px;
  line-height: 1.2;
}

.rnd-oracle-display {
  text-transform: none;
  font-size: clamp(18px, 4.5vw, 26px);
  line-height: 1.25;
  padding: 22px 18px;
}

.rnd-display.is-result {
  background: rgba(255, 255, 255, 0.06);
  border-style: solid;
  border-color: rgba(255, 255, 255, 0.18);
  color: #fff;
}


.rnd-player-display {
  position: relative;
  text-transform: none;
  font-size: clamp(22px, 5vw, 32px);
  padding: 0;
}

.rnd-player-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(28px, 7vw, 44px);
  font-weight: 900;
  color: var(--text-muted, #9ca3af);
}

.rnd-player-placeholder.hidden {
  display: none;
}

.rnd-player-display.is-rolling {
  border-style: solid;
  border-color: rgba(251, 191, 36, 0.55);
  background: rgba(251, 191, 36, 0.08);
  box-shadow:
    inset 0 0 28px rgba(251, 191, 36, 0.14),
    0 0 32px rgba(251, 191, 36, 0.2);
}

.rnd-player-display.has-result {
  border-style: solid;
  border-color: rgba(251, 191, 36, 0.42);
  background: rgba(251, 191, 36, 0.06);
  box-shadow: 0 0 28px rgba(251, 191, 36, 0.16);
}

.rnd-player-slots-wrap {
  align-items: stretch;
  justify-content: center;
  padding: 8px 0;
}

.rnd-player-slots-stage {
  width: 100%;
  align-self: stretch;
}

.rnd-player-slot {
  width: 100%;
  min-width: 0;
}

.rnd-player-slot-window {
  width: 100%;
  flex-shrink: 0;
  border-color: rgba(251, 191, 36, 0.7);
  box-shadow:
    inset 0 12px 20px rgba(0, 0, 0, 0.55),
    inset 0 -12px 20px rgba(0, 0, 0, 0.55),
    0 0 22px rgba(251, 191, 36, 0.38);
  animation: rnd-player-window-spin 700ms ease-in-out infinite alternate;
}

.rnd-player-slot-window.is-revealed {
  animation: rnd-player-window-reveal 420ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.rnd-player-slot-cell {
  font-size: clamp(18px, 4.5vw, 28px);
  text-transform: none;
  font-variant-numeric: normal;
  padding: 0 12px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@keyframes rnd-player-window-spin {
  0% {
    border-color: rgba(251, 191, 36, 0.45);
    box-shadow:
      inset 0 12px 20px rgba(0, 0, 0, 0.55),
      inset 0 -12px 20px rgba(0, 0, 0, 0.55),
      0 0 14px rgba(251, 191, 36, 0.28);
  }
  100% {
    border-color: rgba(252, 211, 77, 0.95);
    box-shadow:
      inset 0 0 16px rgba(251, 191, 36, 0.22),
      0 0 32px rgba(251, 191, 36, 0.62),
      0 0 48px rgba(245, 158, 11, 0.28);
  }
}

@keyframes rnd-player-window-reveal {
  0% {
    border-color: rgba(252, 211, 77, 0.85);
    box-shadow:
      inset 0 0 16px rgba(251, 191, 36, 0.25),
      0 0 28px rgba(251, 191, 36, 0.5);
  }
  100% {
    border-color: #fcd34d;
    box-shadow:
      inset 0 0 22px rgba(251, 191, 36, 0.42),
      0 0 36px rgba(251, 191, 36, 0.72),
      0 0 56px rgba(245, 158, 11, 0.35);
  }
}

.rnd-display.is-result.rnd-pulse {
  animation: rnd-pulse 320ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes rnd-pulse {
  0%   { transform: scale(0.96); }
  60%  { transform: scale(1.025); }
  100% { transform: scale(1); }
}

/* Кнопки */
.rnd-buttons {
  display: grid;
  gap: 10px;
}

.rnd-buttons.two {
  grid-template-columns: 1fr 1fr;
}

.rnd-btn {
  padding: 14px 18px;
  border: none;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease, background 120ms ease;
  font-family: inherit;
}

.rnd-btn:active { transform: scale(0.97); }
.rnd-btn:hover { filter: brightness(1.06); }
.rnd-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: none;
  transform: none;
}

.rnd-btn.primary-tone {
  background: #3B82F6;
  color: #fff;
}
.rnd-btn.accent-tone {
  background: #FACC15;
  color: #1a1a1a;
}
.rnd-btn.full {
  width: 100%;
}

.rnd-max-label {
  font-size: 13px;
  color: var(--text-muted, #9ca3af);
  text-align: center;
  width: 100%;
}

.rnd-slot-cell--idle {
  color: var(--text-muted, #9ca3af);
}

.rnd-hint-line {
  font-size: 12px;
  color: var(--text-muted, #9ca3af);
  text-align: center;
  margin-top: -4px;
}

/* Блок жребия */
.rnd-lottery-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
}

#rnd-guest-input {
  flex: 1;
  min-width: 0;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
}

#rnd-guest-input::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

#rnd-guest-input:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.32);
  background: rgba(255, 255, 255, 0.10);
}

.rnd-lottery-chip {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: opacity 120ms ease, border-color 120ms ease, background 120ms ease;
}

.rnd-lottery-chip.is-excluded {
  opacity: 0.42;
  text-decoration: line-through;
  border-style: dashed;
  background: rgba(255, 255, 255, 0.03);
  color: rgba(255, 255, 255, 0.55);
}

.rnd-lottery-chip:not(.is-excluded):active {
  transform: scale(0.97);
}

.rnd-add-row.hidden {
  display: none;
}

.rnd-add-btn {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: none;
  background: rgba(255, 255, 255, 0.10);
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background 120ms ease, transform 120ms ease;
}

.rnd-add-btn:hover { background: rgba(255, 255, 255, 0.16); }
.rnd-add-btn:active { transform: scale(0.94); }

.rnd-players {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 24px;
}

.rnd-players-empty {
  font-size: 13px;
  color: var(--text-muted, #9ca3af);
  font-style: italic;
}

.rnd-player-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 6px 6px 6px 12px;
  font-size: 14px;
  font-weight: 600;
  max-width: 100%;
}

.rnd-player-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}

.rnd-player-remove {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 120ms ease;
}

.rnd-player-remove:hover { background: rgba(239, 68, 68, 0.55); }

/* Планшет */
@media (min-width: 600px) {
  #screen-random:not(.hidden) {
    max-width: 680px;
    margin: 0 auto;
  }
  .rnd-display { font-size: clamp(28px, 4vw, 38px); }
}

@media (min-width: 900px) {
  /* На широких экранах — сетка 2×2 одинаковой высоты */
  #screen-random:not(.hidden) {
    display: grid;
    max-width: 920px;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto 1fr 1fr;
    grid-template-areas:
      "head head"
      "num player"
      "word oracle";
    gap: 16px;
    align-items: stretch;
  }
  #screen-random .screen-header { grid-area: head; }
  .rnd-block--num { grid-area: num; }
  .rnd-block--player { grid-area: player; }
  .rnd-block--word { grid-area: word; }
  .rnd-block--oracle { grid-area: oracle; }
  .rnd-block {
    min-height: 0;
    height: 100%;
  }
}

/* --- Админ-панель --- */
#screen-admin.screen {
  padding-top: 8px;
  padding-bottom: calc(16px + var(--safe-bottom));
}

#screen-admin:not(.hidden) {
  display: flex;
  flex-direction: column;
  height: var(--app-panel-h);
  max-height: var(--app-panel-h);
  min-height: 0;
  overflow: hidden;
}

.admin-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.admin-panel {
  gap: 0;
}

.admin-panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-panel-body .admin-list {
  flex: 1;
  min-height: 120px;
  max-height: none;
}

.admin-stats {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.admin-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-actions .primary,
.admin-actions .secondary {
  width: 100%;
}

.admin-section-title {
  margin: 8px 0 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
}

.admin-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: min(28vh, 200px);
  overflow-y: auto;
}

.admin-list-item,
.admin-room-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--surface-glass);
  border: 1px solid var(--border-strong);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.admin-room-row:hover {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border-strong));
  box-shadow: var(--shadow-cyan);
}

.admin-room-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.admin-room-main .lobby-code-badge {
  flex-shrink: 0;
  min-width: 6.75rem;
  width: 6.75rem;
  height: 36px;
  font-size: 16px;
}

.admin-room-main:hover,
.admin-room-main:focus-visible {
  opacity: 0.92;
}

.admin-room-main-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: 0;
}

.admin-room-age {
  font-size: 11px;
  color: var(--text-dim);
}

.admin-room-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.admin-room-action-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, #ef4444 35%, var(--border));
  background: color-mix(in srgb, #ef4444 10%, var(--surface-2));
  color: #ef4444;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
}

.admin-room-action-btn:hover,
.admin-room-action-btn:focus-visible {
  background: color-mix(in srgb, #ef4444 18%, var(--surface-2));
}

.admin-room-action-btn:disabled {
  opacity: 0.45;
  cursor: wait;
  pointer-events: none;
}

.admin-room-modal-card {
  max-width: 420px;
  width: calc(100vw - 32px);
  max-height: min(82vh, 640px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.admin-room-detail {
  overflow-y: auto;
  margin-bottom: 12px;
  padding-right: 2px;
}

.admin-room-info {
  margin: 0 0 12px;
  display: grid;
  gap: 8px;
}

.admin-room-info-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 8px;
  font-size: 13px;
}

.admin-room-info-row dt {
  margin: 0;
  color: var(--text-dim);
}

.admin-room-info-row dd {
  margin: 0;
  color: var(--text);
  word-break: break-word;
}

.admin-room-subtitle {
  margin: 12px 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
}

.admin-room-bullets,
.admin-room-teams,
.admin-room-players {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-room-bullets li {
  font-size: 13px;
  color: var(--text);
}

.admin-room-teams li,
.admin-room-players li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--text) 4%, var(--surface-2));
  border: 1px solid var(--border);
  font-size: 13px;
}

.admin-room-teams li {
  justify-content: flex-start;
}

.admin-team-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.admin-room-teams li strong {
  margin-left: auto;
}

.admin-room-player-name {
  font-weight: 500;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.admin-player-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.admin-player-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.admin-player-action-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, #ef4444 35%, var(--border));
  background: color-mix(in srgb, #ef4444 10%, var(--surface-2));
  color: #ef4444;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
}

.admin-player-action-btn--move {
  border-color: color-mix(in srgb, #3b82f6 35%, var(--border));
  background: color-mix(in srgb, #3b82f6 10%, var(--surface-2));
  color: #3b82f6;
}

.admin-player-action-btn:hover,
.admin-player-action-btn:focus-visible {
  filter: brightness(1.08);
}

.admin-player-action-btn:disabled {
  opacity: 0.45;
  cursor: wait;
  pointer-events: none;
}

.admin-room-players--actions .admin-player-row {
  background: color-mix(in srgb, var(--text) 4%, var(--surface-2));
}

.admin-move-label {
  display: block;
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--text-dim);
}

.admin-move-select {
  width: 100%;
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}

.admin-list-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-list-meta {
  font-size: 12px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.admin-list-empty {
  padding: 10px 0;
  font-size: 13px;
  color: var(--text-dim);
}

/* --- Lobby: гибкая вёрстка (координаты 10×20 — только в «Сетке макета») --- */
#screen-lobby.screen {
  padding-top: 8px;
  padding-bottom: calc(16px + var(--safe-bottom));
}

#screen-lobby:not(.hidden) {
  display: flex;
  flex-direction: column;
  height: var(--app-panel-h);
  max-height: var(--app-panel-h);
  min-height: 0;
  overflow: hidden;
  background: transparent;
}

#lobby-actions {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 10px;
}

#lobby-actions.block {
  margin-bottom: 0;
}

.lobby-subtitle {
  margin-top: 4px;
}

.lobby-section-title {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.lobby-player-section {
  position: relative;
  z-index: 2;
  flex-shrink: 0;
  margin-bottom: 12px;
}

.lobby-name-field {
  position: relative;
  z-index: 1;
}

.lobby-name-input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font: inherit;
  font-size: 16px;
  font-weight: 500;
}

.lobby-name-input:focus {
  outline: none;
  border-color: color-mix(in srgb, #3b82f6 45%, var(--border));
}

.lobby-name-input:disabled {
  opacity: 0.45;
  cursor: wait;
}

.lobby-name-suggestions {
  position: absolute;
  z-index: 30;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  margin: 0;
  padding: 4px;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: 0 8px 24px color-mix(in srgb, #000 28%, transparent);
  max-height: 220px;
  overflow-y: auto;
}

.lobby-name-suggestions.hidden {
  display: none;
}

.lobby-name-suggestion {
  appearance: none;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  border-radius: calc(var(--radius-sm) - 2px);
  padding: 10px 12px;
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

.lobby-name-suggestion:hover,
.lobby-name-suggestion:focus-visible {
  background: color-mix(in srgb, var(--text) 6%, var(--surface));
}

.lobby-open-rooms-wrap {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
}

.lobby-open-rooms-wrap.hidden {
  display: none;
}

.lobby-open-rooms-wrap > .lobby-section-title {
  flex-shrink: 0;
  margin-bottom: 10px;
}

.lobby-rooms-panel,
.setup-panel,
.games-panel,
.games-settings-panel,
.admin-panel,
.percent-panel,
.cn-panel,
.tw-panel,
.tone-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
  padding: 14px 14px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  box-sizing: border-box;
  overflow: hidden;
}

.lobby-rooms-panel .lobby-rooms-list {
  flex: 1;
  min-height: 0;
  margin: 0 0 12px;
  padding: 2px 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-sizing: border-box;
}

#lobby-actions .lobby-error {
  flex-shrink: 0;
  margin: 0;
}

.lobby-rooms-panel-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.lobby-test-t3-btn {
  flex-shrink: 0;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  border: 1px solid color-mix(in srgb, #ffb347 45%, var(--border-strong));
  background: color-mix(in srgb, #ffb347 12%, var(--surface));
  color: var(--text);
  border-radius: 999px;
  padding: 13px 14px;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.1s ease;
}

.lobby-test-t3-btn:hover,
.lobby-test-t3-btn:focus-visible {
  border-color: color-mix(in srgb, #ffb347 70%, var(--border-strong));
  background: color-mix(in srgb, #ffb347 18%, var(--surface));
}

.lobby-test-t3-btn:active {
  transform: scale(0.99);
}

.lobby-enter-code-btn {
  flex: 1;
  min-width: 0;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border-strong));
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  color: var(--text);
  border-radius: 999px;
  padding: 13px 18px;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.1s ease, box-shadow 0.12s ease;
}

.lobby-enter-code-btn:hover,
.lobby-enter-code-btn:focus-visible {
  border-color: color-mix(in srgb, var(--accent) 65%, var(--border-strong));
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  box-shadow: var(--shadow-cyan);
}

.lobby-enter-code-btn:active {
  transform: scale(0.99);
}

.lobby-enter-code-btn:disabled {
  opacity: 0.45;
  cursor: wait;
  pointer-events: none;
}

.lobby-create-round-btn {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: none;
  background: var(--gradient-accent);
  color: #fff;
  cursor: pointer;
  padding: 0;
  box-shadow: 0 8px 22px rgba(124, 58, 237, 0.38);
  transition: transform 0.1s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.lobby-create-round-btn-icon {
  width: 26px;
  height: 26px;
  display: block;
  flex-shrink: 0;
}

.lobby-create-round-btn:hover,
.lobby-create-round-btn:focus-visible {
  filter: brightness(1.08);
  box-shadow: 0 10px 28px rgba(236, 72, 153, 0.42);
}

.lobby-create-round-btn:active {
  transform: scale(0.94);
}

.lobby-create-round-btn:disabled {
  opacity: 0.45;
  cursor: wait;
  pointer-events: none;
}

#lobby-code-modal .lobby-code-modal-card {
  width: min(100%, 360px);
  max-height: min(82dvh, 640px);
  padding: 18px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border-strong));
  border-radius: var(--radius-lg);
  background: var(--surface-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow), var(--shadow-cyan), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  box-sizing: border-box;
}

.lobby-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.lobby-code-panel {
  margin: 0;
  padding: 0;
}

.lobby-code-panel.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.lobby-code-panel .lobby-join-section {
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.lobby-code-panel .lobby-keypad {
  padding: 14px 0 2px;
}

.lobby-room-item:disabled {
  opacity: 0.45;
  cursor: wait;
  pointer-events: none;
}

.lobby-keypad.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.lobby-footer-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lobby-rooms-modal-card {
  max-width: 360px;
  width: calc(100vw - 32px);
}

.lobby-rooms-hint {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-dim);
}

.lobby-local-id-hint {
  margin: 0 0 10px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-dim);
  word-break: break-word;
}

.lobby-local-id-hint code {
  font-size: 11px;
}

.lobby-local-id-hint a {
  color: color-mix(in srgb, var(--text) 75%, #3b82f6);
}

.lobby-rooms-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  max-height: min(50vh, 320px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lobby-room-item {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.1s ease, box-shadow 0.12s ease;
}

.lobby-room-item:hover,
.lobby-room-item:focus-visible {
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border-strong));
  box-shadow: var(--shadow-cyan);
}

.lobby-room-item:active {
  transform: scale(0.99);
}

.lobby-room-item.is-current {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

.lobby-room-item-code {
  flex-shrink: 0;
  min-width: 6.75rem;
  width: 6.75rem;
  height: 36px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.16em;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border-strong));
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  color: var(--accent);
}

.lobby-room-item-meta {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--text-dim);
  text-align: right;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.lobby-rooms-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  padding: 16px 12px;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.lobby-share-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: default;
  padding: 0;
  opacity: 0.95;
}

.lobby-share-btn:disabled {
  opacity: 0.95;
}

.lobby-share-btn-icon {
  width: 20px;
  height: 20px;
  opacity: 0.75;
}

.lobby-room-code-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  height: 52px;
  padding: 0 14px;
  margin-bottom: 12px;
  background: var(--surface-glass);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-sizing: border-box;
}

.lobby-room-code-meta .lobby-room-code-label {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.lobby-room-code-meta .lobby-code-badge {
  flex-shrink: 0;
  width: 6.75rem;
  min-width: 6.75rem;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  box-sizing: border-box;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.16em;
}

.lobby-join-section {
  display: grid;
  grid-template-columns: 1fr;
  row-gap: 10px;
  align-items: center;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  flex-shrink: 0;
}

.lobby-join-hint {
  grid-column: 1;
  grid-row: 1;
  margin: 0;
  padding: 0;
  text-align: left;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  color: #fde68a;
  letter-spacing: 0.01em;
}

.lobby-join-input-wrap {
  grid-column: 1;
  grid-row: 2;
  position: relative;
  width: 100%;
  min-width: 0;
}

.lobby-join-input {
  grid-column: auto;
  grid-row: auto;
  width: 100%;
  min-width: 0;
  height: 56px;
  box-sizing: border-box;
  padding: 0 calc(16px + 0.14em);
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border-strong));
  background: color-mix(in srgb, var(--bg) 85%, var(--surface));
  color: var(--text);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
  text-align: center;
  cursor: default;
}

.lobby-join-input-wrap:not(.has-code) .lobby-join-input {
  padding-right: 16px;
}

.lobby-join-input-wrap.has-code .lobby-join-input {
  padding-right: 40px;
}

.lobby-code-back {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: #9ca3af;
  cursor: pointer;
  padding: 0;
  transition: color 0.12s ease, transform 0.1s ease, opacity 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

.lobby-code-back.hidden {
  display: none;
}

.lobby-code-back:hover,
.lobby-code-back:focus-visible {
  color: #d1d5db;
}

.lobby-code-back:active {
  transform: translateY(-50%) scale(0.92);
  color: #6b7280;
}

.lobby-join-input::placeholder {
  color: var(--text-muted, #9ca3af);
  opacity: 1;
}

.lobby-join-input:placeholder-shown {
  color: var(--text-muted, #9ca3af);
}

#lobby-actions > .lobby-error {
  flex-shrink: 0;
  width: 100%;
  margin: 0;
  padding: 6px 0 0;
  text-align: center;
  line-height: 1.35;
  font-size: 13px;
}

#lobby-actions > .lobby-error:empty {
  display: none;
  padding: 0;
}

.lobby-join-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.2);
}

.lobby-keypad {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 16px 0 12px;
}

.lobby-keypad.hidden {
  display: none;
}

.lobby-keypad-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  width: 100%;
  max-width: min(100%, 22rem);
  margin: 0 auto;
}

.lobby-keypad-key {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: min(100%, 5.75rem);
  aspect-ratio: 1;
  margin: 0 auto;
  justify-self: center;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: color-mix(in srgb, var(--surface-2) 90%, transparent);
  color: var(--text);
  font-size: clamp(24px, 6.5vw, 30px);
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transition: background 0.12s ease, transform 0.1s ease, border-color 0.12s ease, box-shadow 0.12s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.lobby-keypad-key:hover,
.lobby-keypad-key:focus-visible {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface-2));
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border-strong));
}

.lobby-keypad-key:active {
  transform: scale(0.94);
  background: color-mix(in srgb, var(--accent) 18%, var(--surface-2));
  box-shadow: var(--shadow-cyan);
}

.lobby-keypad-back {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: min(100%, 4.25rem);
  aspect-ratio: 1;
  margin: 0 auto;
  justify-self: center;
  border-radius: 50%;
  border: 1px solid rgba(153, 27, 27, 0.55);
  background: rgba(127, 29, 29, 0.42);
  color: #fca5a5;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.1s ease, border-color 0.12s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.lobby-keypad-back:hover,
.lobby-keypad-back:focus-visible {
  background: rgba(153, 27, 27, 0.52);
  border-color: rgba(185, 28, 28, 0.62);
  color: #fecaca;
}

.lobby-keypad-back:active {
  transform: scale(0.96);
  background: rgba(127, 29, 29, 0.58);
}

.lobby-keypad-spacer {
  display: block;
  width: min(100%, 5.75rem);
  aspect-ratio: 1;
  margin: 0 auto;
  justify-self: center;
}

#lobby-footer .primary.full-width {
  width: 100%;
}

.lobby-hint {
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.5;
  margin: 12px 0 0;
}

#lobby-room.hidden,
#lobby-join-section.hidden,
#lobby-keypad.hidden {
  display: none;
}

.lobby-code-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-sizing: border-box;
  padding: 0 12px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border-strong));
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.16em;
  color: var(--accent);
}

.lobby-code-badge:not(.lobby-room-item-code) {
  min-height: 36px;
}

.lobby-code-badge,
.lobby-room-item-code,
.setup-header-room-code-value.lobby-code-badge,
.session-room-code.lobby-code-badge {
  /* letter-spacing добавляет отступ после последней цифры — компенсируем для центрирования */
  margin-right: -0.16em;
}

.lobby-code-badge--copy {
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.lobby-code-badge--copy:active {
  transform: scale(0.97);
}

.lobby-code-badge--copy.is-copied {
  border-color: color-mix(in srgb, #22c55e 55%, var(--border));
  background: color-mix(in srgb, #22c55e 14%, var(--surface-2));
  color: #86efac;
}

.lobby-players {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#lobby-room .lobby-players {
  margin-top: 12px;
}

.lobby-player {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-sizing: border-box;
}

.lobby-player .tp-team-dot {
  flex-shrink: 0;
}

.lobby-player-name { flex: 1; font-weight: 500; min-width: 0; }

.lobby-player-name-input {
  appearance: none;
  font: inherit;
  font-weight: 500;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  outline: none;
}

.lobby-player-name-input:focus {
  border-color: color-mix(in srgb, var(--primary) 55%, var(--border));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 22%, transparent);
}

.lobby-player-badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
}

.lobby-player-badge--away {
  background: rgba(234, 179, 8, 0.15);
  color: #facc15;
}

.lobby-player--away {
  opacity: 0.72;
}

.player-kick-btn {
  flex-shrink: 0;
  appearance: none;
  border: 1px solid rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.1);
  color: #fca5a5;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.player-kick-btn:hover {
  background: rgba(248, 113, 113, 0.18);
  border-color: rgba(248, 113, 113, 0.55);
}

.player-kick-btn:active {
  transform: translateY(1px);
}

.full-width { width: 100%; }

.session-badge {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.45;
  padding: 10px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.session-team-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  text-align: center;
  color: var(--text);
  font-weight: 600;
  background: color-mix(in srgb, var(--team-color, var(--primary)) 18%, var(--surface));
  border-color: color-mix(in srgb, var(--team-color, var(--primary)) 42%, var(--border));
  box-shadow: inset 3px 0 0 var(--team-color, var(--primary));
}

.session-room-badge {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
}

.session-room-code {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  letter-spacing: 0.16em;
  text-align: center;
}

.lobby-error {
  color: #f87171;
  font-size: 13px;
  min-height: 0;
}

/* --- Выбор команды --- */
.tp-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  margin-bottom: 12px;
}

#setup-player-name {
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border-strong));
  background: color-mix(in srgb, var(--accent) 8%, var(--surface-glass));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 0 16px rgba(34, 211, 238, 0.22);
  transition: border-color 0.25s ease, box-shadow 0.35s ease, background 0.35s ease;
}

#setup-player-name:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border-strong));
  background: color-mix(in srgb, var(--accent) 12%, var(--surface-glass));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 0 0 3px rgba(34, 211, 238, 0.2),
    0 0 22px rgba(34, 211, 238, 0.32);
}

#screen-setup .team-list {
  contain: layout style;
}

#screen-setup .setup-panel-body #setup-player-block,
#screen-setup .setup-panel-body #setup-teams-block > .block-title,
#screen-setup .team-card-multi:not(.is-mine) {
  filter: grayscale(0) saturate(1);
  transition: filter 3s ease;
}

body.setup-player-in-team #session-header[data-screen="screen-setup"],
body.setup-player-in-team #screen-setup .setup-panel-body #setup-player-block,
body.setup-player-in-team #screen-setup .setup-panel-body #setup-teams-block > .block-title,
body.setup-player-in-team #screen-setup .team-card-multi:not(.is-mine) {
  filter: grayscale(1) saturate(0.15);
}

#screen-setup .team-card-multi.is-mine {
  filter: none;
}

#screen-setup .setup-panel-footer {
  filter: none;
}

.page-toast {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top, 0px));
  left: 50%;
  z-index: 900;
  box-sizing: border-box;
  width: min(272px, 92vw);
  max-width: 92vw;
  padding: 12px 22px;
  border-radius: 999px;
  background: rgba(250, 204, 21, 0.22);
  border: 1px solid rgba(250, 204, 21, 0.62);
  color: #fef9c3;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  letter-spacing: 0.01em;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow:
    0 8px 28px rgba(0, 0, 0, 0.38),
    0 0 24px rgba(250, 204, 21, 0.28);
}

.page-toast.hidden {
  display: none;
}

.page-toast:not(.hidden) {
  display: block;
}

#setup-player-name.is-default-name {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border-strong));
  background: color-mix(in srgb, var(--accent) 8%, var(--surface-glass));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 0 16px rgba(34, 211, 238, 0.22);
}

#setup-player-name.is-default-name:focus {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border-strong));
  background: color-mix(in srgb, var(--accent) 12%, var(--surface-glass));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 0 0 3px rgba(34, 211, 238, 0.2),
    0 0 22px rgba(34, 211, 238, 0.32);
}

.setup-player-name-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin-bottom: 12px;
}

.setup-player-name-row .tp-input {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}

.setup-player-name-reroll {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border-strong));
  background: color-mix(in srgb, var(--accent) 8%, var(--surface-glass));
  color: var(--accent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease, transform 0.1s ease;
}

.setup-player-name-reroll:hover,
.setup-player-name-reroll:focus-visible {
  background: color-mix(in srgb, var(--text) 6%, var(--surface-2));
  border-color: color-mix(in srgb, var(--text) 18%, var(--border));
  color: var(--text);
}

.setup-player-name-reroll:active {
  transform: scale(0.94);
}

.tp-my-team-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.tp-swatch {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 10px;
}

.tp-action-btn { margin-top: 12px; }

.tp-teams-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tp-team-card {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tp-team-card.is-mine {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.25);
}

.tp-team-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tp-team-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tp-team-title {
  flex: 1;
  font-weight: 600;
  font-size: 16px;
}

.tp-team-members {
  font-size: 13px;
  color: var(--text-dim);
  padding-left: 24px;
}

.tp-join-btn {
  align-self: flex-start;
  margin-left: 24px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}

.tp-join-btn.is-active {
  background: rgba(59, 130, 246, 0.15);
  border-color: var(--primary);
  color: #93c5fd;
}

.answer-row.is-opponent-ready {
  border-color: #22c55e;
  box-shadow:
    0 0 0 1px rgba(34, 197, 94, 0.45),
    0 0 20px rgba(34, 197, 94, 0.15);
}

.answer-row.is-opponent-ready .answer-status {
  color: #4ade80;
  font-weight: 600;
}

.answer-row.is-own-waiting {
  border-color: color-mix(in srgb, var(--team-color, var(--primary)) 55%, var(--border));
  opacity: 0.92;
}

.answer-row.is-hidden .answer-value,
.answer-row.is-confirmed-hidden .answer-value {
  color: var(--text-dim);
  letter-spacing: 0.05em;
}

.answer-row.is-hidden .answer-slider,
.answer-row.is-confirmed-hidden .answer-slider {
  opacity: 0.35;
  pointer-events: none;
}

.answer-status.is-ready-label {
  color: #4ade80;
  font-weight: 600;
}

.answer-status {
  grid-column: 1 / -1;
  font-size: 13px;
  color: var(--text-dim);
}

.percent-hint {
  text-align: center;
  font-size: 14px;
  color: var(--text-dim);
  margin: 0 0 12px;
  padding: 8px 16px;
  min-height: 1.25em;
}

.percent-hint:not(:empty) {
  display: inline-block;
  width: 100%;
  box-sizing: border-box;
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.answer-row.is-readonly:not(.result-correct-bar),
.answer-row.is-readonly:not(.result-correct-bar) .answer-slider,
.answer-row.is-readonly:not(.result-correct-bar) .answer-input {
  opacity: 0.55;
  pointer-events: none;
}

.result-correct-bar.answer-row.is-readonly {
  opacity: 1;
  pointer-events: auto;
}

.team-members {
  display: block;
  width: 100%;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
  padding-left: 22px;
}

.controls-disabled .footer-bar,
.controls-disabled .cn-panel-footer,
.controls-disabled .tw-panel-footer,
.controls-disabled .tone-panel-footer,
.controls-disabled .sp-panel-footer,
.controls-disabled .game-card,
.controls-disabled .primary,
.controls-disabled .secondary {
  pointer-events: none;
  opacity: 0.5;
}

#tw-footer-bar.controls-disabled .tw-decide-buttons button {
  pointer-events: none;
  opacity: 0.45;
}

#screen-codenames.cn-turn-blocked .cn-cell:not(.is-flipped) {
  pointer-events: none;
}

#screen-codenames.cn-turn-blocked .cn-cell:not(.is-flipped)::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  background: rgba(0, 0, 0, 0.28);
  pointer-events: none;
}

#screen-codenames.cn-turn-blocked #cn-end-turn {
  pointer-events: none;
  opacity: 0.5;
}

.cn-hints-widget {
  --cn-hints-line-h: 1.35;
  --cn-hints-lines: 4;
  --cn-hints-pad-y: 12px;
  --cn-hints-pad-x: 14px;
  width: 100%;
  margin: 0 0 10px;
  padding: var(--cn-hints-pad-y) var(--cn-hints-pad-x);
  box-sizing: border-box;
  border-radius: 14px;
  border: 1px solid rgba(var(--cn-hint-team-rgb, 255, 255, 255), 0.32);
  background:
    linear-gradient(
      135deg,
      rgba(var(--cn-hint-team-rgb, 255, 255, 255), 0.18) 0%,
      rgba(var(--cn-hint-team-rgb, 255, 255, 255), 0.08) 100%
    );
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow:
    0 0 22px rgba(var(--cn-hint-team-rgb, 255, 255, 255), 0.24),
    0 0 44px rgba(var(--cn-hint-team-rgb, 255, 255, 255), 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.cn-hints-history {
  list-style: none;
  margin: 0;
  padding: 0;
  height: calc(var(--cn-hints-lines) * var(--cn-hints-line-h) * 1em);
  max-height: calc(var(--cn-hints-lines) * var(--cn-hints-line-h) * 1em);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--cn-hint-team-rgb, 255, 255, 255), 0.35) transparent;
}

.cn-hints-history::-webkit-scrollbar {
  width: 5px;
}

.cn-hints-history::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(var(--cn-hint-team-rgb, 255, 255, 255), 0.35);
}

.cn-hints-item {
  flex-shrink: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: var(--cn-hints-line-h, 1.35);
  padding-left: 10px;
  border-left: 3px solid var(--team-color, rgba(255, 255, 255, 0.45));
  color: #fff;
  -webkit-text-stroke: 0.45px rgba(0, 0, 0, 0.65);
  text-shadow:
    0 0 8px rgba(var(--cn-hint-team-rgb, 255, 255, 255), 0.35),
    0 1px 2px rgba(0, 0, 0, 0.45);
}

.cn-hints-item.is-active {
  border-left-width: 4px;
  font-weight: 700;
}

.cn-hints-item--pondering {
  border-left-color: rgba(var(--cn-hint-team-rgb, 255, 255, 255), 0.45);
  color: rgba(255, 255, 255, 0.78);
  font-weight: 600;
}

.cn-hints-item--empty {
  border-left-color: rgba(255, 255, 255, 0.25);
  color: rgba(255, 255, 255, 0.55);
  font-weight: 500;
}

.cn-hints-team-name {
  font-weight: inherit;
}

/* Codenames — геометрия поля и карты капитана (cn-page) */

.cn-page .cap-header-status {
  min-height: 34px;
}

#screen-codenames-captain #cap-map-area[hidden] {
  display: none !important;
}

#screen-codenames-captain.hidden {
  display: none !important;
}

body.captain-tinted {
  background:
    radial-gradient(140% 90% at 50% 0%,
      rgba(var(--cn-tint, 255, 255, 255), 0.32) 0%,
      rgba(var(--cn-tint, 255, 255, 255), 0.14) 42%,
      rgba(var(--cn-tint, 255, 255, 255), 0.05) 72%,
      rgba(var(--cn-tint, 255, 255, 255), 0) 100%),
    var(--bg);
  background-attachment: fixed;
}

#screen-codenames-captain.hidden {
  display: none !important;
}

body.captain-page {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding-bottom: calc(120px + var(--safe-bottom));
}

body.captain-page .captain-screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

body.captain-page .screen-header {
  margin-bottom: 8px;
  flex-shrink: 0;
}

body.captain-page .screen-header .cn-hints-widget {
  margin-top: 8px;
  margin-bottom: 0;
}

#screen-codenames .screen-title-block,
#screen-codenames-captain .screen-title-block {
  min-width: 0;
}

.captain-card {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  aspect-ratio: auto;
  perspective: 720px;
}

.captain-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.4, 0.2, 0.2, 1);
}

.captain-card.is-flipped .captain-card-inner {
  transform: rotateY(180deg);
}

.captain-card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 8px;
}

.captain-card-front {
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.captain-card-back {
  overflow: hidden;
  transform: rotateY(180deg);
  background-color: #374151;
  background-image:
    radial-gradient(circle at 18% 22%, rgba(255, 255, 255, 0.08) 0 8%, transparent 9%),
    radial-gradient(circle at 78% 68%, rgba(0, 0, 0, 0.22) 0 10%, transparent 11%),
    repeating-linear-gradient(
      45deg,
      rgba(17, 24, 39, 0.18) 0 3px,
      rgba(255, 255, 255, 0.03) 3px 6px
    ),
    linear-gradient(145deg, #4b5563 0%, #374151 48%, #3f4654 100%);
  box-shadow: inset 0 0 0 2px rgba(17, 24, 39, 0.55);
}

.captain-card-played-mark {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  border-radius: inherit;
  transform: scale(1);
  transform-origin: center center;
  background: radial-gradient(
    circle farthest-corner at 50% 50%,
    rgba(0, 0, 0, 0) 0%,
    rgba(0, 0, 0, 0.18) 26%,
    rgba(0, 0, 0, 0.52) 46%,
    rgba(0, 0, 0, 0.82) 66%,
    #000 100%
  );
}

.captain-card--pending-reveal {
  pointer-events: none;
}

.captain-card-played-mark--reveal-anim {
  transform: scale(2.85);
  will-change: transform;
  animation: captain-card-reveal-gradient 3s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes captain-card-reveal-gradient {
  from {
    transform: scale(2.85);
  }
  to {
    transform: scale(1);
  }
}

.captain-card.is-revealed .captain-card-front .captain-cell-text {
  position: relative;
  z-index: 3;
}

.captain-card:not(.is-revealed) .captain-card-front .captain-cell-text {
  padding: 0 1px;
}

.captain-card.is-revealed {
  cursor: pointer;
}

.captain-card-back::after {
  content: '';
  position: absolute;
  inset: 18%;
  border: 2px solid rgba(17, 24, 39, 0.65);
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.captain-hint-form--locked {
  opacity: 0.55;
  pointer-events: none;
}

.captain-hint-form--locked .primary {
  cursor: not-allowed;
}

.captain-hint-form {
  display: flex;
  flex-direction: column;
  gap: var(--cn-footer-gap, 8px);
  width: 100%;
}

.captain-hint-input {
  width: 100%;
  box-sizing: border-box;
  min-height: var(--cn-footer-top-h, 48px);
  height: var(--cn-footer-top-h, 48px);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  font-weight: 600;
  padding: 0 14px;
  outline: none;
}

.captain-hint-input:focus {
  border-color: color-mix(in srgb, var(--captain-team-color, var(--primary)) 60%, var(--border));
}

.captain-hint-input:disabled {
  opacity: 0.55;
}

.captain-cell {
  aspect-ratio: auto;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.92);
  box-sizing: border-box;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.01em;
  color: #fff;
}

.captain-grid {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  max-height: 100%;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-template-rows: repeat(5, minmax(0, 1fr));
  gap: 5px;
}

.captain-cell.team1   { background: var(--cn-team1, #E11D48); }
.captain-cell.team2   { background: var(--cn-team2, #2563EB); }
.captain-cell.neutral { background: #C9B58C; }
.captain-cell.assassin { background: #0a0a0a; color: #fff; border-color: #fff; }

.captain-layout-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 8, 14, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.captain-layout-modal.hidden { display: none; }

.captain-layout-modal-card {
  width: min(100%, 360px);
  background: var(--surface-glass);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: grid;
  gap: 10px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

#setup-host-modal .setup-host-modal-card {
  width: min(100%, 380px);
  max-height: min(82vh, 640px);
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
  min-width: 0;
  box-sizing: border-box;
}

#setup-host-modal .setup-host-modal-card .captain-layout-modal-title {
  flex-shrink: 0;
  margin-bottom: 14px;
}

#setup-host-modal .setup-host-modal-section {
  flex-shrink: 0;
  min-width: 0;
  margin-bottom: 14px;
}

#setup-host-modal #setup-host-count-block .segmented {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

#setup-host-modal .seg-btn {
  padding: 10px 4px;
  font-size: 15px;
}

#setup-host-modal #setup-host-players-block {
  flex: 1 1 auto;
  min-height: 0;
  margin-bottom: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#setup-host-modal #setup-players.setup-players {
  flex: 1 1 auto;
  min-height: 0;
  max-height: min(34vh, 260px);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-right: 2px;
}

#setup-host-modal .lobby-player {
  min-width: 0;
  max-width: 100%;
}

#setup-host-modal .lobby-player-name,
#setup-host-modal .lobby-player-name-input {
  min-width: 0;
  flex: 1 1 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

#setup-host-modal .lobby-player-badge,
#setup-host-modal .player-kick-btn {
  flex-shrink: 0;
}

#setup-host-modal #setup-host-modal-close {
  flex-shrink: 0;
  margin-top: 2px;
}

.captain-layout-modal-title {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 800;
  text-align: center;
}

.captain-layout-modal-actions {
  display: grid;
  gap: 8px;
}

.captain-layout-modal-actions button {
  border: 0;
  border-radius: 12px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  padding: 14px;
  cursor: pointer;
}

.captain-layout-modal-actions .primary {
  background: var(--gradient-primary);
  color: #fff;
  box-shadow: 0 8px 20px rgba(239, 68, 68, 0.25);
}

.captain-layout-modal-actions .secondary {
  background: var(--surface-glass);
  color: var(--text);
  border: 1px solid var(--border-strong);
}

@media (min-width: 768px) {
  #screen-codenames-captain:not(.hidden),
  body.captain-page #captain-app {
    max-width: min(920px, 94vw);
    margin: 0 auto;
  }
}

.team-card-multi.is-mine {
  border-color: color-mix(in srgb, var(--team-color, var(--primary)) 72%, var(--border));
  box-shadow:
    inset 4px 0 0 var(--team-color, var(--primary)),
    0 0 0 1px color-mix(in srgb, var(--team-color, var(--primary)) 38%, transparent),
    0 0 22px color-mix(in srgb, var(--team-color, var(--primary)) 28%, transparent);
}

.team-card-multi .team-card-split {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.team-card-multi .team-card-title-row {
  display: block;
  margin-bottom: 0;
  min-width: 0;
}

.team-card-multi .team-swatch {
  display: none;
}

.team-card-multi .team-name {
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.team-card-multi .team-card-body {
  display: flex;
  align-items: stretch;
  gap: 10px;
  height: 168px;
  min-height: 168px;
  max-height: 168px;
}

.team-card-multi .team-card-actions-col {
  position: relative;
  flex: 0 0 52px;
  width: 52px;
  min-width: 52px;
  max-width: 52px;
  height: 168px;
  min-height: 168px;
  max-height: 168px;
}

.team-card-multi .team-action-expand-btn,
.team-card-multi .team-join-btn {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  min-height: 0;
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0;
  border-radius: var(--radius);
  border: 2px solid color-mix(in srgb, var(--team-color, var(--primary)) 42%, var(--border-strong));
  border-style: solid;
  background: color-mix(in srgb, var(--team-color, var(--primary)) 14%, var(--surface-2));
  color: color-mix(in srgb, var(--team-color, var(--text)) 78%, var(--text));
  cursor: pointer;
  font: inherit;
  font-size: inherit;
  font-weight: inherit;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease, box-shadow 0.12s ease;
  box-sizing: border-box;
}

.team-card-multi .team-action-expand-btn:hover,
.team-card-multi .team-action-expand-btn:focus-visible,
.team-card-multi .team-join-btn:hover:not(:disabled),
.team-card-multi .team-join-btn:focus-visible:not(:disabled) {
  background: color-mix(in srgb, var(--team-color, var(--primary)) 24%, var(--surface-2));
  border-color: color-mix(in srgb, var(--team-color, var(--primary)) 62%, var(--border-strong));
  box-shadow: 0 0 18px color-mix(in srgb, var(--team-color, var(--primary)) 22%, transparent);
}

.team-card-multi .team-action-expand-btn:active,
.team-card-multi .team-join-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.team-card-multi .team-action-menu {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
  height: 100%;
  min-height: 0;
  box-sizing: border-box;
}

.team-card-multi .team-action-menu.hidden {
  display: none;
}

.team-card-multi .team-action-menu .team-color-picker-wrap,
.team-card-multi .team-action-menu .team-captain-btn,
.team-card-multi .team-action-menu .team-leave-btn {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  max-width: none;
  max-height: none;
  flex: none;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.team-card-multi .team-action-menu .team-color-picker-wrap {
  display: block;
  position: relative;
}

.team-card-multi .team-action-menu .team-color-picker {
  width: 100%;
  height: 100%;
}

.team-card-multi .team-action-menu .team-color-trigger {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border-radius: var(--radius-sm);
}

.team-card-multi .team-action-menu .team-color-trigger-swatch {
  width: 24px;
  height: 24px;
}

.team-card-multi .team-action-menu .team-captain-btn {
  width: 100%;
  height: 100%;
  min-width: 0;
  max-width: none;
  padding: 0;
  border-radius: var(--radius-sm);
}

.team-card-multi .team-action-menu .team-captain-btn.is-active {
  border-color: rgba(250, 204, 21, 0.62);
  background: rgba(250, 204, 21, 0.22);
  color: #fde047;
  opacity: 1;
  cursor: pointer;
  box-shadow:
    0 0 0 1px rgba(250, 204, 21, 0.18),
    0 0 18px rgba(250, 204, 21, 0.24);
}

.team-card-multi .team-action-menu .team-captain-btn.is-active:hover,
.team-card-multi .team-action-menu .team-captain-btn.is-active:focus-visible {
  background: rgba(250, 204, 21, 0.3);
  border-color: rgba(250, 204, 21, 0.75);
  color: #fef08a;
  box-shadow:
    0 0 0 1px rgba(250, 204, 21, 0.24),
    0 0 22px rgba(250, 204, 21, 0.32);
}

.team-card-multi .team-action-menu .team-captain-btn:disabled:not(.is-active) {
  opacity: 0.55;
  cursor: default;
}

.team-card-multi .team-leave-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid color-mix(in srgb, #ef4444 55%, var(--border-strong));
  background: color-mix(in srgb, #ef4444 22%, var(--surface-2));
  color: #fecaca;
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0;
}

.team-card-multi .team-leave-btn[hidden] {
  display: none !important;
}

.team-card-multi .team-leave-btn:hover:not(:disabled),
.team-card-multi .team-leave-btn:focus-visible:not(:disabled) {
  background: color-mix(in srgb, #ef4444 34%, var(--surface-2));
  border-color: color-mix(in srgb, #ef4444 72%, var(--border-strong));
  color: #fff;
}


.team-card-multi .team-join-btn.hidden,
.team-card-multi .team-action-expand-btn.hidden {
  display: none;
}

.team-card-multi .team-join-btn-icon,
.team-card-multi .team-action-expand-btn-icon {
  flex-shrink: 0;
}

.team-join-btn-label {
  display: none;
}

.team-card-multi .team-roster {
  position: relative;
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
  padding: 10px 12px;
  padding-inline-start: 12px;
  width: auto;
  height: 168px;
  min-height: 168px;
  max-height: 168px;
  border-radius: var(--radius);
  border: 2px solid color-mix(in srgb, var(--team-color, var(--primary)) 42%, var(--border-strong));
  background: color-mix(in srgb, var(--team-color, var(--surface)) 6%, var(--surface-glass));
  box-sizing: border-box;
  overflow: hidden;
  list-style: none;
}

.team-card-multi .team-roster-list {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 8px;
  min-height: 100%;
  max-height: 100%;
  overflow-y: auto;
  transition: opacity 0.15s ease;
}

.team-card-multi .team-roster.is-palette-open .team-roster-list {
  opacity: 0.15;
  pointer-events: none;
}

.team-card-multi .team-roster-name {
  width: 100%;
  text-align: center;
  box-sizing: border-box;
}

.team-card-multi .team-roster-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 120px;
}

.team-card-split {
  position: relative;
}

.team-roster {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.team-roster-empty {
  font-size: 14px;
  color: var(--text-muted);
}

.team-roster-name {
  font-size: 16px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  line-height: 1.2;
}

.players-panel {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
}

.players-panel.hidden {
  display: none;
}

.players-panel:not(.hidden) {
  pointer-events: auto;
}

.players-panel-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(0, 0, 0, 0.55);
  cursor: pointer;
  appearance: none;
}

.players-panel-sheet {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  max-height: min(85vh, 640px);
  overflow: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 20px 20px 0 0;
  padding: 20px 20px calc(24px + var(--safe-bottom));
  animation: players-panel-in 0.22s ease-out;
}

@keyframes players-panel-in {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.players-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.players-panel-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.players-panel-close {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.players-panel-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.players-panel-label {
  font-size: 14px;
  color: var(--text-dim);
  font-weight: 600;
}

body.players-panel-open {
  overflow: hidden;
}

.team-roster-name.is-me {
  border-color: var(--primary);
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.12);
}

.team-roster-name.is-captain {
  border-color: rgba(250, 204, 21, 0.45);
  color: #fde68a;
  background: rgba(250, 204, 21, 0.1);
}

.team-roster-name.is-captain.is-me {
  border-color: rgba(250, 204, 21, 0.55);
  color: #fef08a;
  background: rgba(250, 204, 21, 0.14);
}

.team-captain-btn {
  flex: 1;
  flex-shrink: 0;
  min-width: 0;
  max-width: none;
  margin-top: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 9px 10px;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: #9ca3af;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease;
}

.team-captain-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.team-captain-btn-label {
  display: none;
}

.team-captain-btn:hover:not(:disabled):not(.is-active),
.team-captain-btn:focus-visible:not(:disabled):not(.is-active) {
  color: #d1d5db;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.22);
}

.team-captain-btn:disabled:not(.is-active) {
  opacity: 0.55;
  cursor: default;
}

.team-captain-btn.is-active {
  border-color: rgba(250, 204, 21, 0.62);
  background: rgba(250, 204, 21, 0.22);
  color: #fde047;
  cursor: pointer;
  opacity: 1;
  box-shadow:
    0 0 0 1px rgba(250, 204, 21, 0.18),
    0 0 18px rgba(250, 204, 21, 0.24);
}

.team-captain-btn.is-active:hover,
.team-captain-btn.is-active:focus-visible {
  background: rgba(250, 204, 21, 0.3);
  border-color: rgba(250, 204, 21, 0.75);
  color: #fef08a;
  box-shadow:
    0 0 0 1px rgba(250, 204, 21, 0.24),
    0 0 22px rgba(250, 204, 21, 0.32);
}

.team-captain-btn.is-pending {
  border-color: rgba(255, 255, 255, 0.24);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08);
  opacity: 0.85;
  cursor: default;
}

.team-join-btn {
  margin-top: 8px;
  width: 100%;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}

.team-join-btn.is-active {
  cursor: default;
}

.team-card-multi .team-card-actions-col .team-join-btn,
.team-card-multi .team-card-actions-col .team-action-expand-btn {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  border-style: solid;
  font: inherit;
}

.team-card .team-name:disabled {
  opacity: 0.85;
  cursor: not-allowed;
}

#setup-error:empty {
  display: none;
}

#setup-players-block.hidden {
  display: none;
}

.setup-players {
  margin-top: 0;
}
