/* =========================================
   PUZZLES — PERFECT CHESS ACADEMY
   2025 PREMIUM REDESIGN
   ========================================= */

/* ── Google Fonts ─────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800;900&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;600;700&display=swap');

/* ── Global Reset ─────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --gold: #f59e0b;
  --gold-2: #fbbf24;
  --gold-dark: #d97706;
  --accent-gold-rgb: 245, 158, 11;
  --blue: #3b82f6;
  --green: #10b981;
  --violet: #8b5cf6;
  --orange: #f97316;
  --red-err: #ef4444;
  --bg-deep: #080b14;
  --glass-bg: rgba(15, 23, 42, 0.7);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-blur: blur(24px);
  --radius-xl: 24px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  --header-h: 72px;
  --sidebar-w: 320px;
}

body {
  margin: 0;
  padding-top: var(--header-h) !important;
  background: var(--bg-deep) !important;
  color: #f1f5f9;
  font-family: "Inter", sans-serif;
  overflow: hidden;
  height: 100vh;
}

h1,
h2,
h3,
h4,
.app-nav-btn,
.mode-tab {
  font-family: "Outfit", sans-serif;
}

/* ── Premium Background ────────────────── */
body {
  padding-top: var(--header-h);
}

.ambient-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: radial-gradient(circle at 50% 50%, #0f172a 0%, #080b14 100%);
  overflow: hidden;
}

.geometric-shape {
  position: absolute;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.05), transparent);
  border: 1px solid rgba(245, 158, 11, 0.03);
  pointer-events: none;
  z-index: 1;
}

.shape-1 {
  width: 40vw;
  height: 40vw;
  transform: rotate(45deg);
  top: -10%;
  left: -10%;
  border-radius: 80px;
}

.shape-2 {
  width: 30vw;
  height: 30vw;
  transform: rotate(-15deg);
  bottom: -5%;
  right: -5%;
  border-radius: 60px;
}

.shape-3 {
  width: 15vw;
  height: 15vw;
  transform: rotate(115deg);
  top: 30%;
  right: 15%;
  border-radius: 40px;
}

.ambient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.4;
  animation: floatOrb 25s infinite alternate ease-in-out;
  z-index: 0;
}

.orb-1 {
  top: 10%;
  left: 10%;
  width: 50vw;
  height: 50vw;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.15) 0%, transparent 70%);
}

.orb-2 {
  bottom: 10%;
  right: 10%;
  width: 60vw;
  height: 60vw;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.1) 0%, transparent 70%);
  animation-delay: -5s;
}

@keyframes floatOrb {
  0% {
    transform: translate(0, 0) scale(1);
  }

  100% {
    transform: translate(5%, 10%) scale(1.1);
  }
}

/* ── Main App Container ───────────────── */
.main-layout {
  width: 100%;
  height: calc(100vh - var(--header-h));
  display: flex;
  background: var(--bg-deep);
  /* Use deep background instead of a padded container */
  overflow: hidden;
}

/* ── Left Sidebar Nav ─────────────────── */
.sidebar-left {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: #111;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  overflow-y: auto;
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: #000;
  box-shadow: 0 8px 16px rgba(245, 158, 11, 0.3);
}

.brand-meta h2 {
  font-size: 1.25rem;
  margin: 0;
  color: #fff;
  font-weight: 800;
}

.brand-meta span {
  font-size: 0.75rem;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

.side-panel-content {
  flex: 1;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: #64748b;
  letter-spacing: 1.5px;
  font-weight: 700;
  margin: 1.5rem 0 0.5rem 0.5rem;
}

.nav-section-label:first-child {
  margin-top: 0;
}

.app-nav-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1rem !important;
  background: transparent !important;
  border: 1px solid transparent !important;
  border-radius: var(--radius-md) !important;
  color: #94a3b8 !important;
  font-weight: 500;
  font-size: 0.95rem !important;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
}

.app-nav-btn i {
  width: 24px;
  text-align: center;
  font-size: 1.1rem;
  transition: var(--transition);
}

.app-nav-btn:hover {
  background: rgba(255, 255, 255, 0.05) !important;
  color: #fff !important;
}

.app-nav-btn.active {
  background: rgba(245, 158, 11, 0.15) !important;
  border-color: transparent !important;
  color: var(--gold) !important;
  font-weight: 700;
}

.app-nav-btn.active::before {
  display: none;
  /* Removed the line accent to keep it cleaner */
}

/* ── Mode Tabs ────────────────────────── */
.sidebar-footer {
  padding: 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.mode-tabs-container {
  background: rgba(0, 0, 0, 0.3);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.mode-tabs {
  display: flex;
  gap: 4px;
}

.mode-tab {
  flex: 1;
  padding: 8px 4px;
  border: none;
  background: transparent;
  color: #64748b;
  border-radius: calc(var(--radius-md) - 4px);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.mode-tab:hover {
  color: #fff;
}

.mode-tab.active {
  background: var(--gold);
  color: #000;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.2);
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--gradient-primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.2);
}

/* ── Mobile Layout Optimization ─────────────────── */
@media (max-width: 1024px) {
  .puzzles-app-container {
    padding: 1rem;
  }

  .main-layout {
    flex-direction: column;
    overflow-y: auto;
  }

  .sidebar-left {
    width: 100%;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    border-radius: var(--radius-md);
  }

  .sidebar-header {
    border-bottom: none;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    padding: 0.75rem 1rem;
  }

  .side-panel-content {
    flex-direction: row;
    gap: 0.5rem;
    padding: 0.75rem;
  }

  .nav-section-label {
    display: none;
  }

  .app-nav-btn {
    white-space: nowrap;
    padding: 0.5rem 1rem !important;
  }

  .sidebar-footer {
    display: none;
    /* Hide mode tabs on mobile sidebar, managed elsewhere if needed */
  }

  .sidebar-right {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    height: auto;
  }

  .panel-section {
    flex: 1 1 300px;
  }

  .move-list-container {
    height: 250px;
    /* Fixed height for scrollable move list on mobile */
  }
}

@media (max-width: 768px) {
  .puzzles-app-container {
    padding: 0;
  }

  .main-layout {
    border-radius: 0;
    border: none;
    padding: 0;
    gap: 0;
  }

  .board-area {
    border-radius: 0;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  }

  /* Board width is handled in the main mobile @media below */

  .board-wrapper {
    padding: 0;
    /* Edge to edge board on mobile */
    background: #111;
  }

  .sidebar-right {
    flex-direction: column;
    padding: 1rem;
    gap: 1rem;
  }

  .panel-section {
    flex: none;
  }
}

/* ── Page Views ───────────────────────── */
.page-view {
  display: none !important;
  flex: 1;
  gap: 1.25rem;
  height: 100%;
}

.page-view.active {
  display: flex !important;
  animation: pageFadeIn 0.5s ease;
}

@keyframes pageFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Board Area ───────────────────────── */
.board-area {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: #141415;
}

.board-header {
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Specific Header variants */
.streak-header {
  background: rgba(249, 115, 22, 0.05);
  border-bottom-color: rgba(249, 115, 22, 0.2);
}

.storm-header {
  background: rgba(59, 130, 246, 0.05);
  border-bottom-color: rgba(59, 130, 246, 0.2);
}

.player-info-board {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.puzzle-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.puzzle-icon {
  font-size: 1.5rem;
  color: var(--gold);
}

.puzzle-icon.streak-icon {
  color: #f97316;
}

.puzzle-icon.storm-icon {
  color: #3b82f6;
}

.puzzle-text h3 {
  font-size: 1rem;
  margin: 0;
  color: #fff;
  font-weight: 700;
}

.puzzle-text p {
  font-size: 0.8rem;
  color: #94a3b8;
  margin: 0;
}

.board-indicators {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.turn-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.85rem;
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
  padding: 4px 10px;
  border-radius: 99px;
}

.mode-badges {
  display: flex;
  gap: 8px;
  align-items: center;
}

.mode-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
}

.mode-badge.daily {
  background: rgba(245, 158, 11, 0.15);
  color: var(--gold);
}

.mode-badge.diff {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
}

.board-wrapper {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem;
  position: relative;
  background: #111;
}

.board-footer {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.02);
  gap: 0.5rem;
  flex-wrap: wrap;
  width: 100%;
}

#board,
#streakBoard,
#stormBoard {
  /* Square that fits within both available width and height */
  width: min(calc(100vw - var(--sidebar-w) - 340px - 2rem), calc(100dvh - var(--header-h) - 100px));
  height: auto;
  aspect-ratio: 1;
  max-width: 800px;
  border-radius: 4px;
  background-color: #e8d2a6;
  background-image: conic-gradient(#c28432 90deg, transparent 90deg 180deg, #c28432 180deg 270deg, transparent 270deg);
  background-size: 25% 25%;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* ── Result & Mode Overlays ───────────────────── */
.result-overlay,
.mode-overlay {
  position: absolute;
  inset: 0;
  background: rgba(17, 17, 17, 0.85);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.result-card,
.overlay-content {
  background: #202022;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  max-width: 420px;
  width: 90%;
  animation: cardFade 0.3s ease;
}

@keyframes cardFade {
  0% {
    transform: scale(0.95);
    opacity: 0;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.result-icon {
  font-size: 5rem;
  margin-bottom: 1.5rem;
  display: block;
}

.result-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 2rem;
}

/* ── Sidebar Right ────────────────────── */
.sidebar-right {
  width: 340px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  height: 100%;
  background: #111;
  border-left: 1px solid rgba(255, 255, 255, 0.05);
  overflow-y: auto;
}

.panel-section {
  background: transparent;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  padding: 1rem;
}

/* Session Status */
.session-status .player-details {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.session-status .avatar {
  width: 36px;
  height: 36px;
  background: rgba(245, 158, 11, 0.15);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
}

.session-status .username {
  font-weight: 700;
  color: #fff;
  font-size: 0.9rem;
  display: block;
}

.session-status .solved-count {
  font-size: 0.75rem;
  color: #10b981;
  font-weight: 600;
}

.session-status .puzzle-rating {
  margin-left: auto;
  font-family: "JetBrains Mono", monospace;
  color: #94a3b8;
  font-weight: 700;
}

/* Move List */
.move-list-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0 !important;
  /* Managed by inner elements */
  overflow: hidden;
}

/* ── Streak & Storm Sidebars ──────────── */
.stats-panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.5rem !important;
}

.stat-block {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.stat-block::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
}

.stat-block.current::before {
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.stat-block.best::before {
  background: linear-gradient(90deg, transparent, #3b82f6, transparent);
}

.stat-block .stat-val {
  font-size: 3.5rem;
  font-weight: 900;
  font-family: 'Outfit', sans-serif;
  line-height: 1;
  margin-bottom: 0.5rem;
  color: #fff;
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.stat-block.current .stat-val {
  background: linear-gradient(180deg, #fff, var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.stat-block.best .stat-val {
  background: linear-gradient(180deg, #fff, #93c5fd);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.stat-block .stat-lbl {
  font-size: 0.85rem;
  text-transform: uppercase;
  color: #94a3b8;
  letter-spacing: 2px;
  font-weight: 800;
}

.move-list-header {
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #e2e8f0;
}

.puzzle-id {
  font-size: 0.7rem;
  color: #64748b;
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
}

.move-list-scroll {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  font-family: "JetBrains Mono", monospace;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-content: flex-start;
  background: #141415;
  /* slightly darker well */
}

.mv {
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  font-size: 0.9rem;
  color: #e2e8f0;
  font-weight: 600;
}

.mv.correct {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.mv.wrong {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

.mv.opponent {
  color: #94a3b8;
  background: transparent;
}

/* Control Panel Grid */
.controls-panel {
  padding: 1rem;
}

.game-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.game-actions-grid.single-col {
  grid-template-columns: 1fr;
}

.action-btn {
  padding: 0.75rem !important;
  border: none !important;
  border-radius: var(--radius-sm) !important;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  font-size: 0.85rem !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem !important;
}

.action-btn:active {
  transform: scale(0.98);
}

.control-btn {
  background: rgba(255, 255, 255, 0.08) !important;
  color: #e2e8f0 !important;
}

.control-btn:hover {
  background: rgba(255, 255, 255, 0.15) !important;
}

.control-btn.danger {
  color: #f87171 !important;
}

.control-btn.danger:hover {
  background: rgba(239, 68, 68, 0.2) !important;
}

.action-btn.primary {
  background: var(--gold) !important;
  color: #000 !important;
}

.action-btn.primary:hover {
  background: var(--gold-2) !important;
}

.action-btn.secondary {
  background: rgba(255, 255, 255, 0.1) !important;
  color: #fff !important;
}

.full-width {
  width: 100%;
}

/* ── Mode Selection UI ────────────────── */
.themes-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0.5rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.theme-tag {
  padding: 3px 8px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.2);
  color: var(--gold);
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* ── Explore / Statistics Views ──────── */

/* Shared wrapper for all explore pages */
.explore-view {
  padding: 2rem;
  overflow-y: auto;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

/* Grid layout used in Custom Room / Filters page */
.solve-split {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

/* ── Filter Controls ──────────────────── */
.filter-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #94a3b8;
  margin-bottom: 0.5rem;
  margin-top: 1rem;
}

.filter-select {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  color: #e2e8f0;
  padding: 0.6rem 0.9rem;
  font-size: 0.9rem;
  appearance: none;
  cursor: pointer;
  transition: var(--transition);
}

.filter-select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

.rating-inputs {
  display: flex;
  gap: 0.75rem;
}

.rating-inputs input {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  color: #e2e8f0;
  padding: 0.6rem 0.9rem;
  font-size: 0.9rem;
}

.rating-inputs input:focus {
  outline: none;
  border-color: var(--gold);
}

.btn-filter {
  margin-top: 1.25rem;
  width: 100%;
  background: var(--gold);
  color: #000;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  font-weight: 800;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: var(--transition);
}

.btn-filter:hover {
  background: #f59e0b;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.35);
}

.btn-filter-outline {
  margin-top: 0.75rem;
  width: 100%;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #94a3b8;
  border-radius: var(--radius-md);
  padding: 0.65rem 1rem;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
}

.btn-filter-outline:hover {
  border-color: rgba(255, 255, 255, 0.25);
  color: #e2e8f0;
}

/* ── Theme Pills Grid ─────────────────── */
.theme-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.theme-pill {
  padding: 5px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  font-size: 0.8rem;
  color: #94a3b8;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.theme-pill:hover,
.theme-pill.active {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.4);
  color: var(--gold);
}

/* ── Storm Sidebar Stat Group ─────────── */
.stat-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.stat-block.sm-stat .stat-val {
  font-size: 2.25rem;
}

.stat-block.error::before {
  background: linear-gradient(90deg, transparent, #ef4444, transparent);
}

.stat-block.error .stat-val {
  background: linear-gradient(180deg, #fff, #fca5a5);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ── Statistics Views ─────────────────── */
.page-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.page-header h1 {
  font-size: 2.5rem;
  font-weight: 800;
  margin: 0 0 0.5rem 0;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.page-header p {
  color: #64748b;
  font-size: 1.1rem;
  margin: 0;
}

.stat-grid-premium {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-lg);
  padding: 2rem;
  text-align: center;
  transition: var(--transition);
}

.stat-item:hover {
  border-color: rgba(245, 158, 11, 0.3);
  transform: translateY(-5px);
}

.stat-item .val {
  font-size: 3rem;
  font-weight: 900;
  color: var(--gold);
  font-family: "Outfit", sans-serif;
  line-height: 1;
  margin-bottom: 0.5rem;
}

.stat-item .lbl {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: #64748b;
  letter-spacing: 1.5px;
  font-weight: 800;
}

/* ── Inner Cards ──────────────────────── */
.inner-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.info-row {
  display: flex;
  justify-content: space-between;
  padding: 1rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.info-row:last-child {
  border-bottom: none;
}

.info-row .lbl {
  color: #64748b;
}

.info-row .val {
  font-weight: 700;
  font-family: "JetBrains Mono", monospace;
}

/* ── Streak Calendar ──────────────────── */
.streak-cal {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.cal-day {
  aspect-ratio: 1;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: #64748b;
}

.cal-day.active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.3);
}

.cal-day.today {
  outline: 2px solid #fff;
  outline-offset: -2px;
}

/* ── Theme Gallery ────────────────────── */
.theme-search-bar {
  position: relative;
  margin-bottom: 2rem;
}

.theme-search-bar i {
  position: absolute;
  left: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
  color: #64748b;
}

.theme-search-bar input {
  width: 100%;
  padding: 1rem 1rem 1rem 3.5rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 1rem;
}

.theme-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}

.theme-gallery-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 1.25rem;
  transition: var(--transition);
  cursor: pointer;
}

.theme-gallery-card:hover {
  background: rgba(245, 158, 11, 0.05);
  border-color: rgba(245, 158, 11, 0.2);
  transform: translateY(-5px);
}

.tgc-icon {
  width: 60px;
  height: 60px;
  background: rgba(245, 158, 11, 0.1);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  color: var(--gold);
}

.tgc-name {
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.25rem;
  display: block;
}

.tgc-desc {
  font-size: 0.85rem;
  color: #64748b;
  line-height: 1.4;
  display: block;
}

.tgc-count {
  font-size: 0.75rem;
  color: var(--gold);
  margin-top: 0.5rem;
  display: block;
  font-family: "JetBrains Mono", monospace;
}

/* ── Timer / Badges ───────────────────── */
.timer-pill {
  font-family: "JetBrains Mono", monospace;
  background: rgba(0, 0, 0, 0.5);
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-weight: 700;
  color: var(--gold);
}

.mode-badge {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ── Toast ────────────────────────────── */
#toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toast-msg {
  padding: 1rem 1.5rem;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  animation: toastIn 0.4s ease;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.toast-success {
  border-left: 4px solid var(--green);
}

.toast-error {
  border-left: 4px solid var(--red-err);
}

/* ── Custom Training Filters & Forms ── */
.solve-split {
  display: grid;
  gap: 1.5rem;
  margin-top: 1rem;
}

.inner-card {
  background: linear-gradient(145deg, rgba(35, 35, 42, 0.95), rgba(20, 20, 25, 0.98));
  backdrop-filter: blur(10px);
  border: 1px solid rgba(245, 158, 11, 0.15);
  /* Subtle gold accent */
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(245, 158, 11, 0.2);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filter-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-select {
  width: 100%;
  padding: 0.85rem 1rem;
  background: rgba(10, 10, 12, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  appearance: none;
  cursor: pointer;
  margin-bottom: 1.25rem;
  transition: all 0.2s;
}

.filter-select:focus {
  outline: none;
  border-color: var(--gold);
  background: rgba(10, 10, 12, 0.9);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2), inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.rating-inputs {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.rating-inputs input {
  flex: 1;
  padding: 0.85rem 1rem;
  background: rgba(10, 10, 12, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  transition: all 0.2s;
}

.rating-inputs input:focus {
  outline: none;
  border-color: var(--gold);
  background: rgba(10, 10, 12, 0.9);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2), inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn-filter {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: #000;
  border: none;
  padding: 0.85rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  text-align: center;
  width: 100%;
}

.btn-filter:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
}

.btn-filter-outline {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.85rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  width: 100%;
  margin-top: 0.5rem;
}

.btn-filter-outline:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

/* ── Responsive ────────────────────────── */
@media (max-width: 1050px) {

  .sidebar-left {
    display: none;
    /* Let header hamburger take over for tablets */
  }

  .sidebar-right {
    width: 320px;
  }
}

@media (max-width: 768px) {
  body {
    overflow-y: auto;
    height: auto;
  }

  .main-layout {
    flex-direction: column;
    height: auto;
    padding-bottom: 80px;
    /* Space for mobile nav bar */
  }

  .page-view {
    flex-direction: column !important;
    overflow-y: visible !important;
    height: auto;
    gap: 0;
  }

  .page-view#page-solve {
    overflow-y: visible !important;
  }

  .sidebar-left {
    display: none;
  }

  .board-area {
    flex: none;
    height: auto;
  }

  .sidebar-right {
    width: 100%;
    flex: none;
    border-left: none;
    overflow-y: visible;
  }

  .board-header {
    padding: 1rem 10px;
    background: transparent;
    border-bottom: none;
  }

  .board-indicators {
    width: 100%;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem;
  }

  .board-wrapper {
    width: 100%;
    height: auto;
    padding: 0;
  }

  #board,
  #streakBoard,
  #stormBoard {
    /* On mobile: full-width square capped by available vertical space */
    width: min(100vw, calc(100dvh - var(--header-h) - 130px));
    height: auto;
    aspect-ratio: 1;
    border-radius: 0;
    max-width: 100vw;
  }

  /* Make sure the huge overlays scale down inside mobile screens */
  .result-card,
  .overlay-content {
    padding: 1.25rem !important;
    max-width: 90% !important;
    width: 100% !important;
    box-sizing: border-box;
  }

  .overlay-content h2,
  .result-card h3 {
    font-size: 1.5rem !important;
    margin-bottom: 0.5rem;
  }

  .mode-start-icon,
  .result-icon {
    font-size: 2.5rem !important;
    margin-bottom: 0.5rem;
  }

  .mode-start-desc {
    font-size: 0.9rem !important;
  }
}

/* END MAC-WIDTH: 768px */

/* ── Board Interactions (Desktop & Mobile) ────────────────── */
.board-square.highlight-selected {
  background: rgba(245, 158, 11, 0.4) !important;
  box-shadow: inset 0 0 10px rgba(245, 158, 11, 0.5);
}

.board-square.highlight-lastmove {
  background: rgba(245, 158, 11, 0.25) !important;
}

.board-square.highlight-wrong {
  background: rgba(239, 68, 68, 0.4) !important;
  animation: shake 0.4s;
}

.board-square.highlight-correct {
  background: rgba(16, 185, 129, 0.4) !important;
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-4px);
  }

  75% {
    transform: translateX(4px);
  }
}

.legal-hint-dot {
  width: 25%;
  height: 25%;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 50%;
  pointer-events: none;
}

.legal-hint-ring {
  width: 90%;
  height: 90%;
  border: 4px solid rgba(245, 158, 11, 0.4);
  border-radius: 50%;
  pointer-events: none;
}

.coordinate {
  position: absolute;
  font-size: 10px;
  font-weight: 700;
  pointer-events: none;
  opacity: 0.6;
}

.coordinate.rank {
  top: 2px;
  left: 2px;
}

.coordinate.file {
  bottom: 2px;
  right: 2px;
}

.coordinate.light {
  color: #82a1b1;
}

.coordinate.dark {
  color: #e8eaee;
}

.piece {
  width: 100%;
  height: 100%;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  cursor: grab;
  z-index: 5;
}

.piece:active {
  cursor: grabbing;
}

.board-square {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Custom Board Container ───────────── */
.custom-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 100%;
  height: 100%;
  user-select: none;
}

/* ── Mobile Nav Bar (Default Hidden) ──── */
.mobile-nav-bar {
  display: none;
}

@media (max-width: 768px) {
  .mobile-nav-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 65px;
    background: rgba(8, 11, 20, 0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0 0.5rem;
    align-items: center;
    justify-content: space-around;
    z-index: 1000;
  }

  .mnb-btn {
    background: none;
    border: none;
    color: #64748b;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-weight: 700;
    font-size: 0.65rem;
    text-transform: uppercase;
  }

  .mnb-btn.active {
    color: var(--gold);
  }

  .mnb-btn i {
    font-size: 1.25rem;
  }
}