* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0a0a0a;
  --surface: #131313;
  --surface2: #1a1a1a;
  --border: #252525;
  --accent: #f0c040;
  --accent2: #e07b00;
  --text: #e8e8e8;
  --text2: #888;
  --green: #3cb371;
  --red: #e05555;
  --blue: #4a9eff;
  --radius: 10px;
}
body { background: var(--bg); color: var(--text); font-family: 'Segoe UI', system-ui, sans-serif; min-height: 100vh; }

/* ── WELCOME BAR ───────────────────────────────────────────── */
.welcome-bar {
  background: linear-gradient(135deg, #1a1200 0%, #111 100%);
  border-bottom: 2px solid var(--accent);
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height .5s ease, opacity .4s ease;
  position: relative;
  z-index: 90;
}
.welcome-bar.show { max-height: 400px; opacity: 1; }
.welcome-inner { padding: 18px 20px 20px; max-width: 900px; margin: 0 auto; }
.welcome-title { font-size: 1.1rem; font-weight: 900; color: var(--accent); margin-bottom: 12px; }
.welcome-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; margin-bottom: 14px; }
.welcome-item { display: flex; align-items: flex-start; gap: 8px; font-size: 0.82rem; color: var(--text2); line-height: 1.5; }
.wi-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }
.welcome-close {
  background: var(--accent); color: #000; border: none; border-radius: 8px;
  padding: 10px 26px; font-size: 0.9rem; font-weight: 800; cursor: pointer;
  display: block; margin: 0 auto;
}
.welcome-close:hover { opacity: .88; }

/* ── NAV ───────────────────────────────────────────────────── */
nav {
  background: #0f0f0f; border-bottom: 1px solid var(--border);
  padding: 0 16px; display: flex; align-items: center; gap: 16px;
  min-height: 52px; position: sticky; top: 0; z-index: 100; flex-wrap: nowrap;
  overflow-x: auto; overflow-y: visible; scrollbar-width: none;
}
nav::-webkit-scrollbar { display: none; }
nav .logo { font-weight: 900; font-size: 1.25rem; color: var(--accent); text-decoration: none; letter-spacing: -0.5px; }
nav a { color: var(--text2); text-decoration: none; font-size: 0.86rem; font-weight: 500; white-space: nowrap; flex-shrink: 0; }
nav a:hover { color: var(--text); }
.rules-nav-btn {
  background: transparent; border: 1px solid var(--border); color: var(--text2);
  border-radius: 6px; padding: 4px 12px; font-size: 0.86rem; font-weight: 500;
  cursor: pointer; transition: border-color .15s, color .15s;
}
.rules-nav-btn:hover { border-color: var(--accent); color: var(--text); }
.live-badge {
  display: inline-block; background: var(--red); color: #fff;
  font-size: 0.65rem; font-weight: 800; padding: 2px 7px; border-radius: 20px;
  letter-spacing: 1px; margin-left: 6px; animation: pulse 2s infinite; vertical-align: middle;
}
.viewers-count { color: var(--text2); font-size: 0.78rem; white-space: nowrap; }
#nav-viewers { margin-left: auto; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.5} }

/* ── RULES DRAWER ──────────────────────────────────────────── */
.rules-drawer {
  background: var(--surface); border-bottom: 1px solid var(--accent);
  overflow: hidden; max-height: 0;
  transition: max-height .4s ease;
  position: relative; z-index: 95;
}
.rules-drawer.open { max-height: 500px; }
.rules-inner { padding: 20px; max-width: 900px; margin: 0 auto; position: relative; }
.rules-inner h2 { font-size: 0.95rem; color: var(--accent); margin-bottom: 12px; font-weight: 800; }
.rules-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.rule-item { font-size: 0.81rem; color: var(--text2); line-height: 1.55; background: var(--surface2); border-radius: 7px; padding: 10px 12px; border: 1px solid var(--border); }
.rule-item strong { color: var(--text); }
.rules-close {
  position: absolute; top: 14px; right: 14px;
  background: transparent; border: 1px solid var(--border); color: var(--text2);
  border-radius: 6px; padding: 3px 10px; cursor: pointer; font-size: 0.85rem;
}
.rules-close:hover { border-color: var(--text); color: var(--text); }

/* ── SECTION LAYOUT ────────────────────────────────────────── */
.featured-section, .play-section, .puzzle-section, .lb-section {
  max-width: 1060px; margin: 16px auto; padding: 0 14px;
}

.section-header {
  font-size: 0.75rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: 1.2px; color: var(--text2); padding: 0 0 10px;
  border-bottom: 1px solid var(--border); margin-bottom: 12px;
}

/* ── FEATURED SECTION ──────────────────────────────────────── */
.featured-header {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.82rem; color: var(--text2); padding-bottom: 10px;
  border-bottom: 1px solid var(--border); margin-bottom: 12px;
}
.featured-grid {
  display: grid; grid-template-columns: 1fr 300px; gap: 14px; align-items: start;
}
@media(max-width: 820px) { .featured-grid { grid-template-columns: 1fr; } }

/* Featured board column */
.featured-board-wrap { display: flex; flex-direction: column; gap: 0; }
.featured-vs-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0; padding: 10px 14px; gap: 10px;
}
.vs-side { display: flex; align-items: center; gap: 7px; flex: 1; }
.vs-side.right { justify-content: flex-end; flex-direction: row-reverse; }
.vs-label { font-size: 0.72rem; font-weight: 900; color: var(--text2); letter-spacing: 1px; }
.feat-clock {
  background: var(--surface2); border: 1px solid var(--border); border-radius: 6px;
  padding: 3px 10px; font-size: 1rem; font-weight: 900; font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px; color: var(--text); min-width: 60px; text-align: center;
}
.feat-clock.active { border-color: var(--accent); color: var(--accent); }
.feat-clock.urgent { border-color: var(--red); color: var(--red); animation: pulse .5s infinite; }

.featured-board {
  display: grid; grid-template-columns: repeat(8,1fr);
  width: 100%; aspect-ratio: 1; border: 2px solid #333;
  border-top: none; border-bottom: none;
  box-shadow: 0 6px 30px rgba(0,0,0,.6);
  position: relative;
}

/* ── PLAYER BOARD ──────────────────────────────────────────── */
.player-board {
  display: grid; grid-template-columns: repeat(8,1fr);
  width: 100%; max-width: 380px; aspect-ratio: 1; border: 2px solid #333;
  border-radius: 3px; overflow: hidden; box-shadow: 0 4px 20px rgba(0,0,0,.5);
  margin: 0 auto; position: relative;
}

/* ── SQUARES ───────────────────────────────────────────────── */
.sq {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  font-size: clamp(1.2rem, 4.5vw, 2rem); cursor: pointer;
  position: relative; user-select: none; transition: background 0.08s;
}
.sq.light { background: #f0d9b5; }
.sq.dark  { background: #b58863; }
.sq.selected  { background: #7fc97f !important; }
.sq.last-from { background: rgba(255,220,0,.42) !important; }
.sq.last-to   { background: rgba(255,220,0,.68) !important; }
.sq.legal::after {
  content:''; position:absolute; width:30%; height:30%; border-radius:50%;
  background: rgba(0,140,0,.42); pointer-events:none;
}
.sq.spectator { cursor: default; }

/* ── FILE LABELS ───────────────────────────────────────────── */
.file-labels-small {
  display: flex; justify-content: space-around; max-width: 380px;
  width: 100%; margin: 0 auto; padding: 2px 0;
}
.featured-board-wrap .file-labels-small { max-width: 100%; }
.file-labels-small span { font-size: 0.55rem; color: var(--text2); width: 12.5%; text-align: center; }

/* ── MOVE HISTORY ──────────────────────────────────────────── */
.move-history-wrap { border: 1px solid var(--border); border-top: none; border-radius: 0 0 var(--radius) var(--radius); overflow: hidden; }
.move-history {
  max-height: 80px; overflow-y: auto; padding: 6px 10px;
  font-size: 0.75rem; color: var(--text2); background: var(--surface);
  display: flex; flex-wrap: wrap; gap: 3px 8px; align-items: flex-start;
}
.move-history span { white-space: nowrap; }
.move-history .move-num { color: var(--text2); }
.move-history .move-w { color: var(--text); }
.move-history .move-b { color: var(--accent); }

/* ── FEATURED RIGHT (cheer + chat) ────────────────────────── */
.featured-right { display: flex; flex-direction: column; gap: 12px; }

/* ── PANEL ─────────────────────────────────────────────────── */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.panel-header {
  background: var(--surface2); border-bottom: 1px solid var(--border); padding: 8px 14px;
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text2); display: flex; align-items: center; justify-content: space-between;
}
.panel-body { padding: 12px 14px; }

/* ── CHEER ─────────────────────────────────────────────────── */
.cheer-btn {
  background: linear-gradient(135deg, var(--accent2), var(--accent)); color: #000;
  border: none; border-radius: 10px; padding: 11px; font-size: 1.3rem; font-weight: 900;
  cursor: pointer; width: 100%; transition: transform .1s; letter-spacing: .5px;
}
.cheer-btn:hover { transform: scale(1.03); }
.cheer-btn:active { transform: scale(0.97); }
.cheer-row { display: flex; align-items: center; gap: 7px; padding: 4px 0; font-size: 0.78rem; }
.cheer-flag { font-size: 0.95rem; }
.cheer-bar-wrap { flex: 1; background: var(--border); border-radius: 2px; height: 5px; }
.cheer-bar { height: 5px; border-radius: 2px; background: var(--accent2); transition: width .4s; }
.cheer-num { color: var(--text2); font-size: 0.72rem; min-width: 36px; text-align: right; }

/* ── CHAT ──────────────────────────────────────────────────── */
.chat-panel { display: flex; flex-direction: column; height: 260px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 8px 12px; display: flex; flex-direction: column; gap: 5px; }
.chat-msg { font-size: 0.79rem; line-height: 1.4; }
.chat-msg .from { font-weight: 700; margin-right: 5px; }
.chat-msg.bot .from { color: var(--accent); }
.chat-msg.bot { padding-left: 6px; border-left: 2px solid var(--accent); }
.chat-msg .txt { color: #bbb; }
.chat-input-row { display: flex; gap: 6px; padding: 7px 10px; border-top: 1px solid var(--border); background: var(--surface2); }
.chat-input { flex: 1; background: #0f0f0f; border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px; color: var(--text); font-size: 0.82rem; outline: none; }
.chat-input:focus { border-color: var(--accent); }
.chat-send { background: var(--accent); color: #000; border: none; border-radius: 6px; padding: 7px 14px; font-size: 0.8rem; font-weight: 700; cursor: pointer; white-space: nowrap; }
.chat-send:disabled { opacity: .4; cursor: not-allowed; }

/* ── PLAY SECTION ──────────────────────────────────────────── */
.play-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.play-section-header {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 10px; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--border);
}
.play-section-header h2 { font-size: 1rem; font-weight: 800; color: var(--text); }

/* Mode buttons */
.mode-select { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.mode-btn {
  flex: 1; min-width: 100px; background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 10px; cursor: pointer; color: var(--text);
  text-align: center; transition: border-color .15s, background .15s;
}
.mode-btn:hover { border-color: var(--accent); }
.mode-btn.active { border-color: var(--accent); background: #1a1400; }
.mode-icon { font-size: 1.5rem; margin-bottom: 4px; }
.mode-label { font-size: 0.82rem; font-weight: 700; color: var(--text); }
.mode-sub { font-size: 0.7rem; color: var(--text2); margin-top: 2px; }

/* Difficulty buttons */
.bot-options { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.diff-btns { display: flex; gap: 6px; }
.diff-btn {
  background: var(--surface2); border: 1px solid var(--border); border-radius: 6px;
  padding: 5px 13px; color: var(--text2); font-size: 0.8rem; cursor: pointer;
  transition: border-color .15s, color .15s;
}
.diff-btn:hover { border-color: var(--accent); color: var(--text); }
.diff-btn.active { border-color: var(--accent); color: var(--accent); background: #1a1400; font-weight: 700; }

/* Friend options */
.friend-options { margin-bottom: 12px; }
.friend-code-display { display: flex; flex-direction: column; gap: 8px; }
.friend-link-row { display: flex; gap: 8px; align-items: center; }
.friend-link {
  font-family: monospace; font-size: 0.82rem; background: var(--surface2);
  border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px; flex: 1;
  color: var(--accent); word-break: break-all;
}
.copy-btn {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text2);
  border-radius: 6px; padding: 7px 14px; font-size: 0.8rem; cursor: pointer;
  white-space: nowrap;
}
.copy-btn:hover { border-color: var(--accent); color: var(--text); }

/* Start button */
.btn-start {
  background: var(--accent); color: #000; border: none; border-radius: 8px;
  padding: 12px; font-size: 0.95rem; font-weight: 800; cursor: pointer;
  width: 100%; margin-bottom: 12px; transition: opacity .15s;
}
.btn-start:hover { opacity: .88; }
.btn-start:disabled { opacity: .4; cursor: not-allowed; }

/* Player game section */
/* ── PLAYER GAME GRID (mirrors featured layout) ────────────── */
.player-game-grid {
  display: grid; grid-template-columns: 1fr 300px; gap: 14px;
  align-items: start; margin-top: 12px;
}
@media(max-width: 820px) { .player-game-grid { grid-template-columns: 1fr; } }

.player-board-col { display: flex; flex-direction: column; }

/* Override player-board inside the game grid — full width, no cap */
.player-game-grid .player-board {
  max-width: none; margin: 0; border-radius: 0;
  border-top: none; border-bottom: none;
}

.player-right-col {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  position: sticky; top: 68px;
}

/* Keep old wrap in case referenced elsewhere */
.player-game-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; }

.player-vs-bar {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0; padding: 10px 14px; gap: 8px;
}
.vs-side-sm { display: flex; align-items: center; gap: 6px; }
.vs-side-sm.right { flex-direction: row-reverse; }
.player-clock {
  background: var(--surface); border: 1px solid var(--border); border-radius: 5px;
  padding: 3px 9px; font-size: 0.95rem; font-weight: 900; font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px; min-width: 55px; text-align: center;
}
.active-clock { border-color: var(--accent); color: var(--accent); }
.player-clock.urgent { border-color: var(--red); color: var(--red); animation: pulse .5s infinite; }

/* Resign / reset button */
.btn-reset {
  background: transparent; border: 1px solid var(--border); color: var(--text2);
  border-radius: 7px; padding: 8px 16px; font-size: 0.82rem; cursor: pointer;
  transition: border-color .15s, color .15s;
}
.btn-reset:hover { border-color: var(--red); color: var(--red); }

/* ── PUZZLE SECTION ────────────────────────────────────────── */
.puzzle-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.puzzle-grid { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: start; }
@media(max-width: 680px) { .puzzle-grid { grid-template-columns: 1fr; } }
.puzzle-meta-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.difficulty-badge {
  font-size: 0.68rem; font-weight: 800; text-transform: uppercase; letter-spacing: 1px;
  padding: 3px 9px; border-radius: 20px;
}
.difficulty-badge.Beginner { background: #1a3a1a; color: var(--green); }
.difficulty-badge.Intermediate { background: #2a2000; color: var(--accent); }
.difficulty-badge.Advanced { background: #2a1010; color: var(--red); }
.puzzle-result-box {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px; font-size: 0.82rem; color: var(--text);
}

/* ── LEADERBOARD SECTION ───────────────────────────────────── */
.lb-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.lb-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.lb-tab {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text2);
  border-radius: 6px; padding: 6px 16px; font-size: 0.8rem; font-weight: 600; cursor: pointer;
  transition: border-color .15s, color .15s;
}
.lb-tab:hover { border-color: var(--accent); color: var(--text); }
.lb-tab.active { border-color: var(--accent); color: var(--accent); background: #1a1400; }
.lb-list { display: flex; flex-direction: column; }
.lb-row { display: flex; align-items: center; gap: 8px; padding: 7px 4px; font-size: 0.82rem; border-bottom: 1px solid var(--border); }
.lb-row:last-child { border: none; }
.lb-rank { color: var(--accent); font-weight: 800; width: 24px; flex-shrink: 0; }
.lb-flag { font-size: 1rem; flex-shrink: 0; }
.lb-name { flex: 1; }
.lb-pts { font-weight: 700; color: var(--accent); font-size: 0.85rem; white-space: nowrap; }
.lb-wld { color: var(--text2); font-size: 0.72rem; white-space: nowrap; }

/* ── STATUS DOT ────────────────────────────────────────────── */
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text2); flex-shrink: 0; }
.status-dot.playing { background: var(--green); animation: pulse 1.5s infinite; }
.status-dot.waiting { background: var(--text2); }

/* ── COUNTRY PICKER MODAL ──────────────────────────────────── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.8); z-index: 500; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 20px; max-width: 500px; width: 92%; max-height: 82vh; overflow-y: auto; }
.modal h2 { font-size: .88rem; margin-bottom: 12px; color: var(--text2); text-transform: uppercase; letter-spacing: 1px; }
.country-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px,1fr)); gap: 5px; }
.country-pick-btn {
  background: var(--surface2); border: 1px solid var(--border); border-radius: 7px;
  padding: 7px 10px; color: var(--text); cursor: pointer; font-size: 0.79rem;
  text-align: left; display: flex; align-items: center; gap: 6px;
}
.country-pick-btn:hover { border-color: var(--accent); }
.modal-close { background: transparent; border: 1px solid var(--border); color: var(--text2); border-radius: 7px; padding: 8px 16px; cursor: pointer; margin-top: 12px; width: 100%; font-size: 0.85rem; }
.modal-close:hover { border-color: var(--text); color: var(--text); }
.country-select-btn {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  border-radius: 7px; padding: 7px 12px; cursor: pointer; display: flex;
  align-items: center; gap: 7px; font-size: 0.85rem;
}
.country-select-btn:hover { border-color: var(--accent); }

/* ── RESULT OVERLAY ────────────────────────────────────────── */
.result-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.82); z-index: 300; align-items: center; justify-content: center; }
.result-overlay.show { display: flex; }
.result-card { background: var(--surface); border-radius: 16px; padding: 32px 40px; text-align: center; max-width: 340px; }
.result-card h2 { font-size: 1.9rem; margin-bottom: 8px; }
.result-card.win  { border: 2px solid var(--green); }
.result-card.loss { border: 2px solid var(--red); }
.result-card.draw { border: 2px solid var(--accent); }
.btn-join { background: var(--accent); color: #000; border: none; border-radius: 8px; padding: 10px 20px; font-size: 0.9rem; font-weight: 800; cursor: pointer; width: 100%; transition: opacity .15s; }
.btn-join:hover { opacity: .85; }

/* ── TOAST ─────────────────────────────────────────────────── */
.toast {
  position: fixed; top: 68px; left: 50%; transform: translateX(-50%);
  background: var(--green); color: #fff; font-weight: 800;
  padding: 9px 22px; border-radius: 30px; font-size: 0.9rem;
  z-index: 600; opacity: 0; transition: opacity .3s; pointer-events: none;
  white-space: nowrap;
}
.toast.show { opacity: 1; }

/* ── BLOG ──────────────────────────────────────────────────── */
.blog-main { max-width: 760px; margin: 0 auto; padding: 24px 18px 48px; }
.blog-main h1 { font-size: clamp(1.4rem,4vw,2rem); font-weight: 900; margin-bottom: 12px; letter-spacing: -.5px; }
.blog-meta { color: var(--accent); font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; }
.blog-intro { font-size: 1rem; color: var(--text2); line-height: 1.7; margin-bottom: 22px; }
.blog-main h2 { font-size: 1.1rem; font-weight: 800; margin: 26px 0 8px; color: var(--accent); }
.blog-main p { line-height: 1.75; color: #ccc; margin-bottom: 12px; font-size: 0.93rem; }
.related-posts { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--border); }
.related-posts h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text2); margin-bottom: 10px; }
.related-links { display: flex; flex-direction: column; gap: 7px; }
.related-links a { color: var(--accent); text-decoration: none; font-size: 0.88rem; }
.related-links a:hover { text-decoration: underline; }
.blog-cta { margin-top: 24px; }
.blog-cta a { display: block; background: var(--accent); color: #000; text-align: center; padding: 13px; border-radius: 10px; font-weight: 800; text-decoration: none; }
.blog-index { max-width: 880px; margin: 0 auto; padding: 24px 18px 48px; }
.blog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px,1fr)); gap: 14px; margin-top: 20px; }
.blog-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; text-decoration: none; color: var(--text); display: block; }
.blog-card:hover { border-color: var(--accent); }
.blog-card-tag { color: var(--accent); font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 7px; }
.blog-card h2 { font-size: 0.95rem; font-weight: 700; margin-bottom: 7px; line-height: 1.4; }
.blog-card p { color: var(--text2); font-size: 0.8rem; line-height: 1.5; }

footer { text-align: center; padding: 22px; color: var(--text2); font-size: 0.78rem; border-top: 1px solid var(--border); margin-top: 24px; }
footer a { color: var(--text2); }
footer a:hover { color: var(--text); }

/* ── LEGAL PAGES ───────────────────────────────────────────── */
.legal-main { max-width: 820px; margin: 0 auto; padding: 34px 18px 64px; }
.legal-main h1 { color: var(--accent); font-size: clamp(1.6rem,4vw,2.35rem); margin-bottom: 8px; }
.legal-updated { color: var(--text2); font-size: 0.82rem; margin-bottom: 24px; }
.legal-main h2 { color: var(--text); font-size: 1.05rem; margin: 26px 0 8px; }
.legal-main p, .legal-main li { color: #c8c8c8; font-size: 0.92rem; line-height: 1.75; margin-bottom: 10px; }
.legal-main ul { padding-left: 22px; margin-bottom: 14px; }
.legal-main a { color: var(--accent); }

/* ── MUSIC PANEL ───────────────────────────────────────────── */
.music-panel {
  background: #0d0d0d; border-bottom: 1px solid var(--border);
  overflow: hidden; max-height: 0; transition: max-height .3s ease;
}
.music-panel.open { max-height: 60px; }
.music-inner {
  display: flex; align-items: center; gap: 10px; padding: 8px 16px;
  flex-wrap: wrap;
}
.music-label { font-size: 0.72rem; color: var(--text2); font-weight: 700; text-transform: uppercase; letter-spacing: 1px; white-space: nowrap; }
.genre-btns { display: flex; gap: 6px; }
.genre-btn {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text2);
  border-radius: 6px; padding: 4px 12px; font-size: 0.78rem; cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.genre-btn:hover { border-color: var(--accent); color: var(--text); }
.genre-btn.active { border-color: var(--accent); color: var(--accent); background: #1a1400; font-weight: 700; }
.music-vol-wrap { display: flex; align-items: center; gap: 5px; }
.music-vol-icon { font-size: 0.85rem; }
.music-vol { width: 80px; accent-color: var(--accent); cursor: pointer; }
.music-stop-btn {
  background: transparent; border: 1px solid var(--border); color: var(--text2);
  border-radius: 6px; padding: 4px 10px; font-size: 0.75rem; cursor: pointer;
}
.music-stop-btn:hover { border-color: var(--red); color: var(--red); }
.music-close-btn {
  background: transparent; border: none; color: var(--text2); font-size: 0.85rem;
  cursor: pointer; padding: 2px 6px; margin-left: auto;
}
.music-close-btn:hover { color: var(--text); }

/* ── THEME PANEL ───────────────────────────────────────────── */
.theme-panel {
  background: #0d0d0d; border-bottom: 1px solid var(--border);
  overflow: hidden; max-height: 0; transition: max-height .3s ease;
}
.theme-panel.open { max-height: 52px; }
.theme-inner {
  display: flex; align-items: center; gap: 8px; padding: 8px 16px;
}
.theme-btn {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text2);
  border-radius: 6px; padding: 4px 14px; font-size: 0.78rem; cursor: pointer;
  transition: border-color .15s, color .15s;
}
.theme-btn:hover { border-color: var(--accent); color: var(--text); }
.theme-btn.active { border-color: var(--accent); color: var(--accent); background: #1a1400; font-weight: 700; }

/* ── BOARD THEMES ──────────────────────────────────────────── */
[data-theme="wood"] .sq.light   { background: #c8a96e; }
[data-theme="wood"] .sq.dark    { background: #7a4c1e; }
[data-theme="marble"] .sq.light { background: #e0e0e0; }
[data-theme="marble"] .sq.dark  { background: #8a8a8a; }
[data-theme="ocean"] .sq.light  { background: #a8d8ea; }
[data-theme="ocean"] .sq.dark   { background: #2c6e8c; }

/* ── OPENING NAME ──────────────────────────────────────────── */
.vs-center { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.opening-name {
  font-size: 0.65rem; color: var(--accent); font-weight: 700; letter-spacing: 0.5px;
  text-transform: uppercase; white-space: nowrap; min-height: 14px; text-align: center;
}

/* ── PERSONAL STATS ────────────────────────────────────────── */
.my-stats {
  display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 14px; margin-bottom: 12px; font-size: 0.8rem; color: var(--text2);
}
.my-stats strong { color: var(--accent); }

/* ── STREAK BADGE ──────────────────────────────────────────── */
.streak-badge {
  background: linear-gradient(135deg, #e07b00, #f0c040); color: #000;
  font-size: 0.68rem; font-weight: 800; padding: 3px 9px; border-radius: 20px;
  white-space: nowrap;
}

/* ── SHARE BUTTON ──────────────────────────────────────────── */
.share-btn {
  background: #1da1f2; color: #fff; border: none; border-radius: 8px;
  padding: 9px 18px; font-size: 0.85rem; font-weight: 700; cursor: pointer;
  width: 100%; transition: opacity .15s;
}
.share-btn:hover { opacity: .88; }

/* ── HOW TO PLAY PAGE ──────────────────────────────────────── */
.nav-active { color: var(--accent) !important; }
.htp-wrap { max-width: 860px; margin: 0 auto; padding: 30px 16px 60px; }
.htp-hero { text-align: center; margin-bottom: 44px; }
.htp-hero h1 { font-size: clamp(1.7rem,4vw,2.5rem); color: var(--accent); }
.htp-sub { color: var(--text2); font-size:.92rem; margin-top:10px; max-width:580px; margin-left:auto; margin-right:auto; line-height:1.6; }
.htp-section { margin-bottom: 52px; }
.htp-section > p { color: var(--text2); font-size:.88rem; line-height:1.6; margin-bottom:14px; }
.htp-section h2 { font-size:1.2rem; color:var(--accent); border-bottom:1px solid #2a2a2a; padding-bottom:8px; margin-bottom:16px; }
.htp-rule-box { background:#110f00; border:1px solid var(--accent); border-radius:6px; padding:11px 15px; font-size:.82rem; color:var(--text2); line-height:1.55; margin-top:12px; }
.htp-rule-box strong { color:var(--text); }
.htp-gold-sq { background:rgba(240,192,64,.28); border-radius:3px; padding:0 4px; font-size:.82rem; color:var(--accent); }

/* Starting board */
.htp-start-board { margin:18px auto; max-width:380px; }
.htp-sb-grid { display:grid; grid-template-columns:18px repeat(8,1fr); }
.hs { aspect-ratio:1; display:flex; align-items:center; justify-content:center; font-size:clamp(.9rem,3vw,1.6rem); }
.hl { background:#f0d9b5; }
.hd { background:#b58863; }
.htp-rl { font-size:.6rem; color:var(--text2); display:flex; align-items:center; justify-content:center; }
.htp-fl { font-size:.6rem; color:var(--text2); text-align:center; padding-top:2px; }
.htp-caption { color:var(--text2); font-size:.78rem; text-align:center; margin-top:8px; line-height:1.5; }

/* Piece cards */
.piece-cards { display:grid; grid-template-columns:repeat(auto-fill,minmax(230px,1fr)); gap:14px; margin-top:14px; }
.piece-card { background:var(--surface); border:1px solid #252525; border-radius:8px; padding:14px; }
.pc-header { display:flex; align-items:center; gap:10px; margin-bottom:8px; }
.pc-icon { font-size:1.5rem; }
.pc-header h3 { margin:0; font-size:.95rem; color:var(--accent); }
.piece-card p { color:var(--text2); font-size:.8rem; line-height:1.5; }

/* Mini boards */
.mini-board-wrap { display:flex; justify-content:center; margin:8px 0; }
.mini-board { display:grid; grid-template-columns:repeat(8,1fr); width:152px; aspect-ratio:1; border:1.5px solid #333; }
.ms { aspect-ratio:1; display:flex; align-items:center; justify-content:center; font-size:.85rem; }
.ml { background:#f0d9b5; }
.md { background:#b58863; }
.mp { background:rgba(255,210,0,.22) !important; }
.mm { background:rgba(240,192,64,.62) !important; }
.mc { background:rgba(220,55,55,.52) !important; }

/* Check/checkmate demo */
.htp-checkmate-demo { display:flex; gap:20px; flex-wrap:wrap; justify-content:center; margin-top:16px; }
.htp-demo-label { text-align:center; font-size:.78rem; color:var(--text2); margin-bottom:4px; }

/* Concepts */
.htp-concepts { display:grid; grid-template-columns:repeat(auto-fill,minmax(200px,1fr)); gap:12px; }
.htp-concept { background:var(--surface); border:1px solid #252525; border-radius:8px; padding:16px; text-align:center; }
.concept-icon { font-size:1.8rem; margin-bottom:8px; }
.htp-concept h3 { color:var(--accent); font-size:.9rem; margin-bottom:6px; }
.htp-concept p { color:var(--text2); font-size:.78rem; line-height:1.5; }

/* Special moves */
.htp-specials { display:grid; grid-template-columns:repeat(auto-fill,minmax(220px,1fr)); gap:14px; }
.htp-special { background:var(--surface); border:1px solid #252525; border-radius:8px; padding:14px; }
.htp-special h3 { color:var(--accent); font-size:.9rem; margin-bottom:8px; }
.htp-special p { color:var(--text2); font-size:.78rem; line-height:1.5; margin-top:6px; }
.htp-rule-note { font-style:italic; opacity:.75; }

/* Tips */
.htp-tips { display:flex; flex-direction:column; gap:10px; }
.htp-tip { display:flex; align-items:flex-start; gap:12px; background:var(--surface); border:1px solid #252525; border-radius:8px; padding:13px 14px; }
.tip-num { background:var(--accent); color:#000; width:24px; height:24px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-weight:800; font-size:.76rem; flex-shrink:0; margin-top:1px; }
.htp-tip div { color:var(--text2); font-size:.83rem; line-height:1.55; }
.htp-tip strong { color:var(--text); }

/* CTA */
.htp-cta { text-align:center; background:var(--surface); border:1px solid #2a2a2a; border-radius:10px; padding:36px 20px; }
.htp-cta h2 { color:var(--accent); font-size:1.35rem; margin-bottom:10px; }
.htp-cta p { color:var(--text2); font-size:.87rem; line-height:1.6; margin-bottom:20px; max-width:480px; margin-left:auto; margin-right:auto; }
.htp-play-btn { display:inline-block; background:var(--accent); color:#000; font-weight:800; font-size:.95rem; padding:12px 28px; border-radius:8px; text-decoration:none; transition:opacity .15s; }
.htp-play-btn:hover { opacity:.85; }

/* ── MOBILE ─────────────────────────────────────────────────── */
@media (max-width: 700px) {
  /* Nav: single scrollable row — prevents wrapping / overflow */
  nav {
    min-height: 48px; gap: 10px; padding: 0 12px;
    overflow-x: auto; overflow-y: visible;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  nav::-webkit-scrollbar { display: none; }
  nav .logo { font-size: 1rem; flex-shrink: 0; }
  nav a { font-size: 0.8rem; white-space: nowrap; flex-shrink: 0; }
  .rules-nav-btn { font-size: 0.78rem; white-space: nowrap; flex-shrink: 0; padding: 3px 8px; }
  .viewers-count { display: none; }

  /* Music / theme panels — give room for wrapped buttons */
  .music-panel.open { max-height: 130px; }
  .music-inner { flex-wrap: wrap; gap: 6px; }
  .theme-panel.open { max-height: 90px; }
  .theme-inner { flex-wrap: wrap; gap: 6px; }

  /* Sections */
  .featured-section, .play-section, .puzzle-section, .lb-section { padding: 0 10px; }

  /* Featured vs-bar — tighter on small screens */
  .featured-vs-bar { padding: 7px 8px; gap: 6px; }
  .feat-clock { font-size: 0.82rem; min-width: 46px; padding: 2px 7px; }
  .vs-side span:first-child { font-size: 1rem; }

  /* Result overlay — prevent overflow on 320px phones */
  .result-card { padding: 24px 18px; width: calc(100vw - 40px); max-width: 340px; }

  /* LB: hide W/D/L on small screens to prevent overflow */
  .lb-wld { display: none; }
  .lb-row { gap: 6px; }
  .lb-name { font-size: 0.8rem; }

  /* Mode buttons */
  .mode-select { gap: 7px; }
  .mode-btn { padding: 10px 6px; min-width: 0; }
  .mode-icon { font-size: 1.3rem; }
  .mode-label { font-size: 0.78rem; }
  .mode-sub { font-size: 0.65rem; }

  /* Play section header */
  .play-section-header { flex-wrap: wrap; gap: 8px; }

  /* Diff buttons — allow wrap */
  .bot-options { flex-wrap: wrap; }

  /* Chat panel — shorter on mobile */
  .chat-panel { height: 200px; }

  /* Toast — full width on mobile */
  .toast { width: 90%; text-align: center; white-space: normal; }

  /* Puzzle board — constrain to viewport */
  .puzzle-section .player-board { max-width: 320px; }
}

@media (max-width: 400px) {
  .diff-btns { gap: 4px; }
  .diff-btn { padding: 5px 9px; font-size: 0.75rem; }
  .feat-clock { font-size: 0.76rem; min-width: 42px; }
}
