/* ============================================================================
   Paw & Crown — Cute 2D Multiplayer Chess Stylesheet
   Cozy Kawaii Pastel & Storybook Wood Aesthetic
   ============================================================================ */

:root {
  --bg-cream: #fffbf0;
  --bg-pattern: #fef3c7;
  --card-bg: #ffffff;
  --border-warm: #fde68a;
  --border-cocoa: #d97706;
  --text-dark: #451a03;
  --text-muted: #92400e;
  --sq-light: #fef9e7;
  --sq-dark: #a7d7c5;
  --sq-dark-border: #74b49b;
  --accent-gold: #f59e0b;
  --accent-mint: #10b981;
  --accent-coral: #f43f5e;
  --accent-indigo: #6366f1;
  --shadow-soft: 0 10px 28px rgba(120, 53, 15, 0.08);
  --shadow-tactile: 0 4px 0 #d97706;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-cream);
  background-image: radial-gradient(var(--bg-pattern) 1.5px, transparent 1.5px);
  background-size: 24px 24px;
  color: var(--text-dark);
  font-family: 'Quicksand', -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100vh;
}

h1, h2, h3, strong, .btn, .status-badge, .role-badge, .turn-pill {
  font-family: 'Fredoka', 'Quicksand', sans-serif;
}

.chess-app-shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 18px 20px 36px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Top Header ─────────────────────────────────────────────────────────── */

.chess-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: var(--card-bg);
  border: 3px solid var(--border-warm);
  border-radius: 22px;
  padding: 14px 22px;
  box-shadow: var(--shadow-soft);
}

.brand-box {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  font-size: 2.2rem;
  background: #fef3c7;
  border: 2px solid #fde68a;
  border-radius: 16px;
  padding: 6px 10px;
  line-height: 1;
}

.brand-title {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 700;
  color: #78350f;
  letter-spacing: -0.01em;
}

.brand-sub {
  margin: 2px 0 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.header-badges {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.status-badge, .role-badge {
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 600;
  border: 2px solid transparent;
}

.status-waiting {
  background: #fef3c7;
  color: #b45309;
  border-color: #fde68a;
}

.status-playing {
  background: #d1fae5;
  color: #065f46;
  border-color: #6ee7b7;
}

.status-checkmate {
  background: #ffe4e6;
  color: #be123c;
  border-color: #fda4af;
}

.status-stalemate, .status-resigned {
  background: #e0e7ff;
  color: #3730a3;
  border-color: #a5b4fc;
}

.role-badge {
  background: #f3e8ff;
  color: #6b21a8;
  border-color: #d8b4fe;
}

/* ── Lobby / Join / Waiting / Spectator / Checkmate Cards ──────────────── */

.lobby-card {
  background: var(--card-bg);
  border: 3px solid var(--border-warm);
  border-radius: 22px;
  padding: 18px 24px;
  box-shadow: var(--shadow-soft);
  transition: all 0.2s ease;
}

.join-card {
  background: linear-gradient(135deg, #fffbeb 0%, #ffffff 100%);
  border-color: #fbbf24;
}

.lobby-badge {
  display: inline-block;
  background: #fef3c7;
  color: #92400e;
  border: 2px solid #fde68a;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 8px;
}

.lobby-title {
  margin: 0 0 4px;
  font-size: 1.25rem;
  color: #78350f;
}

.lobby-desc {
  margin: 0 0 12px;
  font-size: 0.92rem;
  color: #92400e;
  font-weight: 600;
}

.join-form-row, .local-p2-box {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.cute-input {
  flex: 1;
  min-width: 210px;
  max-width: 340px;
  padding: 10px 16px;
  font-size: 0.98rem;
  font-family: 'Quicksand', sans-serif;
  font-weight: 700;
  color: var(--text-dark);
  background: #ffffff;
  border: 2.5px solid #fcd34d;
  border-radius: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.cute-input:focus {
  border-color: #f59e0b;
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.18);
}

.input-sm {
  padding: 8px 14px;
  font-size: 0.9rem;
}

.btn {
  cursor: pointer;
  border: none;
  border-radius: 14px;
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.1s, box-shadow 0.1s, background 0.15s;
}

.btn:active {
  transform: translateY(2px);
}

.btn-join {
  background: #f59e0b;
  color: #ffffff;
  border: 2px solid #d97706;
  box-shadow: 0 3px 0 #b45309;
}

.btn-join:hover {
  background: #d97706;
}

.btn-secondary {
  background: #10b981;
  color: #ffffff;
  border: 2px solid #059669;
  box-shadow: 0 3px 0 #047857;
}

.btn-secondary:hover {
  background: #059669;
}

.btn-outline {
  background: #fffbeb;
  color: #78350f;
  border: 2px solid #fcd34d;
  padding: 8px 14px;
  font-size: 0.86rem;
}

.btn-outline:hover {
  background: #fef3c7;
}

.btn-danger-soft {
  background: #ffe4e6;
  color: #be123c;
  border: 2px solid #fda4af;
  padding: 8px 14px;
  font-size: 0.86rem;
}

.btn-danger-soft:hover {
  background: #fecdd3;
}

.waiting-card {
  background: linear-gradient(135deg, #ecfdf5 0%, #ffffff 100%);
  border-color: #6ee7b7;
}

.waiting-Header {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.08rem;
  color: #065f46;
  margin-bottom: 6px;
}

.pulse-dot {
  width: 12px;
  height: 12px;
  background: #10b981;
  border-radius: 50%;
  display: inline-block;
  animation: pulseGlow 1.4s infinite ease-in-out;
}

@keyframes pulseGlow {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.35); opacity: 0.55; }
}

.spectator-card {
  background: linear-gradient(135deg, #f5f3ff 0%, #ffffff 100%);
  border-color: #c4b5fd;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.spectator-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #4c1d95;
}

.spec-icon {
  font-size: 1.8rem;
}

.spec-registered {
  background: #ede9fe;
  color: #5b21b6;
  font-weight: 700;
  font-size: 0.86rem;
  padding: 6px 14px;
  border-radius: 999px;
  border: 2px solid #ddd6fe;
}

.gameover-card {
  background: linear-gradient(135deg, #fff1f2 0%, #fffbeb 100%);
  border-color: #fb7185;
  text-align: center;
  padding: 22px;
}

.trophy-icon {
  font-size: 2.6rem;
  margin-bottom: 6px;
}

.gameover-title {
  margin: 0 0 6px;
  font-size: 1.6rem;
  color: #be123c;
}

.gameover-reason {
  margin: 0 0 16px;
  font-size: 1.02rem;
  font-weight: 700;
  color: #881337;
}

.gameover-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* ── Feedback / Impossible Move / Check Toast Banner ────────────────────── */

.feedback-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-radius: 16px;
  font-weight: 700;
  font-size: 0.95rem;
  border: 2.5px solid transparent;
  animation: popIn 0.18s ease-out;
}

@keyframes popIn {
  from { transform: translateY(-4px); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}

.fb-error {
  background: #ffe4e6;
  color: #be123c;
  border-color: #fb7185;
}

.fb-warn {
  background: #fef3c7;
  color: #b45309;
  border-color: #fbbf24;
}

.fb-info {
  background: #e0f2fe;
  color: #0369a1;
  border-color: #7dd3fc;
}

.fb-check {
  background: #ffe4e6;
  color: #be123c;
  border-color: #f43f5e;
  box-shadow: 0 0 0 4px rgba(244, 63, 94, 0.15);
}

.fb-close {
  background: transparent;
  border: none;
  cursor: pointer;
  font-weight: 800;
  font-size: 1rem;
  color: inherit;
  opacity: 0.7;
}

.fb-close:hover {
  opacity: 1;
}

/* ── Main 2-Column Workspace ────────────────────────────────────────────── */

.chess-workspace {
  display: grid;
  grid-template-columns: minmax(340px, 560px) 1fr;
  gap: 22px;
  align-items: start;
}

@media (max-width: 880px) {
  .chess-workspace {
    grid-template-columns: 1fr;
  }
}

.board-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Player Bars (Top & Bottom of Board) ────────────────────────────────── */

.player-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card-bg);
  border: 3px solid var(--border-warm);
  border-radius: 18px;
  padding: 10px 16px;
  box-shadow: var(--shadow-soft);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.player-bar.active-turn {
  border-color: #10b981;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.14);
}

.player-bar.in-check-bar {
  border-color: #f43f5e;
  background: #fff1f2;
  box-shadow: 0 0 0 4px rgba(244, 63, 94, 0.2);
}

.player-bar.winner-bar {
  border-color: #f59e0b;
  background: #fffbeb;
}

.player-identity {
  display: flex;
  align-items: center;
  gap: 12px;
}

.player-avatar {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fde68a;
  background: #fef3c7;
}

.avatar-b {
  background: #ede9fe;
  border-color: #c4b5fd;
}

.avatar-svg {
  width: 36px;
  height: 36px;
}

.player-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.player-name {
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text-dark);
}

.color-pill {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.pill-w {
  background: #fef3c7;
  color: #92400e;
  border: 1.5px solid #fcd34d;
}

.pill-b {
  background: #3b3054;
  color: #fef3c7;
  border: 1.5px solid #1e1b2e;
}

.you-badge {
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
}

.captured-pieces {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  margin-top: 3px;
}

.mini-captured-piece {
  width: 22px;
  height: 22px;
}

.mini-piece-svg {
  width: 22px;
  height: 22px;
}

.no-captures {
  font-size: 0.76rem;
  color: #a16207;
  opacity: 0.7;
}

.turn-pill {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.thinking-pill {
  background: #d1fae5;
  color: #065f46;
  border: 1.5px solid #34d399;
}

.check-pill {
  background: #f43f5e;
  color: #ffffff;
  animation: pulseGlow 1s infinite;
}

.winner-pill {
  background: #fbbf24;
  color: #78350f;
}

.waiting-pill, .idle-pill {
  background: #f5f5f4;
  color: #78716c;
}

/* ── Cute 2D Chessboard Frame & Squares ─────────────────────────────────── */

.board-frame {
  background: #d97706;
  background: linear-gradient(145deg, #f59e0b, #b45309);
  padding: 14px;
  border-radius: 26px;
  box-shadow: 0 14px 32px rgba(120, 53, 15, 0.22), inset 0 2px 4px rgba(255, 255, 255, 0.35);
  border: 4px solid #92400e;
}

.board-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  aspect-ratio: 1 / 1;
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
  border: 3px solid #78350f;
  background: var(--sq-light);
}

.chess-sq {
  position: relative;
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.14s ease, transform 0.1s ease;
}

.sq-light {
  background-color: var(--sq-light);
}

.sq-dark {
  background-color: var(--sq-dark);
}

.chess-sq:hover {
  filter: brightness(1.04);
}

/* Last move subtle golden highlight */
.sq-last-move.sq-light {
  background-color: #fde68a;
}

.sq-last-move.sq-dark {
  background-color: #86efac;
}

/* Selected piece square */
.sq-selected {
  background-color: #fcd34d !important;
  box-shadow: inset 0 0 0 3.5px #d97706;
}

/* Checked or Checkmated King square */
.sq-king-check {
  background: radial-gradient(circle, #fda4af 15%, #f43f5e 90%) !important;
  box-shadow: inset 0 0 0 3px #be123c;
}

/* Impossible move clicked square flash */
.sq-invalid {
  background-color: #fecdd3 !important;
  box-shadow: inset 0 0 0 3.5px #e11d48;
  animation: invalidShake 0.32s ease-in-out;
}

@keyframes invalidShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* Coordinate Labels */
.coord-rank {
  position: absolute;
  top: 4px;
  left: 5px;
  font-size: 0.68rem;
  font-weight: 800;
  font-family: 'Fredoka', sans-serif;
  opacity: 0.72;
  pointer-events: none;
}

.coord-file {
  position: absolute;
  bottom: 3px;
  right: 5px;
  font-size: 0.68rem;
  font-weight: 800;
  font-family: 'Fredoka', sans-serif;
  opacity: 0.72;
  pointer-events: none;
}

.sq-light .coord-rank, .sq-light .coord-file {
  color: #52947c;
}

.sq-dark .coord-rank, .sq-dark .coord-file {
  color: #315e4d;
}

/* Piece SVG Holder */
.piece-holder {
  width: 86%;
  height: 86%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.sq-selected .piece-holder {
  transform: translateY(-4px) scale(1.07);
}

.piece-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* ── Possible Move Highlights (Empty Dot & Capture Target Ring) ─────────── */

.legal-move-dot {
  position: absolute;
  width: 32%;
  height: 32%;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.85);
  border: 2.5px solid #ffffff;
  box-shadow: 0 2px 6px rgba(6, 95, 70, 0.35);
  z-index: 3;
  pointer-events: none;
  animation: dotPop 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.castle-dot {
  width: 44%;
  height: 44%;
  background: rgba(99, 102, 241, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
}

.castle-tag {
  font-size: 0.72rem;
}

.legal-capture-ring {
  position: absolute;
  inset: 4px;
  border-radius: 12px;
  border: 3.5px dashed #f43f5e;
  background: rgba(244, 63, 94, 0.14);
  z-index: 3;
  pointer-events: none;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 2px;
}

.capture-badge {
  font-size: 0.72rem;
  background: #f43f5e;
  color: #ffffff;
  border-radius: 999px;
  padding: 1px 4px;
  line-height: 1;
}

@keyframes dotPop {
  from { transform: scale(0.3); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ── Right Sidebar (Move Helper, Promotion, History, Spectators) ────────── */

.chess-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.side-card {
  background: var(--card-bg);
  border: 3px solid var(--border-warm);
  border-radius: 20px;
  padding: 16px 18px;
  box-shadow: var(--shadow-soft);
}

.side-card-title {
  font-family: 'Fredoka', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: #78350f;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.selected-piece-info {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fffbeb;
  border: 2px solid #fde68a;
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.sel-preview {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

.sel-piece-svg {
  width: 44px;
  height: 44px;
}

.sel-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sel-moves-count {
  font-size: 0.82rem;
  font-weight: 700;
  color: #059669;
}

.sel-empty-hint {
  background: #f8fafc;
  border: 2px dashed #cbd5e1;
  border-radius: 14px;
  padding: 12px;
  font-size: 0.86rem;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 12px;
}

.promo-picker {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.promo-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
}

.promo-btn-group {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.promo-btn {
  cursor: pointer;
  padding: 6px 4px;
  border-radius: 10px;
  border: 2px solid #fde68a;
  background: #fffbeb;
  color: #78350f;
  font-family: 'Fredoka', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
}

.promo-btn.active {
  background: #f59e0b;
  color: #ffffff;
  border-color: #d97706;
}

/* Move History List */
.move-count-badge {
  background: #fef3c7;
  color: #92400e;
  font-size: 0.76rem;
  padding: 2px 9px;
  border-radius: 999px;
}

.history-list {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 4px;
}

.history-row {
  display: grid;
  grid-template-columns: 36px 1fr 1fr;
  align-items: center;
  padding: 5px 10px;
  border-radius: 10px;
  background: #fffbeb;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
}

.turn-num {
  color: #b45309;
  font-weight: 600;
}

.ply-move {
  font-weight: 600;
  color: #451a03;
}

.ply-check {
  color: #d97706;
  font-weight: 700;
}

.ply-mate {
  color: #e11d48;
  font-weight: 800;
}

.empty-history, .empty-specs {
  font-size: 0.85rem;
  color: #92400e;
  opacity: 0.8;
  padding: 6px 0;
}

.spec-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.spec-pill {
  background: #f3e8ff;
  color: #6b21a8;
  border: 1.5px solid #d8b4fe;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.control-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 2px dashed #fde68a;
}

/* ============================================================================
   Multi-Room Clubhouse, Game Resume Bar & Parallel Tournament Arena Styles
   ============================================================================ */

/* Navigation Tabs */
.nav-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.nav-tab-btn {
  cursor: pointer;
  background: #fffbeb;
  color: #78350f;
  border: 2.5px solid #fde68a;
  border-radius: 14px;
  padding: 8px 16px;
  font-family: 'Fredoka', sans-serif;
  font-size: 0.92rem;
  font-weight: 600;
  transition: all 0.15s ease;
}

.nav-tab-btn:hover {
  background: #fef3c7;
  border-color: #fbbf24;
}

.nav-tab-btn.active {
  background: #f59e0b;
  color: #ffffff;
  border-color: #d97706;
  box-shadow: 0 3px 0 #b45309;
}

/* Pinned "Come Back to Your Game" Resume Bar */
.resume-games-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: linear-gradient(135deg, #ecfdf5 0%, #fef3c7 100%);
  border: 3px solid #34d399;
  border-radius: 18px;
  padding: 10px 18px;
  box-shadow: var(--shadow-soft);
}

.resume-bar-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #065f46;
  font-size: 0.95rem;
}

.resume-pills-list {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.resume-game-pill {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  color: #451a03;
  border: 2px solid #6ee7b7;
  border-radius: 12px;
  padding: 6px 12px;
  font-size: 0.85rem;
  font-family: 'Quicksand', sans-serif;
  font-weight: 700;
  transition: transform 0.12s, box-shadow 0.12s;
}

.resume-game-pill:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.18);
}

.resume-game-pill.my-turn-glow {
  border-color: #f59e0b;
  background: #fffbeb;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.22);
}

.resume-game-pill.active-viewing {
  border-color: #6366f1;
  background: #eef2ff;
}

.resume-turn-tag {
  font-size: 0.75rem;
  padding: 2px 7px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
}

.resume-turn-tag.turn-urgent {
  background: #f59e0b;
  color: #ffffff;
  font-weight: 800;
}

.resume-cta {
  color: #059669;
  font-weight: 800;
  margin-left: 4px;
}

/* Reclaim Seat Button on Player Bar */
.reclaim-btn {
  cursor: pointer;
  background: #fef3c7;
  color: #b45309;
  border: 1.5px solid #f59e0b;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 0.73rem;
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  transition: background 0.15s;
}

.reclaim-btn:hover {
  background: #fde68a;
}

/* Room Context Breadcrumb Bar */
.board-view-wrapper {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.room-context-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  background: #ffffff;
  border: 2.5px solid #fde68a;
  border-radius: 16px;
  padding: 10px 16px;
}

.room-context-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.room-pill-badge {
  background: #fef3c7;
  color: #92400e;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1.5px solid #fcd34d;
}

.room-context-title {
  font-size: 1.08rem;
  color: #78350f;
}

.room-context-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-link {
  background: none;
  border: none;
  color: #d97706;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
}

.btn-link:hover {
  text-decoration: underline;
}

/* Rooms Lobby & Room Cards */
.lobby-hub-container, .tourney-studio-container, .tourney-detail-box {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.create-room-bar, .create-tourney-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rooms-grid-inner {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.room-card {
  background: #ffffff;
  border: 3px solid var(--border-warm);
  border-radius: 22px;
  padding: 16px;
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.room-card:hover {
  transform: translateY(-2px);
  border-color: #fbbf24;
}

.room-card-mine {
  border-color: #10b981;
  background: linear-gradient(180deg, #ecfdf5 0%, #ffffff 35%);
}

.room-card-tourney {
  border-color: #a5b4fc;
}

.room-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.room-card-title-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.room-card-name {
  font-size: 1.08rem;
  color: #78350f;
}

.casual-tag, .tourney-tag {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  width: fit-content;
}

.casual-tag {
  background: #fef3c7;
  color: #92400e;
}

.tourney-tag {
  background: #e0e7ff;
  color: #4338ca;
}

.room-card-body {
  display: grid;
  grid-template-columns: 145px 1fr;
  gap: 14px;
  align-items: center;
}

.room-card-matchup {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.matchup-player {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
}

.matchup-vs {
  font-size: 0.72rem;
  font-weight: 800;
  color: #b45309;
  opacity: 0.65;
  padding-left: 12px;
}

.mini-turn-dot {
  color: #10b981;
  font-size: 0.9rem;
}

.room-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #92400e;
  margin-top: 4px;
}

.check-mini-alert {
  color: #e11d48;
  font-weight: 800;
}

.room-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 2px dashed #fef3c7;
}

/* Live 8x8 Mini-Chessboard (for Rooms & Parallel Tournament Games!) */
.mini-board-frame {
  cursor: pointer;
  background: #d97706;
  padding: 5px;
  border-radius: 12px;
  border: 2px solid #92400e;
  width: 145px;
  height: 145px;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(120, 53, 15, 0.14);
}

.mini-board-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 100%;
  height: 100%;
  border-radius: 7px;
  overflow: hidden;
  border: 1.5px solid #78350f;
}

.mini-sq {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mini-board-piece-svg {
  width: 90%;
  height: 90%;
}

/* Parallel Tournament Studio & Multiplex Multi-Board Grid */
.tourney-create-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  align-items: center;
}

.tourney-tabs-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tourney-hero-card {
  background: linear-gradient(135deg, #eef2ff 0%, #fffbeb 100%);
  border-color: #a5b4fc;
}

.tourney-hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.tourney-hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.champion-trophy-pill {
  background: #fbbf24;
  color: #78350f;
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  padding: 8px 16px;
  border-radius: 999px;
  border: 2px solid #d97706;
}

.tourney-reg-box {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 2px dashed #c7d2fe;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-hdr-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.parallel-boards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(275px, 1fr));
  gap: 16px;
}

.parallel-match-card {
  background: #ffffff;
  border: 3px solid #fde68a;
  border-radius: 22px;
  padding: 16px;
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.parallel-match-card.match-live {
  border-color: #34d399;
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.12);
}

.parallel-match-card.match-mine {
  border-color: #f59e0b;
  background: linear-gradient(180deg, #fffbeb 0%, #ffffff 35%);
}

.parallel-match-card.match-done {
  opacity: 0.92;
  border-color: #cbd5e1;
}

.pm-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.pm-round-tag {
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 0.92rem;
  color: #4338ca;
  background: #e0e7ff;
  padding: 3px 10px;
  border-radius: 999px;
}

.pm-players-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fffbeb;
  border: 2px solid #fde68a;
  border-radius: 12px;
  padding: 7px 12px;
  font-size: 0.88rem;
}

.pm-player {
  display: flex;
  align-items: center;
  gap: 5px;
}

.pm-player.pm-turn {
  color: #059669;
  text-decoration: underline;
}

.pm-vs {
  font-size: 0.75rem;
  font-weight: 800;
  color: #92400e;
}

.pm-board-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.pm-board-wrap .mini-board-frame {
  width: 190px;
  height: 190px;
}

.pm-board-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #78350f;
}

.pm-last-move {
  font-family: 'JetBrains Mono', monospace;
  background: #fef3c7;
  padding: 2px 7px;
  border-radius: 6px;
}

.pm-pending-box {
  width: 190px;
  height: 190px;
  border: 2.5px dashed #cbd5e1;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  font-size: 0.84rem;
  font-weight: 700;
  color: #64748b;
  background: #f8fafc;
}

.pm-footer {
  width: 100%;
}

.btn-full {
  width: 100%;
}

/* Round-Robin Standings Table */
.standings-table {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.st-row {
  display: grid;
  grid-template-columns: 40px 2fr 1fr 1fr 1fr;
  align-items: center;
  padding: 8px 14px;
  border-radius: 12px;
  background: #fffbeb;
  font-size: 0.9rem;
}

.st-head {
  background: #fef3c7;
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  color: #78350f;
}

.st-pts {
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  color: #059669;
}

/* ============================================================================
   Official FIDE / Fischer Chess Clocks & Time Control Bar Styles
   ============================================================================ */

.tc-bar-card {
  background: #ffffff;
  border: 2.5px solid #fde68a;
  border-radius: 18px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-soft);
}

.tc-bar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.tc-current-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tc-icon {
  font-size: 1.4rem;
}

.tc-title-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.96rem;
  color: #78350f;
}

.tc-cat-pill {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 2px 9px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.tc-cat-classical {
  background: #e0e7ff;
  color: #3730a3;
}

.tc-cat-rapid {
  background: #d1fae5;
  color: #065f46;
}

.tc-cat-blitz {
  background: #fef3c7;
  color: #b45309;
}

.tc-cat-bullet {
  background: #ffe4e6;
  color: #be123c;
}

.tc-cat-casual {
  background: #f1f5f9;
  color: #475569;
}

.tc-inc-note {
  font-size: 0.8rem;
  font-weight: 700;
  color: #059669;
}

.tc-pills-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.tc-preset-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tc-pill-btn {
  cursor: pointer;
  background: #fffbeb;
  color: #78350f;
  border: 2px solid #fde68a;
  border-radius: 10px;
  padding: 4px 9px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  font-weight: 700;
  transition: all 0.12s ease;
}

.tc-pill-btn:hover {
  background: #fef3c7;
  border-color: #fbbf24;
  transform: translateY(-1px);
}

.tc-pill-btn.active {
  background: #f59e0b;
  color: #ffffff;
  border-color: #d97706;
  box-shadow: 0 2px 0 #b45309;
}

.tc-custom-toggle {
  font-family: 'Fredoka', sans-serif;
  background: #f3e8ff;
  color: #6b21a8;
  border-color: #d8b4fe;
}

.tc-custom-drawer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 10px;
  border-top: 2px dashed #fde68a;
  background: #fffbeb;
  padding: 10px 14px;
  border-radius: 14px;
}

.tc-custom-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tc-custom-label {
  font-size: 0.82rem;
  font-weight: 800;
  color: #78350f;
}

.tc-choice-row {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.tc-choice-btn {
  cursor: pointer;
  background: #ffffff;
  color: #78350f;
  border: 1.5px solid #fcd34d;
  border-radius: 8px;
  padding: 4px 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.76rem;
  font-weight: 700;
}

.tc-choice-btn.active {
  background: #10b981;
  color: #ffffff;
  border-color: #059669;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.84rem;
}

/* Digital Chess Clock on Player Bar */
.player-status-area {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.chess-clock-box {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #2a223d;
  color: #fef3c7;
  border: 2.5px solid #4c3d6e;
  border-radius: 14px;
  padding: 6px 14px;
  font-family: 'JetBrains Mono', monospace;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.25);
  transition: all 0.15s ease;
}

.chess-clock-box.clock-running {
  background: #065f46;
  color: #ecfdf5;
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.22);
}

.chess-clock-box.clock-low-time {
  background: #9f1239;
  color: #ffe4e6;
  border-color: #f43f5e;
  animation: pulseLowClock 0.8s infinite alternate;
}

.chess-clock-box.clock-flagged {
  background: #e11d48;
  color: #ffffff;
  border-color: #881337;
}

.chess-clock-box.clock-unlimited {
  background: #fef3c7;
  color: #92400e;
  border-color: #fde68a;
  box-shadow: none;
}

.clock-icon {
  font-size: 0.95rem;
}

.clock-digits {
  font-size: 1.24rem;
  font-weight: 800;
  letter-spacing: 0.8px;
}

.clock-inc-tag {
  font-size: 0.74rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.18);
  padding: 2px 6px;
  border-radius: 6px;
}

.tc-mini-badge {
  background: #fef3c7;
  color: #b45309;
  border: 1.5px solid #fcd34d;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 800;
  width: fit-content;
}

.mini-clock-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  font-weight: 700;
  background: #2a223d;
  color: #fef3c7;
  padding: 2px 7px;
  border-radius: 6px;
  margin-left: auto;
}

@keyframes pulseLowClock {
  from { transform: scale(1); }
  to { transform: scale(1.04); }
}
