/* =====================================================
   Chess Master - Play Page (Full Layout) CSS
   ===================================================== */

/* Play Section */
.play-section {
  padding: 0.5rem 0 2.5rem;
}
.container-wide {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding-inline: clamp(0.65rem, 1vw, 1rem);
}

/* Play Layout - 3 Columns */
.play-layout {
  display: grid;
  direction: ltr;
  grid-template-areas: "settings board moves";
  grid-template-columns:
    clamp(178px, 18vw, 260px)
    minmax(540px, 820px)
    clamp(178px, 18vw, 260px);
  gap: clamp(0.55rem, 0.9vw, 0.8rem);
  align-items: start;
  justify-content: center;
}

html[dir="rtl"] .play-layout > * {
  direction: rtl;
}

html[dir="ltr"] .play-layout > * {
  direction: ltr;
}

/* ===== Left Sidebar ===== */
.play-sidebar-left {
  grid-area: settings;
  display: flex; flex-direction: column; gap: 0.75rem;
  position: sticky; top: 70px;
}

.game-settings-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem;
}
.panel-title {
  font-size: var(--font-size-sm); font-weight: 800;
  margin-bottom: 0.95rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}
.setting-group { margin-bottom: 0.85rem; }
.setting-group > label {
  display: block;
  font-size: var(--font-size-xs); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

/* Difficulty Cards */
.diff-grid { display: flex; flex-direction: column; gap: 0.35rem; }
.diff-card {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: var(--text-secondary);
  font-family: var(--font-main);
  text-align: right; cursor: pointer;
  transition: var(--transition-fast);
}
.diff-card:hover { border-color: var(--border-glow); color: var(--text-primary); }
.diff-card.active { border-color: var(--gold); background: rgba(201,168,76,0.08); color: var(--gold); }
.dc-icon { font-size: 1.4rem; flex-shrink: 0; }
.dc-name { font-size: var(--font-size-sm); font-weight: 700; display: block; }
.dc-desc { font-size: var(--font-size-xs); color: var(--text-muted); display: block; }
.diff-card.active .dc-desc { color: rgba(201,168,76,0.7); }

/* Time Grid */
.time-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.35rem; }
.time-chip {
  padding: 0.45rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: var(--text-secondary);
  font-size: var(--font-size-sm); font-weight: 700;
  font-family: monospace; cursor: pointer;
  transition: var(--transition-fast);
}
.time-chip:hover { border-color: var(--border-glow); color: var(--text-primary); }
.time-chip.active { border-color: var(--gold); color: var(--gold); background: rgba(201,168,76,0.08); }

/* Color Grid */
.color-grid { display: flex; flex-direction: column; gap: 0.35rem; }
.color-pick {
  padding: 0.48rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: var(--text-secondary);
  font-size: var(--font-size-sm); font-weight: 600;
  font-family: var(--font-main); cursor: pointer;
  display: flex; align-items: center; gap: 0.5rem;
  transition: var(--transition-fast);
}
.color-pick:hover { border-color: var(--border-glow); color: var(--text-primary); }
.color-pick.active { border-color: var(--gold); color: var(--gold); background: rgba(201,168,76,0.08); }

/* Start / Game Buttons */
.btn-new-game {
  width: 100%;
  padding: 0.7rem;
  border-radius: 8px;
  background: var(--gradient-gold);
  color: var(--bg-primary);
  font-size: var(--font-size-sm); font-weight: 900;
  font-family: var(--font-main); cursor: pointer; border: none;
  transition: var(--transition-normal);
  box-shadow: var(--shadow-btn);
}
.btn-new-game:hover { transform: translateY(-2px); box-shadow: 0 8px 30px rgba(201,168,76,0.45); }

.game-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-top: 0.75rem; }
.btn-resign, .btn-draw {
  padding: 0.5rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: var(--text-secondary);
  font-size: var(--font-size-xs); font-weight: 600;
  font-family: var(--font-main); cursor: pointer;
  transition: var(--transition-fast);
}
.btn-resign:hover { border-color: rgba(233,69,96,0.5); color: var(--accent-red); background: rgba(233,69,96,0.06); }
.btn-draw:hover   { border-color: rgba(248,213,109,0.4); color: var(--gold-light); background: rgba(248,213,109,0.06); }

/* Analysis Panel */
.analysis-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem;
}
.analysis-panel h4 {
  font-size: var(--font-size-sm); font-weight: 800;
  margin-bottom: 1rem; color: var(--text-primary);
}
.eval-display { display: flex; gap: 0.75rem; align-items: center; margin-bottom: 0.75rem; }
.eval-bar-v {
  width: 20px; height: 100px;
  background: #333;
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex; flex-direction: column-reverse;
}
.eval-white-fill {
  width: 100%;
  background: #f0d9b5;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  transition: height 0.5s ease;
}
.eval-details { flex: 1; }
.eval-num {
  font-size: var(--font-size-xl); font-weight: 900;
  color: var(--gold); line-height: 1;
}
.eval-label { font-size: var(--font-size-xs); color: var(--text-muted); }
.engine-info { display: flex; gap: 1rem; }
.depth-info, .nodes-info { font-size: var(--font-size-xs); color: var(--text-muted); }
.depth-info strong, .nodes-info strong { color: var(--text-secondary); font-weight: 700; }

/* ===== Center Board Area ===== */
.play-center {
  grid-area: board;
  --board-size: min(100%, 820px);
  display: flex; flex-direction: column; gap: 0.45rem;
  align-items: center;
  position: relative;
  top: auto;
  min-width: 0;
  justify-self: center;
  width: 100%;
}

/* Player Bars */
.player-bar {
  width: var(--board-size);
  max-width: 100%;
  height: 48px;
  min-height: 48px;
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.42rem 0.8rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  flex-wrap: nowrap;
  overflow: hidden;
}
.pb-avatar {
  width: 32px; height: 32px;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; font-weight: 900;
  flex-shrink: 0;
}
.pb-avatar.ai-avatar   { background: var(--gradient-hero); font-size: 1.3rem; }
.pb-avatar.user-avatar { background: var(--gradient-gold); color: var(--bg-primary); font-size: var(--font-size-sm); }
.pb-info { flex: 1; min-width: 0; }
.pb-name  { font-size: var(--font-size-sm); font-weight: 700; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pb-level { font-size: var(--font-size-xs); color: var(--text-muted); display: block; }
.pb-captured {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 1px;
  max-width: 34%;
  font-size: 0.75rem;
  opacity: 0.72;
}

.player-clock {
  flex-shrink: 0;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.3rem 0.7rem;
  margin-right: auto;
}
.clock-time {
  font-size: var(--font-size-base); font-weight: 900;
  font-family: monospace; color: var(--text-primary);
}
.player-clock.active    { border-color: var(--gold); }
.player-clock.active .clock-time { color: var(--gold); }
.player-clock.warning   { border-color: var(--accent-red); animation: timerPulse 1s ease-in-out infinite; }
.player-clock.warning .clock-time { color: var(--accent-red); }
@keyframes timerPulse { 0%,100% { opacity:1; } 50% { opacity:0.5; } }

/* Board Container */
.board-container {
  position: relative;
  width: var(--board-size);
  max-width: 100%;
}

/* Rank & File Labels */
.rank-labels {
  position: absolute; top: 0; bottom: 0;
  display: flex; flex-direction: column;
  justify-content: space-around;
  padding: 4px 0;
  pointer-events: none;
}
.left-ranks  { left: -20px; }
.right-ranks { right: -20px; }
.rank-labels span { font-size: 10px; color: var(--text-muted); }

.file-labels {
  display: flex; justify-content: space-around;
  padding: 4px 4px 0;
}
.file-labels span { font-size: 10px; color: var(--text-muted); }

/* Main Chess Board */
#chess-board {
  display: grid; grid-template-columns: repeat(8, 1fr);
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 26px 74px rgba(0,0,0,0.58), 0 0 0 1px rgba(255,255,255,0.08), var(--shadow-glow);
  border: 1px solid rgba(255,255,255,0.16);
  background: #8d623d;
  aspect-ratio: 1;
  isolation: isolate;
}
#chess-board .sq {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; position: relative;
  min-width: 0;
  min-height: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: filter var(--transition-fast);
}
#chess-board .sq-light { background: #f0d9b5; }
#chess-board .sq-dark  { background: #b58863; }
#chess-board .sq:hover { filter: brightness(1.1); }
#chess-board .sq.selected     { background: rgba(100,200,100,0.75) !important; }
#chess-board .sq.last-move    { background: rgba(200,180,40,0.55) !important; }
#chess-board .sq.in-check     { background: rgba(233,69,96,0.75) !important; }
#chess-board .sq.legal-target::after,
#chess-board .sq.possible-move::after {
  content: ''; position: absolute;
  width: 28%; height: 28%;
  background: rgba(0,0,0,0.22);
  border-radius: var(--radius-full);
}
#chess-board .sq.legal-capture::after,
#chess-board .sq.possible-capture::after {
  content: ''; position: absolute; inset: 4%;
  border: 3px solid rgba(0,0,0,0.22);
  border-radius: var(--radius-full);
}
#chess-board .piece {
  line-height: 1; cursor: grab;
  user-select: none;
  transition: transform var(--transition-fast);
  position: relative; z-index: 1;
}
#chess-board .piece:hover { transform: scale(1.12); }
#chess-board .piece.dragging { opacity: 0.65; transform: scale(1.2); cursor: grabbing; }
#chess-board.board-disabled {
  pointer-events: none;
}
#chess-board.board-disabled .sq,
#chess-board.board-disabled .piece {
  cursor: not-allowed;
}

/* AI Thinking Overlay */
.ai-thinking {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  background: rgba(13,17,23,0.85);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-lg);
  padding: 0.75rem 1.5rem;
  display: flex; align-items: center; gap: 0.75rem;
  font-size: var(--font-size-sm); font-weight: 600;
  color: var(--accent-purple);
  backdrop-filter: blur(8px);
  z-index: 10;
}
.think-dots { display: flex; gap: 4px; }
.think-dots span {
  width: 6px; height: 6px;
  background: var(--accent-purple);
  border-radius: var(--radius-full);
  animation: dotBounce 1.4s ease-in-out infinite;
}
.think-dots span:nth-child(2) { animation-delay: 0.2s; }
.think-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotBounce {
  0%,80%,100% { transform: scale(0.8); opacity:0.5; }
  40%          { transform: scale(1.3); opacity:1; }
}

/* Promotion Dialog */
.promotion-dialog {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  background: var(--bg-card);
  border: 2px solid var(--border-glow);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  z-index: 20; text-align: center;
  box-shadow: var(--shadow-card), var(--shadow-glow);
}
.promotion-dialog h4 { font-size: var(--font-size-base); font-weight: 800; margin-bottom: 1rem; }
.promotion-pieces { display: flex; gap: 0.5rem; justify-content: center; }
.promotion-pieces button {
  width: 58px; height: 58px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border);
  background: rgba(255,255,255,0.04);
  font-size: 1.1rem; font-weight: 700;
  font-family: var(--font-main); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--text-secondary);
  transition: var(--transition-fast);
}
.promotion-pieces button:hover { border-color: var(--gold); color: var(--gold); background: rgba(201,168,76,0.1); transform: scale(1.08); }

/* Board Controls */
.board-action-row {
  width: var(--board-size);
  max-width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}
.board-controls {
  display: flex; gap: 0.4rem; justify-content: center;
  flex-wrap: wrap;
}
.board-controls button {
  width: 36px; height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text-muted);
  font-size: 1rem; cursor: pointer;
  transition: var(--transition-fast);
  display: flex; align-items: center; justify-content: center;
}
.board-controls button:hover { border-color: var(--border-glow); color: var(--text-primary); background: rgba(255,255,255,0.08); }

.btn-board-fullscreen {
  min-height: 36px;
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--gold);
  background: rgba(201,168,76,0.09);
  color: var(--gold-light);
  font-family: var(--font-main);
  font-size: var(--font-size-xs);
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  transition: var(--transition-fast);
  white-space: nowrap;
}
.btn-board-fullscreen:hover {
  background: rgba(201,168,76,0.18);
  box-shadow: 0 0 16px rgba(201,168,76,0.2);
}
.btn-board-fullscreen[aria-pressed="true"] {
  background: var(--gold);
  color: var(--bg-primary);
}
.fullscreen-icon {
  font-size: 1rem;
  line-height: 1;
}

/* ===== Right Sidebar ===== */
.play-sidebar-right {
  grid-area: moves;
  display: flex; flex-direction: column; gap: 0.75rem;
  position: sticky; top: 70px;
}

.moves-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem;
}
.moves-panel-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1rem;
}
.moves-panel-header h3 { font-size: var(--font-size-sm); font-weight: 800; }
.moves-panel-header span { font-size: var(--font-size-xs); color: var(--text-muted); }

.moves-list-container {
  max-height: clamp(240px, 36dvh, 430px);
  overflow-y: auto;
  font-size: var(--font-size-sm);
}
.moves-list-container::-webkit-scrollbar { width: 4px; }
.moves-list-container::-webkit-scrollbar-track { background: transparent; }
.moves-list-container::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.no-moves-msg, .no-games-msg {
  font-size: var(--font-size-xs); color: var(--text-muted); text-align: center; padding: 1rem;
}

.move-row {
  display: grid; grid-template-columns: 24px 1fr 1fr;
  gap: 0.25rem; margin-bottom: 0.15rem;
}
.move-num  { font-size: 10px; color: var(--text-muted); padding: 0.25rem 0.25rem; align-self: center; }
.move-san {
  padding: 0.2rem 0.4rem;
  border-radius: var(--radius-sm);
  cursor: pointer; font-family: monospace;
  color: var(--text-secondary); font-size: var(--font-size-xs);
  transition: var(--transition-fast);
}
.move-san:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); }
.move-san.current { background: rgba(201,168,76,0.12); color: var(--gold); }

/* Previous Games Panel */
.prev-games-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem;
}
.prev-games-panel h4 {
  font-size: var(--font-size-sm); font-weight: 800;
  margin-bottom: 1rem;
}
.prev-game-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}
.prev-game-item:last-child { border-bottom: none; }
.pg-result { font-size: 1.1rem; flex-shrink: 0; }
.pg-info { flex: 1; }
.pg-info span { font-size: var(--font-size-xs); font-weight: 600; display: block; }
.pg-info small { font-size: 10px; color: var(--text-muted); }
.pg-result.win  {  }
.pg-result.loss {  }
.pg-result.draw {  }

/* ===== Game Over Modal ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 9000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.85); backdrop-filter: blur(12px);
}
.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  text-align: center;
  max-width: 420px; width: 90%;
  animation: fadeInUp 0.4s ease;
  box-shadow: var(--shadow-glow), var(--shadow-card);
}
.modal-trophy { font-size: 4rem; display: block; margin-bottom: 1rem; }
.modal-box h2 { font-size: var(--font-size-3xl); font-weight: 900; margin-bottom: 0.5rem; }
.modal-box p  { font-size: var(--font-size-base); color: var(--text-secondary); margin-bottom: 1.5rem; }

.modal-stats-row {
  display: flex; justify-content: center; gap: 2rem;
  margin-bottom: 1.75rem;
}
.ms-item { text-align: center; }
.ms-item strong {
  display: block; font-size: var(--font-size-2xl); font-weight: 900;
  color: var(--gold);
}
.ms-item strong.positive { color: var(--accent-green); }
.ms-item strong.negative { color: var(--accent-red); }
.ms-item span { font-size: var(--font-size-xs); color: var(--text-muted); }
.modal-actions { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }

/* ===== Board Customization Panel ===== */
.board-customize-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem;
}

/* Theme Swatches */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}
.theme-swatch {
  display: flex; flex-direction: column;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: var(--transition-fast);
  height: 36px;
  background: none;
  padding: 0;
}
.theme-swatch:hover { border-color: var(--border-glow); transform: scale(1.05); }
.theme-swatch.active { border-color: var(--gold); box-shadow: 0 0 10px rgba(201,168,76,0.3); }
.swatch-light, .swatch-dark { flex: 1; }

/* Piece Style Buttons */
.piece-style-grid {
  display: flex; flex-direction: column;
  gap: 0.4rem;
}
.piece-style-btn {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: var(--text-secondary);
  font-family: var(--font-main);
  cursor: pointer;
  transition: var(--transition-fast);
}
.piece-style-btn:hover { border-color: var(--border-glow); color: var(--text-primary); }
.piece-style-btn.active { border-color: var(--gold); color: var(--gold); background: rgba(201,168,76,0.08); }
.ps-preview { font-size: 1.2rem; letter-spacing: 2px; }
.ps-name { font-size: var(--font-size-xs); font-weight: 600; }

/* ===== Board Color Themes ===== */
/* Classic (default) */
.chess-board .sq-light { background: #f0d9b5; }
.chess-board .sq-dark  { background: #b58863; }

/* Walnut */
.chess-board.theme-walnut .sq-light {
  background:
    linear-gradient(110deg, rgba(255,255,255,0.16), transparent 45%, rgba(92,57,29,0.08)),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.08) 0 2px, rgba(104,62,31,0.05) 2px 7px),
    #d8bb8f;
}
.chess-board.theme-walnut .sq-dark {
  background:
    linear-gradient(110deg, rgba(255,255,255,0.08), transparent 48%, rgba(52,31,17,0.16)),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.04) 0 2px, rgba(42,24,13,0.09) 2px 7px),
    #8d623d;
}

/* Tournament */
.chess-board.theme-tournament .sq-light { background: #eeeed2; }
.chess-board.theme-tournament .sq-dark  { background: #769656; }

/* Slate */
.chess-board.theme-slate .sq-light { background: #d9e1e8; }
.chess-board.theme-slate .sq-dark  { background: #5f7688; }

/* Marble */
.chess-board.theme-marble .sq-light {
  background:
    linear-gradient(135deg, rgba(255,255,255,0.55), transparent 45%),
    repeating-linear-gradient(35deg, rgba(80,72,62,0.05) 0 2px, transparent 2px 11px),
    #f4efe5;
}
.chess-board.theme-marble .sq-dark {
  background:
    linear-gradient(135deg, rgba(255,255,255,0.22), transparent 50%),
    repeating-linear-gradient(35deg, rgba(44,39,34,0.08) 0 2px, transparent 2px 12px),
    #9c9080;
}

/* Blue */
.chess-board.theme-blue .sq-light { background: #dee3e6; }
.chess-board.theme-blue .sq-dark  { background: #8ca2ad; }

/* Green */
.chess-board.theme-green .sq-light { background: #ffffdd; }
.chess-board.theme-green .sq-dark  { background: #86a666; }

/* Purple */
.chess-board.theme-purple .sq-light { background: #e8dff5; }
.chess-board.theme-purple .sq-dark  { background: #9b72cf; }

/* Red */
.chess-board.theme-red .sq-light { background: #f0d8d8; }
.chess-board.theme-red .sq-dark  { background: #ba5546; }

/* Dark */
.chess-board.theme-dark .sq-light { background: #cccccc; }
.chess-board.theme-dark .sq-dark  { background: #555555; }

/* Ice */
.chess-board.theme-ice .sq-light { background: #e0f0ff; }
.chess-board.theme-ice .sq-dark  { background: #6ea8d9; }

/* Wood */
.chess-board.theme-wood .sq-light { background: #e8c887; }
.chess-board.theme-wood .sq-dark  { background: #a17a4a; }

.chess-board.pieces-bold .piece { text-shadow: 0 2px 6px rgba(0,0,0,0.5); font-weight: 900; }
.chess-board.pieces-minimal {
  --piece-white-fill: #f7f5ef;
  --piece-white-stroke: #181818;
  --piece-white-detail: #67645e;
  --piece-black-fill: #17191d;
  --piece-black-stroke: #050505;
  --piece-black-detail: #d1d1d1;
  --piece-line: 3.2;
  --piece-detail-line: 2.6;
}
.chess-board.pieces-minimal .piece-art { transform: scale(0.94); }

/* Fullscreen board */
body.board-expanded {
  overflow: hidden;
}
.play-center:fullscreen,
.play-center:-webkit-full-screen,
.play-center.is-board-expanded {
  --board-size: min(calc(100vh - 150px), calc(100vw - 24px), 920px);
  --board-size: min(calc(100dvh - 150px), calc(100vw - 24px), 920px);
  width: 100%;
  height: 100%;
  max-width: none;
  padding: 0.5rem;
  margin: 0;
  position: fixed;
  inset: 0;
  z-index: 10000;
  justify-content: center;
  overflow: auto;
  background: var(--bg-primary);
}
.play-center:fullscreen,
.play-center:-webkit-full-screen,
.play-center.is-board-expanded {
  gap: 0.5rem;
}
.play-center:fullscreen .player-bar,
.play-center:-webkit-full-screen .player-bar,
.play-center.is-board-expanded .player-bar {
  min-height: 48px;
  padding: 0.35rem 0.75rem;
}
.play-center:fullscreen .pb-avatar,
.play-center:-webkit-full-screen .pb-avatar,
.play-center.is-board-expanded .pb-avatar {
  width: 32px;
  height: 32px;
}
.play-center:fullscreen::backdrop {
  background: var(--bg-primary);
}
.play-center:fullscreen .player-bar,
.play-center:-webkit-full-screen .player-bar,
.play-center.is-board-expanded .player-bar,
.play-center:fullscreen .board-container,
.play-center:-webkit-full-screen .board-container,
.play-center.is-board-expanded .board-container,
.play-center:fullscreen .board-action-row,
.play-center:-webkit-full-screen .board-action-row,
.play-center.is-board-expanded .board-action-row {
  width: var(--board-size);
}

/* Responsive */
@media (max-width: 1180px) {
  .play-layout {
    grid-template-columns:
      minmax(178px, 0.78fr)
      minmax(540px, 2.5fr)
      minmax(178px, 0.78fr);
  }
  .game-settings-panel,
  .analysis-panel,
  .board-customize-panel,
  .moves-panel,
  .prev-games-panel {
    padding: 0.7rem;
  }
  .dc-desc {
    display: none;
  }
  .diff-card,
  .piece-style-btn {
    gap: 0.45rem;
    padding-inline: 0.55rem;
  }
  .theme-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (max-width: 940px) {
  .play-layout {
    grid-template-areas:
      "board"
      "settings"
      "moves";
    grid-template-columns: minmax(0, 1fr);
  }
  .play-sidebar-left, .play-sidebar-right { position: relative; top: auto; }
  .play-center {
    width: 100%;
    position: relative;
    top: auto;
    --board-size: min(100%, 760px);
  }
  .play-sidebar-left,
  .play-sidebar-right {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }
  .game-settings-panel {
    grid-column: 1;
    grid-row: 1;
  }
  .analysis-panel {
    grid-column: 2;
    grid-row: 1;
  }
  .moves-panel {
    grid-column: 1;
    grid-row: 1;
  }
  .board-customize-panel {
    grid-column: 2;
    grid-row: 1;
  }
  .prev-games-panel {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}
@media (max-width: 760px) {
  .play-sidebar-left,
  .play-sidebar-right {
    display: flex;
    width: 100%;
    align-items: stretch;
  }
  .game-settings-panel,
  .board-customize-panel,
  .analysis-panel,
  .moves-panel,
  .prev-games-panel {
    grid-column: auto;
    grid-row: auto;
  }
}
@media (max-width: 600px) {
  .play-section { padding-top: 1rem; padding-bottom: 2rem; }
  .container-wide { padding: 0 1rem; }
  .play-center {
    --board-size: min(100%, 520px);
    gap: 0.6rem;
  }
  .rank-labels { display: none; }
  .left-ranks, .right-ranks { display: none; }
  .player-bar {
    height: auto;
    min-height: 54px;
    padding: 0.5rem 0.65rem;
    gap: 0.55rem;
    flex-wrap: wrap;
  }
  .pb-avatar {
    width: 34px;
    height: 34px;
  }
  .pb-captured {
    max-width: 28%;
  }
  .player-clock {
    padding: 0.3rem 0.55rem;
  }
  .board-action-row { gap: 0.5rem; }
  .board-controls { gap: 0.3rem; }
  .board-controls button { width: 40px; height: 40px; }
  .btn-board-fullscreen {
    width: 100%;
    min-height: 44px;
  }
}
@media (max-width: 420px) {
  .container-wide { padding-inline: 0.75rem; }
  .player-bar { border-radius: 8px; }
  .pb-level { font-size: 0.66rem; }
  .clock-time { font-size: 0.9rem; }
  .board-controls {
    width: 100%;
    justify-content: space-between;
    flex-wrap: nowrap;
  }
  .board-controls button {
    width: 42px;
    height: 42px;
  }
}
@media (max-height: 650px) and (min-width: 760px) {
  .play-center {
    gap: 0.45rem;
  }
  .player-bar {
    min-height: 46px;
    padding-block: 0.35rem;
  }
  .pb-avatar {
    width: 32px;
    height: 32px;
  }
  .board-controls button,
  .btn-board-fullscreen {
    min-height: 36px;
    height: 36px;
  }
}
