:root {
  --bg: #0a0e12;
  --panel: rgba(8, 18, 22, 0.92);
  --line: rgba(0, 180, 180, 0.25);
  --line-strong: rgba(0, 180, 180, 0.4);
  --text: #e8ece8;
  --muted: #7a9898;
  --teal: #2ec4b6;
  --teal-bright: #45d9cc;
  --gold: #d4a017;
  --gold-bright: #f0c040;
  --row-odd: rgba(10, 16, 20, 0.95);
  --row-even: rgba(16, 24, 28, 0.95);
  --row-highlight: rgba(0, 160, 160, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Rajdhani", "Barlow", "Exo 2", "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}

@keyframes rainbow-shift {
  0% {
    background-position: 0% 50%;
  }
  100% {
    background-position: 200% 50%;
  }
}

@keyframes wave-gold {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.25);
  }
}

@keyframes wave-rainbow {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.52);
  }
}

.wave-letter {
  display: inline-block;
}

.nickname-gold .wave-letter {
  animation: wave-gold 2.4s ease-in-out infinite;
}

.page-shell {
  position: relative;
  z-index: 1;
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 2.5rem;
}

/* ── Header ── */

.hero {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px dashed rgba(180, 180, 180, 0.3);
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.2rem, 6vw, 3.5rem);
  font-family:
    "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman",
    serif;
  font-weight: normal;
  font-style: normal;
  line-height: 1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: linear-gradient(180deg, #f0c850 0%, #c8942a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: clamp(0.9rem, 1.8vw, 1.1rem);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ── Controls ── */

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  align-items: end;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  margin-bottom: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-bottom: none;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.control-group-select {
  min-width: min(100%, 340px);
  flex: 1 1 300px;
}

label,
.control-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

#mode-select {
  width: 100%;
  appearance: none;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  padding: 0.75rem 1rem;
  background: rgba(6, 12, 16, 0.95);
  color: var(--teal-bright);
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: border-color 150ms ease;
}

#mode-select:hover,
#mode-select:focus-visible {
  border-color: var(--teal);
  outline: none;
}

.platform-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.platform-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 0.6rem 0.85rem;
  background: rgba(6, 12, 16, 0.9);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition:
    border-color 150ms ease,
    color 150ms ease,
    background-color 150ms ease;
}

.platform-filter:hover,
.platform-filter:focus-visible {
  border-color: var(--teal);
  color: var(--text);
  outline: none;
}

.platform-filter.is-active {
  border-color: var(--teal);
  background: rgba(0, 160, 160, 0.12);
  color: var(--teal-bright);
}

.platform-icon,
.platform-badge-icon {
  display: inline-flex;
  width: 1.1rem;
  height: 1.1rem;
  flex: 0 0 auto;
}

.platform-icon svg,
.platform-badge-icon svg {
  width: 100%;
  height: 100%;
}

/* ── Mode title bar ── */

.mode-title-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 0.7rem 1.25rem;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--line);
  border-top: none;
}

.mode-title {
  font-size: 1.15rem;
  font-family:
    "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman",
    serif;
  font-weight: normal;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: center;
  min-width: 460px;
  background: linear-gradient(180deg, #f0c850 0%, #c8942a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.mode-arrow {
  background: none;
  border: none;
  color: rgba(180, 180, 180, 0.6);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0.3rem 0.5rem;
  line-height: 1;
  transition: color 150ms ease;
}

.mode-arrow:hover,
.mode-arrow:focus-visible {
  color: rgba(180, 180, 180, 0.8);
  outline: none;
}

/* ── Table ── */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-top: none;
  transition: opacity 200ms ease;
}

@media (max-width: 768px) {
  .table-wrap {
    border: none;
  }
}

.leaderboard-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
}

.leaderboard-table th,
.leaderboard-table td {
  padding: 0.7rem 1.2rem;
  text-align: left;
  border-bottom: 1px solid rgba(0, 180, 180, 0.15);
  border-right: 1px solid rgba(0, 180, 180, 0.15);
  font-size: 1.05rem;
}

.leaderboard-table th:last-child,
.leaderboard-table td:last-child {
  border-right: none;
}

.leaderboard-table thead th {
  color: rgba(180, 180, 180, 0.6);
  font-family: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  font-weight: normal;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: rgba(0, 0, 0, 0.5);
  border-bottom: 1px solid var(--line);
  border-right-color: rgba(0, 180, 180, 0.2);
  padding: 0.85rem 1.2rem;
}

/* Column alignment */
.leaderboard-table [data-col="rank"] {
  text-align: right;
  white-space: nowrap;
}
.leaderboard-table [data-col="nickname"] {
  min-width: 140px;
}
.leaderboard-table [data-col="score"] {
  white-space: nowrap;
}
.leaderboard-table [data-col="difficulty"] {
  white-space: nowrap;
}
.leaderboard-table [data-col="time"] {
  white-space: nowrap;
}
.leaderboard-table [data-col="awesomeness"] {
  white-space: nowrap;
}
.leaderboard-table [data-col="platform"] {
  white-space: nowrap;
}

.leaderboard-table tbody tr {
  background: var(--row-odd);
}

.leaderboard-table tbody tr:nth-child(even) {
  background: var(--row-even);
}

.leaderboard-table tbody tr:hover {
  background: var(--row-highlight);
}

/* Rank column */
.rank-cell {
  font-weight: 700;
  color: var(--text);
}

/* ── Platform badge ── */

.platform-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
}

/* ── Flair ── */

.score-yellow {
  color: var(--gold-bright);
}

.score-white {
  color: #ffffff;
}

.nickname-gold {
  color: var(--gold-bright);
}

.nickname-rainbow .wave-letter {
  background: linear-gradient(
    90deg,
    #e04040,
    #e0a030,
    #e0d840,
    #40c840,
    #40b8e0,
    #a040d0,
    #e04080
  );
  background-size: 600% auto;
  color: transparent;
  -webkit-background-clip: text;
  background-clip: text;
  animation:
    wave-rainbow 1.4s ease-in-out infinite,
    rainbow-shift 3s linear infinite;
}

/* ── Legend ── */

.legend {
  margin-top: 1.25rem;
  padding: 0.85rem 1.25rem;
  background: var(--panel);
  border: 1px solid var(--line);
}

.legend h2 {
  margin: 0 0 0.6rem;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.legend ul {
  margin: 0;
  padding-left: 1rem;
  display: grid;
  gap: 0.35rem;
  color: var(--text);
  font-size: 0.9rem;
}

.legend-chip {
  font-weight: 700;
}

/* ── Footer ── */

.site-footer {
  margin-top: 1rem;
  padding: 1rem 1.25rem;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer p {
  margin: 0.3rem 0;
}

.site-footer a {
  color: var(--teal);
  text-decoration: none;
}

.site-footer a:hover,
.site-footer a:focus-visible {
  color: var(--teal-bright);
}

.attribution {
  margin: 0.75rem 0 0;
  text-align: center;
  font-size: 0.78rem;
  color: rgba(150, 150, 150, 0.5);
}

.attribution a {
  color: rgba(150, 150, 150, 0.5);
  text-decoration: none;
}

.attribution a:hover {
  color: rgba(150, 150, 150, 0.7);
}

.store-links-box {
  margin: 1.25rem 0 0;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
}

.store-links-title {
  margin: 0 0 0.6rem;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.store-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin: 0;
}

.store-links a {
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  text-align: center;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--line);
  color: var(--teal);
  text-decoration: none;
  transition: color 150ms ease, background-color 150ms ease;
}

.store-icon {
  display: inline-flex;
  width: 1.1rem;
  height: 1.1rem;
}

.store-icon svg {
  width: 100%;
  height: 100%;
}

.store-links a + a {
  border-left: none;
}

.store-links a:hover,
.store-links a:focus-visible {
  color: var(--teal-bright);
  background: rgba(0, 160, 160, 0.08);
  outline: none;
}

.empty-state {
  padding: 1.5rem;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  text-align: center;
}

/* ── Responsive ── */

@media (max-width: 768px) {
  .page-shell {
    width: min(100% - 1rem, 1100px);
    padding-top: 1.25rem;
    padding-bottom: 2rem;
  }

  .hero {
    text-align: center;
  }

  .controls {
    align-items: stretch;
  }

  .control-group,
  .control-group-select,
  .control-group-platforms {
    width: 100%;
  }

  .platform-filters {
    width: 100%;
  }

  .platform-filter {
    flex: 1 1 calc(50% - 0.5rem);
    justify-content: center;
  }

  .mode-title {
    min-width: 0;
    font-size: 1rem;
  }

  .legend ul {
    font-size: 0.85rem;
  }

  .site-footer {
    text-align: center;
  }

  .store-links {
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
