/* =====================================================================
   Paddle Stack — design system

   Tokens are role-named, never hue-named, so light and dark resolve as
   complete sets. Nothing declares a colour outside :root / the theme
   blocks below.

   Palette is grounded in an outdoor court: cool paper surround, deep
   court blue, kitchen teal, and optic lime kept exclusively for the
   "live right now" state so it never becomes decoration.
   ===================================================================== */

:root {
  --bg:            #F1F3EF;
  --bg-alt:        #E8ECE4;
  --surface:       #FFFFFF;
  --surface-alt:   #E8ECE4;
  --border:        #D5DBCF;
  --border-strong: #B4BEAC;

  --text:        #0E1917;
  --text-muted:  #4C5A54;
  --text-faint:  #78867F;

  --brand:       #0F3B4C;
  --brand-deep:  #0A2A36;
  --on-brand:    #EAF0EC;

  --accent:      #16695C;
  --accent-soft: #E2EDE7;
  --on-accent:   #FFFFFF;

  --live:    #C6DC3E;
  --on-live: #17240B;

  --win:      #C0532B;
  --win-soft: #F7E7DF;

  --court-surface: #DCE6E3;
  --court-line:    #FFFFFF;

  --shadow:      0 1px 2px rgba(14,25,23,.06), 0 6px 16px -8px rgba(14,25,23,.18);
  --shadow-lift: 0 2px 6px rgba(14,25,23,.10), 0 18px 40px -18px rgba(14,25,23,.34);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-full: 999px;

  --display: 'Bricolage Grotesque', 'Arial Narrow', system-ui, sans-serif;
  --body:    'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono:    'DM Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  --wrap: 1080px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:            #0B1315;
    --bg-alt:        #101B1D;
    --surface:       #141F21;
    --surface-alt:   #1C2A2C;
    --border:        #27383A;
    --border-strong: #3A5054;

    --text:       #E9EFE9;
    --text-muted: #A6B5AF;
    --text-faint: #7A8B85;

    --brand:      #0D3241;
    --brand-deep: #081F29;
    --on-brand:   #E6EFE9;

    --accent:      #4FC0A8;
    --accent-soft: #17322F;
    --on-accent:   #062420;

    --live:    #CFE84F;
    --on-live: #17240B;

    --win:      #E8794D;
    --win-soft: #3A2019;

    --court-surface: #1B2C2E;
    --court-line:    #3E5A5C;

    --shadow:      0 1px 2px rgba(0,0,0,.4), 0 6px 16px -8px rgba(0,0,0,.6);
    --shadow-lift: 0 2px 6px rgba(0,0,0,.5), 0 18px 40px -18px rgba(0,0,0,.8);
  }
}

:root[data-theme="dark"] {
  --bg:            #0B1315;
  --bg-alt:        #101B1D;
  --surface:       #141F21;
  --surface-alt:   #1C2A2C;
  --border:        #27383A;
  --border-strong: #3A5054;

  --text:       #E9EFE9;
  --text-muted: #A6B5AF;
  --text-faint: #7A8B85;

  --brand:      #0D3241;
  --brand-deep: #081F29;
  --on-brand:   #E6EFE9;

  --accent:      #4FC0A8;
  --accent-soft: #17322F;
  --on-accent:   #062420;

  --live:    #CFE84F;
  --on-live: #17240B;

  --win:      #E8794D;
  --win-soft: #3A2019;

  --court-surface: #1B2C2E;
  --court-line:    #3E5A5C;

  --shadow:      0 1px 2px rgba(0,0,0,.4), 0 6px 16px -8px rgba(0,0,0,.6);
  --shadow-lift: 0 2px 6px rgba(0,0,0,.5), 0 18px 40px -18px rgba(0,0,0,.8);
}

/* ---------- reset ---------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; touch-action: manipulation; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1.05;
  text-wrap: balance;
}
p { margin: 0; }
.mono, .tnum { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); }

/* ---------- layout --------------------------------------------------- */
.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 20px; }
.wrap-narrow { max-width: 520px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grid-2 { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* ---------- site chrome ---------------------------------------------- */
.site-head {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-head .inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 62px; }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--text); text-decoration: none; font-family: var(--display); font-weight: 800; font-size: 18px; letter-spacing: -.02em; }
.brand svg { color: var(--accent); flex: none; }
.site-nav { display: flex; align-items: center; gap: 8px; }
.site-foot { border-top: 1px solid var(--border); margin-top: 64px; padding: 26px 0 34px; color: var(--text-faint); font-size: 13.5px; }

/* ---------- buttons -------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px;
  border-radius: var(--r-md);
  font-weight: 700; font-size: 15px; letter-spacing: -.01em;
  background: var(--accent); color: var(--on-accent);
  text-decoration: none;
  transition: transform .08s ease, filter .15s ease;
}
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: scale(.985); }
.btn:disabled { background: var(--surface-alt); color: var(--text-faint); cursor: not-allowed; filter: none; }
.btn-block { width: 100%; }
.btn-dark { background: var(--brand); color: var(--on-brand); }
.btn-ghost { background: transparent; color: var(--text); border: 1.5px solid var(--border-strong); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: transparent; color: var(--win); border: 1.5px solid var(--win); }
.btn-danger:hover { background: var(--win); color: #fff; filter: none; }
.btn-sm { min-height: 36px; padding: 0 13px; font-size: 13.5px; border-radius: var(--r-sm); }
.btn-lg { min-height: 54px; padding: 0 26px; font-size: 16.5px; }

/* ---------- cards & forms -------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}
.card-pad { padding: 20px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 13px; font-weight: 700; color: var(--text-muted); }
.input {
  width: 100%; min-height: 46px; padding: 11px 14px;
  background: var(--surface); color: var(--text);
  border: 1.5px solid var(--border); border-radius: var(--r-md);
  font-size: 16px; /* 16px keeps iOS from zooming on focus */
}
.input:focus { border-color: var(--accent); outline: none; }
.input[aria-invalid="true"] { border-color: var(--win); }
select.input { appearance: none; padding-right: 38px;
  background-image: linear-gradient(45deg, transparent 49%, currentColor 50%), linear-gradient(-45deg, transparent 49%, currentColor 50%);
  background-position: calc(100% - 19px) 20px, calc(100% - 13px) 20px;
  background-size: 6px 6px; background-repeat: no-repeat;
}
.err { font-size: 12.5px; color: var(--win); font-weight: 600; }
.hint { font-size: 13px; color: var(--text-faint); line-height: 1.5; }

.check { display: flex; gap: 12px; align-items: flex-start; padding: 13px 14px; border: 1px solid var(--border); border-radius: var(--r-md); cursor: pointer; background: var(--surface); }
.check input { width: 20px; height: 20px; flex: none; margin-top: 2px; accent-color: var(--accent); }
.check strong { display: block; font-size: 14.5px; }

.segmented { display: flex; background: var(--surface-alt); border-radius: var(--r-md); padding: 3px; gap: 3px; }
.segmented label { flex: 1; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: flex; align-items: center; justify-content: center;
  min-height: 40px; border-radius: 9px; font-size: 14px; font-weight: 700;
  color: var(--text-muted); cursor: pointer;
}
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.segmented input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- chips, flashes ------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; letter-spacing: .04em;
  padding: 3px 9px; border-radius: var(--r-full);
  background: var(--surface-alt); color: var(--text-muted);
}
.chip-live { background: var(--live); color: var(--on-live); }
.chip-you  { background: var(--accent); color: var(--on-accent); }
.chip-host { background: var(--brand); color: var(--on-brand); }
.chip-done { background: var(--surface-alt); color: var(--text-faint); }

.flash { padding: 12px 16px; border-radius: var(--r-md); font-size: 14px; font-weight: 600; border: 1px solid; }
.flash-success { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.flash-error   { background: var(--win-soft); color: var(--win); border-color: color-mix(in srgb, var(--win) 35%, transparent); }

.livedot { width: 8px; height: 8px; border-radius: 50%; background: var(--live); flex: none; animation: pulse 2.4s ease-out infinite; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(198,220,62,.55); }
  70%  { box-shadow: 0 0 0 8px rgba(198,220,62,0); }
  100% { box-shadow: 0 0 0 0 rgba(198,220,62,0); }
}

/* ---------- tables ---------------------------------------------------- */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th {
  font-family: var(--mono); font-size: 10.5px; font-weight: 500;
  letter-spacing: .12em; text-transform: uppercase; color: var(--text-faint);
  text-align: right; padding: 10px 8px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 12px 8px; text-align: right; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
th:first-child, td:first-child { text-align: left; padding-left: 18px; }
th:last-child, td:last-child { padding-right: 18px; }
tbody tr:last-child td { border-bottom: none; }
.rank-1 td { font-weight: 700; }
.medal { font-family: var(--mono); font-size: 12.5px; color: var(--text-faint); margin-right: 10px; }
.rank-1 .medal { color: var(--win); }

/* ---------- theme toggle (site header) -------------------------------- */
.themebtn {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--r-full);
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  background: var(--surface);
}
.themebtn:hover { color: var(--accent); border-color: var(--accent); }

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

/* ---------- empty state ---------------------------------------------- */
.empty { text-align: center; padding: 42px 22px; color: var(--text-faint); }
.empty h3 { font-size: 18px; color: var(--text-muted); margin-bottom: 6px; }

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