@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  --bg-primary: #0f1015;      /* Deep dark space */
  --bg-secondary: #161824;    /* Slate dark panel */
  --bg-glass: rgba(22, 24, 36, 0.85);
  --border-glass: rgba(255, 255, 255, 0.08);
  --text-primary: #f1f1f5;
  --text-secondary: #a0a5b5;
  --accent-gold: #4fc3f7;     /* High-tech cyan gold alternative */
  
  --square-light: #DED2BC;                         /* Calm ivory/parchment Light */
  --square-dark: #4A6685;                          /* Muted slate blue Dark */
  --square-border: rgba(0, 0, 0, 0.04);
  
  /* Glass Highlights */
  --highlight-select: rgba(6, 182, 212, 0.45);    /* Glass vibrant cyan select */
  --highlight-move: rgba(6, 182, 212, 0.35);      /* Glass valid move dot */
  --highlight-capture: rgba(6, 182, 212, 0.35);   /* Glass capture ring */
  --highlight-check: rgba(239, 68, 68, 0.55);     /* Translucent red check */
  --highlight-last-move: rgba(255, 255, 255, 0.22); /* Frosted last move indicator */
  
  /* Traditional Piece Colors */
  --color-white-fill: #F4EFE4;                     /* Clean Ivory White */
  --color-white-stroke: #222222;                   /* Clean Dark Outline */
  --color-black-fill: #1E1E1E;                     /* Deep Charcoal/Near-Black */
  --color-black-stroke: #111111;                   /* Dark Outline */
  
  /* Multiplayer Color Palettes */
  --color-p1: #ff6b6b; /* Red 1 (Lighter) */
  --color-p2: #c92a2a; /* Red 2 (Darker) */
  --color-p3: #8ce99a; /* Green 1 (Lighter) */
  --color-p4: #2b8a3e; /* Green 2 (Darker) */
  --color-p5: #f59f00; /* Yellow 2 (Darker) */
  --color-p6: #ffec99; /* Yellow 1 (Lighter) */
  --color-p7: #74c0fc; /* Blue 2 (Lighter) */
  --color-p8: #1971c2; /* Blue 1 (Darker) */
  --color-dead: #8e8e93;
}

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

html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  font-family: 'Outfit', sans-serif;
  background: radial-gradient(circle at center, #141622 0%, #07080b 100%);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

header {
  width: 100%;
  max-width: 1400px;
  padding: 15px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-glass);
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 8px;
}

.logo h1 {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.75px;
  background: linear-gradient(135deg, #ffffff 0%, var(--accent-gold) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}


.controls-header {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* Styled Dropdown */
.select-wrapper {
  position: relative;
}
.select-wrapper select {
  appearance: none;
  background: #312e2b;
  border: 1px solid var(--border-glass);
  padding: 8px 36px 8px 14px;
  border-radius: 6px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  outline: none;
}
.select-wrapper select:hover {
  background: #3c3835;
}
.select-wrapper::after {
  content: '▼';
  font-size: 0.6rem;
  color: var(--text-secondary);
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

/* Button styling */
.btn {
  background: #312e2b;
  color: var(--text-primary);
  border: 1px solid var(--border-glass);
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s ease;
}
.btn:hover {
  background: #3c3835;
}
.btn-primary {
  background: #81b64c; /* Chess.com green button */
  border-color: rgba(0,0,0,0.1);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover {
  background: #95c25d;
}

.main-container {
  width: 100%;
  max-width: 900px;
  padding: 20px 16px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  box-sizing: border-box;
}

@media (max-width: 1100px) {
  .main-container {
    padding: 10px;
  }
}

/* Left Section: Board Panel */
.board-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  width: min(96vw, 100%);
  max-width: 628px;
  margin: 0 auto;
  box-sizing: border-box;
}

.board-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.sidebar-panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

/* Custom 4-Player Side Tags layout (INSIDE 3x3 empty corner cutouts) */
.custom-player-tag {
  display: none;
  position: absolute !important;
  width: 21.428% !important; /* 3/14 of board size */
  height: 21.428% !important; /* 3/14 of board size */
  flex-direction: column !important;
  justify-content: center !important;
  align-items: center !important;
  gap: 4px !important;
  background: rgba(20, 22, 34, 0.8) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  border-radius: 8px !important;
  z-index: 20 !important; /* Above board squares */
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.35);
  font-family: inherit;
  box-sizing: border-box !important;
  padding: 6px !important;
  pointer-events: none !important; /* Allow interactions with underlying elements */
}

.custom-player-tag.active {
  background: rgba(20, 22, 34, 0.95) !important;
  border-color: rgba(255, 255, 255, 0.25) !important;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15), 0 0 12px rgba(255, 255, 255, 0.12) !important;
}

.custom-player-tag .tag-meta {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  text-align: center !important;
  width: 100% !important;
}

.custom-player-tag .tag-name {
  font-size: 0.8rem !important;
  font-weight: 700 !important;
  color: #ffffff !important;
  white-space: nowrap !important;
  text-overflow: ellipsis !important;
  overflow: hidden !important;
  width: 100% !important;
}

.custom-player-tag .tag-elo {
  font-size: 0.7rem !important;
  color: var(--text-secondary) !important;
}

.custom-player-tag .tag-clock {
  margin-top: 2px !important;
  padding: 3px 8px !important;
  border-radius: 4px !important;
  font-family: monospace !important;
  font-size: 0.85rem !important;
  font-weight: 800 !important;
  min-width: 44px !important;
  text-align: center !important;
}

/* Color codes for individual side clocks */
#player-tag-1 .tag-clock {
  background: #f0c800 !important; /* Yellow */
  color: #141622 !important;
}

#player-tag-2 .tag-clock {
  background: #3eb85c !important; /* Green */
  color: #ffffff !important;
}

#player-tag-3 .tag-clock {
  background: #f04b4b !important; /* Red */
  color: #ffffff !important;
}

#player-tag-4 .tag-clock {
  background: #2d89ef !important; /* Blue */
  color: #ffffff !important;
}

/* Corner positions */
.custom-player-tag.top-left {
  top: 0 !important;
  left: 0 !important;
}

.custom-player-tag.top-right {
  top: 0 !important;
  right: 0 !important;
}

.custom-player-tag.bottom-left {
  bottom: 0 !important;
  left: 0 !important;
}

.custom-player-tag.bottom-right {
  bottom: 0 !important;
  right: 0 !important;
}

.phase-banner {
  width: 100%;
  padding: 10px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  text-align: center;
  font-weight: 500;
  font-size: 0.95rem;
  background: rgba(129, 182, 76, 0.1);
  border: 1px solid rgba(129, 182, 76, 0.2);
  color: #95c25d;
}

.board-outer-container {
  position: relative;
  width: min(96vw, 100%);
  aspect-ratio: 1 / 1;
  max-width: 580px;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Refined flat board frame */
.chess-board {
  display: grid;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  border: 6px solid #2b3040; /* Sharp, clean dark slate border frame */
  background: #141622;
}

.board-8x8 {
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
}

.board-14x14 {
  grid-template-columns: repeat(14, 1fr);
  grid-template-rows: repeat(14, 1fr);
}

/* Squares */
.square {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background-color 0.1s ease;
  user-select: none;
}

.square:not(.out-of-bounds) {
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.05); /* Extremely subtle bevel grid lines */
}

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

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

.square.out-of-bounds {
  background-color: transparent !important;
  border: none !important;
  pointer-events: none;
  box-shadow: none !important;
}

/* Selection Highlight */
.square.selected {
  background-color: var(--highlight-select) !important;
}

/* Valid moves dot (Chess.com style) */
.square.valid-move::before {
  content: '';
  width: 26%;
  height: 26%;
  background-color: var(--highlight-move);
  border-radius: 50%;
  position: absolute;
  pointer-events: none;
  z-index: 10;
}

/* Valid capture ring (Chess.com style) */
.square.valid-capture::before {
  content: '';
  width: 80%;
  height: 80%;
  border: 6px solid var(--highlight-capture);
  border-radius: 50%;
  position: absolute;
  pointer-events: none;
  z-index: 10;
}

.square.checked-king {
  background: var(--highlight-check) !important;
}

.square.last-move {
  background-color: var(--highlight-last-move);
}

.square.placement-zone::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: color-mix(in srgb, var(--zone-color, #ffffff) 10%, transparent); /* Player-colored transparent sheen */
  box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--zone-color, #ffffff) 22%, transparent); /* Player-colored inset border shadow */
  pointer-events: none;
  z-index: 5;
}

/* Premove Styling */
.square.premove-target {
  background-color: rgba(244, 63, 94, 0.35) !important;
}

.square.premove-selected {
  background-color: rgba(244, 63, 94, 0.45) !important;
}

.square.premove-valid {
  position: relative;
}
.square.premove-valid::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(244, 63, 94, 0.4);
  pointer-events: none;
  z-index: 10;
}

.square.premove-valid-capture {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}
.square.premove-valid-capture::after {
  content: "";
  width: 80%;
  height: 80%;
  border: 5px solid rgba(244, 63, 94, 0.4);
  border-radius: 50%;
  position: absolute;
  pointer-events: none;
  z-index: 10;
}

/* Chess pieces */
.piece {
  width: 90%;
  height: 90%;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  z-index: 15;
  user-select: none;
  transition: transform 0.12s ease;
}

.piece:hover {
  transform: scale(1.03);
}

.piece:active {
  transform: scale(1.08);
}

/* 3D floating effect when piece is selected */
.square.selected .piece {
  transform: scale(1.12);
  z-index: 50;
}
.square.selected .piece svg {
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.45)) !important;
}

.piece svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.38));
  transition: filter 0.12s ease;
}

/* Piece SVG fills and strokes */
/* 2-Player Traditional Chess Colors */
.piece-white svg {
  --piece-fill: var(--color-white-fill);
  --piece-stroke: var(--color-white-stroke);
  --piece-detail: var(--color-white-stroke);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35)) drop-shadow(0 0 0.5px rgba(255, 255, 255, 0.1));
}
.piece-black svg {
  --piece-fill: var(--color-black-fill);
  --piece-stroke: var(--color-black-stroke);
  --piece-detail: #ffffff;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5)) drop-shadow(0 0 1px rgba(255, 255, 255, 0.22));
}

/* Multiplayer Colors */
.piece-p1 svg { --piece-fill: var(--color-p1); --piece-stroke: #5c0e0e; --piece-detail: #ffffff; }
.piece-p2 svg { --piece-fill: var(--color-p2); --piece-stroke: #3a0505; --piece-detail: #ffffff; }
.piece-p3 svg { --piece-fill: var(--color-p3); --piece-stroke: #0c3614; --piece-detail: #ffffff; }
.piece-p4 svg { --piece-fill: var(--color-p4); --piece-stroke: #06210b; --piece-detail: #ffffff; }
.piece-p5 svg { --piece-fill: var(--color-p5); --piece-stroke: #523600; --piece-detail: #ffffff; }
.piece-p6 svg { --piece-fill: var(--color-p6); --piece-stroke: #635003; --piece-detail: #ffffff; }
.piece-p7 svg { --piece-fill: var(--color-p7); --piece-stroke: #08325c; --piece-detail: #ffffff; }
.piece-p8 svg { --piece-fill: var(--color-p8); --piece-stroke: #031e3b; --piece-detail: #ffffff; }
.piece-dead svg {
  --piece-fill: var(--color-dead);
  --piece-stroke: #2c2c2e;
  --piece-detail: #5a5a5c;
  opacity: 0.55;
  filter: grayscale(100%);
  cursor: not-allowed;
}

/* Sidebar and Panel layout */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

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

.turn-header {
  font-size: 0.85rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  font-weight: 600;
  letter-spacing: 0.5px;
}

.active-player-display {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.25rem;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}

.player-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: var(--active-player-color, #fff);
  box-shadow: 0 0 8px var(--active-player-color, #fff);
}

/* Player configuration section */
.settings-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.player-config-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-config-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: #312e2b;
  border-radius: 6px;
  font-size: 0.9rem;
}

.player-config-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.player-config-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--p-color);
}

.player-config-row select {
  background: #262421;
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 0.85rem;
  cursor: pointer;
  outline: none;
}

/* Piece Tray */
.piece-tray {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  padding: 0;
  background: transparent;
  min-height: auto;
  align-items: center;
}

.tray-item {
  width: 40px;
  height: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-glass);
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  transition: background 0.15s ease, transform 0.1s ease;
}

.tray-item:hover {
  background: rgba(255, 255, 255, 0.05);
  transform: translateY(-1px);
}

.tray-item.selected {
  background: rgba(129, 182, 76, 0.15);
  border-color: #81b64c;
  box-shadow: 0 0 8px rgba(129, 182, 76, 0.3);
}

.tray-item-count {
  position: absolute;
  bottom: -3px;
  right: -3px;
  background: #262421;
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-primary);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 8px;
}

/* Logs */
/* Tabbed Log / Chat Widget */
.tabs-container {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  min-height: 600px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.tab-headers {
  display: flex;
  background: #1f1d1b;
  border-bottom: 1px solid var(--border-glass);
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 12px;
  color: var(--text-secondary);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.15s ease;
  outline: none;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.02);
}

.tab-btn.active {
  color: var(--accent-gold);
  border-bottom: 2px solid var(--accent-gold);
  background: var(--bg-secondary);
}

.tab-content {
  display: none;
  flex-direction: column;
  flex-grow: 1;
  padding: 15px;
  overflow: hidden;
  height: 520px;
}

.tab-content.active {
  display: flex;
}

.log-entries {
  overflow-y: auto;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  padding-right: 5px;
}

.log-entry {
  padding: 6px 10px;
  border-radius: 4px;
  background: rgba(255,255,255,0.01);
  border-left: 3px solid transparent;
}
.log-entry.system { border-color: var(--accent-gold); color: var(--text-primary); }
.log-entry.p1 { border-color: var(--color-p1); }
.log-entry.p2 { border-color: var(--color-p2); }



/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  padding: 24px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.5);
  transform: scale(0.95);
  transition: transform 0.2s ease;
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

.modal-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--accent-gold);
}

.modal-text {
  color: var(--text-secondary);
  margin-bottom: 20px;
  font-size: 0.95rem;
}

.promotion-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.promo-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1/1;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  padding: 8px;
}

.promo-option:hover {
  background: rgba(255,255,255,0.06);
  transform: translateY(-1px);
}

.promo-option svg {
  width: 100%;
  height: 100%;
}

.promo-label {
  font-size: 0.7rem;
  font-weight: 600;
  margin-top: 4px;
  color: var(--text-secondary);
}

/* Chess Levels Campaign Styles */
.levels-panel {
  display: flex;
  flex-direction: column;
}

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

.levels-list::-webkit-scrollbar {
  width: 4px;
}
.levels-list::-webkit-scrollbar-thumb {
  background: var(--border-glass);
  border-radius: 2px;
}

.level-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.level-item:hover:not(.locked) {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateX(2px);
}

.level-item.active {
  background: rgba(79, 195, 247, 0.1);
  border-color: var(--accent-gold);
  box-shadow: 0 0 10px rgba(79, 195, 247, 0.05);
}

.level-item.locked {
  opacity: 0.4;
  cursor: not-allowed;
  background: rgba(0, 0, 0, 0.2);
  border-color: rgba(255, 255, 255, 0.02);
}

.level-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.level-title {
  font-weight: 600;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.level-req {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.level-stat {
  font-size: 0.72rem;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Home Screen Styles */
#home-screen {
  width: 100%;
  max-width: 100vw;
  margin: 0 auto;
  padding: 60px 16px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform: scale(1);
  opacity: 1;
  box-sizing: border-box;
}

#game-screen {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform: scale(0.97);
  opacity: 0;
}

.home-hero {
  text-align: center;
  margin-bottom: 50px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 0 16px;
}

.home-logo {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  width: 100%;
  max-width: 100%;
}

.home-logo h1 {
  font-size: 3.2rem;
  font-weight: 800;
  letter-spacing: -1.5px;
  background: linear-gradient(135deg, #ffffff 0%, var(--accent-gold) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-align: center;
  margin: 0;
  word-wrap: break-word;
  max-width: 100%;
}

.home-logo span {
  font-size: 0.9rem;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
  padding: 3px 8px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.home-tagline {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 650px;
  margin: 0 auto;
  line-height: 1.6;
  text-align: center;
}

.home-section-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 30px;
  text-align: center;
  letter-spacing: 2.5px;
  color: var(--text-primary);
  text-transform: uppercase;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 12px;
  max-width: 300px;
  margin-left: auto;
  margin-right: auto;
}

.home-campaign-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 20px;
  max-width: 760px;
  margin: 0 auto 60px auto;
  width: 100%;
  padding: 0 16px;
  box-sizing: border-box;
}

.campaign-card {
  aspect-ratio: 1 / 1;
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow: hidden;
}

.campaign-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(79, 195, 247, 0.08) 0%, rgba(0, 0, 0, 0) 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.campaign-card:hover:not(.locked) {
  transform: translateY(-4px) scale(1.03);
  border-color: var(--accent-gold);
  box-shadow: 0 10px 20px rgba(79, 195, 247, 0.12);
}

.campaign-card:hover:not(.locked) .campaign-num {
  color: var(--accent-gold);
  text-shadow: 0 0 10px rgba(79, 195, 247, 0.4);
}

.campaign-card:hover:not(.locked)::before {
  opacity: 1;
}

.campaign-card.locked {
  opacity: 0.35;
  cursor: not-allowed;
  background: rgba(0, 0, 0, 0.2);
  border-color: rgba(255, 255, 255, 0.02);
}

.campaign-num {
  font-size: 3.2rem;
  font-weight: 800;
  color: var(--text-primary);
  transition: all 0.3s ease;
}

.campaign-card.play-now .campaign-num {
  font-size: 1.15rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 800;
  text-align: center;
  line-height: 1.2;
  color: #74c0fc;
}

.campaign-card.play-now:hover .campaign-num {
  color: #e3fafc;
  transform: scale(1.05);
}

.campaign-lock-icon {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 0.85rem;
  opacity: 0.7;
}

.campaign-card.settings {
  background: rgba(79, 195, 247, 0.05) !important;
  border: 1px solid rgba(79, 195, 247, 0.25) !important;
  box-shadow: inset 0 0 10px rgba(79, 195, 247, 0.05);
}

.campaign-card.settings .campaign-num {
  color: var(--accent-gold) !important;
  font-size: 3.5rem;
  font-weight: 800;
  text-align: center;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.campaign-card.settings:hover .campaign-num {
  transform: rotate(45deg);
}

.campaign-card.profile {
  background: rgba(255, 215, 0, 0.05) !important;
  border: 1px solid rgba(255, 215, 0, 0.25) !important;
  box-shadow: inset 0 0 10px rgba(255, 215, 0, 0.05);
  flex-direction: column;
  gap: 4px;
}

.campaign-card.profile .campaign-num {
  font-size: 2.8rem;
  margin-top: 10px;
  line-height: 1;
}

.campaign-card-sub {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-gold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.campaign-card.profile:hover {
  box-shadow: 0 10px 20px rgba(255, 215, 0, 0.15);
  border-color: var(--accent-cyan) !important;
}

.campaign-card.profile:hover .campaign-card-sub {
  color: var(--accent-cyan);
}

.home-footer {
  text-align: center;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.2);
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  padding-top: 30px;
}

/* Presenting Auto Button Tile */
.btn-auto-presenting-tile {
  width: 40px;
  height: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, var(--accent-gold) 0%, #d49000 100%) !important;
  color: #0d1117 !important;
  border: none !important;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 10px rgba(212, 144, 0, 0.2);
}

.btn-auto-presenting-tile:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 6px 15px rgba(212, 144, 0, 0.4);
  background: linear-gradient(135deg, #ffcf66 0%, var(--accent-gold) 100%) !important;
}

.btn-auto-presenting-tile:active {
  transform: translateY(0);
}

/* Player Info Tags */
.player-info-tag {
  width: min(96vw, 100%);
  max-width: 580px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px;
  box-sizing: border-box;
  font-family: inherit;
}

.player-info-tag.opponent {
  justify-content: flex-start;
  margin-bottom: 2px;
}

.player-info-tag.user {
  justify-content: flex-start;
  margin-top: 2px;
}

.piece-tray-container-inline {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 12px auto 0 auto;
  width: 100%;
}

.player-clock {
  background: #262421;
  color: #c5c5c5;
  font-family: 'Outfit', 'Inter', monospace;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  min-width: 64px;
  text-align: center;
  margin-left: auto;
  letter-spacing: 0.5px;
  transition: all 0.3s ease;
}

.player-clock.active {
  background: var(--accent-gold);
  color: #0d1117;
  border-color: var(--accent-gold);
  box-shadow: 0 0 12px rgba(212, 144, 0, 0.4);
}



/* Speech bubbles next to username tags */
.speech-bubble-tag {
  font-family: 'Outfit', 'Inter', -apple-system, sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  background: #fdfdfd;
  color: #1a1a1a;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  margin-left: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
  opacity: 0;
  letter-spacing: 0.1px;
  transform: scale(0.95) translateX(-8px);
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: inline-block;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.speech-bubble-tag.active {
  opacity: 1;
  transform: scale(1) translateX(0);
}

/* Home Page AI Difficulty Selector Styling */
#home-difficulty-select {
  width: 100%;
  background: #1e1b18;
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  box-sizing: border-box;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#home-difficulty-select:focus {
  border-color: var(--accent-gold);
  box-shadow: 0 0 8px rgba(212, 144, 0, 0.25);
}

#home-difficulty-select option {
  background: #1e1b18;
  color: var(--text-primary);
  padding: 8px;
}

/* Mobile Play Screen & Viewport Adjustments */
@media (max-width: 600px) {
  header {
    padding: 10px 12px;
  }
  
  .logo h1 {
    font-size: 1.35rem;
  }
  


  #game-screen {
    width: 100%;
    max-width: 100vw;
  }

  .main-container {
    padding: 10px 6px;
    gap: 12px;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
  }

  .board-panel {
    padding: 8px;
    border-radius: 8px;
    width: min(96vw, 100%) !important;
    max-width: 100vw !important;
    margin: 0 auto !important;
    box-sizing: border-box;
  }

  .board-outer-container {
    width: 100% !important;
    max-width: 100% !important;
    aspect-ratio: 1 / 1;
    margin: 0 auto !important;
    box-sizing: border-box;
  }

  .chess-board {
    width: 100%;
    height: 100%;
    border-width: 4px; /* Thinner border frame to maximize square cell size on small screens */
    box-sizing: border-box;
  }

  .player-info-tag {
    flex-wrap: wrap;
    gap: 6px;
    font-size: 0.85rem;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 auto !important;
    box-sizing: border-box;
  }

  .piece-tray-container-inline {
    margin-left: 0;
    width: 100%;
    justify-content: center;
    order: 3; /* Push piece tray underneath player name/clock info if wrapped */
  }

  .piece-tray {
    width: 100%;
    justify-content: center;
    gap: 4px;
  }

  .tray-item {
    width: 34px;
    height: 34px;
    border-radius: 4px;
  }
  
  .tray-item svg {
    transform: scale(0.85); /* Slightly scale down piece svgs inside tray on phone */
  }


  
  .speech-bubble-tag {
    max-width: 180px; /* Constrain speech bubble width on narrow screens */
    margin-left: 6px;
    font-size: 0.78rem;
    padding: 3px 8px;
  }
}

/* --- PROFILE CAPSULE & AUTHENTICATION STYLING --- */

.home-header-row {
  width: 100%;
  max-width: 1200px;
  display: flex;
  justify-content: flex-end;
  padding: 20px 20px 0 20px;
  box-sizing: border-box;
}

.profile-capsule {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 8px 18px;
  border-radius: 30px;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--text-primary);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: all 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.profile-capsule:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--accent-cyan);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(79, 195, 247, 0.15);
}

.profile-capsule .avatar-icon {
  font-size: 1rem;
}

/* Modal Content override for Auth & Profile */
.auth-content, .profile-content {
  max-width: 420px;
  background: rgba(20, 22, 34, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  padding: 35px 30px;
  border-radius: 20px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
  position: relative;
  overflow: hidden;
}

.modal-close {
  position: absolute;
  top: 15px;
  right: 15px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  
  /* Reset browser-specific button defaults */
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  box-shadow: none;
  padding: 0;
  margin: 0;
  
  /* Subtle dark background matching modal styling */
  background: rgba(30, 32, 48, 0.95) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  color: rgba(255, 255, 255, 0.7) !important;
  
  font-size: 1.3rem;
  font-family: inherit;
  cursor: pointer;
  z-index: 10;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  line-height: 1;
}

.modal-close:hover {
  background: rgba(40, 44, 66, 0.95) !important;
  border-color: var(--accent-cyan) !important;
  color: var(--text-primary) !important;
  transform: scale(1.05);
}

.auth-content::before {
  content: '';
  position: absolute;
  top: -150px;
  right: -150px;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(79, 195, 247, 0.08) 0%, transparent 70%);
  z-index: 0;
  pointer-events: none;
}

/* Auth Tabs */
.auth-tabs {
  display: flex;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 25px;
  position: relative;
  z-index: 1;
}

.auth-tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  text-align: center;
}

.auth-tab:hover {
  color: var(--text-primary);
}

.auth-tab.active {
  color: var(--text-primary);
}

.auth-tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-gold));
  border-radius: 2px;
}

/* OAuth social sign in buttons */
.oauth-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
  position: relative;
  z-index: 1;
}

.oauth-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.btn-oauth img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.btn-oauth {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-sizing: border-box;
}

.btn-google {
  background: #ffffff;
  color: #1f2024;
  border: 1px solid #e0e0e0;
}

.btn-google:hover {
  background: #f7f7f7;
  transform: translateY(-1.5px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.btn-apple {
  background: #000000;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.btn-apple:hover {
  background: #111111;
  transform: translateY(-1.5px);
  box-shadow: 0 4px 15px rgba(255, 255, 255, 0.05);
}

.auth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: rgba(255, 255, 255, 0.25);
  font-size: 0.85rem;
  font-weight: 500;
  margin: 20px 0;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.auth-divider:not(:empty)::before {
  margin-right: 15px;
}

.auth-divider:not(:empty)::after {
  margin-left: 15px;
}

/* Forms & Inputs */
.auth-form {
  position: relative;
  z-index: 1;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
  text-align: left;
}

.input-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input-group input {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 12px 16px;
  border-radius: 10px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.input-group input:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(79, 195, 247, 0.15);
}

.password-wrapper {
  position: relative;
  width: 100%;
}

.password-wrapper input {
  width: 100%;
  padding-right: 45px;
}

.btn-toggle-password {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

.btn-toggle-password:hover {
  opacity: 1;
}

.btn-block {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  font-weight: 700;
  border-radius: 10px;
  margin-top: 10px;
}

.auth-alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 20px;
  text-align: left;
  line-height: 1.4;
}

.auth-alert.error {
  background: rgba(255, 71, 87, 0.1);
  border: 1px solid rgba(255, 71, 87, 0.2);
  color: #ff4757;
}

.auth-alert.success {
  background: rgba(46, 213, 115, 0.1);
  border: 1px solid rgba(46, 213, 115, 0.2);
  color: #2ed573;
}

/* Profile Dashboard Styling */
.profile-header-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 25px;
}

.profile-avatar {
  width: 80px;
  height: 80px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  margin-bottom: 15px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.profile-name {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 4px;
  letter-spacing: -0.5px;
}

.profile-email {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.rating-badge {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  background: linear-gradient(135deg, rgba(79, 195, 247, 0.08) 0%, rgba(255, 215, 0, 0.08) 100%);
  border: 1px solid rgba(79, 195, 247, 0.2);
  border-radius: 12px;
  padding: 10px 25px;
  box-shadow: 0 4px 20px rgba(79, 195, 247, 0.08);
}

.rating-value {
  font-size: 1.8rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.1;
  letter-spacing: -0.5px;
}

.rating-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 1.5px;
  margin-top: 4px;
}

.profile-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  margin-bottom: 25px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-num {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.stat-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.action-row {
  display: flex;
  gap: 10px;
}

.action-row input {
  flex: 1;
}

.action-row button {
  padding: 0 20px;
  white-space: nowrap;
}

/* Mobile responsive fixes */
@media (max-width: 600px) {
  .home-header-row {
    padding: 15px 15px 0 15px;
  }
  
  .profile-capsule {
    padding: 6px 14px;
    font-size: 0.8rem;
  }
  
  .auth-content, .profile-content {
    padding: 25px 20px;
    margin: 10px;
    border-radius: 16px;
  }

  #home-screen {
    padding: 30px 12px;
  }

  .home-hero {
    margin-bottom: 30px;
    padding: 0 8px;
  }

  .home-logo h1 {
    font-size: 2.2rem;
    letter-spacing: -0.8px;
  }

  .home-tagline {
    font-size: 0.95rem;
    line-height: 1.5;
  }

  .home-campaign-grid {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    padding: 0 8px;
    margin-bottom: 40px;
  }
}

@media (max-width: 400px) {
  .home-campaign-grid {
    grid-template-columns: repeat(2, 1fr); /* Clean 2-column mobile layout */
    gap: 10px;
    padding: 0 4px;
  }
}

@media (max-width: 320px) {
  .home-campaign-grid {
    grid-template-columns: 1fr; /* 1 column layout for extremely narrow viewports */
    gap: 10px;
    padding: 0;
  }
  .home-logo h1 {
    font-size: 1.8rem;
  }
}

/* Verification Code Input Layout */
.verification-code-input {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: 12px;
  text-align: center;
  padding: 10px !important;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--accent-cyan);
  width: 160px;
  margin: 15px auto;
  display: block;
}

.verification-code-input:focus {
  border-color: var(--accent-cyan) !important;
  box-shadow: 0 0 0 3px rgba(79, 195, 247, 0.2) !important;
}

/* Chess Coach Suggestion Highlights */
.board-square.coach-highlight-from {
  box-shadow: inset 0 0 0 4px rgba(79, 195, 247, 0.75) !important;
  outline: 2px dashed rgba(79, 195, 247, 0.5);
  outline-offset: -6px;
}

.board-square.coach-highlight-to {
  box-shadow: inset 0 0 0 4px rgba(46, 204, 113, 0.75) !important;
  animation: pulse-glow-coach 1.5s infinite;
}

@keyframes pulse-glow-coach {
  0% { box-shadow: inset 0 0 0 4px rgba(46, 204, 113, 0.45); }
  50% { box-shadow: inset 0 0 0 6px rgba(46, 204, 113, 0.85); }
  100% { box-shadow: inset 0 0 0 4px rgba(46, 204, 113, 0.45); }
}

/* Mobile responsive adjustments for corner tags (under 600px) */
@media (max-width: 600px) {
  .custom-player-tag {
    padding: 3px !important;
    gap: 2px !important;
    border-radius: 4px !important;
  }
  .custom-player-tag .tag-name {
    font-size: 0.65rem !important;
  }
  .custom-player-tag .tag-elo {
    font-size: 0.55rem !important;
  }
  .custom-player-tag .tag-clock {
    font-size: 0.75rem !important;
    padding: 1px 4px !important;
    min-width: 32px !important;
  }
}

/* PC & Laptop viewports >= 1200px (Sizing optimization for Chess.com layout) */
/* PC & Laptop viewports >= 900px (Sizing optimization for side-by-side Chess.com layout) */
@media (min-width: 900px) {
  .main-container {
    max-width: 1440px !important;
    width: 100% !important;
    min-height: calc(100vh - 75px) !important; /* Stretch to fill viewport height below header */
    padding: 24px 32px !important;
    flex-direction: row !important;
    align-items: center !important; /* Vertically center board panel on screen */
    justify-content: center !important;
    gap: 24px !important; /* Bring board and sidebar closer */
  }

  .board-panel {
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch !important; /* Stretches sidebar to exactly match board wrapper height! */
    justify-content: center !important;
    gap: 24px !important;
    background: transparent !important;
    border-radius: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .board-wrapper {
    position: relative !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-shrink: 0 !important;
  }

  .board-outer-container {
    /* Dynamic scaling board size, keeping height limit to 75vh to prevent vertical scrolling */
    width: min(75vh, calc(100vw - 440px), 880px) !important;
    height: min(75vh, calc(100vw - 440px), 880px) !important;
    max-width: none !important;
    aspect-ratio: 1 / 1 !important;
  }

  .sidebar-panel {
    width: 320px !important; /* Desktop sidebar width */
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
    flex-shrink: 0 !important;
    height: 100% !important; /* Inherit board-panel stretched height */
  }



  .phase-banner {
    margin-bottom: 0 !important;
  }

  /* 2-Player Fallback Desktop Adjustments */
  .player-info-tag {
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .player-info-tag.opponent {
    margin-bottom: 12px !important;
    margin-top: 0 !important;
  }
  .player-info-tag.user {
    margin-top: 12px !important;
    margin-bottom: 0 !important;
  }
}

/* Stacked tablet layout (iPad Portrait) alignment */
@media (min-width: 601px) and (max-width: 899px) {
  .board-panel {
    max-width: 628px !important;
    width: 100% !important;
    margin: 0 auto !important;
    padding: 24px !important;
    box-sizing: border-box !important;
  }
  
  .sidebar-panel {
    width: 100% !important;
    max-width: 580px !important; /* Matches board-outer-container's max-width (580px) */
    margin: 0 auto !important;
    box-sizing: border-box !important;
  }


}

/* Matchmaking Queue Spinner */
.queue-spinner-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px;
}

.queue-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(79, 195, 247, 0.1);
  border-left-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Premium Board Themes */
#board.theme-glassmorphism, #replay-board.theme-glassmorphism {
  --square-light: rgba(255, 255, 255, 0.12);
  --square-dark: rgba(255, 255, 255, 0.05);
  background: radial-gradient(circle at center, rgba(6, 182, 212, 0.15), transparent 70%), #0f1015;
  border: 1px solid rgba(6, 182, 212, 0.3) !important;
  box-shadow: 0 0 30px rgba(6, 182, 212, 0.25) !important;
}

#board.theme-walnut, #replay-board.theme-walnut {
  --square-light: #e3c16f;
  --square-dark: #b87d4b;
  background: #5c3c24;
  border: 8px solid #3d2516 !important;
  box-shadow: 0 10px 25px rgba(0,0,0,0.6) !important;
}

#board.theme-neon, #replay-board.theme-neon {
  --square-light: #121520;
  --square-dark: #0a0c14;
  background: #05060b;
  border: 1px solid #ff007f !important;
  box-shadow: 0 0 20px rgba(255, 0, 127, 0.4) !important;
}

#board.theme-neon .square:not(.out-of-bounds), #replay-board.theme-neon .square:not(.out-of-bounds) {
  box-shadow: inset 0 0 0 0.5px rgba(255, 0, 127, 0.15);
}

#board.theme-neon .square.selected, #replay-board.theme-neon .square.selected {
  background-color: rgba(0, 240, 255, 0.3) !important;
}

/* Spectator Mode Panel styles */
.spectator-panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.spectator-banner {
  width: 100%;
  padding: 10px 16px;
  border-radius: 6px;
  text-align: center;
  font-weight: 600;
  font-size: 0.95rem;
  background: rgba(224, 86, 36, 0.1);
  border: 1px solid rgba(224, 86, 36, 0.25);
  color: #ff6b6b;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  box-sizing: border-box;
}

.pulse-indicator {
  color: #ff6b6b;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { opacity: 0.3; }
  50% { opacity: 1; }
  100% { opacity: 0.3; }
}

/* Live Matches Dashboard styles */
.live-matches-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 16px;
}

.live-match-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.3s ease;
}

.live-match-item:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(116, 192, 252, 0.3);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.live-match-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.live-match-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
}

.live-match-players {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.live-match-specs {
  font-size: 0.8rem;
  color: #74c0fc;
}
