@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('fonts/outfit-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('fonts/outfit-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #111010;
  --bg2: #181716;
  --bg3: #201f1d;
  --bg4: #2a2826;
  --border: #2e2c2a;
  --text: #c8c4bc;
  --text2: #edeae4;
  --muted: #635f58;
  --accent: #a594c0;
  --accent2: #7ea8c4;
  --accent3: #c07ea8;
  --radius: 8px;
}

body::-webkit-scrollbar {
  display: none;
   scrollbar-width: none;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0
}

body {
  font-family: 'Outfit', sans-serif;
  background: radial-gradient(circle at top, #1a1817, #0f0e0d);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* HEADER */
header {
  height: 64px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  background: linear-gradient(90deg, var(--bg2), var(--bg3));
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, .5);
}

.logo {
  font-weight: 700;
  color: var(--text2);
  font-size: 18px;
  letter-spacing: .5px;
}

.nav {
  display: flex;
  padding-left: 20px;
  gap: 24px;
  align-items: center;
}

.nav-item {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--muted);
  cursor: pointer;
  position: relative;
  transition: color .2s, transform .2s;
}

.nav-item:hover {
  color: var(--text2);
  transform: translateY(-1px);
}

.nav-item.active {
  color: var(--accent);
}

.nav-item::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -6px;
  width: 0%;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width .25s ease;
}

.nav-item:hover::after,
.nav-item.active::after {
  width: 100%;
}

/* MAIN */
main {
  flex: 1;
  padding-bottom: 40px;
}

.hero {
  padding: 70px 24px;
  text-align: center;
  max-width: 900px;
  margin: auto;
}

.hero h1 {
  font-size: 44px;
  background: linear-gradient(90deg, var(--text2), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 12px;
}

.hero p {
  color: var(--muted);
  margin-bottom: 28px;
}

.section {
  padding: 40px 24px;
}

.board-wrap {
  width: 100%;
  max-width: 620px;
  margin: auto;
}

#board {
  width: 100%;
}

.player-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  margin: 6px 0;
  background: linear-gradient(145deg, var(--bg2), var(--bg3));
  border: 1px solid var(--border);
  font-weight: 600;
  color: var(--text2);
  width: fit-content
}

.player-bar.top {
  box-shadow: 0 4px 14px rgba(0, 0, 0, .4);
}

.player-bar.bottom {
  box-shadow: 0 -4px 14px rgba(0, 0, 0, .4);
}

.player-bar .title {
  color: var(--accent);
  margin-right: 6px;
}

.player-bar .rating {
  color: var(--muted);
  margin-left: 8px;
}

.square-55d63 {
  position: relative;
}

.piece-417db {
  position: relative;
  z-index: 10;
}

.highlight-square {
  position: relative;
}

.highlight-square::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(120, 180, 255, 0.16);
  pointer-events: none;
  z-index: 0;
}

/* FOOTER */
footer {
  padding: 16px;
  text-align: center;
  border-top: 1px solid var(--border);
  background: linear-gradient(90deg, var(--bg2), var(--bg3));
  font-size: 12px;
  color: var(--muted);
  margin-top: auto;
}

.board-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  max-width: 1100px;
  margin: auto;
}

.mini-board {
  background: linear-gradient(145deg, var(--bg2), var(--bg3));
  border: 1px solid var(--border);
  padding: 8px;
  border-radius: var(--radius);
  width: 100%;
  max-width: 180px;
}

#main-board {
  width: 100%;
  max-width: 520px;
  margin: auto;
}

#boards-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  max-width: 1200px;
  margin: auto;
}

.board-block {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.full-board {
  width: 520px;
}

#puzzle-popup {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.popup-box {
  background: #1a1817;
  border: 1px solid #333;
  padding: 20px;
  border-radius: 10px;
  text-align: center;
  color: white;
  min-width: 220px;
}

.popup-actions {
  margin-top: 15px;
  display: flex;
  gap: 10px;
  justify-content: center;
}

.popup-actions button {
  padding: 8px 12px;
  cursor: pointer;
  background: #333;
  color: white;
  border: none;
  border-radius: 6px;
}

.popup-actions button:hover {
  background: #555;
}

.hidden {
  display: none !important;
}

/* red highlight */
.wrong-square {
  position: relative;
}

.wrong-square::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 60, 60, 0.35);
  pointer-events: none;
}

.puzzle-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

#side-panel {
  width: 180px;
  padding: 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text2);
}

#puzzle-info {
  width: 200px;
}

.info-box {
  background: #1a1817;
  border: 1px solid #333;
  padding: 12px;
  border-radius: 10px;
  color: #eaeaea;
  font-family: sans-serif;
}

.info-box h3 {
  margin-bottom: 10px;
  font-size: 16px;
  color: #fff;
}

.info-box p {
  margin: 8px 0;
  font-size: 14px;
}

.wrong-square::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 0, 0, 0.35);
}

.correct-square::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 255, 120, 0.25);
}

.wrong-square::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 0, 0, 0.25);
}

.puzzle-layout {
  display: flex;
  gap: 16px;
  align-items: stretch;
  max-width: 900px;
  margin: auto;
}

/* BOARD */
.board-wrapper {
  flex: 0 0 60%;
}

/* PANEL */
#puzzle-panel {
  flex: 0 0 40%;
  display: flex;
}

.panel-box {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;

  display: flex;
  flex-direction: column;
}

.panel-title {
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text2);
}

.panel-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  color: var(--muted);
}

.panel-row b {
  color: var(--text2);
}

/* POPUP */
#puzzle-popup {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.popup-box {
  background: #1a1817;
  border: 1px solid #333;
  padding: 20px;
  border-radius: 10px;
  text-align: center;
  color: white;
}

.popup-actions {
  margin-top: 15px;
  display: flex;
  gap: 10px;
  justify-content: center;
}

.popup-actions button {
  padding: 8px 12px;
  cursor: pointer;
  background: #333;
  color: white;
  border: none;
  border-radius: 6px;
}

.popup-actions button:hover {
  background: #555;
}

.hidden {
  display: none !important;
}

/* highlights */
.wrong-square::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 0, 0, 0.25);
}

.correct-square::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 255, 120, 0.25);
}

.highlight-square {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* make squares position:relative so ::after works */
.square-55d63 {
  position: relative;
}

.highlight-green::after,
.highlight-red::after,
.highlight-blue::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.highlight-green::after {
  background: rgba(0, 255, 120, 0.45);
}

.highlight-red::after {
  background: rgba(255, 60, 60, 0.45);
}

.highlight-blue::after {
  background: rgba(120, 180, 255, 0.35);
}

/* COG */
.nav-spacer { flex: 1; }

.settings-wrap {
  position: relative;
}

.cog-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: color .2s, transform .3s;
}

.cog-btn:hover, .cog-btn.active {
  color: var(--text2);
}

.cog-btn.active svg {
  transform: rotate(60deg);
}

.cog-btn svg {
  transition: transform .3s ease;
}

.cog-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 140px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  overflow: hidden;
  z-index: 999;
}

.cog-item {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: background .15s, color .15s;
}

.cog-item:hover {
  background: var(--bg4);
  color: var(--text2);
}

.cog-item.cog-user {
  color: var(--muted);
  font-size: 12px;
  cursor: default;
}

.cog-item.cog-user:hover {
  background: none;
  color: var(--muted);
}

.cog-divider {
  height: 1px;
  background: var(--border);
}

/* AUTH PAGES */
.auth-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 64px - 48px);
  padding: 40px 24px;
}

.auth-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 16px 48px rgba(0,0,0,.4);
}

.auth-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text2);
  margin-bottom: 6px;
}

.auth-sub {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 28px;
}

.auth-field {
  margin-bottom: 16px;
}

.auth-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.auth-field input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text2);
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color .2s;
}

.auth-field input:focus {
  border-color: var(--accent);
}

.auth-btn {
  width: 100%;
  padding: 12px;
  margin-top: 8px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .2s;
}

.auth-btn:hover { opacity: .85; }

.auth-error {
  background: rgba(255, 60, 60, 0.12);
  border: 1px solid rgba(255, 60, 60, 0.3);
  color: #ff6b6b;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 12px;
}

.auth-switch {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--muted);
}

.auth-switch a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.auth-switch a:hover { text-decoration: underline; }

.nav-username {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  margin-right: 12px;
  align-self: center;
}

/* LIGHT MODE */
body.light-mode {
  background: radial-gradient(circle at top, #f0ede8, #e8e4de);
  color: #3a3530;
}

body.light-mode {
  --bg: #f0ede8;
  --bg2: #ffffff;
  --bg3: #f5f2ee;
  --bg4: #ebe7e1;
  --border: #d4cec6;
  --text: #3a3530;
  --text2: #1a1714;
  --muted: #8a8278;
  --accent: #7a6a9a;
  --accent2: #5a88a4;
  --accent3: #a05a88;
}

body.light-mode header,
body.light-mode footer {
  background: linear-gradient(90deg, #ffffff, #f5f2ee);
}

body.light-mode .cog-dropdown {
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
}

body.light-mode .auth-box {
  box-shadow: 0 16px 48px rgba(0,0,0,.1);
}

/* BOARD THEMES */
[data-board-theme="classic"] .white-1e1d7 { background-color: #f0d9b5; }
[data-board-theme="classic"] .black-3c85d { background-color: #b58863; }

[data-board-theme="green"] .white-1e1d7 { background-color: #ffffdd; }
[data-board-theme="green"] .black-3c85d { background-color: #86a666; }

[data-board-theme="blue"] .white-1e1d7 { background-color: #dee3e6; }
[data-board-theme="blue"] .black-3c85d { background-color: #8ca2ad; }

[data-board-theme="purple"] .white-1e1d7 { background-color: #f0e6ff; }
[data-board-theme="purple"] .black-3c85d { background-color: #9b72cf; }

.legal-dot::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 30%;
  height: 30%;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 50%;
  pointer-events: none;
  z-index: 5;
}

/* Larger ring for squares with a piece on them */
.legal-dot-capture::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 6px solid rgba(0, 0, 0, 0.25);
  pointer-events: none;
  z-index: 5;
}

/* INBOX BADGE */
.inbox-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: #e05c5c;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.settings-wrap {
  position: relative;
}

/* Original theme, with the retained accessibility and layout safeguards. */
:root { --muted: #aaa297; --border-strong: var(--border); --success: #52a876; --danger: #e05555; }
body { overflow-x: hidden; min-width: 0; }
body::-webkit-scrollbar { display: initial; width: 10px; }
body::-webkit-scrollbar-thumb { background: var(--bg4); border: 2px solid var(--bg); border-radius: 8px; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--accent2) !important; outline-offset: 3px !important; }
[hidden] { display: none !important; }
.skip-link { position: fixed; z-index: 10001; top: 10px; left: 12px; padding: 10px 14px; color: var(--bg); background: var(--text2); border-radius: 6px; font-weight: 700; transform: translateY(-180%); }
.skip-link:focus { transform: translateY(0); }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
header.site-header { min-width: 0; }
.logo { text-decoration: none; white-space: nowrap; }
.logo-mark { margin-right: 5px; }
.nav { min-width: 0; }
.nav-item { text-decoration: none; }
.nav-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.nav-toggle { display: none; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text2); background: var(--bg3); font: inherit; }
.cog-btn { min-width: 36px; min-height: 36px; font-size: 20px; }
.cog-item { display: block; text-decoration: none; font: inherit; text-align: left; }
button.cog-item { width: 100%; border: 0; background: transparent; }
.cog-heading, .cog-note { padding: 10px 14px; color: var(--muted); font-size: 12px; }
.nav-username { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-title { margin-right: 5px; }
.challenge-item { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.challenge-label { color: var(--text2); font-size: 13px; overflow-wrap: anywhere; }
.challenge-actions { display: flex; gap: 6px; margin-top: 8px; }
.challenge-actions button { min-height: 36px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; color: var(--text2); background: var(--bg4); font: inherit; cursor: pointer; }
.challenge-accept { border-color: var(--accent) !important; }
#board { aspect-ratio: 1; }
.square-55d63.highlight-square { position: relative; inset: auto; }
.square-55d63.highlight-square::after { z-index: 2; }
.live-status, .board-status { color: var(--muted); font-size: 13px; line-height: 1.5; margin-bottom: 8px; }
.live-status[data-state="error"], .board-status[data-state="error"] { color: var(--danger); }
.puzzle-layout { min-width: 0; }
.board-wrapper { flex: 1 1 60%; min-width: 0; }
#puzzle-panel { flex: 1 1 40%; min-width: 0; }
.panel-row { gap: 12px; }
.panel-row b { overflow-wrap: anywhere; text-align: right; }
.move-entry { margin-top: 16px; }
.move-entry label { display: block; margin-bottom: 6px; color: var(--text2); font-size: 13px; }
.move-entry > div { display: flex; gap: 6px; }
.move-entry input { min-width: 0; width: 100%; min-height: 42px; padding: 8px; color: var(--text2); background: var(--bg); border: 1px solid var(--border); border-radius: 6px; font: inherit; }
.move-entry button, .panel-next { min-height: 42px; padding: 8px 12px; color: var(--text2); background: var(--bg4); border: 1px solid var(--border); border-radius: 6px; font: inherit; cursor: pointer; }
.move-entry small, .auth-field small { display: block; color: var(--muted); font-size: 11px; margin-top: 6px; }
.panel-next { margin-top: 16px; width: 100%; }
.popup-box { max-width: calc(100vw - 28px); }
.popup-actions { flex-wrap: wrap; }
.popup-actions button { min-height: 42px; }
.game-entry { width: 100%; font: inherit; color: inherit; text-align: left; }
button:disabled { opacity: .6; cursor: wait; }
.reduce-app-motion *, .reduce-app-motion *::before, .reduce-app-motion *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
@media (max-width: 980px) {
  .nav { gap: 16px; }
}
@media (max-width: 820px) {
  header.site-header { height: auto; min-height: 64px; flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
  .nav-toggle { display: inline-flex; margin-left: auto; }
  .nav-actions { margin-left: 0; }
  .nav { display: none; order: 4; width: 100%; padding: 8px 0; flex-wrap: wrap; gap: 18px 24px; }
  .nav.open { display: flex; }
  .nav-username { display: none !important; }
  .puzzle-layout { flex-direction: column; }
  .board-wrapper, #puzzle-panel { flex-basis: auto; width: 100%; }
  .board-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .hero h1 { font-size: clamp(30px, 9vw, 44px); overflow-wrap: anywhere; }
  .section { padding-inline: 14px; }
  .board-grid { grid-template-columns: minmax(0, 1fr); }
  .auth-box { max-width: calc(100vw - 28px); }
  .cog-dropdown { max-width: calc(100vw - 28px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
