/* ==========================================================================
   Cube Juggling Rankings - design system

   1. Tokens            6. Forms
   2. Base / layout     7. Category UI
   3. Header            8. Toolbar / search
   4. Notice / footer   9. Rankings table + empty states
   5. Buttons          10. Admin  11. Utilities  12. Responsive
   ========================================================================== */

/* Flags-only subset font (Twemoji via country-flag-emoji-polyfill, see
   fonts/NOTICE.txt). Scoped to the regional-indicator block so it is fetched
   only when a flag is actually drawn and touches nothing else. */
@font-face {
  font-family: "Twemoji Country Flags";
  src: url("/fonts/TwemojiCountryFlags.woff2") format("woff2");
  unicode-range: U+1F1E6-1F1FF;
  font-display: swap;
}

/* ---------- 1. tokens ---------- */

:root {
  /* surfaces */
  --bg:           #0b0d11;
  --bg-soft:      #0e1116;
  --surface:      #13171d;
  --surface-2:    #191e26;
  --surface-3:    #212832;
  --line:         #242b35;
  --line-strong:  #333c49;

  /* text */
  --text:         #eef1f6;
  --text-2:       #b9c2d0;
  --muted:        #8792a3;
  --faint:        #6b7686;

  /* brand */
  --accent:       #2ed3bd;
  --accent-hi:    #57e5d1;
  --accent-lo:    #17786d;
  --accent-tint:  rgba(46, 211, 189, .12);
  --accent-ink:   #04221f;
  --gold:         #f2c14e;
  --silver:       #cbd3df;
  --bronze:       #d18a52;

  /* status */
  --danger:       #f2726a;
  --danger-lo:    #5d312e;
  --ok:           #5ec98a;
  --ok-lo:        #2c5740;
  --warn:         #e0aa48;
  --warn-lo:      #58461f;

  /* radii */
  --r-xs: 5px;
  --r-sm: 7px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-pill: 999px;

  /* spacing scale */
  --s-1: 4px;   --s-2: 8px;   --s-3: 12px;  --s-4: 16px;
  --s-5: 20px;  --s-6: 24px;  --s-7: 32px;  --s-8: 40px;
  --s-9: 56px;  --s-10: 72px;

  /* controls */
  --h-control: 40px;
  --h-control-sm: 32px;

  /* type */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* effects */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-md: 0 6px 20px -6px rgba(0, 0, 0, .6);
  --shadow-lg: 0 24px 60px -12px rgba(0, 0, 0, .7);
  --t-fast: 120ms cubic-bezier(.4, 0, .2, 1);
  --t-med: 180ms cubic-bezier(.4, 0, .2, 1);
}

/* ---------- 2. base / layout ---------- */

*, *::before, *::after { box-sizing: border-box; }

/* Beats the display rules set on buttons, navs and fields below. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Faint cube-grid motif, fading out down the page. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, .025) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, .025) 1px, transparent 1px);
  background-size: 72px 72px;
  -webkit-mask-image: radial-gradient(ellipse 85% 50% at 50% 0%, #000 0%, transparent 75%);
  mask-image: radial-gradient(ellipse 85% 50% at 50% 0%, #000 0%, transparent 75%);
}
body > * { position: relative; z-index: 1; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hi); text-decoration: underline; text-underline-offset: 2px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
::selection { background: rgba(46, 211, 189, .28); }

.wrap { width: 100%; max-width: 1140px; margin: 0 auto; padding: 0 var(--s-6); }
.narrow { max-width: 720px; margin-left: auto; margin-right: auto; }

main.wrap { flex: 1; padding-top: var(--s-7); padding-bottom: var(--s-9); }

.skip-link {
  position: absolute;
  left: -9999px;
  top: var(--s-2);
  z-index: 100;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 10px 16px;
  border-radius: var(--r-sm);
  font-weight: 650;
}
.skip-link:focus { left: var(--s-4); text-decoration: none; }

/* type scale */
h1 {
  font-size: clamp(26px, 3.2vw, 31px);
  line-height: 1.15;
  margin: 0;
  letter-spacing: -.022em;
  font-weight: 700;
}
h2 { font-size: 19px; line-height: 1.3; margin: var(--s-7) 0 var(--s-3); letter-spacing: -.012em; font-weight: 650; }
h3 { font-size: 15px; line-height: 1.4; margin: var(--s-5) 0 var(--s-2); font-weight: 650; }

.page-head { margin-bottom: var(--s-6); }
.page-head .page-sub { margin-top: var(--s-2); }
.page-sub { color: var(--muted); margin: 0; max-width: 66ch; font-size: 15px; }
.page-sub a { font-weight: 550; }
.page-sub + .page-sub { margin-top: var(--s-2); }

.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .11em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 0 0 var(--s-2);
}

.muted { color: var(--muted); }
.small { font-size: 13px; }
.tnum { font-variant-numeric: tabular-nums; }

.loading { color: var(--muted); padding: var(--s-8) 0; font-size: 14px; }

/* ---------- 3. header ---------- */

.site-header {
  background: rgba(14, 17, 22, .9);
  backdrop-filter: saturate(150%) blur(10px);
  -webkit-backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: var(--s-5);
  min-height: 62px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  margin-right: auto;
  border-radius: var(--r-sm);
  padding: 2px;
}
.brand:hover { text-decoration: none; color: var(--text); }
.brand-mark { display: flex; flex: none; }
.brand-mark svg { display: block; }

.brand-svg { transition: transform var(--t-med); }
.brand:hover .brand-svg { transform: translateY(-1px); }

.brand-text { display: flex; flex-direction: column; gap: 2px; }
.brand-line1 {
  font-size: 14px;
  font-weight: 750;
  letter-spacing: .05em;
  text-transform: uppercase;
  line-height: 1;
}
.brand-line2 {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .32em;
  text-transform: uppercase;
  color: var(--accent);
  line-height: 1;
}

.main-nav { display: flex; align-items: center; gap: 2px; }
.main-nav a {
  position: relative;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: var(--r-sm);
  font-weight: 550;
  font-size: 14px;
  white-space: nowrap;
  transition: color var(--t-fast), background var(--t-fast);
}
.main-nav a:hover { color: var(--text); text-decoration: none; background: rgba(255, 255, 255, .05); }
.main-nav a.active { color: var(--text); }
.main-nav a.active::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -12px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--accent);
}
.main-nav a .badge { margin-left: 6px; }

.nav-toggle {
  display: none;
  width: var(--h-control);
  height: var(--h-control);
  padding: 0;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text);
  flex: none;
}
.nav-toggle-bars { display: flex; flex-direction: column; gap: 4px; width: 16px; }
.nav-toggle-bars i {
  display: block;
  height: 1.8px;
  background: currentColor;
  border-radius: 2px;
  transition: transform var(--t-med), opacity var(--t-fast);
}
.nav-toggle[aria-expanded="true"] .nav-toggle-bars i:nth-child(1) { transform: translateY(5.8px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-bars i:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bars i:nth-child(3) { transform: translateY(-5.8px) rotate(-45deg); }

/* ---------- 4. notice / footer ---------- */

.site-notice {
  margin-top: var(--s-5);
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--accent-lo);
  background: var(--accent-tint);
  border-radius: var(--r-md);
  font-size: 14px;
}
.site-notice p { margin: 0 0 var(--s-2); }
.site-notice p:last-child { margin-bottom: 0; }

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
  padding: var(--s-6) 0 var(--s-8);
  font-size: 13px;
  color: var(--muted);
}
.footer-inner { display: flex; gap: var(--s-6); align-items: flex-start; flex-wrap: wrap; }
.footer-brand { display: flex; align-items: center; gap: var(--s-2); flex: none; }
.footer-logo { display: flex; opacity: .9; }
.footer-domain {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-2);
}
.footer-copy { flex: 1; min-width: 240px; max-width: 70ch; }
.footer-actions { flex: none; display: flex; align-items: flex-start; }
.footer-actions .btn { text-decoration: none; }
.site-footer p { margin: 0 0 var(--s-1); }
.site-footer p:last-child { margin-bottom: 0; }

/* ---------- 5. buttons ---------- */

button, .btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  height: var(--h-control);
  padding: 0 var(--s-4);
  border-radius: var(--r-sm);
  cursor: pointer;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
  white-space: nowrap;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), transform var(--t-fast);
}
button:hover, .btn:hover {
  background: var(--surface-3);
  border-color: var(--muted);
  text-decoration: none;
  color: var(--text);
}
button:active, .btn:active { transform: translateY(1px); }
button:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary, button.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}
.btn-primary:hover, button.btn-primary:hover {
  background: var(--accent-hi);
  border-color: var(--accent-hi);
  color: var(--accent-ink);
}
.btn-ghost { background: transparent; border-color: var(--line-strong); color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: transparent; border-color: var(--danger-lo); color: var(--danger); }
.btn-danger:hover { background: rgba(242, 114, 106, .1); border-color: var(--danger); color: var(--danger); }
.btn-ok { background: transparent; border-color: var(--ok-lo); color: var(--ok); }
.btn-ok:hover { background: rgba(94, 201, 138, .1); border-color: var(--ok); color: var(--ok); }
.btn-sm { height: var(--h-control-sm); padding: 0 var(--s-3); font-size: 13px; }
.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  padding: 0;
  height: auto;
  font-weight: 550;
}
.btn-link:hover { background: none; text-decoration: underline; color: var(--accent-hi); }
.btn svg, button svg { flex: none; }

/* ---------- 6. forms ---------- */

/* Every text-like input, rather than an enumerated list of types - an
   omitted type (email, tel, ...) would otherwise fall back to the browser's
   default white box. Checkboxes, radios and file inputs style themselves. */
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
select, textarea {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--text);
  border-radius: var(--r-sm);
  height: var(--h-control);
  padding: 0 var(--s-3);
  font: inherit;
  font-size: 14px;
  width: 100%;
  max-width: 100%;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
input:hover:not(:disabled), select:hover:not(:disabled), textarea:hover:not(:disabled) {
  border-color: var(--muted);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
  background: var(--surface-2);
}
input::placeholder, textarea::placeholder { color: var(--faint); }

/* Chrome paints autofilled fields with its own light background. There is no
   background property to override, so flood the field with an inset shadow
   and force the text colour. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
select:-webkit-autofill {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--surface-2) inset;
  box-shadow: 0 0 0 1000px var(--surface-2) inset;
  caret-color: var(--text);
  transition: background-color 9999s ease-out 0s;
}
input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--surface-2) inset, 0 0 0 3px var(--accent-tint);
  box-shadow: 0 0 0 1000px var(--surface-2) inset, 0 0 0 3px var(--accent-tint);
}
textarea { resize: vertical; min-height: 96px; height: auto; padding: 10px var(--s-3); line-height: 1.55; }
select {
  cursor: pointer;
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%238792a3' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6.5 8 10.5 12 6.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 15px;
}
select option { background: var(--surface-2); color: var(--text); }
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(.7); cursor: pointer; }
input.invalid, select.invalid, textarea.invalid { border-color: var(--danger); }
input.invalid:focus, select.invalid:focus, textarea.invalid:focus {
  box-shadow: 0 0 0 3px rgba(242, 114, 106, .14);
}

.form-card {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  padding: var(--s-6);
  box-shadow: var(--shadow-sm);
}

.form-section + .form-section { margin-top: var(--s-6); }
.form-section-head {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}
.form-section-head .step svg { display: block; }
.form-section-head .step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: var(--r-xs);
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.form-section-head h2 {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .11em;
  text-transform: uppercase;
  color: var(--text-2);
}
.form-section-head .rule { flex: 1; height: 1px; background: var(--line); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.hint { font-size: 12px; color: var(--faint); line-height: 1.45; }
.field .field-error {
  font-size: 12px;
  color: var(--danger);
  display: none;
  align-items: center;
  gap: 5px;
}
.field.has-error .field-error { display: flex; }
.field.has-error label { color: var(--danger); }
.req { color: var(--danger); font-weight: 700; }
.optional { color: var(--faint); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; }
.honeypot { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.form-actions {
  display: flex;
  gap: var(--s-3);
  align-items: center;
  margin-top: var(--s-6);
  padding-top: var(--s-5);
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.form-actions .btn-primary { min-width: 150px; }

/* checkbox / switch */
.check {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  color: var(--text-2);
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}
.check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex: none;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  height: var(--h-control);
  transition: color var(--t-fast);
}
.toggle:hover { color: var(--text-2); }
.toggle input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.toggle .track {
  position: relative;
  width: 34px;
  height: 20px;
  flex: none;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  transition: background var(--t-med), border-color var(--t-med);
}
.toggle .track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform var(--t-med), background var(--t-med);
}
.toggle input:checked + .track { background: var(--accent-lo); border-color: var(--accent); }
.toggle input:checked + .track::after { transform: translateX(14px); background: var(--accent); }
.toggle input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.toggle input:checked ~ .toggle-label { color: var(--text); }

/* messages */
.msg {
  padding: 11px var(--s-4);
  border-radius: var(--r-sm);
  font-size: 14px;
  margin-bottom: var(--s-4);
  display: flex;
  gap: var(--s-2);
  align-items: flex-start;
}
.msg-error { background: rgba(242, 114, 106, .1); border: 1px solid var(--danger-lo); color: #f8b8b3; }
.msg-ok { background: rgba(94, 201, 138, .1); border: 1px solid var(--ok-lo); color: #a7e4c1; }

.success-card {
  border: 1px solid var(--ok-lo);
  background: rgba(94, 201, 138, .07);
  border-radius: var(--r-lg);
  padding: var(--s-6);
}
.success-card .success-mark {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(94, 201, 138, .14);
  border: 1px solid var(--ok-lo);
  color: var(--ok);
  margin-bottom: var(--s-4);
}
.success-card p { margin: 0 0 var(--s-3); }
.success-card .actions { display: flex; gap: var(--s-3); flex-wrap: wrap; margin-top: var(--s-5); }

/* country combobox */
.combo { position: relative; }
.combo-btn {
  width: 100%;
  justify-content: space-between;
  background: var(--surface);
  border-color: var(--line-strong);
  font-weight: 500;
  padding: 0 11px;
  color: var(--text);
}
.combo-btn:hover { background: var(--surface); border-color: var(--muted); }
.combo-btn.invalid { border-color: var(--danger); }
.combo-btn.invalid:focus { box-shadow: 0 0 0 3px rgba(242, 114, 106, .14); }
.combo[data-open="true"] .combo-btn {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.combo-btn .combo-value {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.combo-btn.is-empty .combo-value { color: var(--faint); }
.combo-btn .chevron { color: var(--muted); transition: transform var(--t-fast); }
.combo[data-open="true"] .chevron { transform: rotate(180deg); }

.combo-pop {
  position: absolute;
  z-index: 50;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.combo-search { position: relative; padding: var(--s-2); border-bottom: 1px solid var(--line); }
.combo-search input { height: 34px; padding-left: 32px; }
.combo-search .search-icon { position: absolute; left: 19px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.combo-list {
  list-style: none;
  margin: 0;
  padding: var(--s-1);
  max-height: 244px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.combo-list li {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 7px var(--s-2);
  border-radius: var(--r-xs);
  cursor: pointer;
  font-size: 14px;
  color: var(--text-2);
}
.combo-list li[aria-selected="true"] { color: var(--text); font-weight: 600; }
.combo-list li.active { background: var(--surface-3); color: var(--text); }
.combo-list li .tick { margin-left: auto; color: var(--accent); }
.combo-empty { padding: var(--s-4); text-align: center; color: var(--faint); font-size: 13px; }

/* flags */
.flag {
  font-family: "Twemoji Country Flags", var(--font);
  font-size: 16px;
  line-height: 1;
  flex: none;
}
.flag-code {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 18px;
  padding: 0 4px;
  flex: none;
  border-radius: 3px;
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .04em;
}
.flag-code.is-blank { color: var(--faint); }

/* ---------- 7. category UI ---------- */

.cat-picker {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  margin-bottom: var(--s-5);
}

.segmented {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 4px;
  gap: 4px;
  flex-wrap: wrap;
  max-width: 100%;
}
.segmented button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  height: 34px;
  padding: 0 var(--s-4);
  border-radius: var(--r-sm);
}
.segmented button:hover { color: var(--text); background: var(--surface-3); border-color: transparent; }
.segmented button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  font-weight: 700;
}
.segmented button[aria-pressed="true"]:hover { background: var(--accent-hi); }

.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.chips button {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 550;
  height: 32px;
  padding: 0 13px;
  border-radius: var(--r-pill);
}
.chips button:hover { color: var(--text); border-color: var(--line-strong); background: var(--surface-2); }
.chips button[aria-pressed="true"] {
  background: var(--accent-tint);
  border-color: var(--accent);
  color: var(--accent-hi);
  font-weight: 650;
}

/* selected-category banner */
.cat-banner {
  display: flex;
  gap: var(--s-4);
  align-items: flex-start;
  padding: var(--s-5);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md);
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-soft) 100%);
  margin-bottom: var(--s-5);
}
.cat-banner-mark {
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
}
.cat-banner-body { flex: 1; min-width: 0; }
.cat-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.01em;
  line-height: 1.25;
}
.cat-full { margin: 3px 0 0; color: var(--text-2); font-size: 14px; }
.cat-desc { margin: var(--s-2) 0 0; color: var(--muted); font-size: 13.5px; max-width: 78ch; }

.cat-stats {
  display: flex;
  gap: var(--s-6);
  flex: none;
  padding-left: var(--s-5);
  border-left: 1px solid var(--line);
  align-self: stretch;
  align-items: center;
}
.stat { display: flex; flex-direction: column; gap: 3px; }
.stat .stat-value {
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  color: var(--text);
}
.stat .stat-value.is-record { color: var(--gold); font-family: var(--mono); font-size: 16px; }
.stat .stat-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--faint);
}

/* ---------- 8. toolbar / search ---------- */

.toolbar {
  display: flex;
  gap: var(--s-3);
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: var(--s-4);
}
.toolbar .spacer { flex: 1 1 auto; }

.search-field { position: relative; flex: 0 1 300px; min-width: 220px; }
.search-field input[type="search"] {
  padding-left: 36px;
  padding-right: 32px;
  appearance: none;
}
.search-field input[type="search"]::-webkit-search-cancel-button { display: none; }
.search-field .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.search-field input:focus + .search-icon { color: var(--accent); }
.search-clear {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: var(--r-xs);
}
.search-clear:hover { background: var(--surface-3); color: var(--text); border: 0; }

/* ---------- 9. rankings table ---------- */

.table-card {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.table-scroll { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left;
  font-size: 10.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 700;
  padding: 10px var(--s-4);
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td {
  padding: 11px var(--s-4);
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background var(--t-fast); }
tbody tr:hover { background: rgba(255, 255, 255, .026); }

.col-rank { width: 62px; }
.col-time { width: 110px; }
.col-country { width: 150px; color: var(--text-2); }
.col-date { width: 120px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.col-video { width: 96px; }
.col-actions { white-space: nowrap; text-align: right; }
.col-actions button + button { margin-left: 6px; }

td.col-time {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  font-size: 14.5px;
  letter-spacing: -.01em;
  white-space: nowrap;
}
tr.is-first td.col-time { color: var(--gold); }

.rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 26px;
  padding: 0 6px;
  border-radius: var(--r-xs);
  font-weight: 700;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
  border: 1px solid transparent;
}
.rank-1 { color: var(--gold); background: rgba(242, 193, 78, .12); border-color: rgba(242, 193, 78, .3); }
.rank-2 { color: var(--silver); background: rgba(203, 211, 223, .09); border-color: rgba(203, 211, 223, .22); }
.rank-3 { color: var(--bronze); background: rgba(209, 138, 82, .1); border-color: rgba(209, 138, 82, .26); }
.rank-none { color: var(--faint); }

.player { display: flex; align-items: center; gap: var(--s-2); min-width: 0; }
.player-name { font-weight: 600; }
.wca {
  font-size: 11px;
  color: var(--faint);
  font-family: var(--mono);
  letter-spacing: .02em;
}
tr.obsolete { color: var(--muted); }
tr.obsolete .player-name { font-weight: 500; color: var(--muted); }
tr.obsolete td.col-time { font-weight: 550; color: var(--muted); }

.obsolete-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--faint);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-xs);
  padding: 1px 5px;
}

.video-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 550;
  color: var(--text-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-xs);
  padding: 4px 9px;
  transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
}
.video-link:hover {
  color: var(--accent);
  border-color: var(--accent-lo);
  background: var(--accent-tint);
  text-decoration: none;
}

.table-foot {
  padding: 9px var(--s-4);
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--faint);
  font-size: 12px;
  display: flex;
  gap: var(--s-4);
  flex-wrap: wrap;
}

/* empty states */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--s-8) var(--s-5);
  gap: var(--s-2);
}
.empty-state .empty-mark {
  width: 52px;
  height: 52px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--s-2);
}
.empty-state h3 { margin: 0; font-size: 16px; font-weight: 650; }
.empty-state p { margin: 0; color: var(--muted); font-size: 14px; max-width: 46ch; }
.empty-state .btn { margin-top: var(--s-3); }
.empty { padding: var(--s-6) var(--s-4); text-align: center; color: var(--muted); font-size: 14px; }

/* badges */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  color: var(--muted);
  border: 1px solid var(--line-strong);
  vertical-align: middle;
  line-height: 1.5;
}
.badge-pending { background: rgba(224, 170, 72, .13); color: var(--warn); border-color: var(--warn-lo); }
.badge-approved { background: rgba(94, 201, 138, .12); color: var(--ok); border-color: var(--ok-lo); }
.badge-rejected { background: rgba(242, 114, 106, .12); color: var(--danger); border-color: var(--danger-lo); }
.badge-count {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

/* ---------- image uploader ---------- */

.uploader {
  display: flex;
  gap: var(--s-4);
  align-items: center;
  padding: var(--s-3);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
}
.uploader-preview {
  width: 128px;
  height: 78px;
  flex: none;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
}
.uploader-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.uploader-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--faint);
  font-size: 11px;
}
.uploader-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--s-2);
  min-width: 0;
}
.uploader-controls input[type="file"] {
  font-size: 13px;
  color: var(--text-2);
  width: auto;
  max-width: 100%;
  height: auto;
  padding: 0;
  border: 0;
  background: none;
}
.uploader-controls input[type="file"]::file-selector-button {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: 7px 12px;
  margin-right: 10px;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.uploader-controls input[type="file"]::file-selector-button:hover {
  background: var(--surface-3);
  border-color: var(--muted);
}
.uploader-controls input[type="file"]:disabled { opacity: .6; }
.uploader-status { font-size: 12px; color: var(--muted); }
.uploader-status.is-error { color: var(--danger); }

@media (max-width: 480px) {
  .uploader { flex-direction: column; align-items: stretch; }
  .uploader-preview { width: 100%; height: 120px; }
}

/* ---------- news posts ---------- */

.post {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow: hidden;
  margin-bottom: var(--s-5);
  box-shadow: var(--shadow-sm);
}
.post-image {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.post-body { padding: var(--s-5); }
.post-date {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: var(--s-2);
}
.post-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -.015em;
}
.post-summary {
  margin: var(--s-2) 0 0;
  color: var(--text-2);
  font-size: 15px;
}
.post-content { margin-top: var(--s-4); max-width: none; }
.post-content > *:last-child { margin-bottom: 0; }
.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  display: block;
  margin: var(--s-4) 0;
}

/* ---------- prose (rules) ---------- */

.prose { max-width: 72ch; }
.prose h2 { margin-top: var(--s-7); font-size: 19px; }
.prose h2:first-child { margin-top: 0; }
.prose h3 { font-size: 16px; }
.prose ol, .prose ul { padding-left: var(--s-5); margin: 0 0 var(--s-4); }
.prose li { margin-bottom: var(--s-3); color: var(--text-2); }
.prose li::marker { color: var(--accent); font-weight: 700; }
.prose p { margin: 0 0 var(--s-4); color: var(--text-2); }
.prose strong { color: var(--text); font-weight: 650; }
.prose code {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  padding: 1px 5px;
  font-family: var(--mono);
  font-size: 12.5px;
}

/* ---------- 10. admin ---------- */

.admin-bar {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
  margin-bottom: var(--s-5);
  padding-bottom: var(--s-4);
  border-bottom: 1px solid var(--line);
}
.subtabs { display: flex; gap: var(--s-1); flex-wrap: wrap; }
.subtabs button {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  height: var(--h-control-sm);
  padding: 0 var(--s-3);
  font-size: 13.5px;
}
.subtabs button:hover { color: var(--text); background: var(--surface-2); border-color: transparent; }
.subtabs button[aria-pressed="true"] {
  background: var(--surface-3);
  border-color: var(--line-strong);
  color: var(--text);
}

.queue-item {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: var(--s-5);
  margin-bottom: var(--s-3);
}
.queue-head { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; margin-bottom: var(--s-3); }
.queue-head .qtime {
  font-size: 20px;
  font-weight: 700;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.queue-head .qname { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.kv { display: grid; grid-template-columns: 132px 1fr; gap: 5px var(--s-4); font-size: 14px; margin: 0; }
.kv dt { color: var(--faint); font-size: 13px; }
.kv dd { margin: 0; word-break: break-word; color: var(--text-2); }
.queue-actions {
  display: flex;
  gap: var(--s-2);
  margin-top: var(--s-4);
  padding-top: var(--s-4);
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

.proposal {
  margin-top: var(--s-3);
  padding: 10px var(--s-3);
  border-radius: var(--r-sm);
  border: 1px solid var(--warn-lo);
  background: rgba(224, 170, 72, .09);
  font-size: 14px;
  color: var(--text-2);
}

dialog.modal {
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--text);
  padding: 0;
  width: min(720px, calc(100vw - 32px));
  box-shadow: var(--shadow-lg);
}
dialog.modal::backdrop { background: rgba(4, 6, 9, .7); backdrop-filter: blur(2px); }
.modal-head {
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
}
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-body { padding: var(--s-5); max-height: 70vh; overflow-y: auto; }
.modal-body .form-actions { margin-bottom: 0; }

.login-card { max-width: 400px; }

/* ---------- 11. utilities ---------- */

.stack-sm > * + * { margin-top: var(--s-3); }
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- 12. responsive ---------- */

@media (max-width: 960px) {
  .cat-stats {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-left: 0;
    padding-top: var(--s-4);
    width: 100%;
    margin-top: var(--s-1);
  }
  .cat-banner { flex-wrap: wrap; }
  .col-country, thead th.col-country { display: none; }
}

@media (max-width: 860px) {
  .header-inner { gap: var(--s-3); min-height: 58px; }
  .nav-toggle { display: inline-flex; }
  .main-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: var(--bg-soft);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-md);
    padding: var(--s-2) var(--s-3) var(--s-3);
    display: none;
  }
  .main-nav.open { display: flex; }
  .main-nav a { padding: 11px var(--s-3); border-radius: var(--r-sm); font-size: 15px; }
  .main-nav a.active { background: var(--surface-2); }
  .main-nav a.active::after { left: 0; top: 8px; bottom: 8px; right: auto; width: 2px; height: auto; border-radius: 2px; }
}

@media (max-width: 720px) {
  .wrap { padding: 0 var(--s-4); }
  main.wrap { padding-top: var(--s-6); padding-bottom: var(--s-8); }
  .form-grid { grid-template-columns: 1fr; }
  .form-card { padding: var(--s-5) var(--s-4); }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: var(--s-2); }
  .search-field { flex: 1 1 100%; min-width: 0; }
  .toolbar .spacer { display: none; }
  .toolbar > .btn-primary { flex: 1 1 auto; }
  .segmented { display: flex; width: 100%; }
  .segmented button { flex: 1 1 auto; }
  .col-date, thead th.col-date { display: none; }
  .cat-banner { padding: var(--s-4); gap: var(--s-3); }
  .cat-stats { gap: var(--s-5); }
  .form-actions .btn-primary { width: 100%; }
}

@media (max-width: 480px) {
  .brand-mark svg { width: 30px; height: 30px; }
  .brand-line1 { font-size: 13px; }
  .cat-banner-mark { display: none; }
  .queue-item { padding: var(--s-4); }
  .queue-actions button { flex: 1 1 auto; }

  /* Trade the "Watch" wording for the icon alone so the table fits without
     a scrollbar; the link keeps its aria-label. */
  thead th, tbody td { padding-left: 10px; padding-right: 10px; }
  .video-label { display: none; }
  .video-link { padding: 5px 7px; }
  .col-rank { width: 44px; }
  .col-time { width: 92px; }
  .col-video { width: 44px; }
  .player-name { overflow-wrap: anywhere; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}
