/* ==========================================================================
   WESTERN CHESS GUIDE - THEMED SYSTEM
   ========================================================================== */

:root {
  --bg-dark: #070e17;
  --table-felt-1: #1a2a3a;
  --table-felt-2: #0f1a26;
  --table-felt-3: #070e17;
  --panel-bg: rgba(9, 20, 32, 0.88);
  --panel-border: rgba(255, 255, 255, 0.18);
  
  --wood-dark: #160f0a;
  --wood-mid: #2e1e14;
  --wood-light: #4c3322;
  
  --gold: #ffc95a;
  --crimson: #e45b55;
  --ink: #f4f0e7;
  --muted: #aab5c2;
  
  --font-sans: 'Outfit', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --header-height: 72px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body.chess-app {
  font-family: var(--font-sans);
  background: radial-gradient(circle at 50% 10%, var(--table-felt-1) 0%, var(--table-felt-2) 47%, var(--table-felt-3) 100%);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.5;
}

.app-header {
  position: sticky; top: 0; z-index: 100; height: var(--header-height);
  background: rgba(7, 14, 23, 0.94); backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--panel-border);
}
.header-inner { max-width: 1400px; margin: 0 auto; height: 100%; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-tile { font-size: 2rem; font-weight: 900; background: linear-gradient(135deg, #2b3e50, #141e28); border: 2px solid var(--gold); border-radius: 10px; width: 46px; height: 46px; display: grid; place-items: center; color: var(--gold); }
.brand-text h1 { font-size: 1.35rem; font-weight: 800; color: var(--ink); }
.brand-text .badge { font-size: 0.72rem; font-weight: 900; background: var(--gold); color: #151b1a; padding: 2px 8px; border-radius: 99px; }
.brand-text .subtitle { font-size: 0.8rem; color: var(--muted); }

.header-search { flex: 0 1 400px; position: relative; display: flex; align-items: center; }
.header-search input { width: 100%; padding: 10px 16px 10px 42px; background: rgba(3, 15, 12, 0.75); border: 1px solid var(--panel-border); border-radius: 99px; color: var(--ink); }
.search-icon { position: absolute; left: 14px; opacity: 0.6; }

.table-outer-wrapper { max-width: 1400px; margin: 20px auto; padding: 0 20px; }
.table-wood-frame { position: relative; background: linear-gradient(145deg, var(--wood-dark), var(--wood-mid), var(--wood-dark)); border-radius: 28px; padding: 18px; border: 4px solid var(--wood-light); box-shadow: 0 28px 80px rgba(0,0,0,0.75); }
.table-corner { position: absolute; width: 28px; height: 28px; border: 3.5px solid var(--gold); }
.corner-tl { top: 12px; left: 12px; border-right: none; border-bottom: none; }
.corner-tr { top: 12px; right: 12px; border-left: none; border-bottom: none; }
.corner-bl { bottom: 12px; left: 12px; border-right: none; border-top: none; }
.corner-br { bottom: 12px; right: 12px; border-left: none; border-top: none; }
.table-felt-mat { background: linear-gradient(135deg, rgba(26,42,58,0.95), rgba(15,26,38,0.98)); border-radius: 20px; padding: 24px; border: 1px solid var(--panel-border); }

.table-mode-tabs { display: flex; flex-wrap: wrap; gap: 8px; background: rgba(3, 15, 12, 0.85); border: 1px solid var(--panel-border); padding: 10px; border-radius: 16px; margin-bottom: 24px; }
.table-tab { flex: 0 0 auto; padding: 9px 16px; border-radius: 10px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--panel-border); color: var(--muted); font-weight: 800; font-size: 0.85rem; cursor: pointer; white-space: nowrap; }
.table-tab.active { background: var(--gold); color: #151b1a; border-color: var(--gold); box-shadow: 0 4px 14px rgba(255, 201, 90, 0.4); }

.tab-pane { display: none; }
.tab-pane.active { display: block; }
.content-block { background: var(--panel-bg); border: 1px solid var(--panel-border); border-radius: 20px; padding: 28px; }
.tool-block { border-color: rgba(255, 201, 90, 0.4); background: radial-gradient(circle at 50% 20%, rgba(26,42,58,0.95), rgba(15,26,38,0.98)); }

.block-header { margin-bottom: 20px; }
.header-tag { font-size: 0.72rem; font-weight: 900; color: var(--gold); text-transform: uppercase; }
.block-header h2 { font-size: 1.55rem; font-weight: 900; color: var(--ink); }
.block-header p { color: var(--muted); font-size: 0.92rem; }

/* Chessboard 8x8 */
.board-container { display: flex; justify-content: center; margin: 20px 0; }
.chess-board-box { width: 100%; max-width: 480px; aspect-ratio: 1; border: 6px solid var(--wood-light); border-radius: 12px; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,0.6); }
.chessboard { display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); width: 100%; height: 100%; }
.sq { display: grid; place-items: center; font-size: 2.2rem; user-select: none; }
.sq.light { background: #eeeed2; color: #111; }
.sq.dark { background: #769656; color: #111; }

.piece-selector-grid { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.piece-btn { padding: 8px 14px; border-radius: 8px; background: rgba(255,255,255,0.06); border: 1px solid var(--panel-border); color: var(--muted); font-weight: 800; font-size: 0.85rem; cursor: pointer; white-space: nowrap; }
.piece-btn.active { background: var(--gold); color: #151b1a; border-color: var(--gold); }

.piece-detail-card { background: rgba(9, 20, 32, 0.8); border: 1px solid var(--panel-border); border-radius: 14px; padding: 20px; }
.detail-header { display: flex; align-items: center; gap: 14px; }
.piece-avatar { width: 50px; height: 50px; border-radius: 50%; display: grid; place-items: center; font-size: 2.2rem; background: #eeeed2; border: 2px solid var(--gold); color: #111; }

.calculator-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.input-group { background: rgba(9, 20, 32, 0.6); border: 1px solid var(--panel-border); border-radius: 14px; padding: 18px; }
.group-title { display: block; font-size: 0.85rem; font-weight: 900; color: var(--gold); margin-bottom: 10px; }
.counter-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 0.9rem; }
.counter-row input { width: 60px; padding: 4px 8px; border-radius: 6px; background: rgba(0,0,0,0.4); border: 1px solid var(--panel-border); color: #fff; text-align: center; font-family: var(--font-mono); }

.results-card { background: rgba(9, 20, 32, 0.94); border: 2px solid var(--gold); border-radius: 18px; padding: 24px; text-align: center; }
.score-display { display: flex; justify-content: space-around; margin: 16px 0; }
.score-box { display: flex; flex-direction: column; }
.score-box strong { font-size: 2rem; color: var(--gold); font-family: var(--font-mono); }
.eval-result { font-weight: 800; font-size: 1rem; color: #52d1a0; }

.callout-box { display: flex; gap: 14px; padding: 18px; border-radius: 14px; }
.danger-callout { background: rgba(255, 201, 90, 0.12); border: 1px solid rgba(255, 201, 90, 0.35); }
.callout-icon { font-size: 1.8rem; }

.text-card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.info-card { background: rgba(9, 20, 32, 0.7); border: 1px solid var(--panel-border); border-radius: 14px; padding: 18px; }
.info-card.highlight-card { background: rgba(26, 42, 58, 0.4); border-color: rgba(255, 201, 90, 0.4); }
.mt-3 { margin-top: 14px; }
.mt-4 { margin-top: 20px; }

/* ---- Phones. Added after a measured audit: these pages had no media query, so
   the nested table chrome took 180px of a 390px screen and the diagrams
   overflowed the page. Give the content its width back. ---- */
@media (max-width: 720px) {
  .header-inner { padding: 0 12px; gap: 10px; }
  .table-outer-wrapper { margin: 12px auto; padding: 0 10px; }
  .table-wood-frame { padding: 8px; }
  .table-felt-mat { padding: 12px; }
  .table-content-area { padding: 0; }
  .content-block { padding: 14px; }
  .block-header h2 { font-size: 1.15rem; }
  .text-card-grid { grid-template-columns: 1fr; gap: 12px; }
  .table-mode-tabs { padding: 6px; gap: 6px; }
}
