/* Design tokens mirror the existing SquashScore front end so the two apps read
   as one family. Light theme is the fallback; dark follows the OS. */
:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --card-hover: #e8ecf4;
  --card-border: #dde2ed;
  --text: #111827;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-subtle: rgba(37, 99, 235, 0.09);
  --green: #16a34a;
  --green-subtle: rgba(22, 163, 74, 0.1);
  --red: #dc2626;
  --red-subtle: rgba(220, 38, 38, 0.1);
  --amber: #b45309;
  --amber-subtle: rgba(180, 83, 9, 0.1);
  --surface: rgba(0, 0, 0, 0.02);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08);
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-full: 9999px;
  --date-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #080b14;
    --card: #0e1225;
    --card-hover: #1a2048;
    --card-border: #1c2240;
    --text: #f0f2f8;
    --text-secondary: #8b9bc0;
    --text-muted: #4a5580;
    --accent: #4d8eff;
    --accent-hover: #6aa0ff;
    --accent-subtle: rgba(77, 142, 255, 0.14);
    --green: #22c55e;
    --green-subtle: rgba(34, 197, 94, 0.13);
    --red: #ef4444;
    --red-subtle: rgba(239, 68, 68, 0.13);
    --amber: #f59e0b;
    --amber-subtle: rgba(245, 158, 11, 0.13);
    --surface: rgba(255, 255, 255, 0.03);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.5);
    --date-scheme: dark;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

input, button, select, textarea { font: inherit; color: inherit; }
input[type="datetime-local"], input[type="date"] { color-scheme: var(--date-scheme); }

/* ─── Shell ─────────────────────────────────────────── */

.shell {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 64px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
}

.brand { min-width: 0; }

.brand h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand p {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: var(--r-full);
  margin-bottom: 22px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 1 0 auto;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: var(--r-full);
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.tab[aria-selected="true"] { background: var(--card); color: var(--text); box-shadow: var(--shadow-sm); }

/* ─── Cards ─────────────────────────────────────────── */

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--r-lg);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card h2 {
  margin: 0 0 3px;
  font-size: 17px;
  font-weight: 620;
  letter-spacing: -0.01em;
}

.meta {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
}

.meta + .meta { margin-top: 2px; }

.section-title {
  margin: 30px 0 12px;
  font-size: 12px;
  font-weight: 620;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ─── Pills ─────────────────────────────────────────── */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--card-border);
}
.pill.yes { background: var(--green-subtle); color: var(--green); border-color: transparent; }
.pill.no { background: var(--red-subtle); color: var(--red); border-color: transparent; }
.pill.maybe { background: var(--amber-subtle); color: var(--amber); border-color: transparent; }
.pill.accent { background: var(--accent-subtle); color: var(--accent); border-color: transparent; }

/* ─── Answer buttons — the one interaction that must be effortless ── */

.answer {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 16px;
}

.answer button {
  padding: 13px 8px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--card-border);
  background: var(--card);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .1s, border-color .15s, background .15s, color .15s;
}
.answer button:hover:not(:disabled) { border-color: var(--text-muted); }
.answer button:active:not(:disabled) { transform: scale(.97); }
.answer button:disabled { opacity: .5; cursor: not-allowed; }

.answer button[aria-pressed="true"][data-value="yes"] {
  background: var(--green-subtle); border-color: var(--green); color: var(--green);
}
.answer button[aria-pressed="true"][data-value="no"] {
  background: var(--red-subtle); border-color: var(--red); color: var(--red);
}
.answer button[aria-pressed="true"][data-value="maybe"] {
  background: var(--amber-subtle); border-color: var(--amber); color: var(--amber);
}

/* ─── Forms ─────────────────────────────────────────── */

.field { margin-bottom: 12px; }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 560;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

input[type="text"], input[type="email"], input[type="tel"], input[type="number"],
input[type="datetime-local"], input[type="search"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--card-border);
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

textarea { resize: vertical; min-height: 64px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .grid-2 { grid-template-columns: 1fr; } }

/* ─── Buttons ───────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, transform .1s;
}
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn.ghost { background: transparent; border-color: var(--card-border); color: var(--text); }
.btn.ghost:hover { background: var(--card-hover); }
.btn.danger { background: transparent; border-color: var(--card-border); color: var(--red); }
.btn.danger:hover { background: var(--red-subtle); }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.block { width: 100%; }

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }

/* ─── Progress ──────────────────────────────────────── */

.bar {
  height: 6px;
  border-radius: var(--r-full);
  background: var(--card-hover);
  overflow: hidden;
  margin: 12px 0 8px;
}
.bar span { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.bar span.done { background: var(--green); }

/* ─── Roster / grid rows ────────────────────────────── */

.rows { display: flex; flex-direction: column; gap: 1px; background: var(--card-border); border-radius: var(--r-md); overflow: hidden; }

.rows .line {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  background: var(--card);
}

.line .name { font-weight: 560; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line .sub { font-size: 13px; color: var(--text-muted); }

.drag-list { display: flex; flex-direction: column; gap: 6px; }

.drag-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--card-border);
  border-radius: var(--r-md);
  background: var(--card);
}

.drag-item .pos {
  width: 26px; height: 26px;
  flex: 0 0 26px;
  display: grid; place-items: center;
  border-radius: var(--r-full);
  background: var(--accent-subtle);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.move { border: 0; background: transparent; color: var(--text-muted); cursor: pointer; padding: 4px 6px; border-radius: var(--r-sm); }
.move:hover:not(:disabled) { background: var(--card-hover); color: var(--text); }
.move:disabled { opacity: .3; cursor: not-allowed; }

/* ─── Notices ───────────────────────────────────────── */

.notice {
  padding: 12px 14px;
  border-radius: var(--r-md);
  font-size: 14px;
  margin-bottom: 12px;
  border: 1px solid transparent;
}
.notice.warn { background: var(--amber-subtle); color: var(--amber); }
.notice.info { background: var(--accent-subtle); color: var(--accent); }
.notice.ok { background: var(--green-subtle); color: var(--green); }
.notice.error { background: var(--red-subtle); color: var(--red); }

.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.hint { font-size: 13px; color: var(--text-muted); margin: 6px 0 0; line-height: 1.55; }

.copy-field {
  display: flex; gap: 6px; align-items: center;
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: var(--r-md);
  padding: 8px 8px 8px 12px;
}
.copy-field code {
  flex: 1; min-width: 0;
  font-size: 12px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text-secondary);
}

/* ─── Stats ─────────────────────────────────────────── */

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }

.stat {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--r-md);
  padding: 14px;
}
.stat .value { font-size: 24px; font-weight: 680; letter-spacing: -0.02em; }
.stat .label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ─── Toast ─────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(120%);
  background: var(--text);
  color: var(--bg);
  padding: 11px 20px;
  border-radius: var(--r-full);
  font-size: 14px;
  font-weight: 560;
  box-shadow: var(--shadow-md);
  transition: transform .25s cubic-bezier(.2, .8, .3, 1);
  z-index: 50;
  max-width: calc(100vw - 32px);
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--red); color: #fff; }

.hidden { display: none !important; }

details.disclosure { border: 1px solid var(--card-border); border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 12px; background: var(--card); }
details.disclosure summary { cursor: pointer; font-weight: 560; font-size: 14px; }
details.disclosure[open] summary { margin-bottom: 12px; }
