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

/* Ensure [hidden] always wins over CSS display rules */
[hidden] { display: none !important; }

:root {
  --bg: #0f0f1a;
  --surface: #1a1a2e;
  --surface-light: #25253d;
  --primary: #e94560;
  --primary-hover: #ff6b81;
  --secondary: #533483;
  --secondary-hover: #6c44a2;
  --text: #eaeaea;
  --text-muted: #8888aa;
  --border: #333355;
  --error: #ff4757;
  --success: #2ed573;
  --success-hover: #3bde80;
  --radius: 12px;
  --glass: rgba(26, 26, 46, 0.6);
  --glass-border: rgba(255, 255, 255, 0.06);
  --glow: rgba(233, 69, 96, 0.2);
  --glow-strong: rgba(233, 69, 96, 0.45);
}

html, body {
  height: 100%;
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
html {
  overflow-y: auto;
  scrollbar-color: rgba(255,255,255,0.12) transparent;
  scrollbar-width: thin;
}
html::-webkit-scrollbar { width: 6px; }
html::-webkit-scrollbar-track { background: transparent; }
html::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.12);
  border-radius: 3px;
}
html::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }
/* Prevent body scrolling on the play page — game-panel is the scroll container.
   This avoids the sticky nav and players-panel overlapping on mobile scroll and
   ensures phase transitions reset scroll correctly.
   Flex column layout ensures .screen fills remaining space after the nav,
   preventing the players-panel from being hidden behind the navbar. */
body:has(.room-body) {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Inherit font on form elements (UA default doesn't inherit) */
button, input, select {
  font-family: inherit;
}

/* Prevent double-tap zoom on all interactive elements */
button, input, a {
  touch-action: manipulation;
}

/* Screen reader only */
.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;
}

/* Status banner */
.status-banner:not([hidden]) {
  display: block;
  justify-content: center;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  padding: 1rem;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  background: color-mix(in srgb, var(--primary) 90%, transparent);
  color: #fff;
  animation: reconnect-pulse 2s ease-in-out infinite;
}

@keyframes reconnect-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.status-banner.success {
  background: color-mix(in srgb, var(--success) 90%, transparent);
  animation: none;
}

/* Utility */
.screen {
  display: none;
  height: 100%;
}
.screen.active {
  display: flex;
}

/* ---------- Lobby ---------- */
.lobby-screen {
  align-items: center;
  justify-content: center;
  height: auto;
  min-height: 100%;
}

.lobby-screen::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 50% at 12% 25%, rgba(233, 69, 96, 0.07) 0%, transparent 60%),
    radial-gradient(ellipse 60% 80% at 88% 65%, rgba(83, 52, 131, 0.08) 0%, transparent 55%),
    radial-gradient(ellipse 40% 40% at 50% 0%, rgba(233, 69, 96, 0.04) 0%, transparent 50%);
  pointer-events: none;
}

.lobby-container {
  width: 100%;
  max-width: 440px;
  padding: 2rem 1.75rem;
  text-align: center;
  background: var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  box-shadow:
    0 8px 40px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.logo {
  font-size: 3.2rem;
  font-weight: 900;
  letter-spacing: -2px;
  color: var(--text);
}
.logo a {
  color: inherit;
  text-decoration: none;
}
.logo a:hover {
  opacity: 0.85;
}
.logo span {
  background: linear-gradient(135deg, var(--primary) 20%, #ff6b81 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 20px var(--glow-strong));
}

.landing-header {
  text-align: center;
}

.tagline {
  color: var(--text-muted);
  margin-bottom: 2rem;
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 3px;
  text-transform: uppercase;
  opacity: 0.7;
}

.card-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.75rem;
}

/* ---------- Rejoin banner ---------- */
.rejoin-banner:not([hidden]) {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  margin-bottom: 1rem;
  background: rgba(233, 69, 96, 0.06);
  border: 1px solid rgba(233, 69, 96, 0.25);
  border-radius: var(--radius);
  color: var(--primary);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
.rejoin-banner:hover {
  background: rgba(233, 69, 96, 0.1);
}

.lobby-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

input[type="text"],
textarea {
  background: rgba(15, 15, 26, 0.5);
  border: 1px solid rgba(51, 51, 85, 0.5);
  border-radius: var(--radius);
  padding: 0.85rem 1.1rem;
  color: var(--text);
  font-size: 1.05rem;
  outline: none;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
input[type="text"]:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--glow);
}
input[type="text"]::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

#room-code {
  text-transform: uppercase;
  letter-spacing: 4px;
  text-align: center;
  font-weight: 700;
}

.btn {
  border: none;
  border-radius: var(--radius);
  padding: 0.75rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.25s ease, background 0.2s;
}
.btn:disabled,
.btn:disabled:hover {
  background: var(--surface-light);
  box-shadow: none;
  color: var(--text-muted);
  cursor: not-allowed;
  transform: none;
  transition: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), #d63851);
  color: #fff;
  font-weight: 700;
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px var(--glow);
  background: linear-gradient(135deg, var(--primary-hover), var(--primary));
}
.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px var(--glow);
}
.btn-secondary {
  background: var(--secondary);
  color: #fff;
}
.btn-secondary:hover {
  background: var(--secondary-hover);
}
.btn-success {
  background: var(--success);
  color: var(--bg);
}
.btn-success:hover {
  background: var(--success-hover);
}
.btn-small {
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
  background: var(--surface-light);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-small:hover {
  background: var(--border);
}
.btn-small.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-small.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}
.btn-danger {
  background: rgba(233, 69, 96, 0.15);
  color: var(--primary);
  border-color: var(--primary);
}
.btn-danger:hover {
  background: rgba(233, 69, 96, 0.3);
}

.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.field-section input[type="text"] {
  width: 100%;
}

.error-msg {
  margin-top: 0.75rem;
  color: var(--primary);
  font-size: 0.85rem;
}
.error-msg:not([hidden]) {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  background: rgba(233, 69, 96, 0.1);
  border: 1px solid rgba(233, 69, 96, 0.3);
  border-radius: var(--radius);
  padding: 0.6rem 0.85rem;
}

/* Inline field validation */
.field-feedback {
  color: var(--primary);
  font-size: 0.82rem;
  margin-top: 0.25rem;
}
.field-feedback:not([hidden]) {
  display: flex;
  align-items: flex-start;
  text-align: left;
  gap: 0.35rem;
}

/* Warning icon for error/validation messages */
.error-msg::before,
.field-feedback::before,
.setting-feedback.error::before {
  content: '';
  width: 0.95em;
  height: 0.95em;
  flex-shrink: 0;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1L1 14h14L8 1zM7.25 6h1.5v4h-1.5V6zM8 11.5a.75.75 0 100 1.5.75.75 0 000-1.5z'/%3E%3C/svg%3E") no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1L1 14h14L8 1zM7.25 6h1.5v4h-1.5V6zM8 11.5a.75.75 0 100 1.5.75.75 0 000-1.5z'/%3E%3C/svg%3E") no-repeat center / contain;
  background-color: currentColor;
  margin-top: 0.2em;
}
input[type="text"].input-invalid {
  border-color: var(--primary);
  animation: shake 0.4s ease;
}
input[type="text"].input-readonly {
  opacity: 0.6;
  cursor: not-allowed;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* ---------- Game mode cards (lobby) ---------- */
.mode-cards:not([hidden]) {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 1.25rem;
}
.mode-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1.25rem 0.75rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
  color: var(--text);
  text-align: center;
  -webkit-tap-highlight-color: transparent;
}
.mode-card:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-2px);
}
.mode-card:active {
  transform: translateY(0);
}
.mode-card__icon {
  width: 64px;
  height: 64px;
  color: var(--text-muted);
  transition: color 0.15s;
}
.mode-card:hover .mode-card__icon {
  color: var(--primary);
}
.mode-card__title {
  font-size: 1rem;
  font-weight: 700;
}
.mode-card__desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.3;
}
/* Disabled competitive card for guests */
.mode-card--disabled {
  opacity: 0.4;
  pointer-events: none;
  cursor: default;
}
.mode-card--disabled:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--glass-border);
  transform: none;
}
.mode-card__lock-msg {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.3;
}
/* Casual subview (create/join buttons after clicking casual) */
.casual-subview:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.5rem;
  animation: fadeIn 0.2s ease;
}
.casual-subview__back {
  margin-top: 0.5rem;
}
/* Desktop: larger icons */
@media (min-width: 641px) {
  .mode-card {
    padding: 1.75rem 1rem;
  }
  .mode-card__icon {
    width: 96px;
    height: 96px;
  }
  .mode-card__title {
    font-size: 1.1rem;
  }
}

/* ---------- Lobby subviews (Create Game / Join Game) ---------- */
.lobby-buttons:not([hidden]) {
  display: flex;
  gap: 0.75rem;
  flex-direction: column;
  margin-top: 2rem;
}
/* Reduce top margin when lobby-buttons follow casual-subview */
.casual-subview + .lobby-buttons:not([hidden]) {
  margin-top: 0.75rem;
}
.lobby-buttons .btn {
  flex: 1;
}

.lobby-subview:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  animation: fadeIn 0.2s ease;
}
.lobby-subview[hidden] {
  display: none;
}

.subview-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.25rem;
}
.subview-title-left {
  text-align: left;
}

.subview-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.subview-form .setting-group {
  margin-bottom: 0;
  text-align: left;
}

/* Fieldset groups within the create-page subview-form (Game / Lobby sections) */
.subview-form > .qtype-fieldset {
  margin-bottom: 0;
}
.subview-form .qtype-fieldset .setting-group {
  margin-bottom: 0.75rem;
}
.subview-form .qtype-fieldset .setting-group:last-child {
  margin-bottom: 0;
}

.field-section {
  text-align: left;
}

/* ---------- Quick Play row ---------- */
.quick-play-row {
  display: flex;
  gap: 0.5rem;
}
.quick-play-btn {
  flex: 1;
  min-width: 0;
}
.quick-play-row .btn-icon:not([hidden]) {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  flex-shrink: 0;
  padding: 0;
}
.preferred-modes {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
  text-align: center;
}


/* ---------- Link-style button ---------- */
.btn-link {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0.25rem 0;
  transition: color 0.2s;
}
.btn-link:hover {
  color: var(--primary);
}

/* ---------- Lobby footer links ---------- */
.lobby-links {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
}
.lobby-links-row {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}
.btn-badge {
  display: inline-flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  transition: border-color 0.2s, color 0.2s;
}
.btn-badge:hover {
  border-color: var(--primary);
  color: var(--text);
}

/* ==========================================================================
   Site Navigation Bar
   ========================================================================== */

.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  flex-shrink: 0;
  background: rgba(15, 15, 26, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--glass-border);
}

.site-nav__inner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 auto;
  padding: 0 0.75rem;
  height: 56px;
}

.site-nav__logo {
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: -0.5px;
  color: var(--text);
  background-color: var(--surface);
  text-decoration: none;
  margin-right: auto;
  flex-shrink: 0;
  padding: 0.5rem;
  border-radius: var(--radius);
}

.site-nav__logo:hover {
  color: var(--primary);
}

.site-nav__logo-full > span,
.site-nav__logo-abbr > span {
  background: linear-gradient(135deg, var(--primary) 20%, var(--primary-hover) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.site-nav__logo:hover .site-nav__logo-full > span,
.site-nav__logo:hover .site-nav__logo-abbr > span {
  background: linear-gradient(135deg, var(--text) 20%, var(--text-muted) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Desktop links */
.site-nav__links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.site-nav__link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.site-nav__link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.site-nav__link--active {
  color: var(--primary);
}

.site-nav__sign-in {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  background: rgba(233, 69, 96, 0.12);
  color: var(--primary);
  border: 1px solid rgba(233, 69, 96, 0.25);
  transition: color 0.15s, background 0.15s;
}

.site-nav__sign-in:hover {
  background: rgba(233, 69, 96, 0.2);
  color: var(--primary-hover);
}

/* User profile menu (desktop dropdown) */
.site-nav__user-menu {
  position: relative;
  margin-left: 0.25rem;
}

.site-nav__user-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}

.site-nav__user-trigger:hover {
  background: rgba(255, 255, 255, 0.1);
}

.site-nav__user-nick {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-nav__user-caret {
  flex-shrink: 0;
  transition: transform 0.15s;
}

.site-nav__user-trigger[aria-expanded="true"] .site-nav__user-caret {
  transform: rotate(180deg);
}

.site-nav__user-dropdown:not([hidden]) {
  display: flex;
  flex-direction: column;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 150px;
  background: rgba(20, 20, 35, 0.97);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 0.35rem 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 110;
}

.site-nav__user-dropdown-item {
  display: block;
  width: 100%;
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: color 0.15s, background 0.15s;
}

.site-nav__user-dropdown-item:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.site-nav__user-dropdown-item--sign-out {
  color: var(--primary);
}

.site-nav__user-dropdown-item--sign-out:hover {
  background: rgba(233, 69, 96, 0.12);
}

/* Logo: full text on desktop, abbreviated on mobile */
.site-nav__logo-abbr {
  display: none;
}

/* Game action buttons injected into site-nav on the play page */
#game-nav-actions:not([hidden]) {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 0.5rem;
}

/* Chat + Players buttons are mobile-only */
#game-nav-actions .btn-chat-header,
#game-nav-actions .btn-players-header {
  display: none;
}

/* Hamburger — hidden on desktop, shown on mobile and always in game */
.site-nav__hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 0.65rem;
  margin-left: -0.45rem;
  border-radius: 6px;
  line-height: 0;
  flex-shrink: 0;
  min-width: 44px;
  min-height: 44px;
}

.site-nav__hamburger:hover {
  color: var(--primary);
  background: rgba(255, 255, 255, 0.05);
}

/* Game mode: always use hamburger menu regardless of screen size */
.site-nav--game .site-nav__hamburger {
  display: flex;
  align-items: center;
  justify-content: center;
}

.site-nav--game .site-nav__links {
  display: none;
  position: absolute;
  top: 56px;
  left: 0;
  right: 0;
  flex-direction: column;
  align-items: stretch;
  background: rgba(15, 15, 26, 0.97);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--glass-border);
  padding: 0.5rem 0 1rem;
  gap: 0.1rem;
  z-index: 99;
}

.site-nav--game.site-nav--open .site-nav__links {
  display: flex;
}

.site-nav--game .site-nav__link {
  padding: 0.75rem 1.5rem;
  border-radius: 0;
  font-size: 1rem;
  justify-content: flex-start;
}

.site-nav--game .site-nav__sign-in {
  display: none;
}

.site-nav--game .site-nav__user-menu {
  display: none;
}

/* Mobile */
@media (max-width: 640px) {
  .site-nav--game .site-nav__logo-full {
    display: none;
  }

  .site-nav--game .site-nav__logo-abbr {
    display: inline;
  }

  .site-nav__hamburger {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .site-nav__links {
    display: none;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    background: rgba(15, 15, 26, 0.97);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--glass-border);
    padding: 0.5rem 0 1rem;
    gap: 0.1rem;
    z-index: 99;
  }

  .site-nav--open .site-nav__links {
    display: flex;
  }

  .site-nav__link {
    padding: 0.75rem 1.5rem;
    border-radius: 0;
    font-size: 1rem;
    justify-content: flex-start;
  }

  /* Chat + Players buttons are mobile-only in the game nav actions */
  #game-nav-actions .btn-chat-header:not([hidden]),
  #game-nav-actions .btn-players-header:not([hidden]) {
    display: inline-flex;
  }
  .site-nav--game .btn-share svg {
    display: none;
  }
  .site-nav--game .btn-icon:not([hidden]) {
    width: 32px;
  }

}

/* ==========================================================================
   Home Hero Section
   ========================================================================== */

.home-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1.5rem 1.5rem 2rem;
  max-width: 620px;
  width: 100%;
}

.hero-value-prop {
  font-size: 1rem;
  color: var(--text-muted);
  line-height: 1.65;
  margin-bottom: 2rem;
  max-width: 480px;
}

.hero-ctas {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-hero {
  font-size: 1.05rem;
  padding: 0.85rem 2rem;
}

/* ==========================================================================
   Landing layout (updated to work with sticky nav)
   ========================================================================== */

/* ---------- Landing layout ---------- */
.landing-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding-inline: 1rem;
  padding-bottom: 2rem;
}
a.btn-badge {
  text-decoration: none;
}

/* ---------- Card footer links (How to play / Disclaimer below card) ---------- */
.card-footer-links {
  margin-top: 2rem;
}

/* ---------- Invite join ---------- */
#invite-join {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
#invite-join[hidden] {
  display: none;
}
.lobby-form[hidden] {
  display: none;
}
.invite-msg {
  color: var(--text-muted);
  font-size: 1rem;
  margin-bottom: 0.25rem;
}
.invite-code {
  color: var(--primary);
  font-weight: 700;
  letter-spacing: 2px;
}

/* ---------- Share button ---------- */
.btn-share:not([hidden]) {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--secondary);
  border-color: var(--secondary);
  color: #fff;
}
.btn-share:hover {
  background: var(--secondary-hover);
  border-color: var(--secondary-hover);
}
.btn-share svg {
  display: block;
  flex-shrink: 0;
}
#btn-share.copied {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

/* ---------- Room ---------- */
#screen-room {
  flex-direction: column;
  min-height: 0;
}

.app-header:not([hidden]) {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.app-title {
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.room-info {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
}
.app-title-link {
  color: inherit;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.app-title-text {
  font-weight: 900;
  letter-spacing: -1px;
}
.app-title-text span {
  background: linear-gradient(135deg, var(--primary) 20%, #ff6b81 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 12px var(--glow-strong));
}
.app-title-link:hover {
  opacity: 0.85;
}
/* Favicon icon hidden on desktop by default (shown on mobile) */
.app-title-icon {
  display: none;
}
.room-code {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 600;
}

.room-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* Game area (left) */
.game-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.players-panel {
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.players-panel h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  letter-spacing: 1px;
}
.player-count-badge {
  background: var(--surface-light);
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  margin-left: 0.35rem;
  font-weight: 600;
  letter-spacing: 0;
}
.players-panel-header {
  display: flex;
  align-items: center;
  margin-bottom: 0.4rem;
}
.players-panel-header h3 {
  display: flex;
  align-items: center;
  margin-bottom: 0;
}
.players-toggle {
  display: none;
}
#player-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
#player-list li {
  background: var(--surface-light);
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.85rem;
}
#player-list li.host::before {
  content: '\2605';
  margin-right: 0.25em;
  color: var(--primary);
}
#player-list li.host.room-owner::before {
  color: #FFD700;
}
#player-list li.me {
  background: #141428;
  font-weight: 700;
}
.player-score {
  color: var(--primary);
  font-weight: 700;
  margin-left: 0.35rem;
  font-size: 0.8em;
}

/* Slide animations for mobile overlay panels (global so both portrait and
   landscape media queries can reference them). */
@keyframes chat-slide-in {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}
@keyframes chat-slide-out {
  from { transform: translateX(0); }
  to   { transform: translateX(100%); }
}
@keyframes players-slide-in {
  from { transform: translateX(-100%); }
  to   { transform: translateX(0); }
}
@keyframes players-slide-out {
  from { transform: translateX(0); }
  to   { transform: translateX(-100%); }
}

/* Players overlay panel (mobile only — hidden on desktop) */
.players-overlay-panel {
  display: none;
}
.players-overlay-header {
  display: none;
}
.players-overlay-timer {
  display: none;
}

/* Players header button (hidden on desktop) */
.btn-players-header {
  display: none;
}

/* Swipe onboarding overlay */
.swipe-onboarding-overlay:not([hidden]) {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade-in 0.3s ease-out;
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.swipe-onboarding-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.5rem 2rem;
  text-align: center;
  max-width: 280px;
  width: 90%;
}
.swipe-onboarding-hints {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.swipe-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  font-size: 1rem;
  color: var(--text);
}
.swipe-hint svg {
  color: var(--primary);
  flex-shrink: 0;
}
.swipe-onboarding-dismiss {
  min-width: 100px;
}

.game-panel {
  flex: 1;
  display: flex;
  padding: 1rem;
  overflow-y: auto;
  position: relative;
  min-height: 0;
}
.waiting-msg {
  color: var(--text-muted);
  font-size: 1.1rem;
}
.waiting-msg.animated-ellipsis::after {
  content: '';
  animation: ellipsis 1.5s steps(4, end) infinite;
}
@keyframes ellipsis {
  0%  { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
}

.sync-waiting-area:not([hidden]) {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}
.sync-waiting-countdown-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.sync-waiting-countdown-row .hourglass-icon {
  width: 1.6rem;
  height: 1.6rem;
}
.sync-waiting-countdown-number {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--primary);
  min-width: 1.5em;
  text-align: center;
}
.sync-waiting-msg {
  color: var(--text-muted);
  font-size: 1rem;
  text-align: center;
}

.lobby-countdown:not([hidden]) {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}
.lobby-countdown-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.lobby-countdown-row .hourglass-icon {
  width: 1.6rem;
  height: 1.6rem;
}
.lobby-countdown-number {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--primary);
  min-width: 1.5em;
  text-align: center;
}

.casual-lobby-title:not([hidden]) {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0;
  color: var(--text);
}
.casual-lobby-title svg {
  flex-shrink: 0;
  vertical-align: middle;
}

.competitive-lobby-title:not([hidden]) {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0;
  color: var(--text);
}
.competitive-lobby-title svg {
  flex-shrink: 0;
  vertical-align: middle;
}

.opponent-profile-card:not([hidden]) {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  overflow: hidden;
  margin-bottom: 1rem;
  animation: fade-in 0.35s ease 0.3s both;
}
.opponent-profile-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
}

.opponent-profile-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.opponent-profile-tag {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1;
}
@keyframes lobby-slide-down {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.lobby-settings-summary.anim-slide-down {
  animation: lobby-slide-down 0.3s ease both;
}
.opponent-stats-row {
  display: flex;
  border-top: 1px solid var(--border);
}
.opponent-stat-item {
  flex: 1 1 0%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem 0.25rem;
  border-left: 1px solid var(--border);
}
.opponent-stat-item:first-child {
  border-left: none;
}
.opponent-stat-label {
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-muted);
  opacity: 0.7;
  margin-bottom: 0.15rem;
}
.opponent-stat-value {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
}
.vs-divider:not([hidden]) {
  display: block;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin: 0.5rem 0;
  animation: fade-in 0.3s ease both;
}
@keyframes lobby-fade-out {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(8px); }
}
.lobby-settings-summary.anim-fade-out {
  animation: lobby-fade-out 0.3s ease both;
}

.lobby-settings-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  width: 100%;
  max-width: 340px;
}
.lobby-settings-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.lobby-settings-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 0.75rem;
  font-size: 0.85rem;
}
.lobby-setting-label {
  color: var(--text-muted);
}
.lobby-setting-value {
  color: var(--text);
  text-align: right;
}
.lobby-types-badges:not([hidden]) {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem;
  padding-top: 0.15rem;
}
.lobby-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  white-space: nowrap;
}
.lobby-type-badge svg {
  flex-shrink: 0;
  opacity: 0.7;
}

/* ---------- Game states ---------- */
.game-state {
  display: none;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 500px;
  gap: 1rem;
}
.game-state.active {
  display: flex;
  margin: auto;
}
#game-round.game-state.active {
  margin: 0.25rem auto;
  flex: 1;
  position: relative;
}
#game-results.game-state.active {
  margin: 0.25rem auto;
}

.btn-large {
  padding: 0.85rem 2rem;
  font-size: 1.1rem;
}

.start-game-hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  margin: 0.25rem 0 0;
}

/* Round header */
.round-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0;
}
#round-info,
#voting-round-info,
#results-round-info,
#underdog-round-info {
  margin-left: auto;
  color: var(--text-muted);
}
.round-header .timer:not([hidden]) {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--surface);
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  min-width: 48px;
  text-align: center;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* Latency indicator — positioned at bottom-right of game-round */
.latency-indicator:not([hidden]) {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  position: absolute;
  bottom: 0.25rem;
  right: 0.25rem;
  opacity: 0.6;
}
.latency-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
}
.latency-dot.latency-good { background: var(--success); }
.latency-dot.latency-fair { background: var(--warning, #f0a030); }
.latency-dot.latency-poor { background: var(--danger, #e04040); }

/* Question type badge */
.question-type-badge:not([hidden]) {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.2rem 0.55rem;
  letter-spacing: 0.3px;
}
.question-type-badge-icon {
  opacity: 0.7;
  flex-shrink: 0;
}

/* Question type help icon (inside badge) */
.question-type-help-icon {
  opacity: 0.4;
  flex-shrink: 0;
  cursor: pointer;
  transition: opacity 0.15s;
  position: relative;
  top: 1px;
}
.question-type-badge:hover .question-type-help-icon,
.question-type-help-icon:hover {
  opacity: 0.8;
}

/* Question type help tooltip */
.question-type-tooltip:not([hidden]) {
  display: block;
  position: absolute;
  z-index: 50;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  max-width: 280px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  opacity: 1;
  transition: opacity 0.4s ease;
}
.question-type-tooltip.fading-out {
  opacity: 0;
}
.question-type-tooltip-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0 0 0.25rem;
}
.question-type-tooltip-example {
  font-size: 0.8rem;
  font-style: italic;
  color: var(--text);
  margin: 0;
}
@media (max-width: 640px) {
  .question-type-tooltip-desc {
    display: none;
  }
  .question-type-tooltip-example {
    margin: 0;
  }
}

/* Question content — vertically centers prompt + input in remaining space */
.question-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  gap: 1rem;
}

/* Prompt text (question) */
.prompt-text {
  font-size: 1.1rem;
  color: var(--text-muted);
  text-align: center;
  padding: 0.25rem 0 0;
}

/* Prompt word (highlighted element) */
.prompt-word {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--text);
  text-align: center;
  padding: 0.5rem 0 1rem;
  letter-spacing: 1px;
  font-family: Georgia, 'Times New Roman', serif;
}
.prompt-word--requote {
  font-size: 1.5rem;
}

/* Typo letter highlighting — swapped letters shown in red */
.typo-letter-swapped {
  color: var(--error);
}

/* Anagram letter highlighting — matched letters turn primary color */
.anagram-letter-matched {
  color: var(--primary);
  transition: color 0.15s ease;
}

/* Quote attribution (e.g. "— Apollo 13") — smaller, muted, right-aligned */
.prompt-attribution:not([hidden]) {
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: right;
  padding: 0 1rem 0.5rem;
  margin-top: -0.5rem;
  width: 100%;
  font-style: italic;
}

/* Prompt text after word (e.g. Gut Reaction second line) */
.prompt-text-after:not([hidden]) {
  font-size: 1.1rem;
  color: var(--text-muted);
  text-align: center;
  padding: 0 0 0.5rem;
  margin-top: -0.5rem;
}

/* Answer area */
.answer-area {
  width: 100%;
}

/* Answer input */
.answer-row {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}
.input-wrapper {
  position: relative;
  flex: 1;
  display: flex;
}
.answer-row input {
  flex: 1;
  font-size: 1.1rem;
  padding: 0.75rem 3.5rem 0.75rem 1rem;
}
.answer-row textarea {
  flex: 1;
  font-size: 1.1rem;
  padding: 0.75rem 3.5rem 0.75rem 1rem;
  resize: none;
  font-family: inherit;
  line-height: 1.4;
}
.char-count {
  position: absolute;
  right: 0.75rem;
  bottom: 0.4rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  pointer-events: none;
  user-select: none;
  opacity: 0.7;
}
.inline-timer {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
  pointer-events: none;
  user-select: none;
}
.hourglass-icon {
  animation: hourglass-rotate 2s ease-in-out infinite;
}
@keyframes hourglass-rotate {
  0% { transform: rotate(0deg); }
  40% { transform: rotate(180deg); }
  100% { transform: rotate(180deg); }
}

/* ---------- Panic timer effect (≤5 seconds remaining) ---------- */
@keyframes panic-bg {
  0%, 100% { background-color: var(--bg); }
  50% { background-color: #2a0a10; }
}
@keyframes panic-timer {
  0%, 100% { color: var(--primary); }
  50% { color: #ff1a1a; }
}
.game-panel.panic {
  animation: panic-bg 1s ease-in-out infinite;
}
.timer.panic,
.inline-timer.panic {
  animation: panic-timer 1s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  .game-panel.panic {
    background-color: #2a0a10;
    animation: none;
  }
  .timer.panic,
  .inline-timer.panic {
    color: #ff1a1a;
    animation: none;
  }
}

/* Virtual keyboard (mobile on-screen keyboard) */
.vk-container:not([hidden]) {
  display: flex;
  flex-direction: column;
  width: 100%;
  margin-top: 0.5rem;
}
.vk {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 6px 2px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.vk-row {
  display: flex;
  gap: 4px;
  justify-content: center;
  width: 100%;
}
.vk-key {
  flex: 1;
  max-width: 42px;
  min-height: 44px;
  border: none;
  border-radius: 6px;
  background: var(--surface-2, #2a2a3e);
  color: var(--text, #fff);
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.vk-key:active {
  background: var(--primary, #6c63ff);
  color: #fff;
}
.vk-key--backspace {
  flex: 1.4;
  max-width: 60px;
}
.vk-key--disabled {
  opacity: 0.3;
  pointer-events: none;
}
.vk-row--submit {
  margin-top: 4px;
}
.vk-key--submit {
  flex: none;
  width: 100%;
  max-width: none;
  min-height: 44px;
  font-size: 1rem;
  font-weight: 700;
}

.locked-msg {
  color: var(--success);
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
}
.waiting-msg {
  color: var(--text-muted);
  font-size: 0.95rem;
  text-align: center;
  margin-top: 0.5rem;
}

/* Centered bottom timer shown while answer is locked */
.locked-bottom-timer:not([hidden]) {
  display: flex;
  justify-content: center;
  margin-top: 1rem;
}
.locked-bottom-timer .timer {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--surface);
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
#btn-game-over-leave {
  margin-top: 0.75rem;
}

.submitted-list {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
}

/* Results title (above scoring table) */
.results-title {
  font-size: 1.1rem;
  color: var(--text);
  font-weight: 600;
  margin: 0.75rem 0;
  text-align: center;
  width: 100%;
}

/* Source word reveal (competitive mode) */
.results-source-word:not([hidden]) {
  display: block;
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 0.75rem;
  letter-spacing: 0.03em;
}

.source-word-value {
  color: var(--success);
}

.source-word-flag {
  vertical-align: middle;
  margin-left: 0.1rem;
  padding-left: 1px;
}

/* Centered bottom timer for results */
.results-bottom-timer:not([hidden]) {
  display: flex;
  justify-content: center;
  margin-top: 1rem;
}
.results-bottom-timer .timer:not([hidden]) {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--surface);
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.results-table {
  width: 100%;
  min-width: 320px;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.results-table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}
.results-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.results-table tr.correct td {
  color: var(--success);
}
.results-table tr.incorrect td {
  color: var(--text-muted);
}
.results-table tr.results-me td {
  background-color: var(--surface);
}
.results-host-star {
  color: var(--primary);
  margin-right: 0.25rem;
  white-space: nowrap;
}
.results-host-star.room-owner {
  color: #FFD700;
}

/* Report flag button in results rows */
.btn-report-flag {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 2px 4px;
  border-radius: 3px;
  vertical-align: middle;
  opacity: 0.5;
  transition: opacity 0.15s, color 0.15s;
}
.btn-report-flag:hover {
  opacity: 1;
  color: var(--warning, #e8a735);
}
.btn-report-flag.reported {
  opacity: 1;
  color: var(--success);
  cursor: default;
}
.btn-report-flag:disabled:not(.reported) {
  opacity: 0.3;
  cursor: default;
}

/* Game over / leaderboard */
.game-over-title {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.leaderboard {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.leaderboard-entry {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}
.leaderboard-entry.rank-1 {
  border-color: #ffd700;
  background: rgba(255, 215, 0, 0.08);
}
.leaderboard-entry.rank-2 {
  border-color: #c0c0c0;
  background: rgba(192, 192, 192, 0.06);
}
.leaderboard-entry.rank-3 {
  border-color: #cd7f32;
  background: rgba(205, 127, 50, 0.06);
}
.leaderboard-rank {
  font-size: 1.3rem;
  font-weight: 800;
  min-width: 32px;
  text-align: center;
}
.rank-1 .leaderboard-rank { color: #ffd700; }
.rank-2 .leaderboard-rank { color: #c0c0c0; }
.rank-3 .leaderboard-rank { color: #cd7f32; }
.leaderboard-name {
  flex: 1;
  font-weight: 600;
  white-space: nowrap;
  display: flex;
  align-items: center;
}
.leaderboard-pts {
  font-weight: 700;
  color: var(--primary);
  font-size: 1.1rem;
}

.leaderboard-mmr {
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  width: 100%;
  margin-left: calc(32px + 0.75rem);
  margin-top: -0.4rem;
}

.mmr-positive {
  color: var(--success);
}

.mmr-negative {
  color: var(--error);
}

.mmr-neutral {
  color: var(--text-muted);
}

/* Confetti overlay */
.confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
}

/* Chat panel (right) */
.chat-panel {
  width: 320px;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  background: var(--surface);
}
.chat-panel[hidden] {
  display: none;
}
.chat-heading-desktop {
  font-size: 0.85rem;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0.75rem 1rem 0.4rem;
  letter-spacing: 1px;
}

/* Chat toggle (mobile only, hidden on desktop) */
.chat-toggle {
  display: none;
}
.chat-badge {
  display: none;
}
.chat-toggle-icon {
  display: none;
}

/* Chat overlay header (mobile only, hidden on desktop) */
.chat-overlay-header {
  display: none;
}

/* Chat overlay timer pill (mobile only, hidden on desktop) */
.chat-overlay-timer {
  display: none;
}

/* Header chat badge */
.header-chat-badge {
  display: none;
}
.header-chat-badge[hidden] {
  display: none !important;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
}
.chat-messages .msg .author-badge {
  display: inline-flex;
  align-items: center;
  font-weight: 600;
  color: var(--primary);
  background: var(--surface-light);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.8rem;
}
.chat-messages .msg.self .author-badge {
  color: var(--success);
}
.chat-messages .msg .author-badge.admin {
  color: #ffd700;
  font-weight: 600;
}
.chat-host-star::before {
  content: '\2605';
  margin-right: 0.25em;
  color: var(--primary);
}
.chat-host-star.owner::before {
  color: #FFD700;
}
.chat-messages .msg.system strong {
  font-weight: 700;
  font-style: normal;
}
.chat-messages .msg.system {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.8rem;
  white-space: pre-line;
}

/* ---------- Game Banners (start / end) ---------- */
.game-banner {
  border-left: 3px solid var(--secondary);
  background: rgba(83, 52, 131, 0.12);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
  margin: 0.25rem 0;
  font-size: 0.85rem;
}
.game-banner-title {
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 0.15rem;
}
.game-banner-detail {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ---------- Chat notification banners ---------- */
.msg.system.notification-settings {
  border-left: 3px solid rgba(255, 193, 7, 0.7);
  background: rgba(255, 193, 7, 0.08);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  font-style: normal;
  color: var(--text);
}
.msg.system.notification-join {
  border-left: 3px solid var(--secondary);
  background: rgba(83, 52, 131, 0.12);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  font-style: normal;
  color: var(--text);
}
.msg.system.notification-leave {
  border-left: 3px solid var(--text-muted);
  background: rgba(136, 136, 170, 0.08);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  font-style: normal;
  color: var(--text-muted);
}
.msg.system.notification-host-changed {
  border-left: 3px solid var(--primary);
  background: rgba(136, 136, 170, 0.08);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  font-style: normal;
  color: var(--text);
}
.msg.system.notification-owner-reclaimed {
  border-left: 3px solid #FFD700;
  background: rgba(255, 215, 0, 0.1);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  font-style: normal;
  color: #FFD700;
}

/* ---------- Admin broadcast messages ---------- */
.chat-messages .msg.admin-broadcast {
  border-left: 3px solid var(--primary);
  background: rgba(233, 69, 96, 0.08);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
}

.chat-input-row {
  display: flex;
  gap: 0.35rem;
  padding: 0.5rem;
  border-top: 1px solid var(--border);
}
/* Close chat button — hidden on desktop, shown on mobile via media query */
.btn-close-chat-bottom {
  display: none;
}
.chat-input-wrapper {
  position: relative;
  flex: 1;
  display: flex;
}
.chat-input-wrapper input {
  flex: 1;
}
.chat-input-row input {
  flex: 1;
  font-size: 0.85rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
}
/* Timer shown inside the chat input on mobile when input is focused */
.chat-input-inline-timer:not([hidden]) {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
  pointer-events: none;
  user-select: none;
}
/* Pad the input text so it doesn't overlap the timer */
.chat-input-wrapper.timer-visible input {
  padding-right: 3.5rem;
}

/* ---------- Header actions ---------- */
.header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.btn-icon {
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.4rem 0.6rem;
}
.btn-icon:not([hidden]) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
/* Header chat button (hidden on desktop — desktop has sidebar chat) */
.btn-icon.btn-chat-header {
  display: none;
}
.btn-icon svg {
  display: block;
  flex-shrink: 0;
}
/* Desktop: header button sizing */
@media (min-width: 641px) {
  .app-title-link {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 0.35rem 0.7rem;
  }
  .app-header .btn-icon {
    padding: 0.6rem 0.7rem;
  }
  .app-header .btn-share {
    padding: 0.6rem 0.85rem;
  }
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}
.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
}
/* -- Modal size variants (must follow .modal for override specificity) -- */
.modal--settings {
  max-width: 600px;
}
.modal--game-mode-filter {
  max-width: 380px;
}
.modal--vote {
  max-width: 345px;
}
.modal--reserve-nickname {
  max-width: 420px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.modal-title-icon {
  flex-shrink: 0;
  opacity: 0.8;
}
.btn-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.btn-close:hover {
  color: var(--text);
}

/* Close button inside settings tab actions — matches Save button height */
.btn-close-modal {
  background: var(--surface-light);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-close-modal:hover {
  background: var(--border);
}

/* -- Shared modal content structure -- */
.modal-body {
  padding: 1.25rem;
}
.modal-footer {
  display: flex;
  gap: 0.75rem;
  padding: 0 1.25rem 1.25rem;
}
.modal-footer .btn {
  flex: 1;
}
/* Descriptive intro text inside a modal body */
.modal-desc {
  color: var(--text-muted);
  line-height: 1.5;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

/* -- Game mode filter modal content -- */
.mode-filter-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.mode-filter-content .field-feedback {
  margin-top: 0;
}
.mode-filter-content #mode-filter-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* ---------- Tabs ---------- */
.settings-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}
.settings-tabs .tab {
  flex: 1;
  padding: 0.65rem 1rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
}
.settings-tabs .tab:hover {
  color: var(--text);
}
.settings-tabs .tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.settings-tabs .tab.hidden {
  display: none;
}

/* Lock icon before tab title (shown mid-game) */
.tab-lock-icon {
  display: none;
}
.tab-lock-icon:not([hidden]) {
  display: inline;
  vertical-align: middle;
  margin-right: 0.25rem;
  opacity: 0.5;
}

.tab-content-container {
  overflow: hidden;
}

.tab-content {
  display: none;
  padding: 1.25rem;
}
.tab-content.active {
  display: block;
}

@keyframes slide-in-from-right {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes slide-in-from-left {
  from { transform: translateX(-40px); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}
.tab-content.slide-in-right {
  animation: slide-in-from-right 0.2s ease-out;
}
.tab-content.slide-in-left {
  animation: slide-in-from-left 0.2s ease-out;
}
@media (prefers-reduced-motion: reduce) {
  .tab-content.slide-in-right,
  .tab-content.slide-in-left {
    animation: none;
  }
}

/* ---------- Locked tab (mid-game) ---------- */
.tab-content.tab-locked > *:not(.tab-locked-message) {
  display: none !important;
}
.tab-locked-message {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.5rem;
  padding: 2rem 1.25rem;
  color: var(--text-muted);
}
.tab-content.tab-locked .tab-locked-message {
  display: flex;
}
.tab-locked-message svg {
  opacity: 0.4;
}
.tab-locked-title {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.4;
}
.tab-locked-hint {
  font-size: 0.8rem;
  opacity: 0.7;
}

/* ---------- Locked setting (competitive mode) ---------- */
.setting-group.setting-locked {
  opacity: 0.5;
  pointer-events: none;
}

/* ---------- Setting controls ---------- */
.setting-group {
  margin-bottom: 1.25rem;
}
.setting-group:last-child {
  margin-bottom: 0.5rem;
}

.setting-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.setting-group input[type="text"] {
  width: 100%;
}

.setting-row {
  display: flex;
  gap: 0.5rem;
}
.setting-row input[type="text"] {
  flex: 1;
}

.setting-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.setting-feedback {
  font-size: 0.8rem;
  margin-top: 0.35rem;
  color: var(--success);
}
.setting-feedback.error {
  color: var(--primary);
}
.setting-feedback.error:not([hidden]) {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
}

/* Slider */
.slider-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.slider-row input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: var(--surface-light);
  border-radius: 3px;
  outline: none;
}
.slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: none;
}
.slider-row input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: none;
}
.slider-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary);
  min-width: 32px;
  text-align: right;
}

/* Difficulty labels (Beginner ←→ Expert) shown below the slider */
.difficulty-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 0.2rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Speed selector */
.speed-selector {
  display: flex;
  gap: 0.5rem;
}
.speed-btn {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.speed-btn:hover {
  border-color: var(--primary);
  color: var(--text);
}
.speed-btn.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

/* Game mode selector */
.mode-selector {
  display: flex;
  gap: 0.5rem;
}
.mode-btn {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.mode-btn:hover {
  border-color: var(--primary);
  color: var(--text);
}
.mode-btn.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}
.mode-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Toggle switch */
.toggle-row:not([hidden]) {
  display: flex;
  align-items: center;
  gap: 0 0.75rem;
}

.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--surface-light);
  border-radius: 24px;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  bottom: 3px;
  background: var(--text);
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle input:checked + .toggle-slider {
  background: var(--primary);
}
.toggle input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

.toggle-label {
  font-size: 0.9rem;
  color: var(--text);
}

/* Toggle row with wrapping example text (question types, twists) */
.toggle-row-wrap {
  flex-wrap: wrap;
  row-gap: 0.1rem;
  margin-bottom: 0.5rem;
}
.toggle-row-wrap:last-child {
  margin-bottom: 0;
}
.toggle-row-wrap .setting-example {
  flex-basis: 100%;
  margin-left: calc(44px + 0.75rem);
}

/* Question type fieldset groups */
.qtype-fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}
.qtype-fieldset:last-of-type {
  margin-bottom: 0;
}
.qtype-legend {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 0.35rem;
}

/* Checkbox group for question types */
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.checkbox-label {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  column-gap: 0.5rem;
  row-gap: 0.15rem;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  flex-shrink: 0;
}
.checkbox-group-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding-top: 0.25rem;
}
.checkbox-group-label:first-child {
  padding-top: 0;
}
.qtype-icon {
  vertical-align: -2px;
  opacity: 0.7;
  flex-shrink: 0;
}

/* ---------- Difficulty selector (bot difficulty — matches speed/mode selector) ---------- */
.difficulty-selector {
  display: flex;
  gap: 0.5rem;
}
.difficulty-btn {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.difficulty-btn:hover {
  border-color: var(--primary);
  color: var(--text);
}
.difficulty-btn.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}
.difficulty-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Underdog bonus indicator in results points column */
.comeback-badge {
  display: inline-flex;
  align-items: center;
  color: #ff7043;
  vertical-align: middle;
  margin-left: 0.3rem;
  cursor: default;
}

/* ---------- Underdog bonus screen ---------- */
#game-underdog.game-state.active {
  margin: 0.25rem auto;
  gap: 0.75rem;
}
.underdog-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: center;
}
.underdog-flame {
  color: #ff7043;
  flex-shrink: 0;
  width: 1.2rem;
  height: 1.2rem;
}
.underdog-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #ff7043;
  text-align: center;
}
.underdog-tagline-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
  text-align: center;
}
.underdog-tagline {
  text-align: center;
  color: var(--text);
  font-size: 0.9rem;
}
.underdog-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.underdog-table th {
  text-align: left;
  padding: 0.35rem 0.6rem;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
  white-space: nowrap;
}
.underdog-table td {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border);
}
.underdog-table tr:last-child td {
  border-bottom: none;
}
.underdog-table tr.underdog-me td {
  background: rgba(255, 112, 67, 0.1);
  font-weight: 600;
}
.underdog-you {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.85em;
}
.underdog-multiplier {
  font-weight: 700;
  color: #ff7043;
  text-align: right;
}
.underdog-countdown {
  display: flex;
  justify-content: center;
  margin-top: 0.75rem;
}

.underdog-countdown .timer {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: #ff1a1a;
  background: rgba(255, 26, 26, 0.12);
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 26, 26, 0.3);
}

/* ---------- Question type examples ---------- */
.setting-example {
  flex-basis: 100%;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: calc(16px + 0.5rem);
}

/* ---------- Help / Disclaimer modal content ---------- */
.btn-help-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-light);
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  vertical-align: middle;
  position: relative;
  top: -1px;
  margin-left: 4px;
  padding: 0;
  line-height: 1.5;
}
.btn-help-inline:hover {
  background: var(--border);
  color: var(--text);
}
/* Help content styles → static-page.css */

/* ---------- Loading / connection states ---------- */
.btn.loading {
  position: relative;
  pointer-events: none;
  color: transparent;
}
.btn.loading::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  top: 50%;
  left: 50%;
  margin-left: -9px;
  margin-top: -9px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Settings unified footer ---------- */
.settings-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ---------- Settings save confirmation ---------- */
.save-confirmation {
  display: none;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--success);
  font-weight: 600;
  margin-top: 0.5rem;
  animation: fadeIn 0.3s ease;
}
.save-confirmation.visible {
  display: flex;
}
.save-confirmation::before {
  content: '\2713';
  font-size: 1rem;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Responsive (tablet) ---------- */
@media (max-width: 768px) and (min-width: 641px) {
  .chat-panel {
    width: 220px;
  }
  /* Chat: stack send button below input — sidebar is too narrow for inline */
  .chat-input-row {
    flex-direction: column;
    gap: 0.5rem;
  }
  .chat-input-row .btn {
    width: 100%;
  }
  .modal {
    margin: 4rem;
    max-width: calc(100% - 8rem);
    padding: 0;
  }
  .prompt-word {
    font-size: 2.2rem;
  }
  .leaderboard-entry {
    padding: 0.65rem 0.85rem;
  }
}

/* ---------- Responsive (mobile) ---------- */
@media (max-width: 640px) {
  .logo {
    font-size: 2.2rem;
  }

  /* Settings tabs: tighter padding so lock-icon + text fit without overflow */
  .settings-tabs .tab {
    padding: 0.65rem 0.5rem;
  }

  .room-body {
    flex-direction: column;
  }

  /* Status banner: match compact mobile header */
  .status-banner:not([hidden]) {
    padding: 0.4rem 0.6rem;
  }

  /* Room header: compact bar, always visible */
  .app-header {
    padding: 0.4rem 0.6rem;
    gap: 0.35rem;
  }
  .app-title {
    font-size: 0.9rem;
    white-space: nowrap;
    gap: 0.35rem;
  }
  /* Show favicon icon, hide text on mobile */
  .app-title-icon {
    display: block;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
  }
  .app-title-text {
    display: none;
  }
  .room-info {
    margin-left: 0;
  }
  .header-actions {
    margin-left: auto;
    gap: 0.25rem;
  }

  /* Show the header players + chat buttons on mobile */
  .btn-players-header {
    display: inline-flex;
  }
  .btn-icon.btn-chat-header {
    display: inline-flex;
    position: relative;
  }
  .header-chat-badge:not([hidden]) {
    display: inline-flex;
    position: absolute;
    top: -4px;
    right: -4px;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    line-height: 1;
    pointer-events: none;
  }

  /* Chat panel: full-screen overlay on mobile */
  .chat-panel:not([hidden]):not(.chat-overlay-open) {
    display: none;
  }
  .chat-panel.chat-overlay-open:not([hidden]) {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: none;
    z-index: 110;
    background: var(--bg);
    border-left: none;
    border-top: none;
    overflow: hidden;
    animation: chat-slide-in 0.2s ease-out;
  }

  .chat-panel.chat-overlay-open.chat-overlay-closing {
    animation: chat-slide-out 0.2s ease-in forwards;
  }

  /* Hide desktop heading and old toggle bar on mobile */
  .chat-heading-desktop {
    display: none;
  }
  .chat-toggle {
    display: none;
  }

  /* Chat overlay header (mobile only) */
  .chat-overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.75rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .chat-overlay-title {
    font-size: 0.95rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text);
  }

  /* Chat overlay timer pill (inside header bar) */
  .chat-overlay-timer:not([hidden]) {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.15rem 0.6rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--primary);
    margin-left: auto;
    margin-right: 0.5rem;
  }

  /* Chat messages in overlay */
  .chat-panel.chat-overlay-open .chat-messages {
    flex: 1;
    overflow-y: auto;
  }

  /* Chat: stack send button below input like lobby join */
  .chat-input-row {
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    flex-shrink: 0;
  }
  .chat-input-row .btn {
    width: 100%;
    padding: 0.55rem 0.85rem;
  }
  .btn-close-chat-bottom {
    display: block;
  }

  .game-area {
    min-height: 0;
  }

  /* Hide inline players panel on mobile — replaced by overlay */
  .players-panel {
    display: none;
  }

  /* Players overlay panel: full-screen overlay from left */
  .players-overlay-panel:not([hidden]).players-overlay-open {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    z-index: 110;
    background: var(--bg);
    overflow: hidden;
    animation: players-slide-in 0.2s ease-out;
  }
  .players-overlay-panel.players-overlay-open.players-overlay-closing {
    animation: players-slide-out 0.2s ease-in forwards;
  }

  /* Players overlay header */
  .players-overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.75rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .players-overlay-title {
    font-size: 0.95rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text);
  }
  .players-overlay-count {
    color: var(--text-muted);
    font-size: 0.85em;
  }

  /* Players overlay timer pill (inside header bar) */
  .players-overlay-timer:not([hidden]) {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.15rem 0.6rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--primary);
    margin-left: auto;
    margin-right: 0.5rem;
  }

  /* Players overlay list */
  .players-overlay-list {
    list-style: none;
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
    margin: 0;
  }
  .players-overlay-item {
    display: flex;
    align-items: center;
    padding: 0.65rem 1rem;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
  }
  .players-overlay-item:last-child {
    border-bottom: none;
  }
  .players-overlay-item.me {
    background: rgba(99, 102, 241, 0.08);
  }
  .players-overlay-rank {
    color: var(--text-muted);
    font-size: 0.85rem;
    min-width: 1.5rem;
    font-weight: 700;
  }
  .players-overlay-host-star {
    color: var(--primary);
    font-size: 0.9rem;
    margin-right: -0.25rem;
  }
  .players-overlay-host-star.room-owner {
    color: #FFD700;
  }
  .players-overlay-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
  }
  .players-overlay-score {
    color: var(--primary);
    font-weight: 700;
    font-size: 0.9rem;
    white-space: nowrap;
  }
  .players-overlay-bot-tag {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-left: -0.25rem;
  }

  /* Players panel: collapsible on mobile — header is the click target */
  .players-panel-header:has(.players-toggle:not([hidden])) {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .players-toggle:not([hidden]) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-muted);
    pointer-events: none;
    padding: 0.1rem;
    margin-left: auto;
    font-size: 0.7rem;
    transition: transform 0.2s ease;
  }
  .players-toggle[aria-expanded="true"] {
    transform: rotate(180deg);
  }
  #player-list.players-collapsed {
    overflow: hidden;
  }
  /* Minimal collapse: header-only (no player pills visible) */
  .players-panel.players-panel-minimal {
    padding-top: 0.45rem;
    padding-bottom: 0.45rem;
  }
  .players-panel.players-panel-minimal .players-panel-header {
    margin-bottom: 0;
  }

  /* Reduce vertical gap between header and game content */
  .game-panel {
    padding: 0.5rem 0.75rem;
  }
  .game-state {
    gap: 0.6rem;
  }
  .question-content {
    gap: 0.6rem;
  }
  .round-header {
    padding: 0.25rem 0;
  }

  /* Game: stack answer submit row */
  .answer-area {
    width: 100%;
  }
  .answer-row {
    flex-direction: column;
  }
  .input-wrapper {
    width: 100%;
  }
  .answer-row .btn {
    width: 100%;
  }

  /* Prompt word: scale down for small screens */
  .prompt-word {
    font-size: 1.8rem;
    padding: 0.25rem 0 0.5rem;
  }

  /* Results table: allow horizontal scroll if needed */
  .results-table {
    font-size: 0.8rem;
  }
  .results-table th,
  .results-table td {
    padding: 0.4rem 0.5rem;
  }

  /* Leaderboard entries: tighter */
  .leaderboard-entry {
    padding: 0.6rem 0.75rem;
    gap: 0.5rem;
  }
  .leaderboard-mmr {
    margin-left: calc(32px + 0.5rem);
  }

  /* Game over title */
  .game-over-title {
    font-size: 1.6rem;
  }

  .modal {
    margin: 1rem;
    max-width: calc(100% - 2rem);
  }

  /* Chaos level buttons: allow 2-row layout on narrow screens */
  .chaos-btn {
    min-width: 3.8rem;
    font-size: 0.78rem;
    padding: 0.45rem 0.35rem;
  }

}

/* Ensure good touch targets on all interactive elements */
@media (pointer: coarse) {
  .btn {
    min-height: 44px;
  }
  .btn-small {
    min-height: 38px;
  }
  input[type="text"] {
    min-height: 44px;
  }
  input[type="range"]::-webkit-slider-thumb {
    width: 24px;
    height: 24px;
  }
  input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
  }
}

/* ===== Chaos Settings / Twist Indicator ===== */

/* Twist indicator bar above the question prompt */
.twist-indicator:not([hidden]) {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  margin-bottom: 0.75rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 2px solid var(--primary);
  color: var(--primary);
  font-weight: 700;
  font-size: 0.95rem;
}

.twist-icon {
  display: flex;
  align-items: center;
}

.twist-label {
  line-height: 1.3;
}

/* --- Twist warning full-screen phase --- */
#game-twist-warning:not([hidden]) {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  text-align: center;
  animation: twistWarningEntrance 0.4s ease-out;
}

.twist-warning-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2rem 2.5rem;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 16px;
  max-width: 400px;
}

.twist-warning-icon {
  color: #818cf8;
}

.twist-warning-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #c7d2fe;
  margin: 0;
}

.twist-warning-description {
  font-size: 0.95rem;
  color: #a5b4fc;
  margin: 0;
  line-height: 1.4;
}

.twist-warning-countdown {
  display: flex;
  justify-content: center;
  margin-top: 0.75rem;
}

.twist-warning-countdown .timer {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: #a5b4fc;
  background: rgba(129, 140, 248, 0.12);
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid rgba(129, 140, 248, 0.3);
}

@keyframes twistWarningEntrance {
  0%   { opacity: 0; transform: scale(0.9); }
  100% { opacity: 1; transform: scale(1); }
}

/* Small inline twist icon (settings checkboxes, how-to-play) */
.twist-icon-inline {
  vertical-align: middle;
  margin-right: 0.15rem;
}

/* Chaos level selector (same pattern as speed selector) */
.chaos-selector {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.chaos-btn {
  flex: 1;
  min-width: 4.5rem;
  padding: 0.45rem 0.5rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.chaos-btn:hover {
  border-color: var(--primary);
  color: var(--text);
}
.chaos-btn.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}
.chaos-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- Host Controls ---------- */
.host-controls:not([hidden]) {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  position: absolute;
  bottom: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.host-control-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  background: var(--surface-light);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
}
.host-control-btn:hover {
  background: var(--border);
}
.host-control-btn.btn-danger-icon {
  color: var(--primary);
  border-color: rgba(233, 69, 96, 0.4);
  background: rgba(233, 69, 96, 0.1);
}
.host-control-btn.btn-danger-icon:hover {
  background: rgba(233, 69, 96, 0.25);
}

/* Ensure scrollable content clears the floating host controls */
.game-panel:has(.host-controls:not([hidden])) {
  padding-bottom: 4rem;
}

/* ---------- Game Paused Overlay ---------- */
.game-paused-overlay:not([hidden]) {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  inset: 0;
  background: rgba(15, 15, 26, 0.95);
  z-index: 50;
  border-radius: var(--radius);
}
.paused-content {
  text-align: center;
  color: var(--text-muted);
}
.paused-content p {
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 0.5rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.paused-content svg {
  opacity: 0.6;
}

/* game-panel needs position:relative so the overlay can cover it */
.game-panel {
  position: relative;
}

/* ---------- Leave Confirmation Modal ---------- */
.modal--leave-confirm {
  max-width: 380px;
}

/* ---------- End Game Confirmation Modal ---------- */
.modal--end-game-confirm {
  max-width: 380px;
}

/* ---------- Vote Modal ---------- */
.vote-content {
  text-align: center;
}
.vote-option-btn {
  width: 100%;
  margin-bottom: 0.75rem;
}

/* ---------- Vote Chat Message ---------- */
.vote-msg {
  background: rgba(83, 52, 131, 0.25);
  border: 1px solid rgba(108, 68, 162, 0.4);
  border-radius: var(--radius);
  padding: 0.75rem;
  margin: 0.25rem 0;
}
.vote-msg-header {
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}
.vote-msg-buttons {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}
.vote-choice-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.85rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface-light);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  touch-action: manipulation;
}
.vote-choice-btn:hover:not(:disabled) {
  border-color: var(--text-muted);
}
.vote-choice-btn.vote-yes:hover:not(:disabled) {
  border-color: var(--success);
  background: rgba(46, 213, 115, 0.15);
}
.vote-choice-btn.vote-no:hover:not(:disabled) {
  border-color: var(--primary);
  background: rgba(233, 69, 96, 0.15);
}
.vote-choice-btn.selected.vote-yes {
  border-color: var(--success);
  background: rgba(46, 213, 115, 0.2);
}
.vote-choice-btn.selected.vote-no {
  border-color: var(--primary);
  background: rgba(233, 69, 96, 0.2);
}
.vote-choice-btn:disabled {
  opacity: 0.6;
  cursor: default;
}
.vote-count {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.75rem;
}
.vote-timer {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-left: auto;
}
.vote-result {
  margin-top: 0.5rem;
  font-weight: 600;
  font-size: 0.85rem;
}
.vote-result.vote-passed {
  color: var(--success);
}
.vote-result.vote-failed {
  color: var(--text-muted);
}

/* -------------------------------------------------------------------------
   Auth area (Google sign-in / user badge) on the landing page
   ------------------------------------------------------------------------- */
.auth-area {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.btn-google-signin:not([hidden]),
.btn-microsoft-signin:not([hidden]),
.btn-apple-signin:not([hidden]),
.btn-discord-signin:not([hidden]) {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-direction: row;
  justify-content: center;
}

.auth-gate .btn {
  width: 100%;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-badge__name {
  font-size: 0.875rem;
  color: var(--text);
  font-weight: 600;
}

.btn-signout {
  align-self: center;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius);
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.btn-signout:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* ---------- Home page auth states ---------- */

/* State A: Auth gate (sign in + play as guest) */
.auth-gate:not([hidden]) {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.btn-play-guest {
  width: 100%;
  padding: 0.75rem 1rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.btn-play-guest:hover {
  border-color: var(--text-muted);
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

/* State B: Guest form (nickname + buttons + sign-in-instead link) */
.guest-form:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  animation: fadeIn 0.2s ease;
}


/* State C: Signed-in welcome */
.welcome-back:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  animation: fadeIn 0.2s ease;
}

.user-greeting__nickname {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  background-color: var(--bg);
  border-radius: var(--radius);
  padding: 0.5rem 2rem;
}

.mmr-tag {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

.welcome-back__info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
}

.welcome-back__greeting {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

/* Guest tag & Verified badge */
.guest-tag {
  color: var(--text-muted);
  font-size: 0.75em;
  font-weight: 400;
  margin-left: 0.25rem;
}

.verified-badge {
  display: inline-block;
  vertical-align: -0.125em;
  margin-left: 0.25rem;
  flex-shrink: 0;
}

.reserve-nickname-input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: var(--surface-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
}

/* --- Landscape mobile (phones rotated) --- */
@media (orientation: landscape) and (max-height: 500px) {
  /* Stack game and chat vertically (same as portrait mobile) */
  .room-body { flex-direction: column; }

  /* Show header players + chat buttons in landscape (ID prefix needed to
     beat the global #game-nav-actions hide rule) */
  #game-nav-actions .btn-players-header:not([hidden]) { display: inline-flex; }
  #game-nav-actions .btn-chat-header:not([hidden]) { display: inline-flex; position: relative; }
  .header-chat-badge:not([hidden]) {
    display: inline-flex;
    position: absolute;
    top: -4px; right: -4px;
    align-items: center; justify-content: center;
    background: var(--primary); color: #fff;
    font-size: 0.6rem; font-weight: 700;
    min-width: 16px; height: 16px; padding: 0 4px;
    border-radius: 999px; line-height: 1; pointer-events: none;
  }

  /* Chat: full-screen overlay only (mirror portrait mobile behavior) */
  .chat-panel:not([hidden]):not(.chat-overlay-open) { display: none; }
  .chat-panel.chat-overlay-open:not([hidden]) {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%;
    max-height: none;
    z-index: 110;
    background: var(--bg);
    border-left: none; border-top: none;
    overflow: hidden;
    animation: chat-slide-in 0.2s ease-out;
  }
  .chat-panel.chat-overlay-open.chat-overlay-closing {
    animation: chat-slide-out 0.2s ease-in forwards;
  }
  .chat-heading-desktop { display: none; }
  .chat-toggle { display: none; }
  .chat-overlay-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.6rem 0.75rem; background: var(--surface);
    border-bottom: 1px solid var(--border); flex-shrink: 0;
  }
  .chat-overlay-title {
    font-size: 0.95rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 1px; color: var(--text);
  }
  .chat-overlay-timer:not([hidden]) {
    display: flex; align-items: center; gap: 0.35rem;
    padding: 0.15rem 0.6rem; background: var(--surface);
    border: 1px solid var(--border); border-radius: 999px;
    font-size: 0.8rem; font-weight: 700; color: var(--primary);
    margin-left: auto; margin-right: 0.5rem;
  }
  .chat-panel.chat-overlay-open .chat-messages { flex: 1; overflow-y: auto; }
  .chat-input-row {
    flex-direction: column; gap: 0.5rem;
    padding: 0.5rem 0.75rem; flex-shrink: 0;
  }
  .chat-input-row .btn { width: 100%; padding: 0.55rem 0.85rem; }
  .btn-close-chat-bottom { display: block; }

  /* Hide inline players panel in landscape — use overlay */
  .players-panel { display: none; }

  /* Players overlay in landscape */
  .players-overlay-panel:not([hidden]).players-overlay-open {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%;
    max-height: none;
    z-index: 110;
    background: var(--bg);
    overflow: hidden;
    animation: players-slide-in 0.2s ease-out;
  }
  .players-overlay-panel.players-overlay-open.players-overlay-closing {
    animation: players-slide-out 0.2s ease-in forwards;
  }
  .players-overlay-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.6rem 0.75rem; background: var(--surface);
    border-bottom: 1px solid var(--border); flex-shrink: 0;
  }
  .players-overlay-title {
    font-size: 0.95rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 1px; color: var(--text);
  }
  .players-overlay-count { color: var(--text-muted); font-size: 0.85em; }
  .players-overlay-timer:not([hidden]) {
    display: flex; align-items: center; gap: 0.35rem;
    padding: 0.15rem 0.6rem; background: var(--surface);
    border: 1px solid var(--border); border-radius: 999px;
    font-size: 0.8rem; font-weight: 700; color: var(--primary);
    margin-left: auto; margin-right: 0.5rem;
  }
  .players-overlay-list {
    list-style: none; flex: 1; overflow-y: auto;
    padding: 0.5rem 0; margin: 0;
  }
  .players-overlay-item {
    display: flex; align-items: center;
    padding: 0.65rem 1rem; gap: 0.5rem;
    border-bottom: 1px solid var(--border); font-size: 0.95rem;
  }
  .players-overlay-item:last-child { border-bottom: none; }
  .players-overlay-item.me { background: rgba(99, 102, 241, 0.08); }
  .players-overlay-rank {
    color: var(--text-muted); font-size: 0.85rem;
    min-width: 1.5rem; font-weight: 700;
  }
  .players-overlay-host-star { color: var(--primary); font-size: 0.9rem; margin-right: -0.25rem; }
  .players-overlay-host-star.room-owner { color: #FFD700; }
  .players-overlay-name {
    flex: 1; min-width: 0; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap; font-weight: 500;
  }
  .players-overlay-score {
    color: var(--primary); font-weight: 700;
    font-size: 0.9rem; white-space: nowrap;
  }
  .players-overlay-bot-tag { color: var(--text-muted); font-size: 0.75rem; margin-left: -0.25rem; }

  /* Smaller prompt word */
  .prompt-word { font-size: 1.5rem; padding: 0.15rem 0 0.35rem; }

  /* Tighter game panel */
  .game-panel { padding: 0.4rem 0.75rem; }
  .game-state { gap: 0.4rem; }
}

/* ==========================================================================
   Leaderboard Page
   ========================================================================== */

.leaderboard-page {
  width: 100%;
  max-width: 680px;
  padding: 2rem 1.5rem 3rem;
}

.leaderboard-page-title {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--text);
  text-align: center;
  margin-bottom: 1.5rem;
  letter-spacing: -0.5px;
}


.leaderboard-table-wrap {
  background: var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  overflow: hidden;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.leaderboard-table th {
  padding: 0.75rem 0.6rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.leaderboard-table th:first-child {
  width: 3rem;
  text-align: center;
}

.leaderboard-table th:last-child,
.leaderboard-table td:last-child {
  text-align: right;
  padding-right: 1.25rem;
}

.leaderboard-table td {
  padding: 0.7rem 0.6rem;
  color: var(--text);
  border-bottom: 1px solid rgba(51, 51, 85, 0.4);
}

.leaderboard-table tbody tr:last-child td {
  border-bottom: none;
}

.leaderboard-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.leaderboard-rank {
  text-align: center;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-muted);
}

.leaderboard-rank--gold   { color: #FFD700; }
.leaderboard-rank--silver { color: #C0C0C0; }
.leaderboard-rank--bronze { color: #CD7F32; }

.leaderboard-player {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

a.leaderboard-player-link {
  color: inherit;
  text-decoration: none;
}

a.leaderboard-player-link:hover {
  text-decoration: underline;
  color: var(--accent);
}

.leaderboard-controls {
  margin-bottom: 1rem;
}

.leaderboard-sort-filter:not([hidden]) {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
  margin-bottom: 0.75rem;
}

.leaderboard-search {
  display: flex;
  justify-content: center;
}

.leaderboard-search-input {
  width: 100%;
  max-width: 300px;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--glass);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.15s;
}

.leaderboard-search-input::placeholder {
  color: var(--text-muted);
}

.leaderboard-search-input:focus {
  border-color: var(--accent, #6366f1);
}

.leaderboard-table tbody tr.lb-current-user {
  background: rgba(99, 102, 241, 0.12);
  border-left: 3px solid var(--accent, #6366f1);
}

.leaderboard-table tbody tr.lb-current-user:hover {
  background: rgba(99, 102, 241, 0.18);
}

.leaderboard-table th.lb-sort-active {
  color: var(--text);
}

.leaderboard-table td.lb-stat.lb-sort-active, 
.leaderboard-table td.lb-stat.lb-sort-active::before {
  color: var(--text);
}

.leaderboard-pagination:not([hidden]) {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
  padding: 0.75rem 0;
}

.lb-page-btn {
  background: var(--glass);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  transition: background 0.15s;
}

.lb-page-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
}

.lb-page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.lb-page-info {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.leaderboard-empty,
.leaderboard-unavailable {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

@media (max-width: 640px) {
  .leaderboard-page {
    padding: 1.25rem 0.75rem 2rem;
  }

  .leaderboard-table thead {
    display: none;
  }

  .leaderboard-table,
  .leaderboard-table tbody {
    display: block;
  }

  .leaderboard-table tbody tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid rgba(51, 51, 85, 0.4);
  }

  .leaderboard-table tbody tr:last-child {
    border-bottom: none;
  }

  .leaderboard-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
  }

  .leaderboard-table td {
    display: table;
    padding: 0;
    border-bottom: none;
  }

  .leaderboard-table td:last-child {
    text-align: center;
    padding-right: 0;
  }

  .leaderboard-table td.leaderboard-rank {
    width: 2.2rem;
    text-align: center;
    font-size: 1.1rem;
    flex-shrink: 0;
  }

  .leaderboard-table td.lb-player {
    flex: 1 1 calc(100% - 2.2rem);
    min-width: 0;
    font-weight: 600;
  }

  .leaderboard-table td.lb-player .leaderboard-player {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .leaderboard-table td.lb-stat {
    flex: 1 1 0%;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
    text-align: center;
    min-width: 0;
  }

  .leaderboard-table td.lb-stat::before {
    content: attr(data-label);
    display: block;
    font-weight: 700;
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-muted);
    opacity: 0.6;
    margin-bottom: 0.1rem;
  }

  .leaderboard-sort-filter {
    gap: 0.3rem;
  }

  .leaderboard-sort-filter .stats-mode-pill {
    font-size: 0.7rem;
    padding: 0.25rem 0.55rem;
  }
}

/* ==========================================================================
   Toast Notifications (reusable)
   ========================================================================== */

.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--success);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.65rem 1.1rem;
  border-radius: 999px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  z-index: 9999;
  animation: toast-in 0.3s ease;
  pointer-events: none;
}

.toast svg {
  color: var(--success);
  flex-shrink: 0;
}

.toast--warn {
  border-left-color: var(--warning, #f0a030);
}
.toast--warn svg {
  color: var(--warning, #f0a030);
}

.toast.toast-hide {
  animation: toast-out 0.3s ease forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateX(-50%) translateY(0); }
  to   { opacity: 0; transform: translateX(-50%) translateY(12px); }
}

/* ==========================================================================
   Achievement Toast (unlock notification)
   ========================================================================== */

.achievement-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid #FFD700;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.65rem 1rem 0.65rem 0.75rem;
  border-radius: 999px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5), 0 0 12px rgba(255, 215, 0, 0.15);
  z-index: 9999;
  animation: toast-in 0.3s ease;
  pointer-events: auto;
  max-width: min(420px, calc(100vw - 2rem));
}

.achievement-toast__icon {
  flex-shrink: 0;
  line-height: 0;
}

.achievement-toast__text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.achievement-toast__label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #FFD700;
}

.achievement-toast__name {
  font-size: 0.9rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.achievement-toast__close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 0.2rem;
  line-height: 1;
  font-family: inherit;
  transition: color 0.15s;
}
.achievement-toast__close:hover {
  color: var(--text);
}

.achievement-toast.achievement-toast-hide {
  animation: toast-out 0.3s ease forwards;
}

/* ==========================================================================
   Profile Page
   ========================================================================== */

.profile-page {
  width: 100%;
  max-width: 800px;
  padding: 2rem 1.5rem 3rem;
}

.profile-page-title {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--text);
  text-align: center;
  margin-bottom: 1.5rem;
  letter-spacing: -0.5px;
}

.profile-card {
  background: var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.profile-identity {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.profile-nickname {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
}

.profile-edit-btn {
  background: none;
  border: none;
  padding: 0.2rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 0;
  transition: color 0.15s;
  font-family: inherit;
}
.profile-edit-btn:hover {
  color: var(--text);
}

.profile-nickname-form {
  width: 100%;
}

.profile-nickname-input {
  width: 100%;
  font-size: 1.1rem;
  font-weight: 600;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.4rem;
}

.profile-nickname-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.profile-nickname-actions .btn {
  font-size: 0.8rem;
  padding: 0.35rem 0.85rem;
}

.profile-type {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.stats-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.stats-table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.stats-table th:not(:first-child),
.stats-table td:not(:first-child) {
  text-align: right;
}

.stats-table td {
  padding: 0.6rem 0.75rem;
  color: var(--text);
  border-bottom: 1px solid rgba(51, 51, 85, 0.35);
  font-weight: 500;
}

.stats-table tbody tr:last-child td {
  border-bottom: none;
}

.stats-mode-label {
  text-transform: capitalize;
  font-weight: 600;
}

.profile-signin-section {
  background: var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 2rem 1.5rem;
  text-align: center;
}

.profile-signin-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.profile-providers {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.provider-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.provider-row .provider-icon {
  flex-shrink: 0;
}

.provider-email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.provider-disconnect-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.15rem 0.35rem;
  font-size: 0.8rem;
  line-height: 1;
  border-radius: var(--radius);
  opacity: 0.5;
  transition: opacity 0.15s, color 0.15s;
  flex-shrink: 0;
}

.provider-disconnect-btn:hover {
  opacity: 1;
  color: var(--danger, #ef4444);
}

.provider-connect-section {
  margin-top: 1rem;
}

.provider-connect-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.provider-connect-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.provider-connect-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  padding: 0.5rem 0.75rem;
}

.provider-connect-btn .provider-icon {
  flex-shrink: 0;
}

.stats-mode-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.stats-mode-pill {
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  text-transform: capitalize;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  font-family: inherit;
}

.stats-mode-pill:hover {
  background: rgba(255, 255, 255, 0.06);
}

.stats-mode-pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.stat-tile {
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius);
  padding: 0.85rem 0.75rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.stat-tile-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
}

.stat-tile-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.profile-prefs-divider {
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}

/* ---------- Banner theme picker ---------- */

.banner-theme-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin: 0 0 0.6rem;
}

.banner-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.banner-swatch {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
  position: relative;
  padding: 0;
  font-family: inherit;
}
.banner-swatch:hover {
  transform: scale(1.1);
}
.banner-swatch-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.banner-swatch.active {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--bg);
}
.banner-swatch-name {
  display: block;
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 0.2rem;
  line-height: 1;
}

.banner-preview-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.banner-preview-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
}
.banner-preview-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.banner-preview-tag {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1;
}
.banner-preview-stats {
  display: flex;
  border-top: 1px solid var(--border);
}
.banner-preview-stat {
  flex: 1 1 0%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem 0.25rem;
  border-left: 1px solid var(--border);
}
.banner-preview-stat:first-child {
  border-left: none;
}
.banner-preview-stat-label {
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-muted);
  opacity: 0.7;
  margin-bottom: 0.15rem;
}
.banner-preview-stat-value {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
}

.banner-save-btn {
  margin-top: 0.75rem;
  width: 100%;
}

.profile-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.profile-actions .btn {
  width: 100%;
}

/* ---------- Profile multi-column layout (desktop) ---------- */
.profile-columns:not([hidden]) {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: stretch;
}

/* ---------- Difficulty stats ---------- */
.diff-type-section {
  margin-bottom: 1rem;
}
.diff-type-section:last-child {
  margin-bottom: 0;
}
.diff-type-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  text-transform: capitalize;
  margin-bottom: 0.35rem;
}
.diff-row {
  display: grid;
  grid-template-columns: 2.5rem 1fr 2.5rem 2.5rem;
  gap: 0.4rem;
  align-items: center;
  padding: 0.2rem 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.diff-level {
  font-weight: 600;
  color: var(--text);
}
.diff-bar-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}
.diff-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.3s;
}
.diff-pct {
  text-align: right;
  font-weight: 600;
  color: var(--text);
}
.diff-time {
  text-align: right;
}

/* ---------- Difficulty type selector ---------- */
.diff-select-wrap {
  margin-bottom: 0.75rem;
}
.diff-type-select {
  width: 100%;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238888aa' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
  transition: border-color 0.2s;
}
.diff-type-select:hover,
.diff-type-select:focus {
  border-color: var(--primary);
  outline: none;
}
.diff-type-select option {
  background: var(--surface);
  color: var(--text);
}

/* ---------- Game history list ---------- */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.history-row {
  display: grid;
  grid-template-columns: 3.2rem auto 1fr auto auto auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.55rem 0.6rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius);
  font-size: 0.82rem;
  color: var(--text-muted);
}
.history-date {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.history-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}
.history-badge-win {
  background: rgba(34, 197, 94, 0.2);
  color: #22c55e;
}
.history-badge-loss {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}
.history-accuracy,
.history-speed {
  text-align: right;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
}
.history-mode {
  text-transform: capitalize;
  font-weight: 500;
  color: var(--text);
}
.history-points {
  text-align: right;
  font-weight: 600;
  color: var(--text);
}
.history-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
}
.history-page-info {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.btn-sm {
  font-size: 0.75rem;
  padding: 0.3rem 0.65rem;
}

/* Rating history line chart */
.rating-chart-wrap {
  width: 100%;
  overflow: hidden;
}

.rating-chart {
  width: 100%;
  height: auto;
  display: block;
}

.chart-grid {
  stroke: var(--glass-border);
  stroke-width: 0.5;
}

.chart-label {
  fill: var(--text-muted);
  font-size: 10px;
  font-family: inherit;
}

.chart-line {
  fill: none;
  stroke: var(--primary);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-dot {
  fill: var(--primary);
  stroke: var(--glass);
  stroke-width: 2;
  cursor: pointer;
  transition: r 0.15s;
}

.chart-dot:hover {
  r: 6;
}

@media (max-width: 640px) {
  .profile-page {
    padding: 1.25rem 0.75rem 2rem;
  }
  .profile-columns:not([hidden]) {
    display: flex;
    flex-direction: column;
    gap: 0;
  }
  .profile-columns > .profile-card {
    width: 100%;
  }
  .diff-row {
    grid-template-columns: 2.2rem 1fr 2.2rem 2.2rem;
    gap: 0.3rem;
    font-size: 0.72rem;
  }
  .history-row {
    grid-template-columns: 3.2rem auto 1fr auto;
  }
  .history-accuracy,
  .history-speed {
    display: none;
  }
}

/* ---------- Achievements grid ---------- */
.achievements-grid:not([hidden]) {
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem;
  justify-content: center;
  padding: 0.5rem 0;
}

.achievement-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  width: 88px;
  transition: transform 0.2s ease;
}

.achievement-badge:hover {
  transform: translateY(-3px);
}

.achievement-badge__icon {
  width: 64px;
  height: 64px;
  line-height: 0;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.4));
  transition: filter 0.2s ease;
}

.achievement-badge:hover .achievement-badge__icon {
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5));
}

.achievement-badge__name {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  line-height: 1.2;
  word-break: break-word;
}

.achievements-empty {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 0.5rem 0;
}

.achievements-progress {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  margin: -0.5rem 0 1rem;
}

.achievements-unavailable {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 1.5rem 0;
}

.achievement-badge__description {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.3;
  word-break: break-word;
}

.achievement-badge__date {
  font-size: 0.6rem;
  color: var(--primary);
  font-weight: 600;
  text-align: center;
}

.achievement-badge__date--locked {
  color: var(--text-muted);
  font-weight: 400;
  opacity: 0.6;
}

.achievement-badge--locked .achievement-badge__icon {
  filter: grayscale(1);
  opacity: 0.35;
}

.achievement-badge--locked .achievement-badge__name {
  opacity: 0.5;
}

.achievement-badge--locked .achievement-badge__description {
  opacity: 0.5;
}

.achievement-badge--locked:hover {
  transform: none;
}

.achievement-badge[data-key="EDUCATED"] .achievement-badge__icon {
  padding-left: 4px;
}

/* ==========================================================================
   Nav-aware lobby screen (pages with sticky nav)
   ========================================================================== */

.has-nav .lobby-screen {
  min-height: calc(100% - 56px);
  padding-top: 1.5rem;
}

/* ==========================================================================
   Tutorial page
   ========================================================================== */

/* --- Intro screen --- */
.tutorial-intro {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 56px);
  padding: 2rem 1rem;
}
@media (max-width: 640px) {
  .tutorial-intro {
    align-items: flex-start;
    padding-top: 15vh;
  }
}
.tutorial-intro__card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  max-width: 480px;
  width: 100%;
  text-align: center;
}
.tutorial-intro__title {
  font-size: 1.8rem;
  font-weight: 900;
  margin: 0 0 0.75rem;
  color: var(--text);
}
.tutorial-intro__desc {
  color: var(--text-muted);
  margin: 0 0 1.25rem;
  line-height: 1.5;
}
.tutorial-intro__list {
  text-align: left;
  color: var(--text-muted);
  margin: 0 0 1.5rem;
  padding-left: 1.5rem;
  line-height: 1.8;
}
.tutorial-intro__buttons {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  align-items: center;
}
.tutorial-intro__buttons .btn {
  width: 100%;
  max-width: 280px;
}

/* --- Tutorial game wrapper — reuses real game layout --- */
.tutorial-game:not([hidden]) {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.tutorial-game .room-body {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}
.tutorial-game .game-panel {
  width: 100%;
  margin: 0 auto;
  min-height: 0;
}

/* --- Tutorial chat disabled message --- */
.tutorial-chat-disabled {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 2rem 1rem;
  margin: 0;
}

/* --- Rules intro card (shown once before round 1) --- */
#game-rules-intro:not([hidden]) {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  text-align: center;
  animation: twistWarningEntrance 0.4s ease-out;
}
.rules-intro-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2rem 2.5rem;
  background: rgba(233, 69, 96, 0.08);
  border: 1px solid rgba(233, 69, 96, 0.25);
  border-radius: 16px;
  max-width: 640px;
  text-align: center;
}
.rules-intro-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.rules-intro-list {
  text-align: left;
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.8;
}

/* --- Tutorial type intro card --- */
.type-intro-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2rem 2.5rem;
  background: rgba(52, 131, 83, 0.12);
  border: 1px solid rgba(52, 131, 83, 0.3);
  border-radius: 16px;
  max-width: 640px;
  text-align: center;
}
.type-intro-icon {
  color: #6ee7b7;
}
.type-intro-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #a7f3d0;
  margin: 0;
}
.type-intro-description {
  font-size: 0.95rem;
  color: #6ee7b7;
  margin: 0;
  line-height: 1.5;
}
.type-intro-tips {
  text-align: left;
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.8;
}
#btn-type-intro-continue {
  margin-top: 1.5rem;
}

/* --- Chaos intro card --- */
#game-chaos-intro:not([hidden]) {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  text-align: center;
  animation: twistWarningEntrance 0.4s ease-out;
}
.chaos-intro-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2rem 2.5rem;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 16px;
  max-width: 420px;
  text-align: center;
}
.chaos-intro-icons {
  display: flex;
  gap: 1rem;
  color: #a5b4fc;
}
.chaos-intro-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #c7d2fe;
  margin: 0;
}
.chaos-intro-description {
  font-size: 0.95rem;
  color: #a5b4fc;
  margin: 0;
  line-height: 1.5;
}
.chaos-intro-list {
  text-align: left;
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.8;
}
.chaos-intro-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0.25rem 0 0;
  font-style: italic;
}

/* --- Tutorial tips panel --- */
.tutorial-tips {
  margin-top: 1.25rem;
  margin-bottom: 2rem;
  padding: 1rem 1.25rem;
  background: rgba(83, 52, 131, 0.15);
  border: 1px solid rgba(83, 52, 131, 0.3);
  border-radius: var(--radius);
}
.tutorial-tips__header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text);
  margin-bottom: 0.5rem;
}
.tutorial-tips__explanation {
  color: var(--text-muted);
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  line-height: 1.5;
}
.tutorial-tips__list {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--text);
  font-size: 0.85rem;
  line-height: 1.8;
}

/* --- Next round button in results --- */
.tutorial-next-btn {
  margin-top: 1.25rem;
}

/* --- Game over extras --- */
.tutorial-game .game-over-title {
  color: var(--primary);
}
.tutorial-congrats {
  text-align: center;
  color: var(--text-muted);
  margin: 1rem 0;
  font-size: 0.95rem;
}
.tutorial-game-over-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

/* --- Bot badge in results/leaderboard --- */
.bot-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  background: var(--surface-light);
  color: var(--text-muted);
  border-radius: 3px;
  padding: 0.1rem 0.35rem;
  vertical-align: middle;
  margin-left: 0.3rem;
  letter-spacing: 0.05em;
}

/* --- Twist warning "Got it" button --- */
#btn-twist-continue {
  margin-top: 1.5rem;
}
