/* Layout and UI styling for the backgammon canvas demo. */

:root {
  --bg: #111318;
  --panel: #1b1f28;
  --panel2: #232938;
  --line: #394155;
  --text: #eceef4;
  --muted: #b9c0d1;
  --accent: #7fd3ff;
  --gold: #e6c87a;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: linear-gradient(180deg, #0e1015, #171b24);
  color: var(--text);
}
.page { max-width: 1760px; margin: 0 auto; padding: 18px; }
.topbar {
  display: flex; justify-content: space-between; gap: 18px; align-items: flex-start;
  margin-bottom: 18px; flex-wrap: wrap;
}
h1 { margin: 0 0 8px; font-size: 32px; }
p { margin: 0; color: var(--muted); line-height: 1.45; }
.controls-wrap { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.controls { display: flex; gap: 10px; }
.toggle-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 700;
  user-select: none;
}
.toggle-row input { width: 18px; height: 18px; }
button {
  appearance: none; border: 1px solid #4f5b77; background: linear-gradient(180deg, #2f3a52, #20283a);
  color: var(--text); padding: 6px 10px; border-radius: 4px; cursor: pointer; font-weight: 700; font-size: 11px;
}
button.secondary { background: linear-gradient(180deg, #403030, #2e2323); border-color: #755757; }
button:disabled { opacity: .55; cursor: not-allowed; }
.layout { display: grid; grid-template-columns: minmax(760px, 1fr) 150px 240px; gap: 18px; align-items: stretch; }
.board-panel, .panel {
  background: linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,.01));
  border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 10px 32px rgba(0,0,0,.28);
}
.board-panel { padding: 14px; }
canvas { display: block; margin: 0 auto; background: #22170d; border-radius: 12px; }

.sidebar { display: flex; flex-direction: column; gap: 8px; }

.menu-panel-links { display: grid; gap: 4px; }
.menu-link {
  display: block;
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px solid rgba(230,200,122,.28);
  background: linear-gradient(180deg, rgba(255,255,255,.025), rgba(255,255,255,.01));
  color: var(--gold);
  text-decoration: none;
  font-weight: 700;
  font-size: 11px;
  line-height: 1.2;
}
.menu-link:hover {
  text-decoration: none;
  border-color: rgba(230,200,122,.55);
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.02));
}
.play-header-sub { justify-content: flex-start; }
.panel { padding: 8px 8px; }
.panel h2 { margin: 0 0 6px; font-size: 13px; }
.panel h3 { margin: 0 0 4px; font-size: 11px; color: var(--muted); }
#statusText, #selectedText { color: var(--muted); min-height: 26px; }
#historyList { margin: 0; color: var(--muted); font-size: 11px; }

/* Move log - grouped by player with checker-coloured backgrounds */
.move-log { display: flex; flex-direction: column; gap: 3px; max-height: 420px; overflow-y: auto; }
.move-group {
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 11px;
  line-height: 1.35;
}
.move-group-label {
  font-weight: 700;
  margin-bottom: 1px;
}
.move-group-line {
  padding-left: 0;
}
.move-group.player-group {
  background: var(--checker-player-bottom, #d8d0c2);
  color: var(--checker-player-text, #3c2d1c);
  border: 1px solid var(--checker-player-edge, #9b8763);
}
.move-group.computer-group {
  background: var(--checker-computer-bottom, #141927);
  color: var(--checker-computer-text, #eef2ff);
  border: 1px solid var(--checker-computer-edge, #8990a6);
}
.move-log-empty {
  font-size: 11px;
  color: var(--muted);
}
.note p { font-size: 14px; }
@media (max-width: 1400px) {
  .layout { grid-template-columns: 1fr; }
  .controls-wrap { align-items: flex-start; }
}

.topbar-full { margin-bottom: 24px; }
.account-box { margin-left: auto; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
.account-user { display: flex; align-items: center; gap: 10px; }
.account-links { display: flex; gap: 12px; flex-wrap: wrap; }
.account-links a, .small-link { color: var(--gold); text-decoration: none; }
.account-links a:hover, .small-link:hover { text-decoration: underline; }
.avatar-thumb { width: 52px; height: 52px; object-fit: cover; border-radius: 50%; border: 2px solid var(--line); }
.avatar-large { width: 120px; height: 120px; object-fit: cover; border-radius: 16px; border: 2px solid var(--line); }
.muted { color: var(--muted); }
.form-card { max-width: 720px; background: linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,.01)); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 32px rgba(0,0,0,.28); padding: 16px; }
.form-card.wide { max-width: 1200px; }
.stack-form { display: grid; gap: 14px; }
.stack-form label { display: grid; gap: 8px; color: var(--muted); font-weight: 700; }
.stack-form input, .stack-form textarea { width: 100%; padding: 8px 10px; border-radius: 4px; border: 1px solid var(--line); background: #131722; color: var(--text); font-size: 11px; }
.stack-form select, select { padding: 5px 8px; border-radius: 4px; border: 1px solid var(--line); background: #131722; color: var(--text); font-size: 11px; }
.admin-page .games-table td { font-size: 11px; vertical-align: middle; }
.admin-page .games-table th { font-size: 11px; }
.admin-page input[type="number"] { padding: 4px 6px; border-radius: 4px; border: 1px solid var(--line); background: #131722; color: var(--text); font-size: 11px; }
.flash { padding: 8px 10px; border-radius: 4px; background: #1d2f24; border: 1px solid #365442; margin-bottom: 10px; font-size: 11px; }
.flash.error { background: #321d20; border-color: #6f4048; }
.games-table { width: 100%; border-collapse: collapse; }
.games-table th, .games-table td { padding: 10px 8px; border-bottom: 1px solid rgba(255,255,255,.08); text-align: left; }
.actions-cell { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.small-btn { padding: 5px 10px; border-radius: 4px; }
.danger { background: linear-gradient(180deg, #5b2d34, #3b1c21); border-color: #82414c; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 12px; }
.replay-layout { display: grid; grid-template-columns: minmax(760px, 1fr) 320px; gap: 18px; align-items: start; }
.replay-side { display: grid; gap: 14px; }
#replayCanvas { width: 100%; height: auto; display: block; background: #22170d; border-radius: 12px; }
#replayList { margin: 0; padding-left: 18px; color: var(--muted); max-height: 420px; overflow: auto; }

.compact-header { margin-bottom: 10px; }
.header-row { display:flex; justify-content:space-between; align-items:center; gap:16px; }
.header-row-main { margin-bottom: 4px; }
.header-brand { display:flex; align-items:baseline; gap:14px; flex-wrap:wrap; }
.header-brand h1 { margin:0; font-size:30px; line-height:1.05; }
.header-tag, .header-sub-copy, .header-state { color: var(--muted); }
.header-state { text-align:right; font-weight:700; color: var(--gold); }
.slim-controls { display:flex; justify-content:flex-end; align-items:center; gap:16px; margin-bottom: 8px; }
@media (max-width: 1100px) {
  .header-row, .slim-controls { flex-direction:column; align-items:flex-start; }
  .header-state { text-align:left; }
}


.app-version {
  display: inline-block;
  margin-left: 10px;
  font-size: 16px;
  font-weight: 700;
  color: var(--gold);
  vertical-align: middle;
}


.preferences-page { padding-bottom: 28px; }
.pref-head { margin-bottom: 12px; }
.pref-tabs { display:flex; gap:10px; margin: 10px 0 18px; flex-wrap: wrap; }
.pref-tab {
  background: linear-gradient(180deg, #2b3244, #1e2432);
  border: 1px solid #4b5670;
}
.pref-tab.is-active {
  background: linear-gradient(180deg, #8b5a1a, #663f12);
  border-color: #d8a257;
}
.pref-panel { display:none; }
.pref-panel.is-active { display:block; }
.pref-panel-copy { margin-bottom: 14px; }
.theme-grid { display:grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.theme-card {
  position: relative;
  display: grid;
  gap: 10px;
  background: linear-gradient(180deg, rgba(255,255,255,.025), rgba(255,255,255,.01));
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 16px;
  padding: 14px;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.theme-card:hover { transform: translateY(-1px); border-color: rgba(230,200,122,.5); }
.theme-card.is-selected { border-color: #e6c87a; box-shadow: 0 0 0 2px rgba(230,200,122,.18) inset; }
.theme-card input { position:absolute; opacity:0; pointer-events:none; }
.theme-title { font-weight: 700; color: var(--text); }
.theme-preview { display:flex; align-items:center; justify-content:center; }
.board-preview { min-height: 130px; }
.mini-board-outer {
  width: 100%;
  max-width: 260px;
  aspect-ratio: 1.8 / 1;
  border-radius: 14px;
  padding: 12px;
  background: linear-gradient(180deg, var(--outer-top), var(--outer-bottom));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}
.mini-board-inner {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 10px;
  overflow: hidden;
  background: linear-gradient(180deg, var(--inner-top), var(--inner-bottom));
}
.mini-side { position:absolute; top:0; bottom:0; width: 12%; background: var(--side-rail); }
.mini-side.left { left:0; }
.mini-side.right { right:0; }
.mini-bar { position:absolute; top:0; bottom:0; left:50%; width: 7%; transform: translateX(-50%); background: var(--bar); }
.mini-main {
  position:absolute; left: 12%; right: 12%;
  background-size: 40px 100%;
}
.mini-main.top {
  top:0; bottom:50%;
  background-image: linear-gradient(120deg, transparent 0 22%, var(--point-light) 22% 50%, transparent 50%), linear-gradient(240deg, transparent 0 22%, var(--point-dark) 22% 50%, transparent 50%);
  background-position: 0 0, 20px 0;
}
.mini-main.bottom {
  top:50%; bottom:0;
  background-image: linear-gradient(60deg, transparent 0 22%, var(--point-light) 22% 50%, transparent 50%), linear-gradient(300deg, transparent 0 22%, var(--point-dark) 22% 50%, transparent 50%);
  background-position: 0 0, 20px 0;
}
.checker-preview { min-height: 92px; gap: 16px; }
.mini-checker {
  width: 64px; height: 64px; border-radius: 50%;
  background: linear-gradient(180deg, var(--checker-top), var(--checker-bottom));
  border: 3px solid var(--checker-edge);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 6px 18px rgba(0,0,0,.25);
}
.mini-vs { font-size: 20px; font-weight: 700; color: var(--muted); }
.difficulty-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.difficulty-card { text-align: center; }
.difficulty-preview { min-height: 64px; }
.difficulty-icon { font-size: 32px; line-height: 1; }
.difficulty-desc { display: block; font-size: 10px; line-height: 1.4; margin-top: 2px; }
.pref-actions { display:flex; align-items:center; gap:14px; margin-top: 20px; flex-wrap: wrap; }

@media (max-width: 900px) {
  .theme-grid { grid-template-columns: 1fr; }
}


/* Build v31 play-page layout: two-column with full canvas on the left
   and collapsible menu + move log on the right. Player cards, home
   columns, action buttons, and site title are drawn inside the canvas. */
.page.page-play {
  max-width: none;
  padding: 8px 10px 10px;
}
.page.page-play .app-header {
  display: none;
}
.play-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 10px;
  align-items: stretch;
  transition: grid-template-columns 0.25s ease;
}
.play-layout.sidebar-collapsed {
  grid-template-columns: minmax(0, 1fr) auto;
}
.play-board-panel {
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.play-sidebar-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.sidebar-toggle {
  flex-shrink: 0;
  align-self: flex-end;
  width: 26px;
  height: 26px;
  padding: 0;
  font-size: 16px;
  line-height: 1;
  text-align: center;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #2f3a52, #20283a);
  color: var(--gold);
}

@media (max-width: 1100px) {
  .play-layout {
    grid-template-columns: 1fr;
  }
  .play-layout.sidebar-collapsed {
    grid-template-columns: 1fr;
  }
}

/* -----------------------------------------------------------------------
   New Game Modal
   ----------------------------------------------------------------------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.65);
  align-items: center;
  justify-content: center;
}
.modal-overlay.is-open { display: flex; }
.modal-card {
  background: linear-gradient(180deg, #1e2230, #141820);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  width: 380px;
  max-width: 92vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
}
.modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.modal-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #e67e22;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}
.modal-header h3 {
  flex: 1;
  margin: 0;
  font-size: 16px;
  color: #eceef4;
}
.modal-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  font-size: 22px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.modal-close:hover { color: #fff; }
.modal-body { padding: 14px 18px; }
.modal-section { margin-bottom: 16px; }
.modal-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #eceef4;
  margin-bottom: 8px;
}
.modal-hint {
  margin: 6px 0 0;
  font-size: 10px;
  color: rgba(255,255,255,0.45);
  line-height: 1.3;
}
.toggle-group {
  display: flex;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.12);
}
.toggle-btn {
  flex: 1;
  padding: 8px 4px;
  background: rgba(255,255,255,0.04);
  border: none;
  border-right: 1px solid rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.65);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.toggle-btn:last-child { border-right: none; }
.toggle-btn:hover:not(.is-disabled) { background: rgba(255,255,255,0.08); color: #eceef4; }
.toggle-btn.is-active {
  background: rgba(255,255,255,0.14);
  color: #fff;
}
.toggle-btn.is-disabled {
  color: rgba(255,255,255,0.2);
  cursor: not-allowed;
}
.match-length-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.match-length-row input[type="range"] {
  flex: 1;
  accent-color: #e67e22;
  height: 6px;
}
.match-len-btns { display: flex; gap: 4px; }
.match-len-btn {
  width: 30px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.06);
  color: #eceef4;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.match-len-btn:hover { background: rgba(255,255,255,0.12); }
.modal-footer {
  display: flex;
  gap: 12px;
  padding: 12px 18px 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.modal-submit {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  border: none;
  background: #e67e22;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.modal-submit:hover { background: #d35f0f; }
.modal-cancel {
  flex: 0 0 auto;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.12);
  background: transparent;
  color: rgba(255,255,255,0.6);
  font-size: 13px;
  cursor: pointer;
}
.modal-cancel:hover { color: #fff; border-color: rgba(255,255,255,0.25); }

/* -----------------------------------------------------------------------
   Profile page - stats, heatmap, recent results
   ----------------------------------------------------------------------- */
.profile-page { padding-bottom: 28px; display: grid; gap: 14px; }

.profile-header-card { padding: 18px; }
.profile-header { display: flex; gap: 18px; align-items: flex-start; }
.profile-avatar-area { flex-shrink: 0; }
.profile-avatar {
  width: 80px; height: 80px; border-radius: 50%;
  object-fit: cover; border: 3px solid var(--line);
}
.profile-avatar-placeholder {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #8b5a1a, #663f12);
  color: #fff; font-size: 28px; font-weight: 700;
}
.profile-info { flex: 1; min-width: 0; }
.profile-name { margin: 0 0 4px; font-size: 22px; }
.profile-meta { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.profile-meta-item { color: var(--muted); font-size: 12px; }
.streak-badge {
  font-weight: 700; border-radius: 4px; padding: 1px 6px;
}
.streak-win { background: rgba(46, 160, 67, 0.2); color: #56d364; border: 1px solid rgba(46, 160, 67, 0.3); }
.streak-loss { background: rgba(201, 42, 42, 0.2); color: #f47067; border: 1px solid rgba(201, 42, 42, 0.3); }
.profile-bio { color: var(--muted); font-size: 12px; margin: 4px 0 0; line-height: 1.4; }
.profile-actions { display: flex; gap: 12px; margin-top: 8px; }
.profile-actions a { color: var(--gold); text-decoration: none; font-size: 12px; font-weight: 700; }
.profile-actions a:hover { text-decoration: underline; }

/* Stat cards */
.stat-cards-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px;
}
.stat-card {
  background: linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.01));
  border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px;
  text-align: center;
}
.stat-card-accent { border-color: rgba(230, 200, 122, 0.35); }
.stat-value { font-size: 26px; font-weight: 700; color: var(--text); line-height: 1.1; }
.stat-card-accent .stat-value { color: var(--gold); }
.stat-label { font-size: 11px; color: var(--muted); margin-top: 2px; }
.stat-detail { font-size: 10px; color: rgba(255,255,255,0.35); margin-top: 2px; }

/* Profile columns layout */
.profile-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 900px) { .profile-columns { grid-template-columns: 1fr; } }

.profile-section h3 { margin: 0 0 12px; font-size: 14px; color: var(--text); }

/* Activity heatmap */
.heatmap-wrap { overflow-x: auto; padding-bottom: 4px; }
.heatmap { display: inline-block; min-width: 100%; }
.heatmap-container { display: flex; gap: 4px; }
.heatmap-day-labels { display: grid; grid-template-rows: repeat(7, 12px); gap: 2px; padding-top: 16px; }
.heatmap-day-label { font-size: 9px; color: var(--muted); line-height: 12px; text-align: right; padding-right: 4px; }
.heatmap-grid-area { display: grid; gap: 2px; }
.heatmap-months-row { display: flex; gap: 2px; height: 14px; }
.heatmap-month-label { width: 12px; font-size: 9px; color: var(--muted); line-height: 14px; text-align: left; flex-shrink: 0; }
.heatmap-cells-row { display: flex; gap: 2px; }

.hm-cell {
  width: 12px; height: 12px; border-radius: 2px; flex-shrink: 0;
}
.hm-empty { background: transparent; }
.hm-lv-0 { background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.06); }
.hm-lv-1 { background: rgba(46, 160, 67, 0.25); border: 1px solid rgba(46, 160, 67, 0.35); }
.hm-lv-2 { background: rgba(46, 160, 67, 0.45); border: 1px solid rgba(46, 160, 67, 0.55); }
.hm-lv-3 { background: rgba(46, 160, 67, 0.65); border: 1px solid rgba(46, 160, 67, 0.7); }
.hm-lv-4 { background: rgba(46, 160, 67, 0.9); border: 1px solid rgba(46, 160, 67, 0.95); }

.heatmap-legend { display: flex; align-items: center; gap: 3px; margin-top: 8px; }
.hm-legend-text { font-size: 9px; color: var(--muted); padding: 0 3px; }

/* Difficulty breakdown bars */
.difficulty-stats { display: grid; gap: 10px; }
.diff-stat-row { display: grid; grid-template-columns: 90px 1fr auto; gap: 10px; align-items: center; }
.diff-stat-label { display: flex; align-items: center; gap: 6px; }
.diff-stat-icon { font-size: 12px; }
.diff-stat-name { font-size: 12px; font-weight: 700; color: var(--text); }
.diff-stat-bar-wrap {
  height: 8px; border-radius: 4px; background: rgba(255,255,255,0.06);
  overflow: hidden;
}
.diff-stat-bar {
  height: 100%; border-radius: 4px; min-width: 2px;
  background: linear-gradient(90deg, var(--gold), #e67e22);
  transition: width 0.3s ease;
}
.diff-stat-nums { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* Recent results list */
.recent-results { display: grid; gap: 4px; }
.recent-result-row {
  display: grid; grid-template-columns: 120px 80px 70px 60px 1fr auto;
  gap: 8px; align-items: center; padding: 6px 10px; border-radius: 6px;
  font-size: 11px; color: var(--muted);
}
.result-win { background: rgba(46, 160, 67, 0.06); border-left: 3px solid rgba(46, 160, 67, 0.5); }
.result-loss { background: rgba(201, 42, 42, 0.06); border-left: 3px solid rgba(201, 42, 42, 0.4); }
.rr-result { font-weight: 700; }
.result-win .rr-result { color: #56d364; }
.result-loss .rr-result { color: #f47067; }
.rr-diff { white-space: nowrap; }
.rr-moves, .rr-duration { color: rgba(255,255,255,0.4); }
.rr-date { color: rgba(255,255,255,0.35); }
.rr-replay { white-space: nowrap; }

@media (max-width: 700px) {
  .profile-header { flex-direction: column; align-items: center; text-align: center; }
  .profile-meta { justify-content: center; }
  .profile-actions { justify-content: center; }
  .stat-cards-row { grid-template-columns: repeat(2, 1fr); }
  .recent-result-row {
    grid-template-columns: 1fr 1fr;
    gap: 4px;
  }
  .diff-stat-row { grid-template-columns: 80px 1fr; }
  .diff-stat-nums { grid-column: 1 / -1; }
}

