/* =========================
     Theme Variables
  ========================== */
/* Neon grid */
/* Base page colors */
html,
body {
  background: var(--cc-bg, #0b0f16);
  min-height: 100dvh;
}

/* Put the background on HTML so it's reliable on iOS/Android */
html::before,
html::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

/* Neon grid + soft glow */
html::before {
  background: radial-gradient(
      1800px 700px at 50% -10%,
      rgba(125, 211, 252, 0.12),
      transparent 60%
    ),
    linear-gradient(transparent 31px, rgba(38, 49, 67, 0.5) 32px),
    linear-gradient(90deg, transparent 31px, rgba(38, 49, 67, 0.5) 32px);
  background-size: auto, 32px 32px, 32px 32px;
  opacity: 0.85;
  z-index: 0; /* <= not negative */
}

/* Ensure page content sits above */
body {
  position: relative;
  z-index: 1;
}

/* =========================
     Fonts & Global Resets
  ========================== */
@font-face {
  font-family: "Noto Sans Symbols 2";
  src: url("../assets/fonts/NotoSansSymbols2.woff2") format("woff2");
  font-display: swap;
  unicode-range: U+2654-265F; /* chess pieces */
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

html {
  background: var(--cc-bg, #0b0f16);
} /* base color on html */
body {
  background: transparent;
} /* keep grid visible */

body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Inter, Arial,
    sans-serif;
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 100vh;
  padding: 0 16px;
  margin-top: 4px;
}

@supports (height: 100dvh) {
  body {
    min-height: 100dvh;
  } /* mobile safe viewport */
}

/* Chess glyphs everywhere needed */
.sq span,
.piece-card span,
.pieceAnim.dragging,
.capturedFade {
  font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", "Arial Unicode MS",
    sans-serif !important;
}

/* Touch behavior */
#board,
.sq {
  touch-action: none;
}
#boardWrapper {
  touch-action: pan-y;
} /* allow vertical scroll on wrapper */

/* Hidden elements toggled by JS / responsive rules */
#modeSelect {
  display: none;
}
#sidePanel {
  display: none;
} /* default hidden; enabled on desktop */

/* =========================
     Board, Wrapper, Status
  ========================== */
/* Unified card wrapper for board + status */
#boardWrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: min(82vw, 760px);
  max-width: min(82vw, 760px);
  margin: 0 auto;
  background: #1b1f26; /* matches status */
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

#board {
  width: 100%;
  max-width: min(78vw, 720px); /* keeps mobile cap consistent */
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border-radius: 0; /* join wrapper cleanly */
  overflow: hidden;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
  position: relative;
  line-height: 1; /* prevent glyph baseline shift */
}

/* Status bar attaches under the board */
#status {
  width: 100%;
  background: #1b1f26;
  color: #f8f8f8;
  text-align: center;
  font-weight: 600;
  font-size: 1rem;
  padding: 10px 0;
  border-radius: 0 0 10px 10px;
  border-top: 1px solid #11141a; /* subtle separator */
  box-sizing: border-box;
  transition: background 0.3s, color 0.3s;
}
#status.info {
  background: #1d2a36;
  color: #dbeafe;
  border-color: #334155;
}
#status.success {
  background: #15291f;
  color: #d1fae5;
  border-color: #1f3b2e;
}
#status.warning {
  background: #3a2020;
  color: #ffb3b3;
  border-color: #5b2a2a;
}

/* Timer centered above board */
#timerDisplay {
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  width: 100%;
  font-weight: 600;
  margin-bottom: 6px;
}

/* Top / bottom button rows near board */
#topButtons,
#btmButtons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
#topButtons {
  margin-bottom: 2px;
}
#btmButtons {
  margin-top: 6px;
}

/* =========================
     Squares & Hints
  ========================== */
.sq {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  font-size: clamp(28px, 6vw, 52px);
  cursor: pointer;
  user-select: none;
  position: relative;
  transition: transform 0s;
  line-height: 1;
}
.sq.light {
  background: #eaeff6;
  color: #0b1320;
}
.sq.dark {
  background: #90a4b5;
  color: #0b1320;
}

.sq[data-selected="true"] {
  outline: 3px solid #facc15;
}
.sq[data-lastmove="true"] {
  outline: 3px solid #38bdf8;
}

.sq[data-hint="true"]::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40%;
  height: 40%;
  border-radius: 50%;
  background: rgba(34, 197, 94, 0.55);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.sq[data-hint="true"]:has(span)::after {
  width: 70%;
  height: 70%;
  background: rgba(34, 197, 94, 0.35);
}

.sq.hoverable:hover {
  outline: 4px solid #facc15;
  box-shadow: 0 0 10px #facc15;
  z-index: 1;
}

/* File letters → bottom-right; Rank numbers → top-left */
.coord-file,
.coord-rank {
  position: absolute;
  font-size: 11px; /* tweak if you want */
  font-weight: 700; /* ← bold */
  opacity: 0.9;
  pointer-events: none;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35); /* readability on dark squares */
}
.coord-file {
  bottom: 2px;
  right: 4px;
}
.coord-rank {
  top: 2px;
  left: 4px;
}

/* Board flip */
.flipped #board {
  transform: rotate(180deg);
}

/* Board themes */
.theme-classic .sq.light {
  background: #eaeff6;
}
.theme-classic .sq.dark {
  background: #90a4b5;
}
.theme-green .sq.light {
  background: #eeeed2;
}
.theme-green .sq.dark {
  background: #769656;
}
.theme-pink .sq.light {
  background: #fde2e4;
}
.theme-pink .sq.dark {
  background: #f48fb1;
}
.theme-yellow .sq.light {
  background: #fff9c4;
}
.theme-yellow .sq.dark {
  background: #fbc02d;
}
.theme-brown .sq.light {
  background: #f0d9b5;
}
.theme-brown .sq.dark {
  background: #b58863;
}

/* =========================
     Buttons
  ========================== */
button {
  all: unset;
  padding: 12px 18px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  color: #0b1320;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
  background: linear-gradient(90deg, #7dd3fc, #a78bfa); /* default */
}
button:hover {
  box-shadow: 0 6px 8px rgba(0, 0, 0, 0.25);
}
button:active {
  transform: scale(0.95);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.3);
}

#gameHint {
  margin-top: 10px;
  font-size: 12px;
  opacity: 0.95;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
#gameHint button {
  padding: 6px 10px;
  border-radius: 6px;
  background: #7dd3fc;
  cursor: pointer;
}
#linkMsg {
  margin-top: 4px;
  font-size: 12px;
  opacity: 0.9;
  text-align: center;
}
#promoModal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: none; /* hidden by default to avoid capturing touch events */
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  z-index: 3000;
}

/* =========================
     Material
  ========================== */

#matWrap {
  width: 100%;
  max-width: 600px;
  margin-bottom: 6px;
  background: #111827;
  border: 1px solid #374151;
  border-radius: 8px;
  padding: 8px 10px;
  box-sizing: border-box;
}
#matSummary {
  font-weight: 700;
  margin-bottom: 6px;
}
/* Two horizontal capture blocks: [white icons] | [black icons] */
.captures {
  display: flex; /* side-by-side */
  gap: 16px;
  justify-content: space-between;
  align-items: flex-start;
  font-size: 18px;
}

/* Each side behaves like a row of icons (won’t stack vertically) */
.captures > div {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  flex-wrap: nowrap; /* keep in one line; change to wrap if you prefer */
  gap: 6px; /* space between icons */
  min-height: 24px;
  overflow: hidden; /* prevent layout jump if long */
}

/* Individual captured pieces */
.captures div span {
  display: inline-block;
  line-height: 1;
}

/* =========================
     Menus (Settings / Online / AI)
  ========================== */
.settings-wrap {
  position: relative;
}

.menu-dropdown {
  position: absolute;
  top: 110%;
  background: #111827;
  border: 1px solid #374151;
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.35);
  z-index: 9999;
}
.menu-dropdown[hidden] {
  display: none;
}
.menu-dropdown .item {
  display: block;
  padding: 10px 12px;
  cursor: pointer;
  border-radius: 8px;
  font-weight: 600;
}
.menu-dropdown .item:hover {
  background: #1f2937;
}

#settingsMenu {
  min-width: 200px;
}

#onlineMenu,
#aiMenu {
  position: absolute;
  top: 110%;
  left: 0;
  background: #111827;
  border: 1px solid #374151;
  border-radius: 12px;
  min-width: 180px;
  padding: 6px;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.35);
  z-index: 9999;
}
#onlineMenu[hidden],
#aiMenu[hidden] {
  display: none;
}
#onlineMenu .item,
#aiMenu .item {
  display: block;
  padding: 10px 12px;
  cursor: pointer;
  border-radius: 8px;
  font-weight: 600;
}
#onlineMenu .item:hover,
#aiMenu .item:hover {
  background: #1f2937;
}
#onlineWrap {
  display: inline-block;
}

/* Settings toggle row: “✓” only when on */
.settings-menu .item.toggle input[type="checkbox"] {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}
.settings-menu .item.toggle {
  position: relative;
  padding-right: 28px;
}
.settings-menu .item.toggle::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-weight: 900;
  font-size: 16px;
  line-height: 1;
  color: #7dd3fc;
}
.settings-menu .item.toggle.on::after {
  content: "✓";
}

/* =========================
     Chat Dropdown
  ========================== */
#chatWrap {
  position: relative;
  display: none;
} /* shown in online mode via JS */

#chatMenu {
  position: fixed;
  top: 0;
  left: 0;
  width: 240px;
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 10px;
  padding: 8px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);
  z-index: 2000;
  display: none;
  flex-direction: column;
}
#chatMenu.open {
  display: flex;
}

#chatMessages {
  max-height: 220px;
  overflow-y: auto;
  color: #f9fafb;
  margin-bottom: 8px;
  font-size: 14px;
  padding-right: 4px;
}
#chatInput {
  flex: 1;
  padding: 6px;
  border-radius: 6px;
  border: 1px solid #4b5563;
  background: #111827;
  color: #f9fafb;
  font-size: 14px;
  outline: none;
}
#chatSend {
  margin-top: 6px;
  padding: 6px;
  border: none;
  border-radius: 6px;
  background: linear-gradient(45deg, #2563eb, #9333ea);
  color: white;
  cursor: pointer;
  align-self: flex-end;
  width: 70px;
}
#chatSend:hover {
  opacity: 0.85;
}

#chatBtn {
  position: relative;
}
#chatBtn::after {
  content: "";
  position: absolute;
  top: 5px;
  right: 5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: red;
  display: none;
}
#chatBtn.has-unread::after {
  display: block;
}

/* =========================
     Moves Card (Header/Body/Footer unified)
  ========================== */
#moveList.moves-card {
  background: #0c1220;
  border: 1px solid #273247;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
  display: flex;
  flex-direction: column;
}

.moves-footer {
  order: 0;
  display: flex;
  gap: 10px;
  padding: 12px;
  background: #0c1220;
  border-bottom: 1px solid #273247;
  align-items: center;
}
.moves-body {
  order: 1;
  display: grid;
  grid-auto-rows: 32px;
  grid-template-columns: 44px 1fr 1fr;
  max-height: calc(5 * 32px);
  overflow-y: auto;
  font-size: 13px;
  color: #e7edf6;
  scrollbar-width: thin;
  scrollbar-color: #273247 transparent;
}
.moves-body::-webkit-scrollbar {
  width: 8px;
}
.moves-body::-webkit-scrollbar-thumb {
  background: #273247;
  border-radius: 6px;
}
.moves-body::-webkit-scrollbar-track {
  background: transparent;
}

.moves-header {
  order: 2;
  display: grid;
  align-items: center;
  grid-template-columns: 88px 1fr 88px;
  gap: 10px;
  padding: 10px 14px;
  background: linear-gradient(#0f172a, #0d1526);
  color: #c8d2e0;
  font-weight: 700;
  font-size: 13px;
  border-top: 1px solid #273247;
}
.moves-header .hdr-left,
.moves-header .hdr-right {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
}
.moves-header .hdr-center {
  text-align: center;
  opacity: 0.85;
  font-variant-numeric: tabular-nums;
}

.hdr-btn {
  all: unset;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 28px;
  border-radius: 12px;
  font-size: 18px;
  background: #0f182a;
  border: 1px solid #273247;
  color: #cbd5e1;
  cursor: pointer;
}
.hdr-btn:hover {
  background: #111c32;
}
.hdr-btn:active {
  transform: scale(0.98);
}

.move-row {
  display: contents;
} /* keep grid columns aligned */
.mv-no,
.mv {
  padding: 6px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.moves-body .move-row:nth-child(odd) .mv,
.moves-body .move-row:nth-child(odd) .mv-no {
  background: rgba(255, 255, 255, 0.02);
}
.mv-no {
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
}
.mv {
  cursor: pointer;
}

/* Current/review highlights (win over stripes) */
.moves-body .mv.current-move,
.moves-body .mv.selected {
  background: rgba(125, 211, 252, 0.22) !important;
  outline: 1px solid rgba(125, 211, 252, 0.5) !important;
  border-radius: 6px;
  font-weight: 700;
  position: relative;
  z-index: 1;
}

/* Larger footer buttons */
.moves-btn {
  all: unset;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  background: #0f182a;
  border: 1px solid #273247;
  color: #cbd5e1;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
.moves-btn:hover {
  background: #111c32;
}

/* Compact icon button (e.g., Copy PGN) */
.moves-btn.compact {
  min-width: 34px;
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 18px;
  border-radius: 8px;
}

/* =========================
     Game Container (layout)
  ========================== */
#gameContainer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  gap: 8px;
  overflow: visible;
  min-height: 0;
  position: relative;
  height: auto;
}

/* =========================
     Promo Modal
  ========================== */
#promoModal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  z-index: 3000;
}
#promoBox {
  background: #1f2937;
  padding: 20px;
  border-radius: 12px;
  display: flex;
  gap: 12px;
}
.promoChoice {
  font-size: 40px;
  cursor: pointer;
  padding: 10px;
  border-radius: 8px;
  background: #374151;
}
.promoChoice:hover {
  background: #4b5563;
}

/* =========================
     Animations
  ========================== */
.pieceAnim.dragging {
  opacity: 0.9;
  cursor: grabbing;
  transition: none;
}
.capturedFade {
  transition: opacity 180ms ease;
  opacity: 1;
  z-index: 40;
}

/* =========================
     Mobile (<= 900px)
  ========================== */
@media (max-width: 900px) {
  /* Keep page stable & centered on phones */
  html,
  body {
    overflow-x: hidden !important;
    overflow-y: auto !important;
    width: 100vw !important;
    height: 100dvh !important;
    max-width: 100vw !important;
    margin: 0 !important;
    padding: 0 !important;
    touch-action: manipulation;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
  }
  html {
    background: var(--cc-bg, #0b0f16);
  }
  body {
    background: transparent !important;
  }

  /* Slight scale to fit */
  #controls,
  #status,
  #chat {
    transform: scale(0.9);
    transform-origin: top center;
  }

  /* Container & board sizing */
  #gameContainer {
    width: 100vw !important;
    max-width: 600px !important;
    padding: 0 !important;
    gap: 8px !important;
    margin: 0 auto !important;
    align-items: center;
    box-sizing: border-box;
    overflow-x: hidden !important;
  }

  #boardWrapper {
    width: 98vw !important;
    max-width: 98vw !important;
    height: auto !important;
    overflow: visible !important;
    margin: 0px auto 0 !important;
    position: relative !important;
    z-index: 1 !important;
  }
  #board {
    width: 98vw !important;
    max-width: 98vw !important;
    aspect-ratio: 1/1;
    margin: 0 auto;
  }

  /* Mobile-only wrappers for relocated blocks (if used) */
  #mobileTop,
  #mobileBottom {
    width: 98vw !important;
    max-width: 98vw !important;
    margin: 0 auto 10px !important;
    padding: 0 !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
  }
  #mobileTop #topButtons {
    display: flex;
    gap: 2px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 2px;
  }

  /* Hide side panel on mobile (board-first) */
  #sidePanel {
    display: none;
  }
}

/* Slightly narrower phones: widen header buttons & columns */
@media (max-width: 700px) {
  .moves-header {
    grid-template-columns: 96px 1fr 96px;
  }
  .hdr-btn {
    width: 60px;
    height: 44px;
    font-size: 20px;
    border-radius: 14px;
  }
  .moves-btn {
    min-width: 52px;
    height: 44px;
    font-size: 18px;
  }
}

/* =========================
     Desktop (>= 900px)
  ========================== */
@media (min-width: 900px) {
  #gameContainer {
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    max-width: 1320px;
    width: 95%;
    gap: 24px;
    overflow: visible;
  }

  #boardWrapper {
    flex: 0 0 auto;
    max-width: 760px;
    margin: 0;
  }

  #sidePanel {
    display: flex; /* shown on desktop */
    width: 300px;
    flex: 0 0 300px;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  #sidePanel > * {
    align-self: center;
    width: 100%;
  }

  #topButtons {
    display: flex;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 10px;
    width: 100%;
    margin-bottom: 12px;
  }
  #topButtons button {
    flex: 1;
    text-align: center;
    white-space: nowrap;
  }

  #matWrap {
    width: 310px;
  }

  /* Hide mobile-only holders */
  #mobileTop,
  #mobileBottom {
    display: none;
  }
}

/* =========================
     Orientation Guard
  ========================== */
@media (orientation: landscape) {
  html,
  body {
    transform: rotate(0deg);
    overflow: hidden;
    height: 100dvh;
    width: 100vw;
  }
}

/* =========================
     Header
  ========================== */
/* ===== Header (desktop + mobile) ===== */
:root {
  --hdr-h: 52px;
  --board-max: 720px; /* match your #board max-width */
  --piece-scale: 0.84; /* 0.80–0.92 looks best */
}

#board .sq span {
  /* makes pieces grow/shrink with the board; clamp for safety */
  font-size: clamp(
    40px,
    calc(min(100vw, var(--board-max)) / 8 * var(--piece-scale)),
    96px
  );
  line-height: 1;
}

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--hdr-h);
  box-sizing: border-box;
  background: #0c1220;
  border-bottom: 1px solid #273247;
  padding: 0 30px;
}

/* utility used by JS */
.hidden {
  display: none !important;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.brand-with-icon {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}
.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  /* invert so your black favicon shows on dark header */
  filter: invert(1) saturate(0);
  display: inline-block;
  object-fit: contain;
}
.brand-name {
  font-weight: 900;
  letter-spacing: 0.2px;
  font-size: 16px;
  color: #e7edf6;
  white-space: nowrap;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 0 0 auto;
}
.nav-left a,
.nav-left button {
  all: unset;
  cursor: pointer;
  color: #cbd5e1;
  font-weight: 800;
  padding: 8px 10px;
  border-radius: 10px;
}
.nav-left a:hover,
.nav-left button:hover {
  background: #111c32;
  color: #e7edf6;
}

.header-center {
  color: #cbd5e1;
  font-weight: 900;
  letter-spacing: 0.25em;
}

/* right side: burger + tray */
.nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  z-index: 6000;
}
.nav-toggle {
  background: transparent;
  border: 0;
  width: 36px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: none; /* hidden on desktop; shown on mobile below */
}
.burger {
  display: block;
  width: 22px;
  height: 2px;
  background: #e7edf6;
  margin: 0 auto;
  border-radius: 2px;
  position: relative;
}
.burger::before,
.burger::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: #e7edf6;
  border-radius: 2px;
}
.burger::before {
  top: -6px;
}
.burger::after {
  top: 6px;
}

/* header tray (the horizontal group of buttons) */
.tray {
  display: flex;
  align-items: center;
  gap: 10px;
  position: fixed;
  right: 10px;
  top: calc(var(--hdr-h) + 6px);
  background: #0f172a;
  border: 1px solid #273247;
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.35);
}
.tray[hidden] {
  display: none;
}
.tray-btn:hover {
  background: #111c32;
}

.tray-btn {
  all: unset;
  display: inline-flex; /* helps vertical centering */
  align-items: center;
  cursor: pointer;
  color: #e7edf6;
  font-weight: 700;
  padding: 8px 10px;
  border-radius: 10px;
  white-space: nowrap;
  line-height: 1; /* keep the arrow tight */
}

/* Base arrow: points DOWN by default */
#tabSettings,
#tabOnline,
#tabAI {
  position: relative;
  padding-right: 24px;
}
#tabSettings::after,
#tabOnline::after,
#tabAI::after {
  content: "";
  position: absolute;
  right: 8px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-60%) rotate(45deg); /* ▼ */
  opacity: 0.85;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

/* Pure-CSS rotation when the corresponding menu is VISIBLE */
@supports selector(:has(*)) {
  /* if menu is NOT [hidden] (i.e., visible) */
  body:has(#settingsMenu:not([hidden])) #tabSettings::after {
    transform: translateY(-40%) rotate(225deg); /* ▲ */
  }
  body:has(#onlineMenu:not([hidden])) #tabOnline::after {
    transform: translateY(-40%) rotate(225deg);
  }
  body:has(#aiMenu:not([hidden])) #tabAI::after {
    transform: translateY(-40%) rotate(225deg);
  }

  /* optional: if you sometimes use `.open` instead of removing [hidden] */
  body:has(#settingsMenu.open) #tabSettings::after,
  body:has(#onlineMenu.open) #tabOnline::after,
  body:has(#aiMenu.open) #tabAI::after {
    transform: translateY(-40%) rotate(225deg);
  }
}

/* Desktop: tray inline, burger hidden */
@media (min-width: 900px) {
  .nav-toggle {
    display: none;
  }
  .tray {
    position: static;
    right: auto;
    top: auto;
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: 0;
    gap: 12px;
  }
  .tray[hidden] {
    display: flex;
  } /* keep shown on desktop */
}

/* Mobile tweaks: show burger, no extra reserved space */
@media (max-width: 900px) {
  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .brand-name {
    display: none;
  }
  .header-center {
    display: none;
  } /* optional: hide “CHESS” on mobile to save space */

  /* Only reserve the header’s height — no extra gap */
  body {
    padding-top: calc(var(--hdr-h) + 2px) !important;
  }

  /* Keep the mobile tray snug under the header when opened */
  .tray {
    top: calc(var(--hdr-h) + 0px);
  }
}

/* Ensure page content starts below the fixed header on desktop as well */
body {
  margin: 0;
  padding-top: calc(var(--hdr-h) + 6px);
}

#topButtons {
  display: none !important;
}
/* == Floating dropdowns used by header tabs == */
.hdr-fly {
  position: fixed;
  z-index: 6000;
  background: #0f172a;
  border: 1px solid #273247;
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}
.hdr-fly[hidden] {
  display: none;
}
