:root {
  --black: #120d0a;
  --deep-burgundy: #231611;
  --burnt-maroon: #351f16;
  --rust: #ff9b54;
  --golden-amber: #ffbe78;
  --neon-yellow: #ffbe78;
  --text-main: #f5e7d0;
  --text-muted: #d7c5aa;
  --surface: rgba(35, 22, 17, 0.82);
  --border: rgba(255, 212, 164, 0.18);
  --shadow: rgba(0, 0, 0, 0.28);
  --radius: 24px;
  --radius-sm: 18px;
  --font:
    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  background: var(--black);
  color: var(--text-main);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  backdrop-filter: blur(18px);
  background: rgba(18, 13, 10, 0.7);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.5px;
}
.brand .logo {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
}
.brand .logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.brand small {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

/* Layout: row with split, collapse on small */
.layout {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 20px;
  padding: 20px 24px;
  flex: 1;
  max-width: 100%;
  margin: 0 auto;
  width: 100%;
  min-height: 0;
}

/* Region filter bar */
.region-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.region-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  margin-right: 2px;
}

.region-btn {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s,
    border-color 0.15s;
  font-family: var(--font);
}

.region-btn:hover {
  border-color: var(--text-main);
}

.region-btn.active {
  background: var(--rust);
  color: #fff;
  border-color: var(--rust);
}

/* Video Player Section */
.player-panel {
  flex: 1 1 80%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  min-height: 0;
}

.video-stage {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  width: 100%;
  flex: 1;
  min-height: 0;
}
.video-stage video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #000;
}
.noise-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  opacity: 1;
  image-rendering: pixelated;
  transition: opacity 0.3s ease;
}
.noise-canvas.hidden {
  opacity: 0;
}
.video-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 20px;
}
.video-placeholder svg {
  width: 54px;
  height: 54px;
  opacity: 0.4;
}
.video-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  display: none;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.video-badge.visible {
  display: flex;
}
.video-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--rust);
  box-shadow: 0 0 8px var(--rust);
}

.now-playing {
  font-size: 13px;
  color: var(--text-muted);
  padding: 0 4px;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.now-playing strong {
  color: var(--text-main);
}
.now-playing .ts {
  font-variant-numeric: tabular-nums;
}
.now-playing .loc {
  color: var(--text-muted);
  font-size: 12px;
  margin-left: auto;
}
.now-playing .loc::before {
  content: "📍 ";
  font-size: 11px;
}

/* Nav buttons (prev/next) */
.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s,
    border-color 0.15s;
  flex-shrink: 0;
  padding: 0;
}
.nav-btn svg {
  width: 16px;
  height: 16px;
}
.nav-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border-color: var(--text-main);
}
.nav-btn:active {
  background: var(--rust);
  color: #fff;
}

/* =============================================
   Camera Selector: 3-column grid + car graphic
   ============================================= */
.cam-selector {
  flex: 1 1 20%;
  min-width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  align-self: flex-start;
}

.cs-heading {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 10px;
  text-align: center;
}

.cs-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 2px;
  align-items: center;
}

.cs-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cs-col:first-child {
  align-items: flex-end;
}

.cs-col:last-child {
  align-items: flex-start;
}

.cs-col:nth-child(2) {
  align-items: center;
}

.cs-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0.2rem 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition:
    transform 0.25s ease,
    background 0.25s ease,
    color 0.25s ease,
    border-color 0.25s ease;
  white-space: nowrap;
  min-width: 64px;
  justify-content: center;
}

.cs-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border-color: var(--golden-amber);
  transform: translateY(-2px);
}

.cs-btn.active {
  background: linear-gradient(135deg, var(--rust), #ff6b35);
  border-color: var(--rust);
  color: #170d0a;
  box-shadow: 0 10px 22px rgba(255, 155, 84, 0.16);
}

.cs-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* =============================================
   Login Page
   ============================================= */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% 30%, #1a1a22 0%, var(--black) 70%);
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 40px 36px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.login-brand .logo {
  width: 290px;
  height: 158px;
  display: grid;
  place-items: center;
}

.login-brand .logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.login-brand h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-main);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-form label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.login-form input[type="password"] {
  width: 100%;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-main);
  font-size: 15px;
  outline: none;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

.login-form input[type="password"]:focus {
  border-color: var(--text-main);
  box-shadow: 0 0 0 3px rgba(227, 25, 55, 0.15);
}

.login-form button {
  width: 100%;
  padding: 12px;
  background: var(--rust);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 4px;
}

.login-form button:hover {
  background: #cc2a3e;
}

.login-error {
  font-size: 13px;

  text-align: center;
  padding: 8px;
  background: rgba(227, 25, 55, 0.08);
  border-radius: var(--radius-sm);
}

/* =============================================
   Responsive
   ============================================= */
@media (max-width: 700px) {
  .layout {
    flex-direction: column;
    align-items: center;
  }

  .player-panel {
    flex: none;
    width: 100%;
  }

  .cam-selector {
    flex: none;
    width: 100%;
  }

  .cs-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .cs-col:first-child,
  .cs-col:last-child {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
  }

  .cs-col:nth-child(2) {
    flex-direction: row;
    gap: 6px;
  }

  .cs-btn {
    min-width: 100px;
    font-size: 11px;
    padding: 6px 10px;
  }
}

@media (max-width: 560px) {
  header {
    padding: 10px 16px;
  }
  .layout {
    padding: 12px 16px;
  }
  .brand small {
    display: none;
  }
}

[hidden] {
  display: none !important;
}
