/*
 * theme.css - the colours every other stylesheet builds on.
 *
 * Each colour is a custom property defined twice: once for the dark board
 * and once for the light one. theme-boot.js writes data-theme="dark" or
 * "light" onto <html> before the page paints, store.js rewrites it when the
 * gear menu is used, and the whole collection changes with it. No stylesheet below this one should contain a raw colour that needs to
 * differ between the two themes.
 */

:root,
:root[data-theme="dark"] {
  --page-bg: #092e20;
  --page-glow: #1a6b45;
  --page-glow-end: #072418;

  --text: #eaf3ee;
  --text-soft: #b7d3c4;
  --text-muted: #8fae9d;
  --text-faint: #7fa392;

  --surface: rgba(255, 255, 255, 0.07);
  --surface-hover: rgba(255, 255, 255, 0.13);
  --surface-strong: rgba(255, 255, 255, 0.16);
  --surface-stronger: rgba(255, 255, 255, 0.24);
  --border: rgba(255, 255, 255, 0.12);
  --border-soft: rgba(255, 255, 255, 0.16);
  --border-strong: rgba(255, 255, 255, 0.25);

  --panel-bg: rgba(0, 0, 0, 0.22);
  --panel-bg-strong: rgba(0, 0, 0, 0.3);
  --chip-bg: rgba(0, 0, 0, 0.28);
  --chip-text: #9fe0bd;
  --chip-players: #ffd08a;

  --accent: #f4c95d;
  --accent-hover: #ffd97a;
  --accent-text: #2a1d05;
  --link: #9fe0bd;

  --felt-inner: #219359;
  --felt-outer: #14603a;
  --felt-frame: #5a3a1e;

  --slot-border: rgba(255, 255, 255, 0.28);
  --slot-quiet: rgba(255, 255, 255, 0.12);
  --slot-label: rgba(255, 255, 255, 0.45);

  --overlay-bg: rgba(3, 24, 15, 0.85);
  --shadow: rgba(0, 0, 0, 0.45);
  --shadow-soft: rgba(0, 0, 0, 0.2);

  /* board games */
  --cell-bg: rgba(255, 255, 255, 0.12);
  --cell-hover: rgba(255, 255, 255, 0.22);
  --cell-revealed: rgba(0, 0, 0, 0.28);
  --grid-bg: rgba(0, 0, 0, 0.3);
  --reversi-cell: #1c7a4a;
  --reversi-cell-hover: #24925a;
  --wood: #b9843f;
  --wood-dark: #7a4f24;
  --wood-deep: #6b4423;
  --spike-light: #e8d3ac;
  --spike-dark: #8c5a2b;
  --wood-text: rgba(255, 255, 255, 0.8);

  --n1: #7ec8ff; --n2: #7ee08a; --n3: #ff8f8f; --n4: #c9a4ff;
  --n5: #ffb85c; --n6: #66e0d0; --n7: #e8e8e8; --n8: #b0b0b0;
}

:root[data-theme="light"] {
  --page-bg: #eaf0ec;
  --page-glow: #ffffff;
  --page-glow-end: #d5e2d9;

  --text: #14261d;
  --text-soft: #3c5a4a;
  --text-muted: #566f60;
  --text-faint: #66806f;

  --surface: rgba(255, 255, 255, 0.75);
  --surface-hover: rgba(255, 255, 255, 0.95);
  --surface-strong: rgba(0, 0, 0, 0.07);
  --surface-stronger: rgba(0, 0, 0, 0.12);
  --border: rgba(0, 0, 0, 0.14);
  --border-soft: rgba(0, 0, 0, 0.16);
  --border-strong: rgba(0, 0, 0, 0.28);

  --panel-bg: rgba(255, 255, 255, 0.78);
  --panel-bg-strong: rgba(0, 0, 0, 0.07);
  --chip-bg: rgba(0, 0, 0, 0.06);
  --chip-text: #17693f;
  --chip-players: #9a6014;

  --accent: #e0ac2e;
  --accent-hover: #f0be44;
  --accent-text: #2a1d05;
  --link: #17693f;

  --felt-inner: #57c491;
  --felt-outer: #35a06c;
  --felt-frame: #b08a5c;

  --slot-border: rgba(0, 0, 0, 0.3);
  --slot-quiet: rgba(0, 0, 0, 0.14);
  --slot-label: rgba(0, 0, 0, 0.4);

  --overlay-bg: rgba(240, 247, 242, 0.92);
  --shadow: rgba(0, 0, 0, 0.22);
  --shadow-soft: rgba(0, 0, 0, 0.12);

  --cell-bg: rgba(255, 255, 255, 0.8);
  --cell-hover: #ffffff;
  --cell-revealed: rgba(0, 0, 0, 0.1);
  --grid-bg: rgba(0, 0, 0, 0.18);
  --reversi-cell: #3aa771;
  --reversi-cell-hover: #45b981;
  --wood: #d5a969;
  --wood-dark: #a17040;
  --wood-deep: #8a5c31;
  --spike-light: #f4e6cd;
  --spike-dark: #b07a42;
  --wood-text: rgba(0, 0, 0, 0.68);

  --n1: #1560a8; --n2: #1d7a3a; --n3: #b12b2b; --n4: #6b3fb0;
  --n5: #a35d00; --n6: #14776c; --n7: #33383d; --n8: #5b6068;
}

/* The playing area keeps its own text colour in both themes. */
html { color-scheme: dark; }
html[data-theme="light"] { color-scheme: light; }
/*
 * menu.css - the gear button, its menu, and the statistics popup.
 *
 * Loaded by every page, so it must not assume anything about the page
 * underneath beyond the colour tokens in theme.css.
 */

.gear-button {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 1000020;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.gear-button:hover { background: var(--surface-hover); }
.gear-button.open { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

.gear-menu {
  position: fixed;
  top: 60px;
  right: 16px;
  z-index: 1000021;
  min-width: 210px;
  padding: 6px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  background: var(--page-bg);
  box-shadow: 0 12px 30px var(--shadow);
}

.gear-menu[hidden] { display: none; }

.gear-heading {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 6px 10px 8px;
}

.gear-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  padding: 9px 10px;
  cursor: pointer;
}

.gear-item:hover { background: var(--surface-hover); }
.gear-item.danger { color: #e06666; }
.gear-item.danger:hover { background: rgba(224, 102, 102, 0.16); }

.gear-note {
  margin: 6px 10px 4px;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--text-muted);
  max-width: 210px;
}

/* Keep page headers clear of the floating gear at every width. */
.game-header, header.hero { padding-right: 52px; }

/* ------------------------------------------------------------- the popup */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000030;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal {
  background: var(--page-bg);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  color: var(--text);
  width: 100%;
  max-width: 860px;
  max-height: 100%;
  display: flex;
  flex-direction: column;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 10px;
  border-bottom: 1px solid var(--border);
}

.modal-head h2 { margin: 0; font-size: 20px; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.modal-close:hover { color: var(--text); }

.modal-body { padding: 14px 20px; overflow-y: auto; }
.modal-scroll { overflow-x: auto; }

.modal-summary { margin: 0 0 12px; font-size: 14px; color: var(--text-soft); }
.modal-note { margin: 12px 0 0; font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.modal-empty { margin: 0; font-size: 14px; color: var(--text-soft); line-height: 1.6; }

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--border);
}

.stats-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
  white-space: nowrap;
}

.stats-table th,
.stats-table td {
  padding: 6px 12px 6px 0;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.stats-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.stats-table td.num, .stats-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.stats-table tr.variant td { color: var(--text-muted); font-size: 12px; border-bottom-style: dotted; }

.tool-btn {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
}

.tool-btn:hover { background: var(--surface-hover); }

/* ----------------------------------------------------------- players */

/* A player's face and name, wherever a game shows one. Clicking it opens
   the editor, so it gets a pointer even inside a label that ignores clicks. */
.player-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  pointer-events: auto;
  border-radius: 6px;
  padding: 0 3px;
  margin: 0 -3px;
  white-space: nowrap;
}
.player-tag:hover { background: rgba(255, 255, 255, 0.12); }
.player-tag .avatar { font-size: 1.25em; line-height: 1; }

.players-modal { width: min(560px, 94vw); }

.roster { display: flex; flex-direction: column; gap: 10px; }

.roster-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 12px;
  padding: 10px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.roster-row.showing { border-color: var(--accent); }

.avatar-button {
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: var(--surface-strong);
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.avatar-button:hover, .roster-row.showing .avatar-button { border-color: var(--accent); }

.roster-fields { flex: 1 1 200px; display: flex; flex-direction: column; gap: 6px; }

.roster-name {
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--page-bg);
  color: var(--text);
  width: 100%;
  box-sizing: border-box;
}
.roster-name:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.gender-toggle {
  display: inline-flex;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  width: max-content;
}
.gender-toggle button {
  font: inherit;
  font-size: 12px;
  padding: 4px 10px;
  border: none;
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
}
.gender-toggle button + button { border-left: 1px solid var(--border-strong); }
.gender-toggle button:hover { background: var(--surface-hover); }
.gender-toggle button.active { background: var(--accent); color: var(--accent-text); }

.roster-role { font-size: 12px; color: var(--text-muted); line-height: 1.4; }

.icon-gallery {
  flex: 1 1 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.icon-option {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: 2px solid transparent;
  background: var(--surface);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-option:hover { background: var(--surface-hover); }
.icon-option.active { border-color: var(--accent); background: var(--surface-strong); }
.tool-btn.danger { color: #e06666; border-color: rgba(224, 102, 102, 0.45); }
.tool-btn.danger:hover { background: rgba(224, 102, 102, 0.16); }
