/* PvP TV page shell (W3.3) — dark space theme */
:root {
  --bg: #0b0e1e;
  --bg-panel: #12162a;
  --text: #e8ecf4;
  --text-muted: #8b93ad;
  --team1: #28d7ff;
  --team2: #ff6a4d;
  --accent: var(--team1);
  --border: rgba(255, 255, 255, 0.08);
  --stage-ratio: 9 / 16;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body {
  overflow-x: hidden;
}

.app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  background: linear-gradient(180deg, #141832 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header-brand {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--team1);
}

.header-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15rem;
  min-width: 0;
}

.match-id {
  font-size: 0.8rem;
  font-weight: 600;
  font-family: ui-monospace, "Cascadia Code", monospace;
  color: var(--text);
}

.match-date {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Stage — 9:16, letterboxed desktop */
.main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  min-height: 0;
}

.stage-wrap {
  position: relative;
  aspect-ratio: var(--stage-ratio);
  max-height: 92vh;
  width: min(100%, calc(92vh * 9 / 16));
  margin: 0 auto;
  background: #060812;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(40, 215, 255, 0.06);
}

#stage {
  display: block;
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse at 50% 20%, #1a2040 0%, #060812 70%);
}

.stage-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  text-align: center;
  font-size: 0.95rem;
  color: var(--text-muted);
  pointer-events: none;
  z-index: 4;
  background: rgba(11, 14, 30, 0.45);
}

.stage-overlay--tap {
  pointer-events: auto;
  cursor: pointer;
  color: var(--text);
}

.hidden {
  display: none !important;
}

/* Loading */
.loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 14, 30, 0.85);
  z-index: 2;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(40, 215, 255, 0.2);
  border-top-color: var(--team1);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Error */
.error-panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem;
  background: rgba(11, 14, 30, 0.92);
  z-index: 3;
  text-align: center;
}

.error-message {
  margin: 0;
  font-size: 1rem;
  color: var(--team2);
}

.btn-retry {
  padding: 0.5rem 1.25rem;
  border: 1px solid var(--team1);
  border-radius: 4px;
  background: transparent;
  color: var(--team1);
  font-size: 0.9rem;
  cursor: pointer;
}

.btn-retry:hover {
  background: rgba(40, 215, 255, 0.12);
}

/* Bottom chrome */
.chrome {
  flex-shrink: 0;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
}

.transcript-ticker {
  height: 4.5rem;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0.35rem 0.75rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  will-change: scroll-position;
}

.transcript-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.12rem 0;
  line-height: 1.25;
  white-space: nowrap;
}

.transcript-time {
  flex-shrink: 0;
  font-family: ui-monospace, "Cascadia Code", monospace;
  color: var(--text-muted);
  min-width: 2.5rem;
}

.transcript-player {
  flex-shrink: 0;
  max-width: 5.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  font-weight: 600;
}

.transcript-icon-wrap {
  flex-shrink: 0;
  width: 1.1rem;
  height: 1.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.transcript-icon {
  width: 1.1rem;
  height: 1.1rem;
  object-fit: contain;
  vertical-align: middle;
}

.transcript-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
}

.ctrl-btn {
  flex-shrink: 0;
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
}

.ctrl-btn[aria-pressed="true"] {
  border-color: var(--team1);
  color: var(--team1);
  background: rgba(40, 215, 255, 0.1);
}

.speed-group {
  display: flex;
  gap: 0.2rem;
}

.seek-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  height: 1.5rem;
}

.seek-markers {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 0;
  pointer-events: none;
  z-index: 1;
}

.seek-marker {
  position: absolute;
  top: -5px;
  width: 2px;
  height: 10px;
  margin-left: -1px;
  border-radius: 1px;
  transform: translateX(-50%);
}

.seek-marker--death {
  background: #ff3d4d;
  box-shadow: 0 0 4px rgba(255, 61, 77, 0.6);
}

.seek-marker--amber {
  background: #ffb020;
  box-shadow: 0 0 3px rgba(255, 176, 32, 0.45);
}

.seek {
  position: relative;
  z-index: 2;
  width: 100%;
  margin: 0;
  accent-color: var(--team1);
}

/* Mobile portrait — full-bleed stage */
@media (max-width: 768px) and (orientation: portrait) {
  .main {
    padding: 0;
    align-items: stretch;
  }

  .stage-wrap {
    width: 100vw;
    max-width: 100vw;
    max-height: none;
    height: auto;
    border-radius: 0;
    border-left: none;
    border-right: none;
    box-shadow: none;
  }
}
