:root {
  color-scheme: dark;
  --bg-a: #10202d;
  --bg-b: #09131c;
  --panel: rgba(16, 25, 36, 0.88);
  --panel-border: rgba(135, 180, 230, 0.18);
  --table-line: rgba(169, 194, 215, 0.12);
  --text: #eef5ff;
  --muted: #9cb0c7;
  --accent: #78d7a9;
  --accent-strong: #36ab74;
  --danger: #ff9696;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(120, 215, 169, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(126, 168, 255, 0.14), transparent 24%),
    linear-gradient(180deg, var(--bg-a), var(--bg-b));
  color: var(--text);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

a { color: inherit; text-decoration: none; }

.container {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.panel {
  border: 1px solid var(--panel-border);
  background: var(--panel);
  border-radius: 8px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28);
}

.panel + .panel { margin-top: 18px; }

.panel-body { padding: 18px; }

.hero { text-align: center; margin-bottom: 14px; }

.hero h1, .title-row h2, h1 { margin: 0; }

.brand-logo {
  display: block;
  width: min(100%, 600px);
  margin: 0 auto;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  color: var(--muted);
}

.muted { color: var(--muted); }

.demo-title {
  margin: 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.demo-box {
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.demo-button {
  width: 100%;
}

.demo-hint {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
}

.actions, .stack { display: grid; gap: 12px; }

.button, .button-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 16px;
  border-radius: 12px;
  font: inherit;
  cursor: pointer;
}

.button {
  border: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #04150e;
  font-weight: 700;
}

.button-secondary {
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.text-input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 0 12px;
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.login-layout {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card { width: min(460px, 100%); }

.title-row, .topbar, .field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.profile-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.profile-main {
  min-width: 0;
}

.profile-name-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.best-time-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.chip-label {
  color: var(--muted);
  font-size: 13px;
}

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

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
}

.status-badge::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: currentColor;
}

.status-badge.live { color: #85f0be; }
.status-badge.offline { color: var(--muted); }

.leaderboard-panel {
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    rgba(13, 20, 28, 0.94);
  background-size: 24px 24px;
}

.leaderboard-toolbar {
  align-items: flex-end;
  margin-bottom: 14px;
}

.leaderboard-toolbar h2 {
  font-size: 24px;
  line-height: 1.15;
}

.leaderboard-toolbar .muted {
  margin: 8px 0 0;
  font-size: 14px;
}

.leaderboard-search {
  display: grid;
  gap: 6px;
  width: min(280px, 100%);
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.leaderboard-search input {
  width: 100%;
  height: 38px;
  border: 1px solid rgba(120, 145, 168, 0.34);
  border-radius: 4px;
  padding: 0 12px;
  color: var(--text);
  background: rgba(3, 8, 13, 0.72);
  font: inherit;
  letter-spacing: 0;
  text-transform: none;
  outline: none;
}

.leaderboard-search input:focus {
  border-color: rgba(120, 215, 169, 0.72);
  box-shadow: 0 0 0 3px rgba(120, 215, 169, 0.12);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid rgba(6, 13, 20, 0.88);
  border-radius: 4px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.016) 1px, transparent 1px),
    rgba(12, 19, 26, 0.9);
  background-size: 22px 22px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 18px 42px rgba(0, 0, 0, 0.32);
}

.leaderboard-table {
  min-width: 820px;
  table-layout: fixed;
}

.leaderboard-name {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
}

.leaderboard-name:hover,
.leaderboard-name[aria-expanded="true"] {
  color: var(--accent);
}

.leaderboard-subtle {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.runner-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.runner-avatar {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  object-fit: cover;
  border: 1px solid rgba(160, 190, 215, 0.26);
  background: rgba(255, 255, 255, 0.08);
}

.runner-copy {
  min-width: 0;
}

.time-cell {
  color: #73d94a;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 10px rgba(115, 217, 74, 0.14);
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 28px;
  border-radius: 3px;
  color: #e8eef8;
  font-weight: 800;
  font-size: 13px;
  background: linear-gradient(180deg, #3d4852, #202832);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.rank-1 {
  color: #fff7c4;
  background: linear-gradient(180deg, #d6aa18, #83620d);
}

.rank-2 {
  color: #f4f8ff;
  background: linear-gradient(180deg, #8794a3, #4b5663);
}

.rank-3 {
  color: #ffe3c2;
  background: linear-gradient(180deg, #b76a23, #724018);
}

.leaderboard-detail-row td {
  padding-top: 0;
  background: rgba(6, 11, 17, 0.86);
}

.leaderboard-detail-card {
  margin: 4px 0 10px;
  padding: 14px;
  border-radius: 4px;
  border: 1px solid rgba(120, 145, 168, 0.18);
  background: rgba(8, 14, 21, 0.92);
}

.sector-table {
  width: 100%;
  border-collapse: collapse;
}

.sector-table th,
.sector-table td {
  padding: 12px 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--table-line);
  text-align: left;
  vertical-align: middle;
}

th {
  height: 34px;
  font-size: 11px;
  color: #d7e0ea;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(7, 12, 18, 0.84);
  border-bottom-color: rgba(169, 194, 215, 0.18);
}

td {
  color: #cbd8e6;
  font-size: 14px;
  background: rgba(17, 25, 34, 0.68);
}

.leaderboard-row:nth-child(4n + 1) td {
  background: rgba(20, 29, 38, 0.74);
}

.leaderboard-row:hover td {
  background: rgba(34, 48, 61, 0.82);
}

.leaderboard-empty {
  margin: 14px 0 0;
}

.table-empty-cell {
  height: 72px;
  color: var(--muted);
  text-align: center;
}

tr:last-child td { border-bottom: 0; }

.message { margin: 0; }
.message.error { color: var(--danger); }
.message.success { color: #85f0be; }

.profile-layout {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 24px;
  align-items: start;
}

.avatar-column {
  gap: 8px;
  align-content: start;
}

.editor-box > summary,
.inline-editor > summary {
  list-style: none;
}

.editor-box > summary::-webkit-details-marker,
.inline-editor > summary::-webkit-details-marker {
  display: none;
}

.editor-trigger {
  width: 100%;
  cursor: pointer;
}

.avatar-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.avatar {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 24px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.04);
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.stat-card {
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
}

.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { margin-top: 6px; font-size: 24px; font-weight: 700; }

.nick-card {
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
}

.nick-inline-form {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.nick-inline-display {
  font-size: 24px;
  font-weight: 700;
}

.nick-inline-input {
  display: none;
}

.nick-inline-form.is-editing .nick-inline-input {
  display: block;
  width: min(260px, 100%);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.icon-check {
  display: none;
}

.nick-inline-form.is-editing .icon-pencil {
  display: none;
}

.nick-inline-form.is-editing .icon-check {
  display: block;
}

@media (max-width: 720px) {
  .container { width: min(100%, calc(100% - 24px)); padding-top: 24px; }
  .profile-layout, .stats { grid-template-columns: 1fr; }
  .nick-inline-form {
    width: 100%;
  }
  .nick-inline-form.is-editing .nick-inline-input {
    width: 100%;
  }
}
