:root {
  color-scheme: dark;
  --bg-primary: #000000;
  --bg-card: #111418;
  --bg-input: #1c1f26;
  --bg-elevated: #181c22;
  --border: #2a2e36;
  --border-subtle: #1e2228;
  --text-primary: #ffffff;
  --text-secondary: #71767b;
  --accent: #3e6ae1;
  --accent-hover: #2d5bd1;
  --accent-glow: rgba(62, 106, 225, 0.12);
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, Helvetica, sans-serif;
  margin: 0;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 680px;
  margin: 0 auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Header */
.hero {
  text-align: center;
  padding: 28px 0 4px;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.logo svg {
  color: var(--accent);
  opacity: 0.9;
}

h1 {
  font-size: 22px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.3px;
}

.tagline {
  color: var(--text-secondary);
  font-size: 13px;
  margin: 4px 0 0;
  font-weight: 400;
}

/* Card — Tesla-style soft raised surface */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.card-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Form */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.label-text {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

input {
  height: 48px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  padding: 0 14px;
  font-size: 18px;
  font-weight: 500;
  font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
  letter-spacing: 1px;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  -webkit-appearance: none;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

input::placeholder {
  color: #363a42;
  font-weight: 400;
}

/* Tesla-style primary button */
.btn-primary {
  grid-column: 1 / -1;
  height: 48px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  padding: 0 24px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-primary:active {
  transform: scale(0.98);
}

/* Advanced toggle */
.advanced {
  margin-top: 12px;
}

.advanced summary {
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  letter-spacing: 0.3px;
}

.advanced label {
  margin-top: 10px;
}

.advanced input {
  font-size: 13px;
  font-family: inherit;
  letter-spacing: 0;
  font-weight: 400;
}

/* Video */
.video-wrap {
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 340px;
  position: relative;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.video-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-secondary);
  font-size: 13px;
}

.video-placeholder.hidden {
  display: none;
}

video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Stats panel */
.stats-panel {
  padding: 14px 18px;
}

.stats-panel pre {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  white-space: pre-wrap;
  font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
  font-size: 11px;
  line-height: 1.7;
  color: var(--text-secondary);
  margin: 0;
}

/* Footer */
footer {
  text-align: center;
  padding: 8px 0 16px;
  color: #2a2e36;
  font-size: 11px;
}

/* Mobile */
@media (max-width: 480px) {
  main { padding: 12px; gap: 12px; }
  .hero { padding: 16px 0 0; }
  h1 { font-size: 20px; }
  .form-grid { grid-template-columns: 1fr; }
  input { height: 52px; font-size: 20px; }
  .btn-primary { height: 52px; font-size: 16px; }
  .video-wrap { min-height: 280px; }
}

/* Fullscreen layout for Tesla standalone PWA */
@media (display-mode: standalone) {
  main {
    max-width: none;
    padding: 0;
  }

  .hero, footer, .stats-panel {
    display: none;
  }

  #join-form {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    z-index: 10;
    background: rgba(17, 20, 24, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }

  #join-form.hidden {
    display: none;
  }

  .video-wrap {
    position: fixed;
    inset: 0;
    min-height: 100vh;
    min-height: 100dvh;
    border-radius: 0;
    border: none;
    z-index: 1;
    box-shadow: none;
  }

  video {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    object-fit: contain;
    background: #000;
  }
}
