/* Courtside — shared design system */

:root {
  --bg: #f3f5f4;
  --surface: #ffffff;
  --surface-2: #eef2f0;
  --border: #dce3df;
  --text: #13201b;
  --muted: #5b6a64;
  --brand: #0b7a53;
  --brand-ink: #ffffff;
  --brand-soft: #dcf2e8;
  --court: #116b4a;
  --line: rgba(255, 255, 255, 0.85);
  --accent: #d9f24a;
  --a: #2257d6;
  --a-soft: #e3ebff;
  --b: #d02c2c;
  --b-soft: #fde6e6;
  --live: #e0244e;
  --warn: #b45309;
  --warn-soft: #fff1dc;
  --ok: #15803d;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 20, 0.05), 0 6px 20px rgba(16, 24, 20, 0.06);
  --font: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0b1210;
    --surface: #121b18;
    --surface-2: #19241f;
    --border: #25322d;
    --text: #e7eeeb;
    --muted: #91a29b;
    --brand: #2fbf87;
    --brand-ink: #03140c;
    --brand-soft: #123628;
    --court: #0f5a3f;
    --a: #6ea2ff;
    --a-soft: #172a4d;
    --b: #ff7676;
    --b-soft: #3d1a1c;
    --live: #ff4d73;
    --warn: #f0a44b;
    --warn-soft: #3a2a14;
    --ok: #4ade80;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #0b1210;
  --surface: #121b18;
  --surface-2: #19241f;
  --border: #25322d;
  --text: #e7eeeb;
  --muted: #91a29b;
  --brand: #2fbf87;
  --brand-ink: #03140c;
  --brand-soft: #123628;
  --court: #0f5a3f;
  --a: #6ea2ff;
  --a-soft: #172a4d;
  --b: #ff7676;
  --b-soft: #3d1a1c;
  --live: #ff4d73;
  --warn: #f0a44b;
  --warn-soft: #3a2a14;
  --ok: #4ade80;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
a {
  color: var(--brand);
}
.num,
.score {
  font-variant-numeric: tabular-nums;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 13px;
}
.hidden {
  display: none !important;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* ------------------------------------------------------------ controls */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: 600 14px/1 var(--font);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover {
  background: var(--surface-2);
}
.btn:active {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-ink);
}
.btn-primary:hover {
  background: var(--brand);
  filter: brightness(1.08);
}
.btn-danger {
  color: #fff;
  background: var(--b);
  border-color: var(--b);
}
.btn-danger:hover {
  background: var(--b);
  filter: brightness(1.08);
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
}
.btn-sm {
  min-height: 30px;
  padding: 0 10px;
  font-size: 13px;
}
.btn-lg {
  min-height: 52px;
  padding: 0 22px;
  font-size: 17px;
  border-radius: var(--radius);
}
.btn-block {
  width: 100%;
}
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
}
.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}
.icon-btn:disabled {
  opacity: 0.3;
  cursor: default;
  background: transparent;
}

label.field {
  display: grid;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
input[type='text'],
input[type='password'],
input[type='search'],
input[type='number'],
input:not([type]),
select,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: 15px/1.3 var(--font);
}
textarea {
  min-height: 160px;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  resize: vertical;
}
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.btn:focus-visible,
.icon-btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

.seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 10px;
  background: var(--surface-2);
  gap: 2px;
}
.seg button {
  min-height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: 600 14px var(--font);
  cursor: pointer;
}
.seg button[aria-pressed='true'] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

/* --------------------------------------------------------------- surfaces */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad {
  padding: 18px;
}
.card h3 {
  font-size: 16px;
  margin-bottom: 4px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.pill-live {
  background: var(--live);
  color: #fff;
}
.pill-live::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  animation: pulse 1.4s ease-in-out infinite;
}
.pill-confirm,
.pill-break {
  background: var(--warn-soft);
  color: var(--warn);
}
.pill-done {
  background: var(--brand-soft);
  color: var(--brand);
}
.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--muted);
}
@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

.table-wrap {
  overflow-x: auto;
}
table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table th {
  position: sticky;
  top: 0;
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--surface);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tr:last-child td {
  border-bottom: 0;
}
.win {
  font-weight: 700;
}

/* ------------------------------------------------------------------ modal */

dialog.modal {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
dialog.modal-wide {
  width: min(880px, calc(100vw - 32px));
}
dialog.modal::backdrop {
  background: rgba(8, 14, 12, 0.55);
  backdrop-filter: blur(2px);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 0;
}
.modal-head h2 {
  font-size: 18px;
}
.modal-body {
  padding: 16px 18px;
}
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 18px 18px;
}
.confirm-text {
  margin: 0;
  white-space: pre-line;
}

/* ------------------------------------------------------------------ toast */

.toasts {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 1000;
  display: grid;
  gap: 8px;
  transform: translateX(-50%);
  width: min(440px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  padding: 11px 16px;
  border-radius: 10px;
  background: #13201b;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  white-space: pre-line;
  animation: toast-in 0.2s ease-out;
  transition: opacity 0.3s, transform 0.3s;
}
.toast-ok {
  background: var(--ok);
}
.toast-error {
  background: #b91c1c;
}
.toast-warn {
  background: #b45309;
}
.toast.out {
  opacity: 0;
  transform: translateY(8px);
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ------------------------------------------------------------ brand mark */

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--court);
  color: var(--accent);
}
.brand-mark svg {
  width: 20px;
  height: 20px;
}

/* -------------------------------------------------- shared score display */

.scoreline {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  align-items: center;
}
.scoreline .who {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.scoreline .who span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.scoreline .who.won {
  font-weight: 700;
}
.games {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}
.games .g {
  min-width: 26px;
  text-align: center;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.games .g.cur {
  min-width: 34px;
  padding: 1px 4px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 800;
}
.games .g.gw {
  color: var(--text);
  font-weight: 700;
}
.shuttle {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--court);
  flex: none;
}
.shuttle.off {
  visibility: hidden;
}
.side-dot {
  width: 4px;
  height: 18px;
  border-radius: 2px;
  flex: none;
}
.side-dot.a {
  background: var(--a);
}
.side-dot.b {
  background: var(--b);
}
