:root {
  --bg: #0f1419;
  --panel: #1a2332;
  --border: #2d3a4f;
  --text: #e8edf4;
  --muted: #8b9cb3;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #34d399;
  --error: #f87171;
  --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.header {
  padding: 2rem 1.5rem 1rem;
  max-width: 960px;
  margin: 0 auto;
}

.header h1 {
  margin: 0 0 0.5rem;
  font-size: 1.75rem;
  font-weight: 700;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  max-width: 42rem;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
}

label.optional {
  margin-top: 1rem;
  font-weight: 500;
  color: var(--muted);
}

input[type="url"],
textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

textarea {
  resize: vertical;
  min-height: 3rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

button {
  font: inherit;
  font-weight: 600;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
}

button:hover:not(:disabled) {
  background: var(--accent-hover);
}

button.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.status {
  margin: 1rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
  min-height: 1.4em;
}

.status.loading {
  color: var(--accent);
}

.status.error {
  color: var(--error);
}

.status.ok {
  color: var(--success);
}

.results.hidden {
  display: none;
}

.summary {
  margin-top: 1.5rem;
}

.summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.summary h2 {
  margin: 0;
  font-size: 1.1rem;
}

.timing-badge {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  font-size: 0.85rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.timing-badge.hidden {
  display: none;
}

#video-link a {
  color: var(--accent);
  word-break: break-all;
}

.meta {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.75rem;
}

.rallies-heading {
  margin: 2rem 0 1rem;
  font-size: 1.15rem;
}

.rallies-heading span {
  color: var(--muted);
  font-weight: 500;
}

.player-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 1.5rem;
  align-items: start;
  /* Break out of the 960px container so only the player area is wide. */
  width: min(1500px, 94vw);
  margin-left: 50%;
  transform: translateX(-50%);
}

.rally-sidebar {
  max-height: 80vh;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.rally-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.rally-btn {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.65rem 0.8rem;
  cursor: pointer;
  width: 100%;
}

.rally-btn:hover {
  border-color: var(--accent);
  background: #1f2c3f;
}

.rally-btn.active {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.18);
}

.rally-btn-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.rally-btn-index {
  font-weight: 700;
  font-size: 0.9rem;
}

.rally-btn-time {
  font-size: 0.78rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.rally-btn-desc {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 400;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.player-pane {
  position: sticky;
  top: 1rem;
}

.player-frame {
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.player-frame iframe,
.player-frame > div {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.now-playing {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: var(--text);
  min-height: 1.3em;
}

@media (max-width: 760px) {
  .player-layout {
    grid-template-columns: 1fr;
    width: 100%;
    margin-left: 0;
    transform: none;
  }
  .rally-sidebar {
    max-height: none;
    order: 2;
  }
  .player-pane {
    position: static;
    order: 1;
  }
}

.rally-list {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.rally-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.rally-header {
  padding: 1rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.rally-title {
  margin: 0;
  font-size: 1rem;
}

.rally-time {
  color: var(--muted);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.rally-desc {
  margin: 0.35rem 0 0;
  font-size: 0.95rem;
}

.rally-commentary {
  margin: 0.5rem 0 0;
  font-size: 0.88rem;
  color: var(--muted);
  font-style: italic;
}

.rally-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.rally-actions a,
.rally-actions button {
  font-size: 0.85rem;
  padding: 0.4rem 0.75rem;
  text-decoration: none;
  border-radius: 6px;
}

.rally-actions a {
  color: var(--accent);
  border: 1px solid var(--border);
  background: var(--bg);
}

.rally-player {
  aspect-ratio: 16 / 9;
  background: #000;
}

.rally-player iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.rally-player.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
}

.rally-player.placeholder:hover {
  background: #111;
}

@media (max-width: 600px) {
  .rally-header {
    flex-direction: column;
  }
}
