:root {
  color-scheme: dark;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  background: #050a10;
  color: #c8d0dc;
}

* {
  box-sizing: border-box;
}

/* Accessibility - Skip link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: #c49a4a;
  color: #0a1018;
  padding: 8px 16px;
  z-index: 10000;
  text-decoration: none;
  font-weight: 500;
}

.skip-link:focus {
  top: 0;
}

/* Screen reader only text */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 12px;
  background: linear-gradient(180deg, #080d14 0%, #050a10 50%, #030508 100%);
  overflow-x: hidden;
}

.screen {
  width: 100%;
  max-width: 1400px;
  display: grid;
  gap: 12px;
  transition: transform 0.1s ease-out;
}

/* Header */
.header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.header h1 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  color: #e8eef6;
}

.subtitle {
  margin: 0;
  color: #8a9aac;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
}

.meta {
  margin: 0;
  margin-left: auto;
  color: #c49a4a;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
}

/* Media controls in sidebar */
.media-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* Hide music controls when not available */
.music-control.hidden {
  display: none;
}

.media-btn {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(200, 200, 200, 0.3);
  color: #e8eef6;
  font-size: 1.25rem;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  padding: 0;
}

.media-btn:hover {
  background: rgba(0, 255, 0, 0.2);
  border-color: #00ff00;
  transform: scale(1.05);
}

.media-btn:focus {
  outline: 2px solid #c49a4a;
  outline-offset: 2px;
}

.media-btn:active {
  transform: scale(0.95);
}

.media-btn[aria-pressed="true"] {
  background: rgba(0, 255, 0, 0.3);
  border-color: #00ff00;
}

.volume-slider {
  width: 60px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(200, 200, 200, 0.3);
  border-radius: 2px;
  cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: #c49a4a;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.volume-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.volume-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: #c49a4a;
  border-radius: 50%;
  border: none;
  cursor: pointer;
}

.volume-slider:focus {
  outline: 2px solid #c49a4a;
  outline-offset: 2px;
}

/* Main content: Landscape layout */
.main-content {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 12px;
  align-items: start;
}

.panel {
  background: #0a1018;
  border: 1px solid #1a2530;
  padding: 10px;
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

/* Video Panel */
.video-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.video-area {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #030508;
  border-radius: 2px;
  overflow: hidden;
  border: 1px solid #1a2530;
}

video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Mirror video for natural selfie view */
  transform: scaleX(-1);
}

#overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  /* Mirror canvas to match video */
  transform: scaleX(-1);
}

/* TV noise overlay for idle state */
.noise-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  opacity: 0.6;
  mix-blend-mode: overlay;
}

.noise-canvas.hidden {
  display: none;
}

/* Scan lines overlay - always visible during game */
.scan-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.15) 2px,
    rgba(0, 0, 0, 0.15) 4px
  );
  opacity: 0.5;
}

.scan-lines.hidden {
  display: none;
}

/* Smile feedback overlay - bottom left of video */
.smile-feedback {
  position: absolute;
  bottom: 12px;
  left: 12px;
  padding: 6px 12px;
  background: rgba(10, 16, 24, 0.9);
  border: 1px solid #c49a4a;
  border-radius: 4px;
  font-size: 0.8rem;
  color: #c49a4a;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  z-index: 15;
  animation: pulse-feedback 2s ease-in-out infinite;
}

.smile-feedback.hidden {
  display: none;
}

@keyframes pulse-feedback {
  0%, 100% {
    opacity: 0.9;
  }
  50% {
    opacity: 0.6;
  }
}

.status {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 4px 8px;
  background: rgba(5, 10, 16, 0.9);
  border: 1px solid #2a3a4a;
  font-size: 0.7rem;
  border-radius: 2px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #8a9aac;
}

.notice {
  position: absolute;
  bottom: 10px;
  right: 10px;
  padding: 6px 12px;
  background: rgba(10, 16, 24, 0.95);
  border: 1px solid #c49a4a;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #c49a4a;
  font-weight: 500;
  z-index: 10;
}

.notice.hidden {
  display: none;
}

.privacy {
  margin: 0;
  color: #6a7a8a;
  font-size: 0.75rem;
  font-style: italic;
}

/* Loading Overlay */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(5, 10, 16, 0.95);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 20;
}

.loading-overlay.hidden {
  display: none;
}

.loading-content {
  text-align: center;
}

.loading-text {
  font-size: 1rem;
  color: #8a9aac;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 12px;
}

.countdown-display {
  font-size: 4rem;
  font-weight: 700;
  color: #c49a4a;
  font-family: "Consolas", "Monaco", monospace;
  animation: pulse 1s ease-in-out infinite;
}

.countdown-display.hidden {
  display: none;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.1);
  }
}

/* Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-section {
  background: #0a1018;
  border: 1px solid #1a2530;
  padding: 10px;
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.timer {
  font-size: 1.5rem;
  letter-spacing: 0.1em;
  color: #c49a4a;
  font-family: "Consolas", "Monaco", monospace;
  font-weight: 400;
  text-align: center;
  margin-bottom: 10px;
}

button {
  width: 100%;
  background: #12202e;
  color: #c8d0dc;
  border: 1px solid #2a3a4a;
  padding: 10px 14px;
  border-radius: 2px;
  cursor: pointer;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
}

button:hover:not(:disabled) {
  background: #1a2a3a;
  border-color: #3a4a5a;
}

button:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(196, 154, 74, 0.3);
}

button:focus-visible {
  outline: 1px solid #c49a4a;
  outline-offset: 1px;
}

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

/* Instructions */
.instructions {
  border: 1px solid #1a2530;
  border-radius: 2px;
  padding: 10px;
  background: rgba(5, 10, 16, 0.5);
}

.instructions h2 {
  margin: 0 0 6px;
  font-size: 0.8rem;
  color: #8a9aac;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
}

.instructions ul {
  margin: 0;
  padding-left: 16px;
  color: #a0aab8;
  display: grid;
  gap: 4px;
  font-size: 0.8rem;
}

.instructions li {
  color: #a0aab8;
}

/* Prompt */
.prompt {
  color: #a0aab8;
  min-height: 1.2rem;
  font-size: 0.85rem;
  padding: 0 4px;
}

/* Debug Panel */
.debug-panel {
  background: rgba(10, 20, 10, 0.8);
  border: 1px solid #2a4a2a;
  border-radius: 2px;
  padding: 8px;
}

.debug-panel.hidden {
  display: none;
}

.debug-panel h3 {
  margin: 0 0 6px;
  font-size: 0.7rem;
  color: #6a9a6a;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.debug-values {
  font-family: "Consolas", "Monaco", monospace;
  font-size: 0.7rem;
  color: #8aba8a;
  line-height: 1.4;
}

.debug-values .debug-line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.debug-values .debug-label {
  color: #6a8a6a;
}

.debug-values .debug-value {
  color: #aadaaa;
}

.debug-values .debug-value.warning {
  color: #daca6a;
}

.debug-values .debug-value.danger {
  color: #da6a6a;
}

/* Leaderboard */
.leaderboard {
  display: grid;
  gap: 10px;
}

.leaderboard h2 {
  margin: 0;
  font-size: 0.8rem;
  color: #8a9aac;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
}

/* Scrollable scores container - shows 5 items, scrolls for more */
.scores-container {
  max-height: 160px; /* ~5 items */
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #2a3a4a #0a1018;
}

.scores-container::-webkit-scrollbar {
  width: 6px;
}

.scores-container::-webkit-scrollbar-track {
  background: #0a1018;
  border-radius: 3px;
}

.scores-container::-webkit-scrollbar-thumb {
  background: #2a3a4a;
  border-radius: 3px;
}

.scores-container::-webkit-scrollbar-thumb:hover {
  background: #3a4a5a;
}

.score-entry {
  display: grid;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid #1a2530;
  margin-bottom: 6px;
}

.score-entry label {
  font-size: 0.75rem;
  color: #6a7a8a;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.score-entry.hidden {
  display: none;
}

#playerName {
  padding: 8px 10px;
  border-radius: 2px;
  border: 1px solid #2a3a4a;
  background: #0a1018;
  color: #c8d0dc;
  font-size: 0.85rem;
  font-family: inherit;
}

#playerName:focus {
  outline: none;
  border-color: #c49a4a;
  box-shadow: 0 0 0 2px rgba(196, 154, 74, 0.2);
}

#playerName::placeholder {
  color: #4a5a6a;
}

ol {
  padding-left: 18px;
  margin: 0;
  display: grid;
  gap: 4px;
}

li {
  color: #a0aab8;
  font-size: 0.8rem;
}

li strong {
  color: #c8d0dc;
  font-weight: 500;
}

.classification {
  color: #6a7a8a;
  font-size: 0.75rem;
  font-style: italic;
}

/* Badge */
.badge {
  position: absolute;
  top: 8px;
  right: 8px;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 11px;
  background: #c49a4a;
  color: #0a1018;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.65rem;
  box-shadow: 0 0 8px rgba(196, 154, 74, 0.5);
}

.badge.hidden {
  display: none;
}

/* Veil animation */
.veil {
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, rgba(5, 10, 16, 0.3), rgba(196, 154, 74, 0.1));
  backdrop-filter: blur(1px);
  opacity: 0;
  z-index: 5;
}

.veil.show {
  animation: veil-slide 1.4s ease-in-out;
}

.veil.hidden {
  display: none;
}

@keyframes veil-slide {
  0% {
    opacity: 0;
    transform: translateX(-20%);
  }
  30% {
    opacity: 0.5;
  }
  70% {
    opacity: 0.5;
  }
  100% {
    opacity: 0;
    transform: translateX(20%);
  }
}

/* Cursor distraction */
.cursor {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #c49a4a;
  box-shadow: 0 0 6px rgba(196, 154, 74, 0.4);
  pointer-events: none;
  z-index: 5;
}

.cursor.hidden {
  display: none;
}

/* ===== RESPONSIVE: Mobile Portrait ===== */
@media (max-width: 768px) {
  body {
    padding: 8px;
    align-items: flex-start;
  }

  .screen {
    gap: 8px;
  }

  .header {
    gap: 8px;
  }

  .header h1 {
    font-size: 1rem;
  }

  .subtitle {
    font-size: 0.7rem;
  }

  .meta {
    font-size: 0.65rem;
  }

  /* Stack vertically on mobile */
  .main-content {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .panel {
    padding: 8px;
  }

  .video-area {
    aspect-ratio: 4 / 3;
  }

  .privacy {
    font-size: 0.65rem;
  }

  /* Sidebar becomes stacked sections */
  .sidebar {
    gap: 8px;
  }

  .sidebar-section {
    padding: 8px;
  }

  .timer {
    font-size: 1.25rem;
    margin-bottom: 8px;
  }

  button {
    padding: 8px 12px;
    font-size: 0.8rem;
  }

  .instructions h2 {
    font-size: 0.75rem;
  }

  .instructions ul {
    font-size: 0.75rem;
    padding-left: 14px;
  }

  .prompt {
    font-size: 0.8rem;
  }

  .debug-panel {
    padding: 6px;
  }

  .debug-panel h3 {
    font-size: 0.65rem;
  }

  .debug-values {
    font-size: 0.65rem;
  }

  .leaderboard h2 {
    font-size: 0.75rem;
  }

  .score-entry label {
    font-size: 0.7rem;
  }

  #playerName {
    padding: 6px 8px;
    font-size: 0.8rem;
  }

  ol {
    padding-left: 14px;
    gap: 3px;
  }

  li {
    font-size: 0.75rem;
  }

  .classification {
    font-size: 0.7rem;
  }

  .loading-text {
    font-size: 0.9rem;
  }

  .countdown-display {
    font-size: 3rem;
  }
}

/* ===== RESPONSIVE: Landscape on small screens (phones in landscape) ===== */
@media (max-height: 500px) and (orientation: landscape) {
  body {
    padding: 6px;
  }

  .screen {
    gap: 6px;
  }

  .header {
    display: none;
  }

  .main-content {
    grid-template-columns: 1fr 220px;
    gap: 6px;
  }

  .panel {
    padding: 6px;
  }

  .video-area {
    aspect-ratio: 16 / 9;
  }

  .privacy {
    display: none;
  }

  .sidebar {
    gap: 6px;
    max-height: calc(100vh - 12px);
    overflow-y: auto;
  }

  .sidebar-section {
    padding: 6px;
  }

  .timer {
    font-size: 1.1rem;
    margin-bottom: 6px;
  }

  button {
    padding: 6px 10px;
    font-size: 0.75rem;
  }

  .instructions {
    padding: 6px;
  }

  .instructions h2 {
    font-size: 0.7rem;
    margin-bottom: 4px;
  }

  .instructions ul {
    font-size: 0.7rem;
    padding-left: 12px;
  }

  .prompt {
    font-size: 0.75rem;
    min-height: 1rem;
  }

  .debug-panel {
    padding: 4px 6px;
  }

  .debug-panel h3 {
    font-size: 0.6rem;
    margin-bottom: 4px;
  }

  .debug-values {
    font-size: 0.6rem;
    line-height: 1.3;
  }

  .leaderboard h2 {
    font-size: 0.7rem;
  }

  ol {
    padding-left: 12px;
    gap: 2px;
  }

  li {
    font-size: 0.7rem;
  }

  .score-entry {
    gap: 4px;
    padding-bottom: 6px;
  }

  .score-entry label {
    font-size: 0.65rem;
  }

  #playerName {
    padding: 4px 6px;
    font-size: 0.75rem;
  }

  .loading-text {
    font-size: 0.85rem;
  }

  .countdown-display {
    font-size: 2.5rem;
  }
}

/* ===== RESPONSIVE: Large landscape screens ===== */
@media (min-width: 1200px) {
  .main-content {
    grid-template-columns: 1fr 320px;
  }

  .timer {
    font-size: 1.75rem;
  }

  .instructions ul {
    font-size: 0.85rem;
  }

  li {
    font-size: 0.85rem;
  }
}

/* Site footer */
.site-footer {
  grid-column: 1 / -1;
  text-align: center;
  padding: 12px 8px;
  font-size: 0.75rem;
  color: #6a7a8a;
  letter-spacing: 0.02em;
}

.site-footer a {
  color: #8a9aac;
  text-decoration: none;
  transition: color 0.2s ease;
}

.site-footer a:hover {
  color: #c49a4a;
}

.site-footer a:focus {
  outline: 1px solid #c49a4a;
  outline-offset: 2px;
}
