/* ==========================================================================
   TIC-TAC-TOE & GOMOKU GUIDE - THEMED SYSTEM
   ========================================================================== */

:root {
  --bg-dark: #0f0c1b;
  --table-felt-1: #211c38;
  --table-felt-2: #141026;
  --table-felt-3: #0f0c1b;
  --panel-bg: rgba(20, 16, 38, 0.88);
  --panel-border: rgba(255, 255, 255, 0.18);
  
  --wood-dark: #141b24;
  --wood-mid: #253342;
  --wood-light: #3d5063;
  
  --gold: #ffc95a;
  --purple: #845ef7;
  --crimson: #e45b55;
  --ink: #f4f0e7;
  --muted: #b1a9cc;
  
  --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.ttt-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(15, 12, 27, 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; background: var(--purple); border: 2px solid var(--gold); border-radius: 10px; width: 46px; height: 46px; display: grid; place-items: center; color: #fff; }
.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(33,28,56,0.95), rgba(20,16,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(33,28,56,0.95), rgba(20,16,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; }

/* 3x3 Box */
.board-container { display: flex; justify-content: center; margin: 20px 0; }
.ttt-board-box { width: 100%; max-width: 380px; aspect-ratio: 1; border: 4px solid var(--wood-light); border-radius: 16px; background: #120e24; padding: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.6); }
.ttt-grid { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 8px; width: 100%; height: 100%; }
.t-sq { background: rgba(255,255,255,0.06); border: 2px solid var(--panel-border); border-radius: 12px; display: grid; place-items: center; font-size: 3rem; font-weight: 900; user-select: none; }

.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(20, 16, 38, 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: 1.8rem; background: var(--purple); border: 2px solid var(--gold); color: #fff; }

.text-card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.info-card { background: rgba(20, 16, 38, 0.7); border: 1px solid var(--panel-border); border-radius: 14px; padding: 18px; }
.info-card.highlight-card { background: rgba(33, 28, 56, 0.4); border-color: rgba(255, 201, 90, 0.4); }

.faq-list { display: flex; flex-direction: column; gap: 10px; }
.faq-item { background: rgba(20, 16, 38, 0.7); border: 1px solid var(--panel-border); border-radius: 12px; padding: 12px 16px; }
.faq-item summary { font-weight: 800; color: var(--ink); cursor: pointer; }
.faq-item p { margin-top: 8px; font-size: 0.88rem; color: var(--muted); }
.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; }
}
