/* =============================================================================
   lobby.css — GomokuVN Lobby Page
   Style: Modern Premium — soft depth, two-column layout with sidebar
   ============================================================================= */

/* ── Two-column layout wrapper ────────────────────────────────────────────── */
.lobby-layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  grid-template-rows: auto;
  gap: 0;
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  align-items: start;
}

/* Pages that reuse .lobby-layout for its centered/max-width column but never
   render a .lobby-sidebar (tournament.html — TODO.md #56 item 2) — without
   this, the reserved 260px column just sits empty as dead space. */
.lobby-layout--single {
  grid-template-columns: 1fr;
}

/* ── Main lobby column ────────────────────────────────────────────────────── */
.lobby {
  width: 100%;
  box-sizing: border-box;
  padding: 32px 24px 48px 32px;
  min-width: 0; /* prevent grid overflow */
}

/* ── Sidebar column ───────────────────────────────────────────────────────── */
.lobby-sidebar {
  padding: 32px 24px 48px 0;
  position: sticky;
  top: 56px; /* match topnav height */
  max-height: calc(100vh - 56px);
  max-height: calc(100dvh - 56px);
  overflow-y: auto;
}

/* ── Section header + action bar ──────────────────────────────────────────── */
.lobby__header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
}

@media (max-width: 640px) {
  .lobby__header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
}

.lobby__title {
  font-size: calc(24px * var(--fs-scale, 1));
  font-weight: 800;
  color: var(--c-ink);
  letter-spacing: -0.02em;
}

.lobby__count {
  font-size: calc(14px * var(--fs-scale, 1));
  color: var(--c-ink-3);
  margin-left: 12px;
  font-weight: 600;
  padding: 4px 10px;
  background: var(--c-surface-2);
  border-radius: 9999px;
  vertical-align: middle;
}

/* Primary "Create room" button - Button-in-Button architecture */
.btn-create {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 6px 16px 6px 6px;
  font-size: calc(14px * var(--fs-scale, 1));
  font-weight: 700;
  font-family: var(--font);
  color: var(--c-on-brand);
  background: var(--c-brand);
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  transition: var(--duration-normal) var(--ease-spring);
  transition-property: background-color, color, border-color, box-shadow, transform, opacity;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.btn-create:hover {
  background: var(--c-brand-dark);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px var(--c-brand-light);
}
.btn-create:active { transform: translateY(0) scale(0.96) !important; }
.btn-create i { 
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px; 
  height: 32px; 
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  flex-shrink: 0; 
  transition: transform var(--duration-fast) var(--ease-spring);
}
.btn-create:hover i {
  transform: scale(1.1) rotate(90deg);
}

/* Secondary "History" button */
.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: calc(14px * var(--fs-scale, 1));
  font-weight: 700;
  font-family: var(--font);
  color: var(--c-ink-2);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 9999px;
  cursor: pointer;
  transition: var(--duration-normal) var(--ease-spring);
  transition-property: background-color, color, border-color, box-shadow, transform, opacity;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}
.btn-secondary:hover {
  background: var(--c-surface-2);
  color: var(--c-ink);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.btn-secondary:active { transform: translateY(0) scale(0.96) !important; }
/* ui-audit R1: room.html (start modal, QR) uses .btn-primary but never loaded login.css where it lived. Same pill as .btn-secondary, brand fill. */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; font-size: calc(14px * var(--fs-scale, 1)); font-weight: 700; font-family: var(--font);
  color: var(--c-on-brand); background: var(--c-brand); border: 1px solid transparent; border-radius: 9999px;
  cursor: pointer; text-decoration: none; box-shadow: var(--shadow-sm);
  transition: var(--duration-normal) var(--ease-spring); transition-property: background-color, color, box-shadow, transform, opacity;
}
.btn-primary:hover:not(:disabled) { background: var(--c-brand-dark); }
.btn-primary:disabled { background: var(--c-ink-3); cursor: not-allowed; }
.btn-secondary i { width: 18px; height: 18px; flex-shrink: 0; }

/* ── Generic brand-filled pill button (TODO.md #73) ──────────────────────────
   .btn/.btn-confirm previously had no base rule outside .modal__actions
   (see below), so every use elsewhere (tournament cards, pairing rows,
   match-result overlays) fell back to the browser's default button chrome.
   This is the shared look; scoped rules (.pairing-card__actions .btn,
   .tournament-card__actions .btn, .modal__actions .btn, ...) still override
   sizing/width on top of it. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  font-size: calc(14px * var(--fs-scale, 1));
  font-weight: 700;
  font-family: var(--font);
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  transition: var(--duration-normal) var(--ease-spring);
  transition-property: background-color, color, border-color, box-shadow, transform, opacity;
  text-decoration: none;
}
.btn-confirm {
  background: var(--c-brand);
  color: var(--c-on-brand);
  box-shadow: var(--shadow-sm);
}
.btn-confirm:hover {
  background: var(--c-brand-dark);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--c-brand-light);
}
.btn-confirm:active { transform: translateY(0) scale(0.96) !important; }

/* ── Room List ────────────────────────────────────────────────────────────── */
.room-list {
  /* Handled by .ui-shell > .ui-core */
}

/* Premium empty state */
.room-list__empty {
  padding: 56px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.room-list__empty-icon {
  margin-bottom: 20px;
  opacity: 0.75;
}

.room-list__empty-text {
  display: block;
  font-size: calc(16px * var(--fs-scale, 1));
  font-weight: 600;
  color: var(--c-ink-2);
  margin-bottom: 6px;
}

.room-list__empty-sub {
  display: block;
  font-size: calc(14px * var(--fs-scale, 1));
  color: var(--c-ink-3);
  font-weight: 400;
}

/* Card list (replaces the old 6-column .room-table at every viewport) */
.room-cards {
  display: flex;
  flex-direction: column;
}

.room-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: var(--card-pad);
  border-bottom: 1px solid var(--c-border-light);
  transition: background var(--duration-fast) var(--ease-out);
}
.room-card:last-child { border-bottom: none; }
.room-card:hover { background: var(--c-surface-2); }

.room-card__body {
  flex: 1 1 auto;
  min-width: 0;
}

.room-card__title {
  font-size: calc(15px * var(--fs-scale, 1));
  font-weight: 600;
  color: var(--c-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-card__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  font-size: calc(14px * var(--fs-scale, 1));
  color: var(--c-ink-3);
  min-width: 0;
}

.room-card__host {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 45%;
}

.room-card__dot { color: var(--c-border); }

.room-card__id {
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.room-card__chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

/* Room ID column */
.room-id {
  font-weight: 800;
  font-family: var(--font);
  color: var(--c-ink-2);
  font-size: calc(14px * var(--fs-scale, 1));
  letter-spacing: 0.04em;
}

/* State badge */
.state-badge {
  display: inline-block;
  padding: 6px 12px;
  font-size: calc(14px * var(--fs-scale, 1));
  font-weight: 700;
  border-radius: 9999px;
  letter-spacing: 0.02em;
}
.state-badge--idle {
  background: var(--c-surface-2);
  color: var(--c-state-idle);
  border: 1px solid var(--c-border);
}
.state-badge--playing {
  background: var(--c-success-bg);
  color: var(--c-state-playing);
}
.state-badge--waiting {
  background: var(--c-warning-bg);
  color: var(--c-warning);   /* ui-audit F2: state-waiting is a dot colour (4.2:1), text uses --c-warning */
}

/* Single plain-language rule summary chip */
.rule-chip {
  display: inline-block;
  padding: 5px 10px;
  font-size: calc(14px * var(--fs-scale, 1));
  font-weight: 600;
  border-radius: 9999px;
  white-space: nowrap;
  background: var(--c-surface-2);
  color: var(--c-ink-3);
  border: 1px solid var(--c-border);
}
.rule-chip--custom {
  background: var(--c-brand-light);
  color: var(--c-brand-text);
  border-color: transparent;
}

/* Rule tags */
.rule-tags { display: flex; gap: 6px; }
.rule-tag {
  padding: 4px 10px;
  font-size: calc(14px * var(--fs-scale, 1));
  font-weight: 700;
  white-space: nowrap;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--c-surface-2);
  color: var(--c-ink-2);
  border: 1px solid var(--c-border);
}
.rule-tag--wall {
  color: var(--c-error);
  background: var(--c-error-bg);
  border-color: transparent;
}
.rule-tag--portal {
  color: var(--c-brand-text);
  background: var(--c-brand-light);
  border-color: transparent;
}
.rule-tag--swap2 {
  color: var(--c-success);
  background: var(--c-success-bg);
  border-color: transparent;
}
.rule-tag--win {
  color: var(--c-accent);
  background: var(--c-accent-light);
  border-color: transparent;
}
.rule-tag--size {
  color: var(--c-ink-3);
  text-transform: none;
  letter-spacing: 0.02em;
}

/* Player count */
.player-count { font-weight: 700; font-size: calc(15px * var(--fs-scale, 1)); }
.player-count--full { color: var(--c-state-playing); }
.player-count--open { color: var(--c-ink-2); }

/* Join button */
.btn-join {
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 8px 20px;
  font-size: calc(14px * var(--fs-scale, 1));
  font-weight: 700;
  font-family: var(--font);
  color: var(--c-brand-text);
  background: var(--c-brand-light);
  border: 1px solid transparent;
  border-radius: 9999px;
  cursor: pointer;
  transition: var(--duration-fast) var(--ease-spring);
  transition-property: background-color, color, border-color, box-shadow, transform, opacity;
}
.btn-join:hover {
  background: var(--c-brand);
  color: var(--c-on-brand);
  transform: translateY(-2px);
  box-shadow: 0 8px 16px var(--c-brand-light);
}
.btn-join:active { transform: translateY(0) scale(0.96) !important; }

/* ── Create Room Modal ────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: var(--z-modal);
  display: none;
  align-items: center;
  justify-content: center;
}
@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal-overlay.visible { 
  display: flex; 
  animation: overlayIn var(--duration-normal) var(--ease-out) forwards;
}

.modal {
  background: var(--c-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg), var(--shadow-glass-inset);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn var(--duration-normal) var(--ease-spring) forwards;
  border: 1px solid var(--c-border);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(24px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal__header {
  padding: 24px 32px 20px;
  border-bottom: 1px solid var(--c-border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--c-surface);
}
.modal__title {
  font-size: calc(20px * var(--fs-scale, 1));
  font-weight: 800;
  color: var(--c-ink);
  letter-spacing: -0.01em;
}
.modal__close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  font-size: calc(16px * var(--fs-scale, 1));
  color: var(--c-ink-3);
  cursor: pointer;
  border-radius: 50%;
  transition: var(--duration-fast) var(--ease-spring);
  transition-property: background-color, color, border-color, box-shadow, transform, opacity;
}
.modal__close .icon { width: 20px; height: 20px; }   /* #214: sprite x replaces the ✕ glyph */
.modal__close:hover { background: var(--c-border); color: var(--c-ink); transform: scale(1.05); }
.modal__close:active { transform: scale(0.95) !important; }

.modal__body { 
  padding: 32px; 
  overflow-y: auto;
  flex: 1; /* allow it to take available space inside the column flex modal */
}

/* Setting row */
.setting-row { margin-bottom: 20px; }
.setting-row:last-child { margin-bottom: 0; }

.setting-label {
  display: block;
  font-size: calc(14px * var(--fs-scale, 1));
  font-weight: 600;
  color: var(--c-ink-3);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 8px;
}

/* Radio-pill group */
.pill-group {
  display: flex;
  gap: 6px;
  background: var(--c-surface-2);
  padding: 6px;
  border-radius: 9999px;
  border: 1px solid var(--c-border);
}
.pill-group input[type="radio"] { display: none; }
.pill-group label {
  flex: 1;
  padding: 10px 8px;
  text-align: center;
  font-size: calc(14px * var(--fs-scale, 1));
  font-weight: 700;
  color: var(--c-ink-2);
  background: var(--c-surface-2);
  cursor: pointer;
  transition: var(--duration-fast) var(--ease-spring);
  transition-property: background-color, color, border-color, box-shadow, transform, opacity;
  border-radius: 9999px;
  user-select: none;
}
.pill-group input:not(:checked) + label:hover {
  background: var(--c-hover);
  color: var(--c-ink);
}
.pill-group label:active {
  transform: scale(0.96);
}
.pill-group input:checked + label {
  background: var(--c-surface);
  color: var(--c-ink);
  box-shadow: var(--shadow-sm);
}

/* Toggle switch */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
}
.toggle-row + .toggle-row { margin-top: 8px; }

.toggle-name { flex: 1; min-width: 0; font-size: calc(14px * var(--fs-scale, 1)); color: var(--c-ink); font-weight: 500; }

.toggle-switch { position: relative; flex: none; width: 44px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--c-border);
  border-radius: 12px;
  cursor: pointer;
  transition: var(--duration-fast) var(--ease-spring);
  transition-property: background-color, color, border-color, box-shadow, transform, opacity;
}
.toggle-switch:active .toggle-slider {
  transform: scale(0.92);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  left: 2px; top: 2px;
  width: 20px; height: 20px;
  background: var(--c-knob);
  border-radius: 50%;
  transition: transform var(--duration-fast) var(--ease-spring);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.toggle-switch input:checked + .toggle-slider { background: var(--c-brand); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* Timer input */
.timer-input { display: flex; align-items: center; gap: 12px; }
.timer-input input[type="number"],
.timer-input input[type="text"],
.timer-input input[type="date"],
.timer-input input[type="datetime-local"] {
  width: 100px;
  padding: 12px 16px;
  font-size: calc(14px * var(--fs-scale, 1));
  font-family: var(--font);
  color: var(--c-ink);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  outline: none;
  transition: var(--duration-fast) var(--ease-spring);
  transition-property: background-color, color, border-color, box-shadow, transform, opacity;
}
.timer-input input[type="text"], .timer-input input[type="date"], .timer-input input[type="datetime-local"] { width: 100%; }
.timer-input input:focus {
  border-color: var(--c-brand);
  box-shadow: 0 0 0 4px var(--c-brand-light);
}
.timer-input .unit { font-size: calc(14px * var(--fs-scale, 1)); color: var(--c-ink-3); font-weight: 600; }

/* Modal actions */
/* ── Create-room modal: UI-mode affordances ───────────────────────────────── */
/* Quick match and the Advanced disclosure are hidden unless Lite is on. */
.modal__quick,
.modal__advanced-toggle { display: none; }

.modal--lite .modal__quick {
  display: block;
  width: 100%;
  padding: 14px 20px;
  margin-bottom: 8px;
  font-size: calc(15px * var(--fs-scale, 1));
  font-weight: 700;
}

.modal--lite .modal__advanced-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 4px;
  font-family: var(--font);
  font-size: calc(14px * var(--fs-scale, 1));
  font-weight: 600;
  color: var(--c-ink-2);
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: 12px;
  cursor: pointer;
}
.modal--lite .modal__advanced-toggle:hover { color: var(--c-ink); }

.modal__advanced-arrow {
  display: inline-flex;
  transition: transform var(--duration-normal) var(--ease-out);
}
.modal__advanced-toggle[aria-expanded="true"] .modal__advanced-arrow { transform: rotate(180deg); }

/* Collapsed only in Lite — Default keeps the form flat and always open. */
.modal--lite .modal__advanced {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--duration-normal) var(--ease-out);
}
.modal--lite .modal__advanced.open {
  max-height: 1200px;
  overflow: visible;
}

/* Lite collapsed: Quick match is the only create action. Once Advanced is
   expanded the user is customising, so the explicit "Create room" confirm —
   which submits the edited form rather than the remembered preset — returns. */
.modal--lite .modal__actions .btn-confirm { display: none; }
.modal--lite .modal__advanced.open ~ .modal__actions .btn-confirm { display: block; }

.modal__actions { display: flex; gap: 16px; margin-top: 40px; }
.modal__actions .btn {
  flex: 1;
  padding: 14px 0;
  font-size: calc(16px * var(--fs-scale, 1));
  font-weight: 800;
  font-family: var(--font);
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  transition: var(--duration-fast) var(--ease-spring);
  transition-property: background-color, color, border-color, box-shadow, transform, opacity;
}
.modal__actions .btn-cancel {
  background: var(--c-surface-2);
  color: var(--c-ink-2);
  border: 1px solid var(--c-border);
}
.modal__actions .btn-cancel:hover { background: var(--c-border-light); color: var(--c-ink); transform: translateY(-2px); }
.modal__actions .btn-confirm {
  background: var(--c-brand);
  color: var(--c-on-brand);
  box-shadow: var(--shadow-sm);
}
.modal__actions .btn-confirm:hover {
  background: var(--c-brand-dark);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--c-brand-light);
}
.modal__actions .btn-confirm:active { transform: translateY(0) scale(0.96) !important; }

/* ── Online Users Sidebar Panel ──────────────────────────────────────────── */
.online-panel {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--duration-normal) var(--ease-out);
}

.online-panel__header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  cursor: pointer;
  user-select: none;
  transition: background var(--duration-fast) var(--ease-in-out);
}
.online-panel__header:hover { background: var(--c-surface-2); }

.online-panel__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--c-success);
  box-shadow: 0 0 6px var(--c-success);
  flex-shrink: 0;
  animation: pulse-dot 2.5s ease-in-out 2;   /* stops after 5s (DEP-AUTO-MOTION) */
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 6px var(--c-success); }
  50%       { box-shadow: 0 0 12px var(--c-success); }
}

@media (prefers-reduced-motion: reduce) {
  .online-panel__dot { animation: none; }
}

.online-panel__title {
  font-size: calc(14px * var(--fs-scale, 1));
  font-weight: 600;
  color: var(--c-ink);
  flex: 1;
}

.online-panel__count {
  font-size: calc(14px * var(--fs-scale, 1));
  font-weight: 700;
  color: var(--c-brand-text);
  background: var(--c-brand-light);
  border-radius: 10px;
  padding: 2px 8px;
  min-width: 22px;
  text-align: center;
}

.online-panel__arrow {
  color: var(--c-ink-3);
  transition: transform var(--duration-normal) var(--ease-spring);
  display: flex;
  align-items: center;
}
.online-panel__header.open .online-panel__arrow { transform: rotate(180deg); }

/* Sidebar: always show user list (no collapse needed at desktop) */
.online-panel__body {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--duration-normal) var(--ease-out);
}
.online-panel__body.open {
  max-height: calc(100vh - 180px);
  max-height: calc(100dvh - 180px);
  overflow-y: auto;
}

/* On desktop sidebar, open by default via JS — graceful fallback */
.lobby-sidebar .online-panel__body {
  max-height: calc(100vh - 200px);
  max-height: calc(100dvh - 200px);
  overflow-y: auto;
}

.online-panel__list {
  list-style: none;
  margin: 0;
  padding: 6px 0;
  border-top: 1px solid var(--c-border-light);
}

.online-panel__list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  font-size: calc(14px * var(--fs-scale, 1));
  font-weight: 500;
  color: var(--c-ink);
  transition: background var(--duration-fast) var(--ease-in-out);
  cursor: default;
}
.online-panel__list li:hover { background: var(--c-surface-2); }

.online-panel__list li::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c-success);
  flex-shrink: 0;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .lobby-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .lobby-sidebar {
    padding: 0 24px 32px;
    position: static;
    max-height: none;
  }

  /* Collapse sidebar panel on mobile (original behavior) */
  .lobby-sidebar .online-panel__body {
    max-height: 0;
  }
  .lobby-sidebar .online-panel__body.open {
    max-height: 400px;
  }

  .lobby { padding: 24px 20px 24px; }
}

@media (max-width: 640px) {
  .lobby { padding: 16px 12px 20px; }
  .lobby-sidebar { padding: 0 12px 32px; }

  /* Card list keeps every field (incl. status) at phone widths — only tighten it */
  .room-card { padding: 12px; gap: 10px; }
  .room-card__title { font-size: calc(14px * var(--fs-scale, 1)); }
  .btn-join { padding: 8px 16px; }

  .modal { max-width: calc(100vw - 32px); }
}

/* ─────────────────────────────────────────────────────────────────────────
 * Tables & Tournaments — section tabs, tournament cards, filter row.
 * Moved here verbatim from the approved static mockup
 * (client/tables-tournaments-mockup.html, feature/tables-tournaments-mockup)
 * once Phase 5 wired it into the real lobby — see TODO.md #48 / instruction.md B48.
 * ────────────────────────────────────────────────────────────────────────── */

.section-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--c-border);
}
.section-tabs__btn {
  appearance: none;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: calc(15px * var(--fs-scale, 1));
  font-weight: 600;
  color: var(--c-ink-2);
  /* min-height 44px keeps this a valid touch target on mobile, per
     touch-target-size guideline, without changing desktop density. */
  min-height: 44px;
  padding: 0 4px;
  margin-right: 24px;
  display: inline-flex;
  align-items: center;
  border-bottom: 2px solid transparent;
  transition: color .15s ease, border-color .15s ease;
}
.section-tabs__btn:hover { color: var(--c-ink); }
.section-tabs__btn:focus-visible {
  outline: 2px solid var(--c-brand);
  outline-offset: 2px;
  border-radius: 4px;
}
.section-tabs__btn.is-active {
  color: var(--c-brand-text);
  border-bottom-color: var(--c-brand);
}
.section-tabs__btn .icon { margin-right: 6px; font-size: calc(16px * var(--fs-scale, 1)); vertical-align: -2px; }

.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  /* .filter-row and .tournament-grid are siblings directly inside .ui-core,
     which (main.css's Double-Bezel Architecture) carries no padding of its
     own — .tournament-grid supplies its own 16px, but .filter-row had none,
     so the pills sat flush against the card's top/left border. */
  padding: 16px 16px 0;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

@media (max-width: 640px) {
  .filter-row { padding: 12px 8px 0; }
}
.filter-pill {
  appearance: none;
  background: var(--c-surface-2);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 8px 14px;
  min-height: 36px;
  font-size: calc(14px * var(--fs-scale, 1));
  font-weight: 600;
  color: var(--c-ink-2);
  cursor: pointer;
  font-family: inherit;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.filter-pill:hover { background: var(--c-border-light); }
.filter-pill:focus-visible {
  outline: 2px solid var(--c-brand);
  outline-offset: 2px;
}
.filter-pill.is-active {
  background: var(--c-brand-light);
  color: var(--c-brand-text);
  border-color: var(--c-brand);
}
.filter-spacer { flex: 1; }
.filter-select {
  font-family: inherit;
  font-size: calc(14px * var(--fs-scale, 1));
  font-weight: 600;
  color: var(--c-ink-2);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 8px 10px;
  min-height: 36px;
  cursor: pointer;
}
.filter-select:focus-visible {
  outline: 2px solid var(--c-brand);
  outline-offset: 2px;
}

.tournament-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  padding: 16px;
}
.tournament-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--card-radius);
  padding: var(--card-pad-lg);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: box-shadow .15s ease, transform .15s ease;
  cursor: pointer;
}
.tournament-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.tournament-card:focus-visible {
  outline: 2px solid var(--c-brand);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  .tournament-card,
  .section-tabs__btn,
  .filter-pill {
    transition: none;
  }
  .tournament-card:hover { transform: none; }
}
@media (max-width: 480px) {
  /* Filter pills and select need the full 44px touch target on small
     screens even though 36px reads fine at desktop pointer precision. */
  .filter-pill, .filter-select { min-height: 44px; }
}
.tournament-card__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.tournament-card__name {
  font-size: calc(15px * var(--fs-scale, 1));
  font-weight: 700;
  color: var(--c-ink);
  line-height: 1.3;
}
.badge {
  display: inline-block;
  font-size: calc(14px * var(--fs-scale, 1));
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge--format {
  background: var(--c-surface-2);
  color: var(--c-ink-2);
}
.badge--live {
  background: var(--c-success-bg);
  color: var(--c-success);
}
.badge--upcoming {
  background: var(--c-warning-bg);
  color: var(--c-warning);
}
.badge--done {
  background: var(--c-surface-2);
  color: var(--c-ink-3);
}
.tournament-card__meta {
  font-size: calc(14px * var(--fs-scale, 1));
  color: var(--c-ink-2);
  display: flex;
  align-items: center;
  gap: 6px;
}
.tournament-card__meta .icon { font-size: calc(16px * var(--fs-scale, 1)); }
.tournament-card__status {
  margin-top: 2px;
  font-size: calc(14px * var(--fs-scale, 1));
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--c-border-light);
}
.tournament-card__status--your-turn { color: var(--c-brand-text); }
.tournament-card__status--waiting { color: var(--c-ink-3); font-weight: 600; }
.tournament-card__status--registered { color: var(--c-success); }
.tournament-card__actions { display: flex; gap: 8px; margin-top: 2px; }
.tournament-card__actions .btn, .tournament-card__actions .btn-secondary { flex: 1; }

.empty-tournaments {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 24px;
  text-align: center;
}
.empty-tournaments .room-list__empty-text { margin-top: 14px; }

@media (max-width: 640px) {
  .tournament-grid { padding: 8px; gap: 12px; }
  .tournament-card { padding: var(--card-pad); }
}

/* ── Live matches browser (TODO.md #60) ─────────────────────────────────── */
.live-matches-panel {
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 14px;
  padding: 14px 16px; margin-bottom: 16px; width: 100%; box-sizing: border-box;
}
.live-matches-panel__header {
  display: flex; align-items: center; gap: 8px; font-size: calc(14px * var(--fs-scale, 1)); font-weight: 700;
  color: var(--c-ink-3); text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 10px;
}
.live-matches-panel__header .icon { color: var(--c-error); font-size: calc(16px * var(--fs-scale, 1)); }
.live-matches-panel__list { display: flex; flex-direction: column; gap: 8px; }
.live-match-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--c-border-light); border-radius: 10px;
  background: var(--c-surface-2); cursor: pointer; transition: border-color var(--duration-fast);
  flex-wrap: wrap;
}
.live-match-row:hover { border-color: var(--c-brand); }
.live-match-row__players { font-size: calc(14px * var(--fs-scale, 1)); font-weight: 700; color: var(--c-ink); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.live-match-row__vs { font-size: calc(14px * var(--fs-scale, 1)); font-weight: 600; color: var(--c-ink-3); }
.live-match-row__meta { font-size: calc(14px * var(--fs-scale, 1)); color: var(--c-ink-3); display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.live-match-row__meta .icon { font-size: calc(16px * var(--fs-scale, 1)); }
.live-match-row__tournament { font-size: calc(14px * var(--fs-scale, 1)); color: var(--c-ink-2); width: 100%; }

/* ── Create-room modal: Arena skin (flat, square, grouped) ────────────────── */
:is(#modal-create, .modal-overlay--form) .modal { max-width: 460px; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); animation-timing-function: var(--ease-out); }
:is(#modal-create, .modal-overlay--form) .modal__header { padding: 18px 24px 14px; }
:is(#modal-create, .modal-overlay--form) .modal__title { font-size: calc(17px * var(--fs-scale, 1)); font-weight: 700; }
:is(#modal-create, .modal-overlay--form) .modal__close { width: 32px; height: 32px; border: 0; background: var(--c-fill); border-radius: var(--radius); }
:is(#modal-create, .modal-overlay--form) .modal__close .icon { width: 16px; height: 16px; }
@media (max-width: 860px) { .modal__close, :is(#modal-create, .modal-overlay--form) .modal__close { width: 44px; height: 44px; } }   /* B306 */
@media (max-width: 860px) { .toggle-switch::after { content: ""; position: absolute; inset: -8px 0; } }   /* ui-audit F6: 24px switch -> 40px hit area, no visual change (8px row gap, no overlap) */
:is(#modal-create, .modal-overlay--form) .modal__body { padding: 20px 24px 24px; }
:is(#modal-create, .modal-overlay--form) .setting-row { margin-bottom: 18px; }
:is(#modal-create, .modal-overlay--form) .setting-label { font-size: var(--text-xs); font-weight: 600; letter-spacing: .1em; margin-bottom: 7px; }
:is(#modal-create, .modal-overlay--form) .setting-hint { margin: 8px 0 0; font-size: calc(14px * var(--fs-scale, 1)); color: var(--c-ink-3); }

:is(#modal-create, .modal-overlay--form) .timer-input--block input { width: 100%; box-sizing: border-box; }
:is(#modal-create, .modal-overlay--form) .timer-input input { border-radius: var(--radius); background: var(--c-field); }
:is(#modal-create, .modal-overlay--form) .setting-row--pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
:is(#modal-create, .modal-overlay--form) .setting-row--pair .timer-input { gap: 8px; }
:is(#modal-create, .modal-overlay--form) .setting-row--pair .timer-input input[type="number"] { min-width: 0; flex: 1; }

/* Squared segmented control (replaces the round pill) */
:is(#modal-create, .modal-overlay--form) .pill-group { gap: 2px; padding: 3px; border-radius: var(--radius-lg); background: var(--c-fill); border: 0; }
:is(#modal-create, .modal-overlay--form) .pill-group label { padding: 8px 6px; font-size: calc(14px * var(--fs-scale, 1)); font-weight: 600; border-radius: var(--radius); color: var(--c-ink-2); }
:is(#modal-create, .modal-overlay--form) .pill-group input:checked + label { background: var(--c-brand); color: var(--c-on-brand); box-shadow: none; border: 0; }

:is(#modal-create, .modal-overlay--form) .toggle-row { padding: 8px 0; border-bottom: 1px solid var(--c-border-light); }
:is(#modal-create, .modal-overlay--form) .toggle-row + .toggle-row { margin-top: 0; }
:is(#modal-create, .modal-overlay--form) .toggle-row:last-child { border-bottom: 0; }
:is(#modal-create, .modal-overlay--form) .toggle-name { font-size: calc(13.5px * var(--fs-scale, 1)); }

/* Create-room choices are native <select>s (F402): OS picker on phones, type-ahead + arrows on desktop */
#modal-create .setting-select {
  display: block; width: 100%; min-height: 44px; padding: 0 40px 0 12px;
  font: inherit; font-size: calc(15px * var(--fs-scale, 1)); font-weight: 600; color: var(--c-ink);
  background-color: var(--c-field); border: 1px solid var(--c-border); border-radius: var(--radius);
  appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239a968c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  transition: border-color var(--duration-fast) var(--ease-out), background-color var(--duration-fast) var(--ease-out);
}
#modal-create .setting-select:hover { border-color: var(--c-ink-3); }
#modal-create .setting-select:focus-visible { outline: 2px solid var(--c-ink); outline-offset: 2px; }
#modal-create .setting-select option { background: var(--c-surface); color: var(--c-ink); }
/* What "Tạo nhanh" will create, right above the button */
.modal__summary { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.modal__chip { padding: 3px 10px; font-size: calc(13px * var(--fs-scale, 1)); line-height: 1.4; color: var(--c-ink-2); background: var(--c-fill); border: 1px solid var(--c-border); border-radius: 999px; }
.modal__summary:empty { display: none; }

:is(#modal-create, .modal-overlay--form) .modal__actions { gap: 10px; margin-top: 22px; }
:is(#modal-create, .modal-overlay--form) .modal__actions .btn { padding: 11px 0; font-size: calc(14px * var(--fs-scale, 1)); font-weight: 700; border-radius: var(--radius); }
:is(#modal-create, .modal-overlay--form) .modal__actions .btn-cancel { background: var(--c-fill); border: 0; }
:is(#modal-create, .modal-overlay--form) .modal__actions .btn-confirm:hover { box-shadow: none; transform: none; opacity: .88; }
:is(#modal-create, .modal-overlay--form) .modal__actions .btn-cancel:hover { transform: none; }
#modal-create.modal--lite .modal__quick { border-radius: var(--radius); }
#modal-create.modal--lite .modal__advanced-toggle { margin-bottom: 16px; border: 0; background: var(--c-fill); border-radius: var(--radius); }

@media (max-width: 420px) {
  :is(#modal-create, .modal-overlay--form) .modal { max-width: calc(100vw - 24px); }
  :is(#modal-create, .modal-overlay--form) .modal__body { padding: 16px; }
}
