: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;
}