/* ==========================================================================
   ДУЭЛЬ — Elevated Minimalist Bento Design System (v2)
   - Fluid Screen-Resolution Adaptive Presets (Mobile -> Laptop -> Full HD -> 2K/4K)
   - Full Uncropped Character Stages (Ambient Blur Backdrop + object-fit: contain)
   - Refined Dark & Light Glass-Matte Themes
   ========================================================================== */

:root,
[data-theme="dark"] {
  --bg: #0b0c10;
  --bg-glow: radial-gradient(ellipse 85% 45% at 50% -10%, rgba(99, 102, 241, 0.14), rgba(16, 185, 129, 0.03) 55%, transparent 80%);
  --topbar-bg: rgba(17, 19, 25, 0.82);
  --surface: #13151b;
  --surface-2: #1a1d25;
  --surface-3: #222631;
  --surface-hover: #252a36;
  --border: rgba(255, 255, 255, 0.085);
  --border-strong: rgba(255, 255, 255, 0.16);
  --inner-shine: inset 0 1px 0 rgba(255, 255, 255, 0.055);

  --text: #f5f6f8;
  --text-muted: #989eae;
  --text-subtle: #686f82;

  --primary: #f5f6f8;
  --primary-fg: #0b0c10;
  --primary-hover: #ffffff;

  --accent: #6366f1;
  --accent-bright: #818cf8;
  --accent-soft: rgba(99, 102, 241, 0.15);
  --accent-glow: 0 0 0 1px rgba(99, 102, 241, 0.4), 0 8px 28px rgba(99, 102, 241, 0.14);

  --red: #f43f5e;
  --red-soft: rgba(244, 63, 94, 0.16);
  --red-card-bg: rgba(244, 63, 94, 0.09);
  --red-border: rgba(244, 63, 94, 0.52);

  --green: #10b981;
  --green-soft: rgba(16, 185, 129, 0.16);

  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.17);

  --slate-pill: rgba(148, 163, 184, 0.16);
  --stage-bg: #181b23;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.26);
  --shadow-md: 0 12px 34px rgba(0, 0, 0, 0.42);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.62);
  --backdrop: rgba(5, 6, 9, 0.76);
}

[data-theme="light"] {
  --bg: #f4f5f7;
  --bg-glow: radial-gradient(ellipse 85% 45% at 50% -12%, rgba(79, 70, 229, 0.08), rgba(16, 185, 129, 0.03) 55%, transparent 80%);
  --topbar-bg: rgba(255, 255, 255, 0.85);
  --surface: #ffffff;
  --surface-2: #f1f2f5;
  --surface-3: #e7e9ef;
  --surface-hover: #e5e7ee;
  --border: rgba(15, 23, 42, 0.09);
  --border-strong: rgba(15, 23, 42, 0.18);
  --inner-shine: inset 0 1px 0 rgba(255, 255, 255, 0.8);

  --text: #111318;
  --text-muted: #5f6573;
  --text-subtle: #8b91a0;

  --primary: #14161c;
  --primary-fg: #ffffff;
  --primary-hover: #252833;

  --accent: #4f46e5;
  --accent-bright: #4f46e5;
  --accent-soft: rgba(79, 70, 229, 0.1);
  --accent-glow: 0 0 0 1px rgba(79, 70, 229, 0.35), 0 8px 24px rgba(79, 70, 229, 0.1);

  --red: #e11d48;
  --red-soft: rgba(225, 29, 72, 0.11);
  --red-card-bg: #fff1f2;
  --red-border: rgba(225, 29, 72, 0.45);

  --green: #059669;
  --green-soft: rgba(5, 150, 105, 0.12);

  --amber: #d97706;
  --amber-soft: rgba(217, 119, 6, 0.13);

  --slate-pill: rgba(100, 116, 139, 0.12);
  --stage-bg: #eef0f4;

  --shadow-sm: 0 2px 6px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 12px 30px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 24px 56px rgba(15, 23, 42, 0.15);
  --backdrop: rgba(15, 18, 26, 0.44);
}

/* ==================== FLUID ADAPTIVE RESOLUTION TOKENS ==================== */
:root {
  --base-font: 15.5px;
  --app-max-w: 1860px;
  --side-col-w: 380px;
  --card-min: 190px;
  --grid-gap: 13px;
}

/* Resolution Presets injected dynamically by ScreenAdapter */
[data-screen-preset="4k"] {
  --base-font: 17.2px;
  --app-max-w: 2460px;
  --side-col-w: 435px;
  --grid-gap: 16px;
}

[data-screen-preset="fhd"] {
  --base-font: 16px;
  --app-max-w: 1940px;
  --side-col-w: 395px;
  --grid-gap: 14px;
}

[data-screen-preset="laptop"] {
  --base-font: 15.2px;
  --app-max-w: 1640px;
  --side-col-w: 350px;
  --grid-gap: 12px;
}

[data-screen-preset="tablet"] {
  --base-font: 15.5px;
  --app-max-w: 100%;
  --grid-gap: 11px;
}

[data-screen-preset="mobile"] {
  --base-font: 15px;
  --app-max-w: 100%;
  --grid-gap: 9px;
}

/* Card Size Multipliers (XXL / Large / Medium) */
[data-card-size="xl"] { --card-min: 235px; }
[data-card-size="lg"] { --card-min: 190px; }
[data-card-size="md"] { --card-min: 146px; }

[data-screen-preset="4k"][data-card-size="xl"] { --card-min: 280px; }
[data-screen-preset="4k"][data-card-size="lg"] { --card-min: 228px; }
[data-screen-preset="4k"][data-card-size="md"] { --card-min: 176px; }

[data-screen-preset="laptop"][data-card-size="xl"] { --card-min: 215px; }
[data-screen-preset="laptop"][data-card-size="lg"] { --card-min: 176px; }
[data-screen-preset="laptop"][data-card-size="md"] { --card-min: 138px; }

/* Manual UI Scale Override */
[data-ui-scale="compact"] { font-size: calc(var(--base-font) * 0.91); }
[data-ui-scale="auto"]    { font-size: var(--base-font); }
[data-ui-scale="large"]   { font-size: calc(var(--base-font) * 1.09); }
[data-ui-scale="xlarge"]  { font-size: calc(var(--base-font) * 1.18); }

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: var(--base-font);
}

body {
  margin: 0;
  padding: 0;
  min-height: 100dvh;
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.22s ease, color 0.22s ease;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: var(--bg-glow);
  pointer-events: none;
  z-index: 0;
}

/* Custom sleek scrollbars */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
}

button,
input,
textarea {
  font-family: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 120;
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ==================== FLOATING FROSTED TOP BAR ==================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 45;
  height: 3.85rem;
  padding: 0 1.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  background: var(--topbar-bg);
  backdrop-filter: blur(18px) saturate(1.35);
  -webkit-backdrop-filter: blur(18px) saturate(1.35);
  border-bottom: 1px solid var(--border);
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.topbar-center {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
}

.brand-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  background: transparent;
  border: none;
  padding: 0.25rem 0.4rem 0.25rem 0;
  font-weight: 800;
  letter-spacing: -0.025em;
  font-size: 1.05rem;
}

.brand-mark {
  width: 2.05rem;
  height: 2.05rem;
  border-radius: 0.62rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent-bright) 180%);
  color: var(--primary-fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.95rem;
  box-shadow: var(--shadow-sm);
}

.room-pill,
.score-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.34rem 0.72rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  box-shadow: var(--inner-shine);
}

.score-pill {
  font-weight: 800;
  color: var(--accent-bright);
  background: var(--accent-soft);
  border-color: rgba(99, 102, 241, 0.26);
}

.room-pill-label {
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-subtle);
  flex-shrink: 0;
}

.status-dot.online {
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}

.status-dot.connecting {
  background: var(--amber);
}

/* Scale & Screen Resolution Popover */
.popover-anchor {
  position: relative;
}

.scale-trigger-btn {
  gap: 0.38rem;
  padding: 0 0.65rem;
}

.scale-popover {
  position: absolute;
  top: calc(100% + 0.55rem);
  right: 0;
  width: 310px;
  padding: 1rem;
  border-radius: 1.15rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg), var(--inner-shine);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  z-index: 80;
  animation: popIn 0.16s cubic-bezier(0.22, 1, 0.36, 1);
}

.popover-section {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.screen-info-line {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent-bright);
}

/* ==================== COMMON BUTTONS & INPUTS ==================== */
.icon-btn {
  height: 2.35rem;
  min-width: 2.35rem;
  padding: 0 0.6rem;
  border-radius: 0.7rem;
  border: 1px solid var(--border);
  background: var(--surface-2);
  box-shadow: var(--inner-shine);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
  transition: all 0.16s cubic-bezier(0.22, 1, 0.36, 1);
}

.icon-btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.icon-btn:active {
  transform: scale(0.96);
}

.icon-btn-badge {
  font-size: 0.78rem;
  font-weight: 600;
}

.icon-mini-btn {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 0.5rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.icon-mini-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.pref-btn {
  border-radius: 0.82rem;
  font-weight: 600;
  font-size: 0.94rem;
  padding: 0.65rem 1.1rem;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.18s cubic-bezier(0.22, 1, 0.36, 1);
  white-space: nowrap;
}

.primary-btn {
  background: var(--primary);
  color: var(--primary-fg);
  box-shadow: var(--shadow-sm);
}

.primary-btn:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-1.5px);
  box-shadow: var(--shadow-md);
}

.secondary-btn {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
  box-shadow: var(--inner-shine);
}

.secondary-btn:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.ghost-btn {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}

.ghost-btn:hover {
  color: var(--text);
  background: var(--surface-2);
}

.pref-btn {
  background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(244, 63, 94, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.pref-btn:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1.5px);
  box-shadow: 0 10px 26px rgba(244, 63, 94, 0.42);
}

button:disabled {
  opacity: 0.44;
  cursor: not-allowed;
  transform: none !important;
}

.btn-lg {
  height: 3.15rem;
  padding: 0 1.35rem;
  font-size: 1rem;
  border-radius: 0.9rem;
}

.btn-sm {
  height: 2.25rem;
  padding: 0 0.85rem;
  font-size: 0.84rem;
  border-radius: 0.68rem;
}

.btn-full {
  width: 100%;
}

.text-input,
.textarea-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 0.82rem;
  padding: 0.75rem 0.95rem;
  font-size: max(16px, 0.98rem);
  color: var(--text);
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.text-input::placeholder,
.textarea-input::placeholder {
  color: var(--text-subtle);
}

.text-input:focus,
.textarea-input:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3.5px var(--accent-soft);
}

.input-lg {
  height: 3.15rem;
}

.surface-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  padding: 1.25rem;
  box-shadow: var(--shadow-sm), var(--inner-shine);
}

.eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.pill-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.muted-tag {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ==================== SCREEN 1: HOME ==================== */
.screen-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.8rem 1rem;
}

.home-card {
  width: 100%;
  max-width: 30.5rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 1.65rem;
  padding: 2.3rem 2rem;
  box-shadow: var(--shadow-lg), var(--inner-shine);
}

.home-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.34rem 0.8rem;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid rgba(99, 102, 241, 0.25);
  color: var(--accent-bright);
  font-weight: 600;
  font-size: 0.79rem;
  margin-bottom: 1rem;
}

.badge-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-bright);
  box-shadow: 0 0 8px var(--accent-bright);
}

.home-title {
  margin: 0 0 0.7rem;
  font-size: 1.85rem;
  line-height: 1.16;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.home-subtitle {
  margin: 0 0 1.5rem;
  color: var(--text-muted);
  font-size: 0.96rem;
  line-height: 1.52;
}

.invite-banner {
  padding: 0.75rem 0.95rem;
  border-radius: 0.85rem;
  background: var(--green-soft);
  color: var(--green);
  font-size: 0.9rem;
  margin-bottom: 1.1rem;
  border: 1px solid rgba(16, 185, 129, 0.28);
}

.field-group {
  margin-bottom: 1.2rem;
}

.field-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.45rem;
}

.home-actions {
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
}

.divider-text {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  color: var(--text-subtle);
  font-size: 0.8rem;
}

.divider-text::before,
.divider-text::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.join-row {
  display: flex;
  gap: 0.65rem;
}

.code-input {
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-align: center;
}

.home-features {
  margin-top: 1.5rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.55rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ==================== SCREEN 2: FLUID LOBBY ==================== */
.screen-lobby {
  flex: 1;
  width: 100%;
  max-width: min(96vw, var(--app-max-w));
  margin: 0 auto;
  padding: 1.35rem 1.4rem 2.4rem;
}

.lobby-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--side-col-w);
  gap: 1.2rem;
  align-items: start;
}

.lobby-main {
  display: flex;
  flex-direction: column;
  gap: 1.05rem;
}

.room-share-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.8rem;
  padding-bottom: 1.05rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.05rem;
}

.room-code-big {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  font-variant-numeric: tabular-nums;
}

.share-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.players-strip {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.8rem;
  align-items: center;
}

.player-slot {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: 0.95rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.player-slot.waiting {
  border-style: dashed;
  opacity: 0.85;
}

.player-slot-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.player-slot-info strong {
  font-size: 0.96rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slot-role {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.vs-pill {
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--text-subtle);
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.95rem;
}

.section-head h2,
.section-head h3 {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.section-sub {
  margin: 0.22rem 0 0;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.mode-card {
  text-align: left;
  padding: 1.05rem 1.15rem;
  border-radius: 1rem;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  transition: all 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

.mode-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1.5px);
}

.mode-card.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: var(--accent-glow);
}

.mode-card-top {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.4rem;
}

.mode-icon {
  font-size: 1.35rem;
}

.mode-title {
  font-weight: 700;
  font-size: 1.02rem;
}

.mode-desc {
  margin: 0;
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.44;
}

.suboptions-box {
  margin-top: 0.95rem;
  padding-top: 0.95rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.segmented-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  background: var(--surface-2);
  padding: 0.28rem;
  border-radius: 0.82rem;
  border: 1px solid var(--border);
}

.seg-btn {
  flex: 1;
  min-width: fit-content;
  padding: 0.52rem 0.78rem;
  border-radius: 0.6rem;
  border: none;
  background: transparent;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.15s ease;
}

.seg-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm), var(--inner-shine);
}

/* Packs Grid */
.packs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13.5rem, 1fr));
  gap: 0.72rem;
}

.pack-tile {
  text-align: left;
  padding: 0.88rem 0.95rem;
  border-radius: 0.98rem;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 0.72rem;
  transition: all 0.16s cubic-bezier(0.22, 1, 0.36, 1);
}

.pack-tile:hover {
  border-color: var(--border-strong);
  transform: translateY(-1.5px);
}

.pack-tile.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.14);
}

.pack-icon {
  font-size: 1.45rem;
  line-height: 1;
  margin-top: 0.1rem;
}

.pack-info {
  min-width: 0;
  flex: 1;
}

.pack-name {
  display: block;
  font-weight: 700;
  font-size: 0.92rem;
  margin-bottom: 0.15rem;
}

.pack-sub {
  display: block;
  font-size: 0.77rem;
  color: var(--text-muted);
  line-height: 1.32;
}

/* Custom Pack Uploader */
.custom-pack-panel {
  margin-top: 0.95rem;
  padding: 0.95rem;
  border-radius: 0.95rem;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
}

.custom-pack-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.file-upload-btn {
  cursor: pointer;
}

.custom-cards-list {
  margin-top: 0.85rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8.2rem, 1fr));
  gap: 0.65rem;
}

.custom-mini-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  padding: 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.custom-mini-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: var(--stage-bg);
  border-radius: 0.55rem;
}

.custom-mini-card input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0.45rem;
  padding: 0.28rem 0.42rem;
  font-size: 0.78rem;
}

.custom-del-btn {
  position: absolute;
  top: 0.3rem;
  right: 0.3rem;
  width: 1.45rem;
  height: 1.45rem;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 0.7rem;
}

.settings-row {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 0.95rem;
}

.lobby-start-bar {
  margin-top: 1.2rem;
}

.readonly-lock .mode-card,
.readonly-lock .pack-tile,
.readonly-lock .seg-btn {
  pointer-events: none;
  opacity: 0.85;
}

/* Lobby Chat Sidebar */
.lobby-chat-col {
  position: sticky;
  top: 4.9rem;
  height: calc(100dvh - 6.4rem);
  min-height: 440px;
  max-height: 760px;
  display: flex;
  flex-direction: column;
  padding: 1rem;
}

/* ==================== SCREEN 3: FLUID ACTIVE GAME ==================== */
.screen-game {
  flex: 1;
  width: 100%;
  max-width: min(97vw, var(--app-max-w));
  margin: 0 auto;
  padding: 1rem 1.35rem 1.8rem;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--side-col-w);
  gap: 1.15rem;
  align-items: start;
}

.game-main-col {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

/* Secret Hero & Opponent Counter Strip */
.hero-status-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.9rem;
}

.my-secret-card,
.opponent-progress-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1.15rem;
  padding: 0.75rem 1.05rem;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  box-shadow: var(--shadow-sm), var(--inner-shine);
}

.secret-thumb-wrap {
  width: 3.7rem;
  height: 3.7rem;
  border-radius: 0.88rem;
  background: var(--stage-bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.secret-thumb {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 2px;
  transition: filter 0.2s ease;
}

.my-secret-card.blurred .secret-thumb,
.my-secret-card.blurred .secret-name,
.my-secret-card.blurred .secret-tag {
  filter: blur(9px);
  user-select: none;
}

.secret-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.secret-name {
  font-size: 1.08rem;
  font-weight: 800;
  letter-spacing: -0.015em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.secret-tag {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.opponent-progress-card {
  justify-content: space-between;
  gap: 1.25rem;
}

.opp-counter-row {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  font-variant-numeric: tabular-nums;
}

.opp-counter-row strong {
  font-size: 1.45rem;
  font-weight: 800;
}

.muted-slash {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.delta-badge {
  margin-left: 0.3rem;
  padding: 0.16rem 0.5rem;
  border-radius: 999px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 0.76rem;
  font-weight: 700;
  animation: popIn 0.25s ease;
}

.btn-pref-hero {
  height: 2.85rem;
  padding: 0 1.2rem;
  font-size: 0.95rem;
  border-radius: 0.88rem;
}

/* ==================== BIG INTERACTIVE TURN CONSOLE ==================== */
.turn-console {
  padding: 1.25rem 1.4rem;
  border-width: 1.5px;
  transition: border-color 0.22s ease, box-shadow 0.22s ease;
}

.turn-console.my-turn-highlight {
  border-color: var(--accent);
  box-shadow: var(--accent-glow);
}

.turn-console.answer-highlight {
  border-color: var(--amber);
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.35), 0 10px 30px rgba(245, 158, 11, 0.12);
}

.console-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-bottom: 0.85rem;
}

.console-title-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.turn-pill {
  padding: 0.28rem 0.72rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.turn-pill.mine {
  background: var(--accent-soft);
  color: var(--accent-bright);
}

.turn-pill.theirs {
  background: var(--surface-2);
  color: var(--text-muted);
}

.turn-pill.bonus {
  background: var(--amber-soft);
  color: var(--amber);
}

.question-box-large {
  min-height: 5.5rem;
  resize: vertical;
  font-size: 1.05rem;
  line-height: 1.46;
  padding: 0.9rem 1.05rem;
  border-radius: 0.95rem;
}

.question-Ideas-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.42rem;
  margin-top: 0.6rem;
}

.idea-chip {
  padding: 0.35rem 0.72rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.79rem;
  transition: all 0.14s ease;
}

.idea-chip:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.console-actions-row {
  margin-top: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.incoming-question-quote {
  font-size: 1.18rem;
  font-weight: 700;
  line-height: 1.4;
  padding: 0.95rem 1.15rem;
  border-radius: 0.95rem;
  background: var(--surface-2);
  border-left: 4px solid var(--accent);
  margin-bottom: 0.95rem;
  word-break: break-word;
}

/* Answer Buttons ("Кнопки + Ответ") */
.answer-btns-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.55rem;
  margin-bottom: 0.75rem;
}

.ans-choice-btn {
  height: 3.1rem;
  border-radius: 0.85rem;
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  font-weight: 700;
  font-size: 0.96rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.42rem;
  transition: all 0.16s cubic-bezier(0.22, 1, 0.36, 1);
}

.ans-choice-btn:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.ans-choice-btn[data-ans="yes"].selected {
  background: var(--green-soft);
  border-color: var(--green);
  color: var(--green);
}

.ans-choice-btn[data-ans="no"].selected {
  background: var(--red-soft);
  border-color: var(--red);
  color: var(--red);
}

.ans-choice-btn[data-ans="partial"].selected {
  background: var(--amber-soft);
  border-color: var(--amber);
  color: var(--amber);
}

.ans-choice-btn[data-ans="unknown"].selected {
  background: var(--slate-pill);
  border-color: var(--text-muted);
  color: var(--text);
}

/* Received Answer Result Banner */
.answer-result-box {
  padding: 0.95rem 1.1rem;
  border-radius: 0.95rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  margin-bottom: 0.95rem;
}

.answer-result-q {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.answer-result-a {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.ans-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.75rem;
  border-radius: 0.55rem;
  font-weight: 800;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ans-badge.yes {
  background: var(--green-soft);
  color: var(--green);
}

.ans-badge.no {
  background: var(--red-soft);
  color: var(--red);
}

.ans-badge.partial {
  background: var(--amber-soft);
  color: var(--amber);
}

.ans-badge.unknown {
  background: var(--slate-pill);
  color: var(--text);
}

.answer-comment-text {
  font-size: 1.02rem;
  font-weight: 600;
}

/* Assign Character Picker for "Кто я?" */
.assign-picker-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.assign-custom-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.7rem;
}

/* ==================== LARGE FLUID CHARACTER CARDS GRID ==================== */
.board-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.board-toolbar-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.92rem;
}

.board-search-input {
  height: 2.15rem;
  width: 12.5rem;
  padding: 0 0.75rem;
  border-radius: 0.65rem;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.83rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, width 0.2s ease;
}

.board-search-input:focus {
  border-color: var(--accent);
  width: 15.5rem;
}

.board-toolbar-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.42rem;
}

.size-pills {
  display: inline-flex;
  gap: 0.22rem;
  padding: 0.16rem;
  border-radius: 0.7rem;
  background: var(--surface);
  border: 1px solid var(--border);
}

.size-pills .chip-btn {
  border: none;
  background: transparent;
  padding: 0.3rem 0.62rem;
}

.size-pills .chip-btn.active {
  background: var(--surface-3);
  color: var(--text);
}

.chip-btn {
  padding: 0.42rem 0.78rem;
  border-radius: 0.65rem;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.15s ease;
}

.chip-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.chip-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-bright);
}

/* Fluid auto-fill grid adapting dynamically to screen width & chosen card size! */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--card-min), 1fr));
  gap: var(--grid-gap);
}

.cards-grid.hide-eliminated .char-card.eliminated {
  display: none;
}

.char-card.filtered-out {
  display: none;
}

.char-card {
  position: relative;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 1.2rem;
  padding: 0.6rem 0.6rem 0.78rem;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  user-select: none;
  box-shadow: var(--shadow-sm), var(--inner-shine);
  transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.16s ease, background 0.16s ease, box-shadow 0.18s ease;
}

.char-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md), var(--inner-shine);
}

.char-card:active {
  transform: scale(0.975);
}

/* UNCROPPED CHARACTER STAGE: Ambient Blurred Backdrop + Full `object-fit: contain` Portrait */
.char-img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1.02;
  border-radius: 0.88rem;
  overflow: hidden;
  background: var(--stage-bg);
  margin-bottom: 0.58rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.char-img-backdrop {
  position: absolute;
  inset: -12%;
  width: 124%;
  height: 124%;
  object-fit: cover;
  filter: blur(20px) saturate(1.4);
  opacity: 0.36;
  pointer-events: none;
  z-index: 0;
}

.char-img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 5px;
  display: block;
  filter: drop-shadow(0 5px 12px rgba(0, 0, 0, 0.24));
  transition: filter 0.2s ease, transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.char-card:hover .char-img {
  transform: scale(1.035);
}

.char-name {
  font-size: 0.94rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.24;
  text-align: center;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 1.3em;
  padding: 0 0.15rem;
}

.char-tag {
  margin-top: 0.2rem;
  font-size: 0.76rem;
  color: var(--text-muted);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Corner mini controls on card (? maybe & zoom) */
.card-corner-btn {
  position: absolute;
  top: 0.42rem;
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(12, 14, 20, 0.65);
  backdrop-filter: blur(6px);
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease, transform 0.14s ease;
  z-index: 4;
}

.char-card:hover .card-corner-btn,
.char-card.maybe .card-maybe-btn {
  opacity: 1;
}

.card-maybe-btn {
  left: 0.42rem;
}

.card-zoom-btn {
  right: 0.42rem;
}

.card-corner-btn:hover {
  background: rgba(12, 14, 20, 0.9);
  transform: scale(1.06);
}

/* ELIMINATED (RED) STATE */
.char-card.eliminated {
  background: var(--red-card-bg);
  border-color: var(--red-border);
}

.char-card.eliminated .char-img,
.char-card.eliminated .char-img-backdrop {
  filter: grayscale(0.82) opacity(0.34);
}

.char-card.eliminated .char-name {
  color: var(--red);
  text-decoration: line-through;
  opacity: 0.88;
}

.red-cross-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(244, 63, 94, 0.16);
  pointer-events: none;
}

.char-card.eliminated .red-cross-overlay {
  display: flex;
}

.red-cross-pill {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-weight: 800;
  font-size: 1.12rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(244, 63, 94, 0.45);
}

/* MAYBE (YELLOW) STATE */
.char-card.maybe:not(.eliminated) {
  border-color: var(--amber);
  box-shadow: 0 0 0 2.5px var(--amber-soft);
}

.char-card.maybe:not(.eliminated) .card-maybe-btn {
  background: var(--amber);
  color: #fff;
}

/* Opponent's visible forehead badge in "Кто я?" */
.forehead-ribbon {
  position: absolute;
  bottom: 0.4rem;
  left: 0.4rem;
  right: 0.4rem;
  padding: 0.22rem 0.45rem;
  border-radius: 0.45rem;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  text-align: center;
  z-index: 3;
  box-shadow: var(--shadow-sm);
}

.notes-area {
  min-height: 11rem;
  resize: vertical;
}

/* ==================== SIDEBAR: LOG & LIVE CHAT ==================== */
.game-side-col {
  position: sticky;
  top: 4.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
  height: calc(100dvh - 6.1rem);
}

.side-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0.95rem 1rem;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding-bottom: 0.68rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.68rem;
  font-size: 0.92rem;
}

.qa-log-list,
.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding-right: 0.2rem;
}

.empty-placeholder {
  margin: auto;
  text-align: center;
  color: var(--text-subtle);
  font-size: 0.84rem;
  padding: 1.2rem 0.6rem;
}

.qa-entry {
  padding: 0.72rem 0.82rem;
  border-radius: 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.85rem;
}

.qa-entry.pref-entry {
  border-color: var(--red-border);
  background: var(--red-card-bg);
}

.qa-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-bottom: 0.28rem;
}

.qa-q {
  font-weight: 600;
  margin-bottom: 0.42rem;
  word-break: break-word;
}

.qa-a {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.48rem;
}

/* Chat Messages */
.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 86%;
}

.chat-msg.mine {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-msg.theirs {
  align-self: flex-start;
  align-items: flex-start;
}

.chat-msg.system {
  align-self: center;
  max-width: 96%;
}

.chat-author {
  font-size: 0.72rem;
  color: var(--text-subtle);
  margin-bottom: 0.16rem;
  padding: 0 0.25rem;
}

.chat-bubble {
  padding: 0.55rem 0.85rem;
  border-radius: 0.95rem;
  font-size: 0.88rem;
  line-height: 1.4;
  word-break: break-word;
}

.chat-msg.mine .chat-bubble {
  background: var(--primary);
  color: var(--primary-fg);
  border-bottom-right-radius: 0.25rem;
}

.chat-msg.theirs .chat-bubble {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 0.25rem;
}

.chat-msg.system .chat-bubble {
  background: transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-align: center;
  padding: 0.2rem 0.5rem;
}

.quick-reactions {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  padding: 0.48rem 0;
  scrollbar-width: none;
}

.quick-reactions::-webkit-scrollbar {
  display: none;
}

.react-chip {
  flex-shrink: 0;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 0.78rem;
  transition: background 0.14s;
}

.react-chip:hover {
  background: var(--surface-hover);
}

.chat-input-row {
  display: flex;
  gap: 0.48rem;
  margin-top: 0.15rem;
}

.btn-icon-send {
  width: 2.85rem;
  padding: 0;
  flex-shrink: 0;
  font-size: 1.08rem;
}

/* ==================== MODALS ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 95;
  background: var(--backdrop);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-card {
  width: 100%;
  max-height: 91dvh;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 1.5rem;
  padding: 1.5rem;
  box-shadow: var(--shadow-lg), var(--inner-shine);
  display: flex;
  flex-direction: column;
  animation: popIn 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal-sm { max-width: 26rem; }
.modal-md { max-width: 35rem; }
.modal-xl { max-width: min(92vw, 62rem); }

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.95rem;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.2rem;
}

.modal-body {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.modal-footer {
  margin-top: 1.1rem;
  padding-top: 0.95rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
}

/* Pref Modal Grid — Uncropped contain portraits */
.pref-candidates-grid {
  margin-top: 0.85rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
  gap: 0.65rem;
}

.pref-candidate {
  padding: 0.5rem;
  border-radius: 0.92rem;
  background: var(--surface-2);
  border: 2px solid var(--border);
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pref-candidate.is-eliminated {
  opacity: 0.45;
}

.pref-candidate.selected {
  border-color: var(--red);
  background: var(--red-card-bg);
  opacity: 1;
  transform: translateY(-2px);
}

.pref-candidate-stage {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 0.65rem;
  background: var(--stage-bg);
  margin-bottom: 0.4rem;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pref-candidate img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 3px;
}

.pref-candidate span {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.22;
}

/* Zoom Modal — Full uncropped showcase stage */
.zoom-card {
  position: relative;
  align-items: center;
  text-align: center;
}

.zoom-close {
  position: absolute;
  top: 0.95rem;
  right: 0.95rem;
  z-index: 5;
}

.zoom-portrait-stage {
  position: relative;
  width: 16.5rem;
  height: 16.5rem;
  border-radius: 1.35rem;
  overflow: hidden;
  background: var(--stage-bg);
  border: 1px solid var(--border);
  margin-bottom: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.zoom-portrait {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 8px;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.28));
}

.zoom-title {
  margin: 0 0 0.4rem;
  font-size: 1.35rem;
}

.zoom-actions {
  width: 100%;
  margin-top: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* Victory / Game Over Modal */
.gameover-card {
  text-align: center;
  align-items: center;
}

.gameover-badge {
  padding: 0.35rem 0.95rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin-bottom: 0.55rem;
}

.gameover-badge.win {
  background: var(--green-soft);
  color: var(--green);
}

.gameover-badge.lose {
  background: var(--red-soft);
  color: var(--red);
}

.gameover-title {
  margin: 0 0 0.4rem;
  font-size: 1.7rem;
}

.reveal-duel-row {
  width: 100%;
  margin: 1.2rem 0 1.45rem;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.8rem;
}

.reveal-hero-box {
  padding: 0.95rem 0.7rem;
  border-radius: 1.1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
}

.reveal-img-stage {
  width: 7.4rem;
  height: 7.4rem;
  border-radius: 1rem;
  background: var(--stage-bg);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reveal-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
}

.gameover-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.rules-content {
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
}

.rule-block p {
  margin: 0.28rem 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ==================== TOASTS ==================== */
.toast-container {
  position: fixed;
  top: 4.5rem;
  right: 1rem;
  z-index: 115;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-width: 23rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: 0.78rem 1.05rem;
  border-radius: 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-md);
  font-size: 0.88rem;
  font-weight: 500;
  animation: popIn 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.toast.error {
  border-color: var(--red);
}

.toast.success {
  border-color: var(--green);
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ==================== MOBILE BOTTOM NAV & RESPONSIVE ==================== */
.mobile-bottom-nav {
  display: none;
}

@media (max-width: 1120px) {
  .lobby-layout {
    grid-template-columns: 1fr;
  }

  .lobby-chat-col {
    position: static;
    height: 360px;
    min-height: 320px;
  }

  .game-layout {
    grid-template-columns: 1fr;
  }

  .game-side-col {
    position: static;
    height: auto;
  }

  .screen-game {
    padding-bottom: calc(4.9rem + env(safe-area-inset-bottom, 0px));
  }

  .mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    height: calc(3.9rem + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--topbar-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .mob-nav-btn {
    position: relative;
    border: none;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text-muted);
  }

  .mob-nav-btn.active {
    color: var(--text);
  }

  .nav-badge {
    position: absolute;
    top: 6px;
    right: calc(50% - 26px);
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: 0.68rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .nav-badge.unread {
    background: var(--red);
    color: #fff;
    border-color: var(--red);
  }

  .screen-game[data-active-tab="board"] #game-sidebar {
    display: none;
  }

  .screen-game[data-active-tab="log"] #mobile-pane-board,
  .screen-game[data-active-tab="log"] #mobile-pane-chat {
    display: none;
  }

  .screen-game[data-active-tab="chat"] #mobile-pane-board,
  .screen-game[data-active-tab="chat"] #mobile-pane-log {
    display: none;
  }

  .screen-game[data-active-tab="log"] #mobile-pane-log,
  .screen-game[data-active-tab="chat"] #mobile-pane-chat {
    height: calc(100dvh - 9.4rem - env(safe-area-inset-bottom, 0px));
  }

  .card-corner-btn {
    opacity: 0.9;
  }
}

@media (max-width: 680px) {
  .topbar {
    padding: 0 0.75rem;
    height: 3.45rem;
  }

  .brand-text,
  .room-pill-label,
  .topbar-center {
    display: none;
  }

  .screen-lobby,
  .screen-game {
    max-width: 100%;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .home-card {
    padding: 1.65rem 1.3rem;
  }

  .home-title {
    font-size: 1.48rem;
  }

  .players-strip,
  .mode-grid,
  .settings-row,
  .hero-status-strip {
    grid-template-columns: 1fr;
  }

  .players-strip .vs-pill {
    display: none;
  }

  .packs-grid {
    grid-template-columns: 1fr 1fr;
  }

  .turn-console {
    padding: 0.95rem;
  }

  .answer-btns-grid {
    grid-template-columns: 1fr 1fr;
  }

  /* Generous readable cards on mobile: 2 per row on XXL/Large, 3 per row on Compact */
  [data-card-size="xl"] { --card-min: 148px; }
  [data-card-size="lg"] { --card-min: 136px; }
  [data-card-size="md"] { --card-min: 100px; }

  .board-search-input,
  .board-search-input:focus {
    width: 100%;
  }

  .board-search-wrap {
    flex: 1;
    min-width: 140px;
  }

  .toast-container {
    left: 0.75rem;
    right: 0.75rem;
    max-width: none;
  }
}

@media (max-width: 360px) {
  .packs-grid {
    grid-template-columns: 1fr;
  }
}
