:root {
  --bg: #0a0b0e;
  --surface: #14161d;
  --surface-2: #1c1f28;
  --line: #272b36;
  --text: #e8eaf0;
  --muted: #939aab;
  --accent: #3ddc97;
  --accent-ink: #06281a;
  --danger: #ff6b6b;
  --radius: 12px;
  --live: #ff5d5d;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

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

header.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

h1 {
  font-size: 20px;
  letter-spacing: -0.02em;
  margin: 0;
}

h1 .dot { color: var(--accent); }

.sub {
  color: var(--muted);
  font-size: 13px;
  margin: 2px 0 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 16px;
}

textarea, input[type="text"], input[type="password"], input[type="search"] {
  width: 100%;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  font: inherit;
  font-size: 16px; /* keeps iOS from zooming on focus */
  resize: vertical;
}

textarea { min-height: 92px; }

textarea:focus, input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

button {
  font: inherit;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 16px;
  min-height: 44px;
  cursor: pointer;
  transition: filter 0.15s ease, border-color 0.15s ease, transform 160ms var(--ease-out);
}

/* Hover only where there is a real pointer: on a phone a tap would leave it stuck on. */
@media (hover: hover) and (pointer: fine) {
  button:hover:not(:disabled) { filter: brightness(1.25); }
}
/* Press feedback, so a tap visibly lands before the server has answered. */
button:active:not(:disabled) { transform: scale(0.97); }
button:disabled { opacity: 0.5; cursor: default; }

button.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}

button.ghost { background: transparent; }
button.icon { padding: 8px 11px; min-height: 38px; }
button.danger:hover { border-color: var(--danger); color: var(--danger); }

.note {
  color: var(--muted);
  font-size: 13px;
  margin: 10px 0 0;
}

.links { display: flex; flex-direction: column; gap: 8px; }

.link {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.link-body { flex: 1; min-width: 0; }

.link-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-meta {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
}

.link.dead .link-title { color: var(--muted); }

.tag {
  display: inline-block;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  margin-right: 6px;
}

.tag.ok { color: var(--accent); border-color: rgba(61, 220, 151, 0.4); }
.tag.bad { color: var(--danger); border-color: rgba(255, 107, 107, 0.4); }

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

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 14px;
  max-width: min(92vw, 520px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 50;
}

.toast.show { opacity: 1; }
.toast.error { border-color: var(--danger); color: #ffd9d9; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 7, 10, 0.88);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  text-align: center;
  padding: 24px;
  z-index: 60;
}

.overlay.show { display: flex; }

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 3s; }
  button:active:not(:disabled) { transform: none; }
}

/* ---------- tabs & agenda ---------- */

/* Switched many times a day, so it does not animate: the panel simply swaps. */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.tabs button {
  flex: 1;
  min-height: 40px;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
}

.tabs button[aria-selected="true"] {
  background: var(--surface-2);
  color: var(--text);
}

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0 14px;
}

.chip {
  min-height: 36px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
}

.chip[aria-pressed="true"] {
  color: var(--accent);
  border-color: rgba(61, 220, 151, 0.5);
  background: rgba(61, 220, 151, 0.08);
}

.agenda-group { margin-bottom: 18px; }

.agenda-group h2 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 8px;
}

.agenda-group h2.live { color: var(--live); }

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

/* A whole row is the tap target: one tap on the match plays it. */
.match {
  display: grid;
  grid-template-columns: 46px 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  padding: 10px 12px;
  text-align: left;
  font-weight: 400;
  background: var(--surface);
  border-radius: var(--radius);
}

.match-time {
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

.match.is-live .match-time { color: var(--live); }

.match-body { min-width: 0; }

.match-name {
  display: block;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.match-meta {
  display: block;
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.match-badges { display: flex; gap: 4px; }
.match-badges .tag { margin: 0; }

.match:disabled .match-name { color: var(--muted); }

.agenda-status { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }

button.linkish {
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: 500;
  font-size: 13px;
}

.fav-card { margin-top: 18px; }
.fav-card summary { cursor: pointer; color: var(--muted); font-size: 14px; }
.fav-card input { margin-top: 10px; }

/* ---------- player ---------- */

body.player { background: #000; overflow: hidden; }

.stage {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

.stage video {
  width: 100%;
  height: 100%;
  background: #000;
}

.bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0));
  z-index: 10;
  transition: opacity 0.25s ease;
}

.bar.hidden { opacity: 0; pointer-events: none; }

.bar .title {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar button {
  background: rgba(28, 31, 40, 0.8);
  backdrop-filter: blur(8px);
  min-height: 38px;
  padding: 8px 12px;
  font-size: 13px;
}

.center-msg {
  color: var(--muted);
  text-align: center;
  max-width: 520px;
  padding: 24px;
}

.center-msg h2 { color: var(--text); font-size: 18px; margin: 0 0 8px; }
.center-msg code {
  display: block;
  margin-top: 12px;
  padding: 10px;
  background: var(--surface);
  border-radius: 8px;
  font-size: 12px;
  word-break: break-all;
}

.login-wrap {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card { width: 100%; max-width: 340px; }
