/* asr-points — shared styles. Visual language borrowed from the S1OP Points
   System (Manrope, pastel blue palette, 1rem radii, pill buttons, huge
   leaderboard type). Class names are stable — JS depends on them. */

@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
  /* S1OP palette (hsl from the reference project's globals.css) */
  --ink: hsl(339 20% 20%);          /* foreground */
  --muted: hsl(210 22% 45%);        /* secondary text */
  --bg: hsl(210 100% 97%);          /* aliceblue */
  --card: hsl(0 0% 100%);
  --line: hsl(210 40% 80%);         /* border */
  --primary: hsl(339 20% 20%);      /* dark charcoal-plum: main CTAs (S1OP neutral-800) */
  --primary-ink: hsl(210 100% 97%); /* text on primary */
  --lilac: hsl(308 56% 85%);        /* soft pink-lilac highlight */
  --cyan: hsl(196 75% 88%);         /* light cyan fill */
  --accent: hsl(211 86% 70%);       /* sky blue: selection */
  --accent-deep: hsl(211 70% 52%);  /* sky blue pressed/hover */
  --danger: hsl(0 93% 73%);         /* coral red */
  --danger-deep: hsl(0 70% 48%);
  --ok: hsl(160 64% 40%);           /* success green (kept for toasts/health) */
  --warn: hsl(38 92% 50%);
  --chip: hsl(210 100% 94%);
  --radius: 1rem;
  --radius-lg: calc(var(--radius) + 4px);
  --radius-sm: calc(var(--radius) - 6px);
  --shadow-sm: 0 1px 2px rgba(46, 39, 51, 0.06);
  --shadow-md: 0 4px 16px rgba(46, 39, 51, 0.10);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  margin: 0;
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
body.big { font-size: 22px; }

h1, h2, h3, h4, h5, h6 { font-weight: 800; letter-spacing: -0.01em; }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: hsl(210 64% 98%);
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
}
.topbar h1 { font-size: 1.15rem; margin: 0; font-weight: 800; }
.topbar .row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.topbar a { color: var(--muted); text-decoration: none; font-size: .85rem; font-weight: 700; }
.topbar a.pill {
  background: transparent; padding: 7px 14px; border-radius: 999px;
  border: 1.5px solid var(--line); color: var(--ink);
  transition: background .15s, border-color .15s;
}
.topbar a.pill:hover { background: var(--chip); border-color: transparent; }
main { max-width: 760px; margin: 0 auto; padding: 18px 14px 96px; }
main.wide { max-width: 1100px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.card h2 { margin: 0 0 10px; font-size: 1.05rem; color: var(--ink); }
.hint { color: var(--muted); font-size: .84rem; margin: 4px 0 10px; line-height: 1.45; }

/* ---------- buttons & chips ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 50px; padding: 11px 20px; border: 1.5px solid transparent; border-radius: 999px;
  background: var(--primary); color: var(--primary-ink); font-size: 1rem; font-weight: 700;
  font-family: inherit;
  cursor: pointer; user-select: none; width: 100%;
  transition: background .15s, transform .05s;
}
.btn:hover { background: hsl(339 20% 28%); }
.btn:active { transform: scale(.985); }
.btn.secondary { background: var(--chip); color: var(--ink); border-color: var(--line); }
.btn.secondary:hover { background: var(--cyan); }
.btn.danger { background: var(--danger); color: hsl(0 60% 15%); }
.btn.danger:hover { background: var(--danger-deep); color: white; }
.btn.success { background: var(--accent); color: hsl(211 60% 14%); }
.btn.success:hover { background: var(--accent-deep); color: white; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.slim { min-height: 42px; padding: 8px 16px; width: auto; font-size: .9rem; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; min-width: 64px; padding: 8px 16px;
  background: var(--card); border: 1.5px solid var(--line); border-radius: 999px;
  font-weight: 700; font-size: 1rem; font-family: inherit; color: var(--ink);
  cursor: pointer; user-select: none;
  transition: background .12s, border-color .12s, transform .05s;
}
.chip:hover { background: var(--chip); }
.chip:active { transform: scale(.97); }
.chip.selected {
  background: var(--accent); color: hsl(211 60% 12%);
  border-color: var(--accent-deep); font-weight: 800;
}
.chip.gold { background: var(--lilac); color: var(--ink); border-color: hsl(308 40% 68%); }
.chip .sub { font-weight: 500; font-size: .72rem; opacity: .8; margin-left: 4px; }
.chip.off { opacity: .4; }

.stationbar { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: none; }
.stationbar::-webkit-scrollbar { display: none; }
.stationbar .chip { flex: 0 0 auto; min-height: 44px; font-size: .92rem; }
.stationbar .chip.selected {
  background: var(--ink); color: var(--bg); border-color: var(--ink);
}
.phasetoggle { display: flex; gap: 8px; margin-bottom: 10px; }
.phasetoggle button {
  flex: 1; min-height: 44px; border-radius: 999px; border: 1.5px solid var(--line);
  background: transparent; color: var(--muted); font-weight: 800; font-family: inherit;
  font-size: .95rem; cursor: pointer; transition: background .15s, color .15s;
}
.phasetoggle button.selected { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* ---------- slots (rank order) ---------- */
.slots { display: grid; gap: 8px; margin: 12px 0; }
.slot {
  display: flex; align-items: center; gap: 10px; min-height: 54px;
  background: var(--cyan); border-radius: var(--radius-sm); padding: 8px 14px;
  cursor: pointer; border: 1.5px solid transparent;
}
.slot .place { font-weight: 800; width: 46px; color: hsl(210 40% 30%); }
.slot .pts { margin-left: auto; font-weight: 800; color: hsl(211 70% 34%); }
.slot.empty {
  opacity: .6; border: 1.5px dashed var(--line); background: transparent;
}
.slot.empty .name { color: var(--muted); font-weight: 600; }
.slot .name { font-weight: 800; font-size: 1.05rem; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { padding: 12px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); position: sticky; top: 0; background: var(--card);
  font-weight: 800;
}
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--chip); }
.lb-table {
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  overflow: hidden; background: var(--card); box-shadow: var(--shadow-sm);
}
.lb-table td { font-size: 1.15rem; padding: 14px 12px; }
.lb-table td.points-cell { font-size: 1.35rem; }
body.big .lb-table td { font-size: 1.7rem; padding: 16px 12px; }
body.big .lb-table td.points-cell { font-size: 2rem; }
.rankcell { font-weight: 800; width: 52px; }
.medal { font-size: 1.35em; }
tr.breakrow td { background: var(--chip); font-size: .85rem; color: var(--muted); }
.delta-up { color: var(--ok); font-weight: 800; }
.delta-down { color: var(--danger-deep); font-weight: 800; }
.points-cell { font-weight: 800; color: hsl(211 70% 34%); }

/* big page title (S1OP-style leaderboard heading) */
.lb-title {
  font-size: clamp(2.6rem, 9vw, 5.5rem);
  font-weight: 800; letter-spacing: -0.02em; line-height: 1.02;
  margin: 0 0 6px;
}

/* ---------- misc ---------- */
.badge {
  display: inline-block; padding: 4px 12px; border-radius: 999px;
  background: var(--warn); color: hsl(38 80% 14%); font-size: .78rem; font-weight: 800;
}
.badge.ok { background: hsl(160 64% 88%); color: var(--ok); }
.badge.gray { background: var(--chip); color: var(--muted); }
.badge.red { background: var(--danger); color: hsl(0 60% 15%); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 50;
  background: var(--ink); color: var(--bg); padding: 13px 20px; border-radius: 999px;
  font-weight: 700; max-width: 92vw; text-align: center;
  box-shadow: var(--shadow-md); animation: pop .18s ease-out;
}
.toast.error { background: var(--danger-deep); color: white; }
@keyframes pop { from { opacity: 0; transform: translateX(-50%) translateY(8px); } }

.bottombar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
}
.bottombar .inner { max-width: 760px; margin: 0 auto; display: flex; gap: 10px; align-items: center; }
.bottombar .summary { flex: 1; font-size: .86rem; color: var(--muted); font-weight: 600; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: .8rem; font-weight: 800; color: var(--muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .05em; }
.field input, .field select, .field textarea {
  width: 100%; min-height: 50px; padding: 11px 14px; font-size: 1rem; font-family: inherit;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: var(--card); color: var(--ink);
}
.field textarea { min-height: 110px; font-family: ui-monospace, monospace; font-size: .85rem; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px hsl(211 86% 70% / .3);
}

.tabs { display: flex; gap: 8px; margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: 0 0 auto; min-height: 44px; padding: 8px 18px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--card); font-weight: 800;
  cursor: pointer; color: var(--muted); font-family: inherit; font-size: .92rem;
}
.tabs button.selected { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.updatedline { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .84rem; margin: 8px 2px 14px; font-weight: 600; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); }
.dot.fetching { animation: pulse .8s infinite alternate; background: var(--warn); }
@keyframes pulse { from { opacity: .4; } to { opacity: 1; } }

.modal-back {
  position: fixed; inset: 0; background: hsl(339 20% 20% / .45); z-index: 60;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--card); width: 100%; max-width: 560px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 20px 18px calc(22px + env(safe-area-inset-bottom)); max-height: 88vh; overflow-y: auto;
  box-shadow: var(--shadow-md);
}
.modal h3 { margin: 0 0 8px; font-size: 1.2rem; }
.modal .sumrow { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px dashed var(--line); font-weight: 700; }
.modal .actions { display: flex; gap: 10px; margin-top: 16px; }

.login-wrap { max-width: 380px; margin: 10vh auto 0; padding: 0 16px; }
.login-wrap .logo { text-align: center; font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 22px; }

.muted { color: var(--muted); font-size: .85rem; }
.error-text { color: var(--danger-deep); font-weight: 700; font-size: .9rem; min-height: 1.2em; margin: 8px 0; }
.success-text { color: var(--ok); font-weight: 800; font-size: .9rem; }
.pre { background: var(--chip); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; font-family: ui-monospace, monospace; font-size: .8rem; white-space: pre-wrap; overflow-x: auto; }
.flexrow { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.flexrow > * { flex: 1 1 auto; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }

@media (min-width: 700px) {
  .login-wrap { margin-top: 14vh; }
  .lb-title { margin: 8px 0 10px; }
}
