:root {
  color-scheme: light;
  --bg: #f7f4ec;
  --card: #fffdf8;
  --ink: #1d1d1b;
  --muted: #625f57;
  --line: #ddd3c1;
  --accent: #155eef;
  --accent-soft: #e6efff;
  --success: #0a7d32;
  --error: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, #fff4d6 0, transparent 35%),
    linear-gradient(180deg, #f9f6ef 0%, #f1ece1 100%);
  color: var(--ink);
}

.shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}

.site-footer {
  display: flex;
  justify-content: center;
  gap: 18px;
  padding: 0 20px 32px;
  font-size: 14px;
}

.site-footer a {
  color: var(--muted);
}

.topbar,
.section-header,
.button-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.admin-grid {
  align-items: start;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 10px 24px rgba(29, 29, 27, 0.06);
  margin-bottom: 18px;
}

.login-card {
  max-width: 460px;
  margin: 12vh auto 0;
  text-align: center;
}

.stacked-form {
  text-align: left;
  margin: 20px 0 18px;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--muted);
  font-size: 14px;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--line);
}

.legal-card {
  max-width: 820px;
  margin: 24px auto 0;
  line-height: 1.6;
}

.legal-card ul {
  padding-left: 20px;
}

.metric-card .metric {
  font-size: 52px;
  font-weight: 700;
  margin: 8px 0 0;
}

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

h1,
h2 {
  margin-top: 0;
}

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

.details div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

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

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

th {
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

label {
  display: block;
  margin-bottom: 14px;
}

label span {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  color: var(--muted);
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

button,
.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 0;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
}

.secondary-button {
  background: var(--accent-soft);
  color: var(--accent);
}

.message {
  min-height: 24px;
  margin-top: 12px;
  font-size: 14px;
}

.message.success {
  color: var(--success);
}

.message.error {
  color: var(--error);
}

.hidden {
  display: none;
}

.rank-cell {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  width: 64px;
}

.last-change-cell {
  max-width: 420px;
}

.points-hover-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.points-link {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 0;
  border-radius: 0;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.points-tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  z-index: 20;
  display: none;
  width: min(340px, calc(100vw - 40px));
  transform: translateX(-50%);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #1d1d1b;
  color: #fff;
  box-shadow: 0 12px 30px rgba(29, 29, 27, 0.24);
  font-size: 13px;
  line-height: 1.35;
  white-space: normal;
}

.points-tooltip::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translateX(-50%);
  border: 7px solid transparent;
  border-top-color: #1d1d1b;
}

.points-hover-wrap:hover .points-tooltip,
.points-hover-wrap:focus-within .points-tooltip {
  display: grid;
  gap: 6px;
}

.tooltip-line {
  display: block;
}

.tooltip-hint {
  display: block;
  color: #cbd5e1;
  font-size: 12px;
}

.points-link:hover,
.points-link:focus {
  color: #0b46bd;
}

.history-dialog {
  width: min(920px, calc(100vw - 28px));
  max-height: min(760px, calc(100vh - 28px));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 24px 80px rgba(29, 29, 27, 0.28);
}

.history-dialog::backdrop {
  background: rgba(29, 29, 27, 0.32);
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.table-wrap {
  overflow-x: auto;
}

.leaderboard-wrap {
  overflow: visible;
}

code {
  font-family: "JetBrains Mono", monospace;
}

@media (max-width: 720px) {
  .topbar,
  .section-header,
  .button-row,
  .dialog-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .shell {
    padding: 20px 14px 32px;
  }
}
