:root {
  color-scheme: dark;
  --bg: #0a0a0a;
  --surface: #141414;
  --surface-strong: #1c1c1c;
  --text: #ffffff;
  --muted: #a3a3a3;
  --accent: #5d2a9b;
  --accent-bright: #7a3cc4;
  --accent-soft: rgba(93, 42, 155, 0.18);
  --accent-border: rgba(93, 42, 155, 0.32);
  --danger: #ff8a80;
  --gold: #f4d06f;
  --silver: #d9d9d9;
  --bronze: #d49a6a;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-card: 0 16px 40px rgba(0, 0, 0, 0.42);
  --header-height: 72px;
  --dock-height: 68px;
  --player-nav-height: 72px;
  --user-dock-height: 168px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(circle at top, rgba(93, 42, 155, 0.22) 0, transparent 42%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.45;
  text-size-adjust: 100%;
}

a {
  color: var(--accent-bright);
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: min(100%, 720px);
  margin: 0 auto;
  padding:
    calc(12px + var(--safe-top))
    calc(16px + var(--safe-right))
    12px
    calc(16px + var(--safe-left));
  background: rgba(10, 10, 10, 0.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.app-header__brand {
  min-width: 0;
}

.app-header__title {
  margin: 6px 0 0;
  font-size: clamp(22px, 6vw, 32px);
  line-height: 1.1;
  font-weight: 700;
}

.app-shell {
  width: min(100%, 720px);
  margin: 0 auto;
  padding:
    12px
    calc(16px + var(--safe-right))
    calc(24px + var(--safe-bottom))
    calc(16px + var(--safe-left));
}

.page-player .app-shell {
  padding-bottom: calc(var(--player-nav-height) + var(--safe-bottom) + 20px);
}

.page-player-leaderboard .app-shell {
  padding-bottom: calc(var(--user-dock-height) + var(--player-nav-height) + var(--safe-bottom) + 20px);
}

.app-logo {
  display: block;
  height: 16px;
  width: auto;
  max-width: min(180px, 58vw);
}

.eyebrow {
  margin: 0;
  color: var(--accent-bright);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.section-title,
.hero-card__title,
.card h2 {
  margin: 4px 0 0;
  font-size: clamp(20px, 5vw, 28px);
  line-height: 1.15;
}

.age-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--accent);
  border-radius: 50%;
  color: var(--text);
  background: var(--accent-soft);
  font-size: 13px;
  font-weight: 700;
}

.card {
  margin-bottom: 12px;
  padding: 16px;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-lg);
  background: rgba(20, 20, 20, 0.94);
  box-shadow: var(--shadow-card);
}

.hero-card {
  background: linear-gradient(160deg, rgba(93, 42, 155, 0.18), rgba(20, 20, 20, 0.96));
}

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.stat-chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.stat-chip--accent {
  color: var(--text);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
}

.notice {
  color: var(--accent-bright);
  font-weight: 600;
}

.notice--compact {
  margin: 12px 0 0;
  font-size: 13px;
}

.muted {
  color: var(--muted);
}

.legal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding: 4px 0 8px;
  font-size: 14px;
}

.legal-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 16px;
  padding: 8px 0 4px;
  color: var(--muted);
  font-size: 13px;
}

.legal-footer a {
  color: var(--muted);
  text-decoration: none;
}

.legal-footer a:hover,
.legal-footer a.is-active {
  color: var(--text);
}

.legal-footer a.is-active {
  font-weight: 600;
}

.legal-hero h2 {
  margin-bottom: 8px;
}

.legal-section h2 {
  margin-bottom: 12px;
}

.legal-clause {
  margin: 0 0 12px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}

.legal-clause:last-child {
  margin-bottom: 0;
}

.legal-meta {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.legal-meta li {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.legal-meta span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.legal-meta strong {
  font-size: 14px;
  font-weight: 600;
  word-break: break-word;
}

.player-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 2px;
  width: min(100%, 720px);
  margin: 0;
  padding:
    6px
    calc(8px + var(--safe-right))
    calc(6px + var(--safe-bottom))
    calc(8px + var(--safe-left));
  transform: translateX(-50%);
  background: rgba(12, 12, 12, 0.98);
  backdrop-filter: blur(16px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.35);
}

.player-nav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 56px;
  padding: 6px 4px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-decoration: none;
  touch-action: manipulation;
}

.player-nav__item.is-active {
  color: var(--text);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent-border);
}

.player-nav__item.is-active .player-nav__icon {
  color: var(--accent-bright);
}

.player-nav__icon {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
}

.player-nav__label {
  font-size: 9px;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
}

.page-admin .app-shell {
  padding-bottom: calc(var(--player-nav-height) + var(--safe-bottom) + 20px);
}

.player-nav--player-only {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.player-nav__item--admin[hidden] {
  display: none;
}

.home-summary__head,
.profile-summary__head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
}

.home-more-link {
  color: var(--accent-bright);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.activity-list--compact .activity-row {
  padding: 10px 12px;
}

.score-table-wrap {
  overflow-x: auto;
  margin: 0 -4px;
}

.score-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: 14px;
}

.score-table th,
.score-table td {
  padding: 12px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  text-align: left;
  vertical-align: top;
}

.score-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.score-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: var(--accent-bright);
  font-weight: 700;
}

.limit-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.limit-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
}

.profile-summary__avatar,
.current-user__avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  font-weight: 700;
}

.profile-summary__score,
.current-user__score {
  text-align: right;
}

.profile-summary__score strong,
.current-user__score strong {
  display: block;
  font-size: 28px;
  line-height: 1;
}

.profile-summary__score span,
.current-user__score span {
  color: var(--muted);
  font-size: 12px;
}

.profile-summary__place,
.current-user__place {
  margin: 12px 0 0;
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.profile-stats li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
  font-size: 13px;
}

.activity-list {
  display: grid;
  gap: 8px;
}

.activity-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  padding: 12px;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
}

.activity-row__main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.activity-row__status {
  color: var(--muted);
  font-size: 12px;
}

.activity-row__points {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-bright);
}

.activity-row--rejected .activity-row__points,
.activity-row--ignored .activity-row__points {
  color: var(--muted);
}

.activity-row__time {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
}

.section-heading,
.leader,
.actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-heading {
  justify-content: space-between;
  margin-bottom: 14px;
}

.pill {
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--text);
  background: var(--accent-soft);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.pill--ok {
  color: #8ee0b0;
  border-color: rgba(142, 224, 176, 0.35);
}

.pill--warn {
  color: #f0c48a;
  border-color: rgba(240, 196, 138, 0.35);
}

.top-three {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.leader {
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
}

.leader.top-leader {
  padding: 14px 12px;
}

.leader--gold {
  border-color: rgba(244, 208, 111, 0.45);
  background: linear-gradient(145deg, rgba(244, 208, 111, 0.14), rgba(255, 255, 255, 0.03));
}

.leader--silver {
  border-color: rgba(217, 217, 217, 0.35);
}

.leader--bronze {
  border-color: rgba(212, 154, 106, 0.35);
}

.place {
  flex: 0 0 auto;
  min-width: 38px;
  color: var(--accent-bright);
  font-size: 14px;
  font-weight: 800;
}

.avatar {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
}

.name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 600;
}

.leader strong {
  flex: 0 0 auto;
  font-size: 16px;
  font-weight: 800;
}

.leaderboard-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.current-user {
  position: fixed;
  left: 50%;
  bottom: calc(var(--player-nav-height) + var(--safe-bottom));
  z-index: 35;
  width: min(100%, 720px);
  margin: 0;
  transform: translateX(-50%);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border-bottom: none;
  padding:
    14px
    calc(16px + var(--safe-right))
    14px
    calc(16px + var(--safe-left));
  background: rgba(16, 16, 16, 0.96);
  backdrop-filter: blur(16px);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.45);
}

.current-user__head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
}

.current-user__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--accent), var(--accent-bright));
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
}

.current-user__meta {
  min-width: 0;
}

.current-user__name {
  margin: 2px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 18px;
  line-height: 1.2;
}

.current-user__score {
  text-align: right;
}

.current-user__score strong {
  display: block;
  font-size: 24px;
  line-height: 1;
}

.current-user__score span {
  color: var(--muted);
  font-size: 12px;
}

.current-user__place {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.current-user__hint {
  margin: 8px 0 0;
  font-size: 13px;
}

.actions {
  flex-wrap: wrap;
  margin-top: 12px;
}

.actions--stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent);
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}

.button:active {
  transform: scale(0.98);
}

.button-secondary {
  background: transparent;
  color: var(--text);
}

.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.copy-fallback {
  overflow-wrap: anywhere;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.admin-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 0 0 12px;
  padding: 2px 0 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.admin-tabs::-webkit-scrollbar {
  display: none;
}

.admin-tabs__item {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 10px 14px;
  border: 1px solid var(--accent-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.admin-tabs__item.is-active {
  color: var(--text);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent-border);
}

.grid-card {
  display: grid;
  gap: 10px;
}

.admin-tile {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  text-decoration: none;
}

.admin-tile strong {
  font-size: 16px;
}

.admin-tile span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.form-grid {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.form-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  background: #0f0f0f;
  color: var(--text);
  font-size: 16px;
}

.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
  outline: 2px solid rgba(122, 60, 196, 0.45);
  outline-offset: 1px;
}

.form-section {
  grid-column: 1 / -1;
  padding-top: 4px;
}

.form-divider {
  grid-column: 1 / -1;
  height: 1px;
  margin: 4px 0;
  background: rgba(255, 255, 255, 0.08);
}

.app-toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--player-nav-height) + var(--safe-bottom) + 12px);
  z-index: 50;
  width: min(calc(100% - 32px), 420px);
  transform: translateX(-50%);
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--accent-border);
  background: rgba(20, 20, 20, 0.96);
  box-shadow: var(--shadow-card);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  animation: toast-in 0.24s ease;
}

.page-player-leaderboard .app-toast {
  bottom: calc(var(--user-dock-height) + var(--player-nav-height) + var(--safe-bottom) + 12px);
}

.app-toast.is-error {
  border-color: rgba(255, 138, 128, 0.45);
  color: var(--danger);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.events-list {
  display: grid;
  gap: 8px;
}

.event-row {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
  font-size: 14px;
}

.event-row strong {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.event-row__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.event-row__points {
  font-weight: 700;
  color: var(--accent-bright);
}

.event-row--voided .event-row__points,
.event-row--rejected .event-row__points,
.event-row--pending_review .event-row__points {
  color: var(--muted);
}

.event-row__details {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 12px;
}

.event-row__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.event-row__actions .button {
  width: auto;
  min-height: 36px;
  padding: 8px 12px;
}

.season-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.season-item {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  text-decoration: none;
}

.season-item.is-selected {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent-border);
}

.season-item span {
  color: var(--muted);
  font-size: 13px;
}

.form-grid .checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 600;
}

.form-grid .checkbox-label input {
  width: 18px;
  height: 18px;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.admin-details {
  grid-column: 1 / -1;
  padding: 12px;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-md);
}

.admin-details summary {
  cursor: pointer;
  font-weight: 700;
}

.card--warn {
  border-color: rgba(240, 196, 138, 0.45);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.page-admin .actions .button {
  width: 100%;
}

@media (min-width: 640px) {
  .app-header__title {
    font-size: 32px;
  }

  .top-three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: end;
  }

  .top-three .leader.top-leader:nth-child(1) {
    order: 2;
  }

  .top-three .leader.top-leader:nth-child(2) {
    order: 1;
  }

  .top-three .leader.top-leader:nth-child(3) {
    order: 3;
  }

  .actions--stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-card {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .page-admin .actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .page-admin .actions .button {
    width: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .button:active {
    transform: none;
  }
}
