/* ═══════════════════════════════════════════════════════════════
   WhiteBoard Live — Game-Specific Styles
   ═══════════════════════════════════════════════════════════════ */

/* ─── Board Container ──────────────────────────────────────────── */
.board-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-top: 64px;
}

.board-toolbar {
  background: hsla(225, 30%, 8%, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: var(--space-3) var(--space-6);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  z-index: 100;
}

.board-main {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* ─── Whiteboard ───────────────────────────────────────────────── */
#wb-canvas-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: hsl(225, 20%, 8%);
}

#wb-canvas {
  display: block;
  cursor: crosshair;
  touch-action: none;
}

.wb-sidebar {
  width: 220px;
  background: var(--bg-glass);
  backdrop-filter: var(--glass-blur);
  border-right: 1px solid var(--border);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  overflow-y: auto;
}

[dir="rtl"] .wb-sidebar {
  border-right: none;
  border-left: 1px solid var(--border);
}

.tool-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.tool-section-title {
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border);
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
}

.tool-btn {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: hsla(225, 25%, 15%, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--trans-base);
  font-size: 18px;
}

.tool-btn:hover {
  background: hsla(250, 85%, 65%, 0.15);
  border-color: var(--border-bright);
  color: var(--text-primary);
}

.tool-btn.active {
  background: hsla(250, 85%, 65%, 0.25);
  border-color: var(--primary);
  color: var(--primary-glow);
  box-shadow: 0 0 10px hsla(250, 85%, 65%, 0.2);
}

.tool-btn span {
  font-size: 9px;
  font-weight: 600;
}

.color-palette {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--space-1);
}

.color-swatch {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform var(--trans-fast), box-shadow var(--trans-fast);
  border: 2px solid transparent;
}

.color-swatch:hover {
  transform: scale(1.2);
}

.color-swatch.active {
  border-color: white;
  box-shadow: 0 0 8px currentColor;
}

.size-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: var(--radius-full);
  outline: none;
  cursor: pointer;
}

.size-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--grad-primary);
  cursor: pointer;
  box-shadow: 0 0 8px hsla(250,85%,65%,0.4);
  transition: transform var(--trans-fast);
}

.size-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.wb-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2);
}

.wb-cursor-preview {
  border-radius: 50%;
  background: var(--primary);
  transition: all var(--trans-base);
}

/* ─── Tic-Tac-Toe ──────────────────────────────────────────────── */
.xo-layout {
  display: flex;
  gap: var(--space-8);
  align-items: flex-start;
  justify-content: center;
  padding: var(--space-8);
  flex-wrap: wrap;
}

.xo-board-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-6);
}

.xo-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: var(--space-4);
  background: hsla(250, 60%, 50%, 0.08);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md), inset 0 0 40px hsla(250,60%,50%,0.05);
}

.xo-cell {
  width: calc(min(30vw, 130px));
  height: calc(min(30vw, 130px));
  max-width: 130px;
  max-height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: hsla(225, 25%, 12%, 0.8);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: clamp(2.5rem, 8vw, 4rem);
  font-weight: 900;
  cursor: pointer;
  transition: all var(--trans-slow);
  position: relative;
  overflow: hidden;
  user-select: none;
}

.xo-cell::before {
  content: '';
  position: absolute;
  inset: 0;
  background: hsla(255,100%,100%,0.05);
  opacity: 0;
  transition: opacity var(--trans-fast);
}

.xo-cell:hover::before { opacity: 1; }

.xo-cell:not(.taken):hover {
  border-color: var(--border-bright);
  box-shadow: 0 0 20px hsla(250,85%,65%,0.15);
  transform: scale(1.03);
}

.xo-cell.x {
  color: hsl(250, 85%, 70%);
  border-color: hsla(250, 85%, 65%, 0.4);
  background: hsla(250, 85%, 65%, 0.08);
  text-shadow: 0 0 20px currentColor;
}

.xo-cell.o {
  color: hsl(0, 75%, 65%);
  border-color: hsla(0, 75%, 60%, 0.4);
  background: hsla(0, 75%, 60%, 0.08);
  text-shadow: 0 0 20px currentColor;
}

.xo-cell.win-cell {
  background: hsla(145, 65%, 50%, 0.15) !important;
  border-color: hsl(145, 65%, 50%) !important;
  animation: winPulse 1s ease infinite alternate;
}

@keyframes winPulse {
  from { box-shadow: 0 0 10px hsl(145,65%,50%); }
  to   { box-shadow: 0 0 30px hsl(145,65%,60%); }
}

.xo-mark {
  display: inline-block;
  animation: markAppear 0.3s var(--trans-spring) forwards;
}

@keyframes markAppear {
  from { transform: scale(0) rotate(-20deg); opacity: 0; }
  to   { transform: scale(1) rotate(0); opacity: 1; }
}

.xo-side {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 240px;
  max-width: 300px;
}

.xo-status {
  padding: var(--space-4) var(--space-5);
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-align: center;
}

.xo-turn-indicator {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-lg);
  font-weight: 700;
}

.xo-scores {
  display: flex;
  gap: var(--space-3);
}

.xo-score-card {
  flex: 1;
  padding: var(--space-3);
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-align: center;
}

.xo-score-card .score-val {
  font-size: var(--font-size-2xl);
  font-weight: 900;
}

.xo-score-card .score-label {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

/* ─── Snake & Ladders ──────────────────────────────────────────── */
.snake-layout {
  display: flex;
  gap: var(--space-6);
  padding: var(--space-6);
  align-items: flex-start;
  justify-content: center;
  flex-wrap: wrap;
}

.snake-board-wrap {
  position: relative;
}

#snake-canvas {
  display: block;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), 0 0 40px hsla(250,60%,50%,0.2);
  max-width: 100%;
  height: auto;
}

.snake-side {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 240px;
  max-width: 300px;
}

.dice-area {
  padding: var(--space-5);
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
}

.dice {
  width: 80px;
  height: 80px;
  background: var(--bg-card);
  border: 2px solid var(--border-bright);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  box-shadow: var(--shadow-md);
  transition: transform var(--trans-slow), box-shadow var(--trans-slow);
  position: relative;
  cursor: default;
}

.dice.rolling {
  animation: diceRoll 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) infinite;
}

@keyframes diceRoll {
  0%   { transform: rotate(0deg) scale(1); }
  25%  { transform: rotate(15deg) scale(1.05); }
  50%  { transform: rotate(-15deg) scale(0.95); }
  75%  { transform: rotate(10deg) scale(1.05); }
  100% { transform: rotate(0deg) scale(1); }
}

.snake-players {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.snake-player-card {
  padding: var(--space-3) var(--space-4);
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  transition: all var(--trans-base);
}

.snake-player-card.active-turn {
  border-color: var(--primary);
  background: hsla(250, 85%, 65%, 0.1);
  box-shadow: 0 0 15px hsla(250, 85%, 65%, 0.15);
}

.player-token {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: var(--shadow-sm);
}

.token-p1 { background: linear-gradient(135deg, hsl(250,85%,55%), hsl(270,85%,60%)); }
.token-p2 { background: linear-gradient(135deg, hsl(0,75%,55%), hsl(330,75%,55%)); }

/* ─── Chess ────────────────────────────────────────────────────── */
.chess-layout {
  display: flex;
  gap: var(--space-6);
  padding: var(--space-6);
  align-items: flex-start;
  justify-content: center;
  flex-wrap: wrap;
}

.chess-board-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.chess-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  border: 3px solid var(--border-bright);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-lg), 0 0 40px hsla(250,60%,50%,0.2);
}

.chess-cell {
  width: calc(min(8vw, 72px));
  height: calc(min(8vw, 72px));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  cursor: pointer;
  transition: all var(--trans-fast);
  position: relative;
}

.chess-cell.light { background: hsl(220, 30%, 80%); }
.chess-cell.dark  { background: hsl(250, 35%, 35%); }
.chess-cell:hover { filter: brightness(1.2); }
.chess-cell.selected { background: hsla(145, 65%, 50%, 0.5) !important; }
.chess-cell.valid-move::after {
  content: '';
  position: absolute;
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: hsla(145, 65%, 50%, 0.6);
}
.chess-cell.valid-capture::after {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: var(--radius-sm);
  border: 4px solid hsla(0, 75%, 60%, 0.5);
}
.chess-cell.check { background: hsla(0, 75%, 50%, 0.35) !important; }
.chess-cell.last-move { background: hsla(40, 90%, 60%, 0.25) !important; }

.chess-piece {
  user-select: none;
  cursor: grab;
  transition: transform var(--trans-fast);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.chess-piece:hover { transform: scale(1.15); }
.chess-piece.dragging { cursor: grabbing; opacity: 0.7; }

.chess-side {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 220px;
}

.chess-captured {
  padding: var(--space-3);
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  min-height: 60px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 1.2rem;
}

.move-history {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-y: auto;
  max-height: 300px;
}

.move-row {
  display: grid;
  grid-template-columns: auto 1fr 1fr;
  padding: var(--space-2) var(--space-3);
  gap: var(--space-3);
  font-size: var(--font-size-sm);
  font-family: var(--font-en);
  border-bottom: 1px solid var(--border);
}

.move-row:last-child { border-bottom: none; }
.move-row:hover { background: hsla(255,100%,100%,0.03); }
.move-num { color: var(--text-muted); font-weight: 700; }

/* ─── Dots & Boxes ─────────────────────────────────────────────── */
.dots-layout {
  display: flex;
  gap: var(--space-6);
  padding: var(--space-6);
  align-items: flex-start;
  justify-content: center;
  flex-wrap: wrap;
}

.dots-board-wrap {
  position: relative;
}

#dots-canvas {
  display: block;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  cursor: pointer;
}

.dots-side {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 220px;
}

.dots-score-display {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  text-align: center;
}

.dots-player-score {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.dots-player-score .p-name {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  font-weight: 600;
}

.dots-player-score .p-score {
  font-size: var(--font-size-4xl);
  font-weight: 900;
  line-height: 1;
}

.p1-score { color: hsl(250, 85%, 70%); }
.p2-score { color: hsl(0, 75%, 65%); }

.dots-vs {
  font-size: var(--font-size-2xl);
  font-weight: 900;
  color: var(--text-muted);
}

/* ─── Game Status Overlay ──────────────────────────────────────── */
.game-result-overlay {
  position: absolute;
  inset: 0;
  background: hsla(225, 30%, 5%, 0.9);
  backdrop-filter: blur(12px);
  border-radius: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-6);
  z-index: 100;
  animation: overlayIn 0.4s ease forwards;
}

@keyframes overlayIn {
  from { opacity: 0; backdrop-filter: blur(0); }
  to   { opacity: 1; backdrop-filter: blur(12px); }
}

.result-emoji {
  font-size: 5rem;
  animation: resultBounce 0.6s var(--trans-spring) forwards;
}

@keyframes resultBounce {
  from { transform: scale(0) rotate(-30deg); opacity: 0; }
  to   { transform: scale(1) rotate(0); opacity: 1; }
}

.result-title {
  font-size: var(--font-size-3xl);
  font-weight: 900;
  text-align: center;
  background: var(--grad-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ─── Turn Banner ──────────────────────────────────────────────── */
.turn-banner {
  padding: var(--space-3) var(--space-5);
  background: var(--bg-glass);
  backdrop-filter: var(--glass-blur-sm);
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  font-size: var(--font-size-md);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  transition: all var(--trans-slow);
}

.turn-banner.my-turn {
  border-color: var(--primary);
  background: hsla(250, 85%, 65%, 0.12);
  box-shadow: 0 0 20px hsla(250, 85%, 65%, 0.2);
  animation: myTurnGlow 2s ease infinite alternate;
}

@keyframes myTurnGlow {
  from { box-shadow: 0 0 10px hsla(250, 85%, 65%, 0.2); }
  to   { box-shadow: 0 0 30px hsla(250, 85%, 65%, 0.4); }
}

.turn-banner.enemy-turn {
  border-color: hsla(0, 75%, 60%, 0.3);
  color: var(--text-secondary);
}

/* ─── Score Board ──────────────────────────────────────────────── */
.score-board {
  padding: var(--space-4);
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.score-board-title {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.score-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.score-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  transition: background var(--trans-fast);
}

.score-item:hover { background: hsla(255,100%,100%,0.04); }

.score-rank {
  width: 20px;
  font-weight: 700;
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  font-family: var(--font-en);
}

.score-rank:nth-child(1) { color: hsl(40,90%,60%); }

.score-name {
  flex: 1;
  font-weight: 600;
}

.score-val {
  font-weight: 800;
  color: var(--primary-glow);
  font-family: var(--font-en);
}
