/*
  Clean semantic stylesheet for FBLACER
  - Uses CSS variables for semantic roles
  - Light defaults in :root, dark overrides in :root.dark
  - Dark mode avoids pure white; text uses high-contrast off-white
  - Includes neumorphic surfaces, floating points, and theme toggle
*/

:root {
  /* geometry & timing */
  --radius: 12px;
  --gap: 12px;
  --transition-fast: 160ms ease;

  /* Light (default) palette */
  --bg: #eef3f7; /* page background start */
  --bg-2: #e9f0f6; /* page background end */
  --surface: #e6eef6; /* cards / panels */
  --text-color: #102027; /* primary text */
  --muted: #516a72; /* secondary text */
  --option-bg-start: rgba(255, 255, 255, 0.95);
  --option-bg-end: rgba(0, 0, 0, 0.02);

  /* accents */
  --accent: #2e8b57; /* green */
  --accent-2: #1e88e5; /* blue */
  --danger: #c94444; /* red */

  /* floating badges */
  --floating-contrast: #04231a; /* dark text when on bright gradient */

  /* theme toggle */
  --toggle-knob: #ffffff;
  --toggle-track-checked: linear-gradient(
    90deg,
    var(--accent),
    var(--accent-2)
  );

  /* shadows for neumorphism */
  --shadow-light: rgba(255, 255, 255, 0.9);
  --shadow-dark: rgba(0, 0, 0, 0.12);
  /* fallback body color if gradient can't render fully */
  --body-fallback: #eef3f7;
}

/* Dark mode overrides: attached to the root element as the 'dark' class */
:root.dark {
  --bg: #071921; /* deep teal/near-black */
  --bg-2: #0b2830;
  --surface: #0f2a33; /* panels in dark */
  --text-color: #d7f2eb; /* warm off-white for high contrast (not pure white) */
  --muted: #9fb7bd; /* muted but readable */
  --option-bg-start: rgba(12, 36, 45, 0.78);
  --option-bg-end: rgba(8, 28, 36, 0.78);

  --accent: #4cd08a; /* brighter green in dark */
  --accent-2: #3bb0ff; /* brighter blue in dark */
  --danger: #ff7b7b; /* soft red for dark */

  --floating-contrast: #0c1b17; /* dark text color used for badge labels */

  --toggle-knob: #0f2a33;
  --toggle-track-checked: linear-gradient(90deg, #4cd08a, #3bb0ff);

  --shadow-light: rgba(255, 255, 255, 0.03);
  --shadow-dark: rgba(0, 0, 0, 0.6);
  --body-fallback: #071921;
}

/* Base layout */
html,
body,
html {
  min-height: 100%;
}
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  /* Use CSS variables for gradient stops so theme can override --bg/--bg-2 */
  background-image: linear-gradient(180deg, var(--bg), var(--bg-2));
  background-attachment: fixed; /* prevents gradient from shifting with content */
  background-repeat: no-repeat;
  background-size: 100% 100vh; /* ensure it fills the full viewport height */
  background-color: var(--body-fallback);
  color: var(--text-color);
  text-align: center;
  padding: 32px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 260ms ease, background-image 260ms ease,
    color 180ms ease;
}

/* Typographic tweaks */
h1,
h2,
h3,
h4,
h5 {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  margin: 0.25em 0;
}
h1 {
  font-weight: 800;
  font-size: 1.9rem;
}
button,
select,
.custom-select-display {
  font-weight: 700;
}
body {
  font-weight: 400;
}

h1 {
  margin-bottom: 18px;
  letter-spacing: 0.4px;
}

/* Card / flashcard */
.flashcard {
  background: var(--surface);
  padding: 22px;
  margin: 20px auto;
  max-width: 760px;
  border-radius: var(--radius);
  box-shadow: 10px 10px 20px var(--shadow-dark),
    -8px -8px 20px var(--shadow-light);
  transition: transform var(--transition-fast),
    box-shadow var(--transition-fast);
}

/* Charts / containers */
#chart-container {
  width: 100%;
  max-width: 780px;
  height: 420px;
  margin: 18px auto;
  padding: 0; /* let the canvas fill the container */
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  transition: none;
  position: relative;
}
#topicChart {
  display: block;
  width: 100% !important;
  height: auto !important;
  border-radius: 8px;
}

/* HTML legend placed under the canvas so its colors update immediately via CSS variables */
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  justify-content: center;
  margin-top: 12px;
  color: var(--text-color);
  font-weight: 700;
}
.chart-legend .item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 999px;
  background: transparent;
}
.chart-legend .swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06) inset;
}

/* Chart container chrome removed: the doughnut canvas renders concave inner shadows via a plugin. */

.stats-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
  margin-top: 8px;
}

/* Options list (neumorphic buttons) */
.options {
  list-style: none;
  padding: 0;
  margin: 12px 0 0 0;
  /* prevent selecting option text */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}
.options li {
  background: linear-gradient(
    180deg,
    var(--option-bg-start),
    var(--option-bg-end)
  );
  margin: 8px 12px;
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  box-shadow: inset 2px 2px 6px rgba(0, 0, 0, 0.04),
    6px 6px 12px rgba(0, 0, 0, 0.04), -4px -4px 8px rgba(255, 255, 255, 0.06);
  transition: transform 120ms ease, box-shadow 120ms ease,
    background-color 160ms ease;
}

/* Improved select/dropdown styling with neumorphism and dark-mode aware variables */
select#testSelect {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding: 10px 40px 10px 12px; /* room for custom arrow on the right */
  border-radius: 10px;
  border: none;
  min-width: 220px;
  background: linear-gradient(
    180deg,
    var(--option-bg-start),
    var(--option-bg-end)
  );
  color: var(--text-color);
  box-shadow: 6px 6px 12px var(--shadow-dark),
    -6px -6px 12px var(--shadow-light);
  cursor: pointer;
  font-weight: 600;
  transition: box-shadow 140ms ease, transform 120ms ease, background 160ms ease;
  /* arrow made from two gradients so color follows --text-color in both themes */
  background-image: linear-gradient(
      45deg,
      var(--text-color) 50%,
      transparent 50%
    ),
    linear-gradient(135deg, var(--text-color) 50%, transparent 50%);
  background-repeat: no-repeat;
  background-position: right 14px center, right 6px center;
  background-size: 8px 8px, 8px 8px;
}

/* Custom select wrapper styles */
.custom-select-wrapper {
  display: inline-block;
}
.custom-select-display {
  padding: 10px 14px;
  min-width: 220px;
  border-radius: 10px;
  background: linear-gradient(
    180deg,
    var(--option-bg-start),
    var(--option-bg-end)
  );
  box-shadow: 6px 6px 12px var(--shadow-dark),
    -6px -6px 12px var(--shadow-light);
  color: var(--text-color);
  font-weight: 600;
  cursor: pointer;
  border: none;
}
.custom-select-menu {
  background: var(--surface);
  padding: 10px;
  border-radius: 10px;
  box-shadow: 8px 12px 24px rgba(0, 0, 0, 0.08);
  z-index: 1000;
}
.custom-select-search {
  border: 1px solid rgba(0, 0, 0, 0.06);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.98),
    rgba(255, 255, 255, 0.9)
  );
}
.custom-select-item {
  padding: 8px 10px;
  border-radius: 8px;
  margin: 6px 0;
  text-align: left;
  cursor: pointer;
}
.custom-select-item:hover {
  background: rgba(0, 0, 0, 0.04);
}

/* limit menu height and show scrollbar when needed */
.custom-select-menu {
  max-height: 320px;
  overflow-y: auto;
}

/* scrollbar styling for modern browsers */
.custom-select-menu::-webkit-scrollbar {
  width: 10px;
}
.custom-select-menu::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 8px;
}
.custom-select-menu::-webkit-scrollbar-track {
  background: transparent;
}

/* Hover and focus states */
/* Only apply hover transforms for devices that support hovering (mouse/trackpad) */
@media (hover: hover) and (pointer: fine) {
  select#testSelect:hover,
  .custom-select-display:hover,
  .custom-select-item:hover,
  button:hover {
    transform: translateY(-2px);
    box-shadow: 8px 8px 18px var(--shadow-dark),
      -6px -6px 14px var(--shadow-light);
  }
  .custom-select-item:hover {
    background: linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.03),
      rgba(0, 0, 0, 0.02)
    );
  }
}

select#testSelect:focus {
  outline: none;
  box-shadow: 0 0 0 4px rgba(50, 150, 230, 0.08),
    6px 6px 12px var(--shadow-dark);
}

/* Disabled state */
select#testSelect:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: inset 2px 2px 6px rgba(0, 0, 0, 0.04);
}
.options li.incorrect {
  /* stronger red background and border for visibility */
  background: linear-gradient(
    180deg,
    rgba(244, 67, 54, 0.16),
    rgba(244, 67, 54, 0.06)
  );
  border: 1px solid rgba(244, 67, 54, 0.22);
  color: #641212; /* darker red text for contrast in light mode */
  box-shadow: 4px 6px 14px rgba(244, 67, 54, 0.09),
    inset 1px 1px 0 rgba(255, 255, 255, 0.02);
}

:root.dark .options li {
  background: linear-gradient(
    180deg,
    rgba(12, 44, 52, 0.92),
    rgba(8, 28, 36, 0.92)
  );
  color: var(--text-color);
  border: 1px solid rgba(255, 255, 255, 0.03);
  box-shadow: inset 2px 2px 8px rgba(255, 255, 255, 0.02),
    6px 6px 18px rgba(0, 0, 0, 0.6);
}

:root.dark .options li.correct {
  background: linear-gradient(
    180deg,
    rgba(76, 208, 138, 0.26),
    rgba(76, 208, 138, 0.1)
  );
  border: 1px solid rgba(76, 208, 138, 0.36);
  color: var(--text-color);
  box-shadow: 4px 6px 18px rgba(76, 208, 138, 0.1),
    inset 1px 1px 0 rgba(0, 0, 0, 0.2);
}

:root.dark .options li.incorrect {
  background: linear-gradient(
    180deg,
    rgba(255, 123, 123, 0.22),
    rgba(255, 123, 123, 0.08)
  );
  border: 1px solid rgba(255, 123, 123, 0.28);
  color: var(--text-color);
  box-shadow: 4px 6px 18px rgba(255, 123, 123, 0.1),
    inset 1px 1px 0 rgba(0, 0, 0, 0.2);
}

/* correct option state - more vibrant green */
.options li.correct {
  background: linear-gradient(
    180deg,
    rgba(46, 139, 87, 0.16),
    rgba(46, 139, 87, 0.06)
  );
  border: 1px solid rgba(46, 139, 87, 0.22);
  color: #0b3f24; /* darker green text for contrast */
  box-shadow: 4px 6px 14px rgba(46, 139, 87, 0.09),
    inset 1px 1px 0 rgba(255, 255, 255, 0.02);
}

.explanation {
  margin-top: 14px;
  font-style: italic;
  color: var(--muted);
}

/* Buttons */
button {
  background: var(--surface);
  border: none;
  padding: 10px 14px;
  margin-left: 8px;
  border-radius: 10px;
  box-shadow: 6px 6px 12px var(--shadow-dark),
    -6px -6px 12px var(--shadow-light);
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
  color: var(--text-color);
}
button:hover {
  transform: translateY(-2px);
}
button:active {
  transform: translateY(1px);
  box-shadow: 3px 3px 6px var(--shadow-dark), -3px -3px 6px var(--shadow-light);
}

/* duplicate simple select rule removed; improved select styles are defined earlier */

#livePoints,
#liveStreak,
#liveProgress {
  font-weight: 700;
  color: var(--text-color);
}

/* Focus outlines (slightly translucent) */
.options li:focus,
button:focus,
select:focus {
  outline: 3px solid rgba(50, 150, 230, 0.12);
  outline-offset: 3px;
}

@media (max-width: 520px) {
  .flashcard {
    margin: 12px 10px;
    padding: 16px;
  }
  #chart-container {
    height: 320px;
  }
}

/* Mobile / tablet breakpoint: <= 991px - touch first layout and remove hover-only interactions */
@media (max-width: 991px) {
  /* Make main containers full-width and centered */
  .flashcard {
    margin: 12px 10px;
    padding: 16px;
    width: calc(100% - 28px);
    max-width: none;
    box-shadow: 6px 6px 16px var(--shadow-dark),
      -4px -4px 10px var(--shadow-light);
  }

  /* Chart and legend should fit and not require hover */
  #chart-container {
    height: 360px;
    width: 100%;
    max-width: none;
  }
  #topicChart {
    height: 100% !important;
  }
  .chart-legend {
    justify-content: flex-start;
    padding: 8px;
    overflow-x: auto;
  }

  /* Make selects, custom select displays and buttons full-width for easier tapping */
  select#testSelect,
  .custom-select-display,
  button {
    width: 100%;
    max-width: none;
    box-sizing: border-box;
    padding: 14px 16px;
    font-size: 16px;
  }

  /* Custom select menu should be full width and positioned statically for mobile */
  .custom-select-wrapper {
    width: 100%;
  }
  .custom-select-menu {
    position: static !important;
    top: auto !important;
    left: auto !important;
    width: 100%;
    max-height: 40vh;
    overflow-y: auto;
    margin-top: 8px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  }

  /* Increase tappable area for custom select items */
  .custom-select-item {
    padding: 14px 12px;
    font-size: 15px;
  }

  /* Ensure the search field in the custom select is full width and easy to tap */
  .custom-select-search {
    width: 100%;
    padding: 12px;
    font-size: 15px;
    border-radius: 10px;
  }

  /* Make native select and custom select display consistent and full width */
  select#testSelect,
  .custom-select-display {
    -webkit-appearance: none;
    appearance: none;
  }

  /* Options list: larger touch targets and remove hover-dependent styles */
  .options li {
    padding: 14px 16px;
    margin: 10px 8px;
    font-size: 16px;
  }

  /* Remove hover transform effects for mobile/touch - handled by pointer media queries above */

  /* Disable :hover-specific states that hide functionality on touch devices */
  .custom-select-display[aria-expanded="true"] + .custom-select-menu,
  .custom-select-menu[style] {
    display: block !important;
  }

  /* Make leaderboard responsive: stack columns and enlarge inputs */
  .lb-panel {
    width: 96%;
    max-height: 92vh;
    padding: 12px;
  }
  .lb-list {
    max-height: 48vh;
    padding: 10px;
  }
  .lb-item {
    padding: 12px;
    gap: 6px;
  }
  .lb-bottom {
    gap: 8px;
  }
  .lb-submit {
    flex-direction: column;
    align-items: stretch;
  }
  .lb-submit input {
    width: 100%;
    padding: 12px;
  }
  .lb-submit button {
    width: 100%;
    min-width: auto;
  }
  .lb-close {
    right: 12px;
    top: 8px;
    font-size: 22px;
  }
  .lb-list .lb-item {
    margin-bottom: 8px;
  }
  @media (max-width: 420px) {
    .lb-panel {
      max-height: 100vh;
      padding-bottom: 18px;
    }
    .lb-list {
      max-height: 54vh;
    }
  }

  /* Toasts: ensure they don't overflow on small screens */
  .toast-wrap {
    right: 10px;
    left: 10px;
    bottom: 16px;
  }
  .toast {
    width: auto;
    max-width: calc(100% - 40px);
  }

  /* Floating points: move into top-right so they don't overlap content on small screens */
  #floating-container {
    left: auto;
    right: 12px;
    transform: none;
    top: 12px;
  }

  /* Make inputs bigger and remove small-radius interactions */
  input[type="search"],
  input,
  textarea {
    font-size: 16px;
    padding: 12px;
  }

  /* Ensure leaderboard overlay panel is easy to dismiss and fill viewport */
  .lb-overlay {
    align-items: flex-end;
    padding-bottom: 10px;
  }
  .lb-panel {
    border-radius: 12px 12px 0 0;
    width: 100%;
    max-width: 100%;
  }

  /* Reduce complex shadows for performance on mobile */
  .flashcard,
  .lb-panel,
  .custom-select-display,
  .options li,
  button {
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
  }
}

/* Theme toggle (top-right) */
.settings-btn {
  position: fixed;
  right: 18px;
  top: 18px;
  z-index: 1200;
  background: var(--surface, #ffffff);
  border: none;
  border-radius: 8px;
  padding: 8px 10px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  font-size: 16px;
}
.settings-btn:focus {
  outline: 2px solid rgba(0, 0, 0, 0.12);
}

.settings-modal .settings-panel {
  max-width: 720px;
  overflow: hidden;
  padding: 20px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 12px;
}
.settings-close {
  cursor: pointer;
}

/* Ensure theme-switch label aligns nicely in the settings panel */
.settings-panel .theme-switch {
  align-items: center;
  gap: 10px;
}
.settings-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.settings-section #settingsThemeLabel {
  font-size: 15px;
}
.settings-section small {
  font-size: 12px;
}

/* Report section layout inside settings modal */
.report-section {
  display: block;
}
.report-input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  margin-bottom: 8px;
}
.report-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.report-status {
  font-size: 13px;
  color: var(--text-color, #102027);
}
.settings-panel .theme-switch .slider {
  width: 46px;
  height: 26px;
}
.settings-panel .theme-switch input {
  display: none;
}
.settings-panel .theme-switch span {
  display: inline-block;
  vertical-align: middle;
}

/* Make sure modal content doesn't let backdrop bleed out */
.settings-modal {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

/* Extra padding so blur from floating elements doesn't overflow the panel */
.settings-panel {
  box-sizing: border-box;
  padding: 22px;
}
.theme-switch {
  display: inline-block;
  position: relative;
  width: 46px;
  height: 26px;
}
.theme-switch input {
  display: none;
}
.theme-switch .slider {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.04),
    rgba(0, 0, 0, 0.02)
  );
  border-radius: 999px;
  box-shadow: inset 2px 2px 6px rgba(0, 0, 0, 0.06),
    -2px -2px 6px rgba(255, 255, 255, 0.04);
  transition: background 180ms ease;
}
.theme-switch .slider:before {
  content: "";
  position: absolute;
  left: 4px;
  top: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--toggle-knob);
  transition: transform 180ms ease, background 180ms ease;
  box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.12);
}
.theme-switch input:checked + .slider {
  background: var(--toggle-track-checked);
}
.theme-switch input:checked + .slider:before {
  transform: translateX(20px);
  background: var(--toggle-knob);
}

/* Floating points container & animation */
#floating-container {
  position: fixed;
  left: 50%;
  top: 18px;
  pointer-events: none;
  transform: translateX(-50%);
  z-index: 1300;
}
.floating-pts {
  display: inline-block;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 12px;
  margin: 6px 0;
  opacity: 1;
  transform: translateY(0);
  animation: floatUp 1000ms forwards;
  box-shadow: 6px 6px 14px rgba(0, 0, 0, 0.08),
    -4px -4px 10px rgba(255, 255, 255, 0.04);
  color: var(--floating-contrast);
}
.floating-pts.positive {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
.floating-pts.negative {
  background: linear-gradient(90deg, var(--danger), rgba(255, 154, 154, 0.9));
}
@keyframes floatUp {
  0% {
    transform: translateY(0);
    opacity: 1;
  }
  70% {
    transform: translateY(-36px);
    opacity: 0.95;
  }
  100% {
    transform: translateY(-64px);
    opacity: 0;
  }
}

/* Small helpers */
.center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* Custom select (styled dropdown replacing native options) */
.custom-select-wrapper {
  z-index: 1400;
}
.custom-select-display {
  background: var(--surface);
  border-radius: 10px;
  padding: 10px 14px;
  box-shadow: 6px 6px 12px var(--shadow-dark),
    -6px -6px 12px var(--shadow-light);
  border: none;
  cursor: pointer;
  color: var(--text-color);
  font-weight: 700;
}
.custom-select-display:hover {
  transform: translateY(-2px);
}
.custom-select-menu {
  background: var(--surface);
  border-radius: 10px;
  padding: 8px;
  box-shadow: 10px 10px 30px rgba(0, 0, 0, 0.35);
}
.custom-select-item {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  color: var(--text-color);
}
.custom-select-item + .custom-select-item {
  margin-top: 6px;
}
.custom-select-item:hover {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.03),
    rgba(0, 0, 0, 0.02)
  );
  transform: translateY(-2px);
}
.custom-select-item.selected {
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.06),
    rgba(255, 255, 255, 0.02)
  );
  box-shadow: inset 2px 2px 6px rgba(0, 0, 0, 0.04);
}

/* End of stylesheet */

/* Leaderboard (appended improved styles) */
.lb-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  z-index: 99999;
}
.lb-panel {
  width: min(560px, 94%);
  max-height: 92vh;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.98),
    var(--surface)
  );
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.36);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.lb-close {
  position: absolute;
  right: 18px;
  top: 14px;
  background: transparent;
  border: none;
  font-size: 20px;
}
.lb-title {
  margin: 2px 0 0 0;
}
.lb-subtitle {
  color: var(--muted);
  font-weight: 600;
}
.lb-list {
  overflow: auto;
  flex: 1 1 auto;
  padding: 12px;
  border-radius: 12px;
  background: linear-gradient(
    180deg,
    rgba(250, 250, 250, 0.95),
    rgba(240, 245, 250, 0.95)
  );
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.lb-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
  padding: 14px;
  border-radius: 12px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.95),
    rgba(245, 250, 255, 0.98)
  );
  box-shadow: 0 10px 18px rgba(13, 37, 45, 0.06);
}
.lb-rank {
  font-weight: 800;
  font-size: 13px;
  color: var(--muted);
}
.lb-name {
  font-weight: 800;
  font-size: 16px;
}
.lb-points {
  text-align: left;
  font-weight: 800;
  color: var(--accent);
}
.lb-bottom {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  margin-top: 6px;
}
.lb-controls {
  align-self: flex-start;
}
.lb-submit {
  margin-left: 0;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: stretch;
}
.lb-submit input {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  width: 100%;
}
.lb-submit button {
  padding: 12px 14px;
  border-radius: 10px;
  min-width: 120px;
}
.lb-empty,
.lb-loading,
.lb-error {
  padding: 18px;
  color: var(--muted);
}

/* toast notifications */
.toast-wrap {
  position: fixed;
  right: 20px;
  bottom: 22px;
  z-index: 12000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 10px 14px;
  border-radius: 10px;
  color: white;
  font-weight: 700;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.24);
  opacity: 0.98;
}
.toast.success {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
.toast.error {
  background: linear-gradient(90deg, #ff6b6b, #ff9472);
}
.toast.info {
  background: linear-gradient(90deg, #4a90e2, #6fb6ff);
}

.lb-timestamp {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}
.lb-submitted {
  padding: 10px 12px;
  border-radius: 10px;
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.04),
    rgba(255, 255, 255, 0.02)
  );
  font-weight: 700;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 520px) {
  .lb-panel {
    padding: 12px;
    width: 96%;
  }
  .lb-item {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .lb-rank {
    width: auto;
    text-align: left;
  }
  .lb-points {
    text-align: left;
  }
  .lb-submit {
    margin-left: 0;
    width: 100%;
    justify-content: space-between;
  }
  .lb-submit input {
    flex: 1 1 auto;
  }
}

/* Dark mode leaderboard tweaks to match neumorphic theme */
:root.dark .lb-panel {
  background: linear-gradient(180deg, rgba(15, 42, 51, 0.92), var(--surface));
  box-shadow: 10px 18px 36px rgba(0, 0, 0, 0.72),
    -8px -8px 18px rgba(255, 255, 255, 0.02);
  color: var(--text-color);
}
:root.dark .lb-list {
  background: linear-gradient(
    180deg,
    rgba(6, 20, 26, 0.84),
    rgba(10, 28, 34, 0.84)
  );
}
:root.dark .lb-item {
  background: linear-gradient(
    180deg,
    rgba(12, 36, 45, 0.72),
    rgba(8, 28, 36, 0.72)
  );
  box-shadow: inset 2px 2px 6px rgba(255, 255, 255, 0.02),
    8px 12px 22px rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.02);
}
:root.dark .lb-rank {
  color: var(--muted);
}
:root.dark .lb-name {
  color: var(--text-color);
}
:root.dark .lb-points {
  color: var(--accent);
}
:root.dark .lb-timestamp {
  color: var(--muted);
}
:root.dark .lb-submitted {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.02),
    rgba(0, 0, 0, 0.06)
  );
  color: var(--muted);
}

/* Toast adjustments for dark mode: slightly brighter accents */
:root.dark .toast.success {
  background: linear-gradient(90deg, #3dd07f, #39aaff);
}
:root.dark .toast.info {
  background: linear-gradient(90deg, #5ea9ff, #7ecbff);
}
:root.dark .toast.error {
  background: linear-gradient(90deg, #ff8a8a, #ffb2a2);
}
