:root {
  --bg: #14110f;
  --surface: #1e1a17;
  --surface-2: #2a241f;
  --gold: #e8b54a;
  --gold-deep: #b8862e;
  --cream: #f2e8d5;
  --smoke: #a89f93;
  --green: #6fbf73;
  --red: #e07a6b;
  --radius: 14px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--cream);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
}

h1, h2, h3, .serif {
  font-family: 'Playfair Display', Georgia, serif;
  letter-spacing: 0.02em;
}

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: 1060px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- Nav ---------- */
nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(20, 17, 15, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(232, 181, 74, 0.15);
}

.nav-inner {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 16px 24px;
  max-width: 1060px;
  margin: 0 auto;
}

.nav-brand {
  font-family: 'Playfair Display', serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--cream);
  display: flex;
  align-items: center;
  gap: 10px;
}
.nav-brand:hover { text-decoration: none; }
.nav-brand .knight { color: var(--gold); font-size: 1.6rem; }

.nav-links {
  margin-left: auto;
  display: flex;
  gap: 22px;
  font-size: 0.95rem;
}
.nav-links a { color: var(--smoke); }
.nav-links a.active, .nav-links a:hover { color: var(--gold); text-decoration: none; }

/* ---------- Hero ---------- */
.hero {
  text-align: center;
  padding: 90px 24px 70px;
  background:
    radial-gradient(ellipse 60% 50% at 50% 0%, rgba(232, 181, 74, 0.12), transparent),
    repeating-conic-gradient(rgba(232,181,74,0.022) 0% 25%, transparent 0% 50%) 50% / 90px 90px;
}

.hero .knight-big {
  font-size: 4.6rem;
  color: var(--gold);
  display: block;
  margin-bottom: 6px;
  text-shadow: 0 8px 40px rgba(232, 181, 74, 0.35);
}

.hero h1 {
  font-size: clamp(2.6rem, 7vw, 4.2rem);
  font-weight: 800;
  margin-bottom: 14px;
}

.hero .tagline {
  font-size: clamp(1.05rem, 2.5vw, 1.3rem);
  color: var(--smoke);
  max-width: 560px;
  margin: 0 auto 34px;
}

.btn {
  display: inline-block;
  padding: 14px 32px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 1.05rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover { transform: translateY(-2px); text-decoration: none; }

.btn-gold {
  background: linear-gradient(135deg, var(--gold), var(--gold-deep));
  color: #14110f;
  box-shadow: 0 6px 30px rgba(232, 181, 74, 0.35);
}
.btn-outline {
  border: 1px solid rgba(232, 181, 74, 0.5);
  color: var(--gold);
  margin-left: 12px;
}

.hero .fine { margin-top: 16px; font-size: 0.85rem; color: var(--smoke); }

/* ---------- Sections ---------- */
section { padding: 64px 0; }
section h2 {
  font-size: 2rem;
  margin-bottom: 36px;
  text-align: center;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

.card {
  background: var(--surface);
  border: 1px solid rgba(232, 181, 74, 0.1);
  border-radius: var(--radius);
  padding: 26px;
}
.card .icon { font-size: 2rem; margin-bottom: 12px; display: block; }
.card h3 { font-size: 1.2rem; margin-bottom: 8px; color: var(--gold); }
.card p { color: var(--smoke); font-size: 0.95rem; }

/* ---------- Leaderboard ---------- */
.board-wrap {
  background: var(--surface);
  border: 1px solid rgba(232, 181, 74, 0.12);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 8px;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid rgba(232, 181, 74, 0.07);
}
.lb-row:last-child { border-bottom: none; }
.lb-row:hover { background: var(--surface-2); }
.lb-row .rank {
  width: 44px;
  font-weight: 700;
  color: var(--smoke);
  font-size: 1.05rem;
}
.lb-row .rank.top { font-size: 1.4rem; }
.lb-row .avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--gold-deep));
  color: #14110f;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  flex-shrink: 0;
}
.lb-row .who { flex: 1; min-width: 0; }
.lb-row .who .name {
  font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lb-row .who .record { font-size: 0.82rem; color: var(--smoke); }
.lb-row .elo {
  font-size: 1.25rem; font-weight: 800; color: var(--gold);
  font-family: 'Playfair Display', serif;
}

.state-msg {
  text-align: center;
  color: var(--smoke);
  padding: 60px 20px;
}
.state-msg .big { font-size: 2.4rem; display: block; margin-bottom: 10px; }

/* ---------- Profile page ---------- */
.profile-card {
  background: var(--surface);
  border: 1px solid rgba(232, 181, 74, 0.12);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  max-width: 480px;
  margin: 30px auto;
}
.profile-card .avatar {
  width: 84px; height: 84px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--gold-deep));
  color: #14110f;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.2rem; font-weight: 800;
  margin: 0 auto 16px;
  font-family: 'Playfair Display', serif;
}
.profile-card h2 { margin-bottom: 4px; }
.profile-card .elo-big {
  font-size: 3rem; font-weight: 800; color: var(--gold);
  font-family: 'Playfair Display', serif;
  margin: 14px 0 2px;
}
.profile-card .elo-label { color: var(--smoke); font-size: 0.85rem; letter-spacing: 0.15em; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 28px;
}
.stat-grid .stat {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 14px 6px;
}
.stat-grid .num { font-size: 1.3rem; font-weight: 700; }
.stat-grid .lbl { font-size: 0.75rem; color: var(--smoke); }
.num.w { color: var(--green); }
.num.l { color: var(--red); }

/* ---------- Privacy / footer ---------- */
.privacy {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px;
  border: 1px solid rgba(232, 181, 74, 0.1);
}
.privacy ul { margin: 14px 0 0 22px; color: var(--smoke); }
.privacy li { margin-bottom: 8px; }

footer {
  border-top: 1px solid rgba(232, 181, 74, 0.12);
  padding: 36px 24px;
  text-align: center;
  color: var(--smoke);
  font-size: 0.85rem;
}
footer p { margin-bottom: 6px; }

/* ---------- Badge shelf ---------- */
.badge-shelf {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0;
}

.badge-chip {
  background: var(--surface-2);
  border: 1px solid rgba(232, 181, 74, 0.15);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.82rem;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--smoke);
  white-space: nowrap;
}

.badge-chip.earned {
  border-color: rgba(232, 181, 74, 0.45);
  color: var(--gold);
}

.badge-emoji { font-size: 1rem; }

/* ---------- Puzzle board ---------- */
.puzzle-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  width: min(480px, 92vw);
  aspect-ratio: 1;
  border: 2px solid rgba(232, 181, 74, 0.2);
  border-radius: 6px;
  overflow: hidden;
  margin: 0 auto;
  cursor: pointer;
}

.puzzle-board .sq {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.7rem, 7vw, 3.1rem);
  line-height: 1;
  user-select: none;
  position: relative;
}

/* White pieces: light fill, dark halo */
.puzzle-board .sq.piece-w {
  color: #f9f1e0;
  text-shadow: 0 0 4px #000, 0 0 2px #000;
}

/* Black pieces: dark fill, faint light halo */
.puzzle-board .sq.piece-b {
  color: #1a1208;
  text-shadow: 0 0 3px rgba(255,255,255,0.35);
}

.puzzle-board .sq.light { background: #f0d9b5; }
.puzzle-board .sq.dark  { background: #b58863; }
.puzzle-board .sq.selected { outline: 3px solid var(--gold); outline-offset: -3px; }
.puzzle-board .sq.hint { background: rgba(232, 181, 74, 0.45); }
.puzzle-board .sq.last-move { background: rgba(232, 181, 74, 0.3); }

.puzzle-turn {
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--smoke);
  margin: 8px 0;
  letter-spacing: 0.05em;
}

.puzzle-result {
  text-align: center;
  padding: 14px 0 8px;
  font-size: 1.05rem;
  font-weight: 700;
}

.puzzle-result.success { color: var(--green); }
.puzzle-result.fail    { color: var(--red); }

/* ---------- Ad container ---------- */
.ad-container {
  text-align: center;
  padding: 14px 0;
  min-height: 90px;
}

@media (max-width: 640px) {
  .nav-links { gap: 14px; font-size: 0.85rem; }
  .hero { padding: 60px 20px 50px; }
  .btn-outline { margin-left: 0; margin-top: 12px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Cookie consent banner ---------- */
#consent-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: #1e1a17;
  border-top: 1px solid rgba(232, 181, 74, 0.25);
  padding: 14px 20px;
}
.consent-inner {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.consent-inner p {
  flex: 1;
  margin: 0;
  font-size: 0.88rem;
  color: #a89f93;
  min-width: 220px;
}
.consent-inner a { color: #e8b54a; }
.consent-btns {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}
.consent-btns button {
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid rgba(232, 181, 74, 0.4);
  background: transparent;
  color: #a89f93;
  transition: background 0.15s, color 0.15s;
}
.consent-btns button:hover { background: rgba(232, 181, 74, 0.08); color: #f2e8d5; }
.consent-accept-btn {
  background: #e8b54a !important;
  color: #14110f !important;
  border-color: #e8b54a !important;
}
.consent-accept-btn:hover { background: #d4a03c !important; }
