*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  color-scheme: dark;

  --bg-primary: #0a0a0a;
  --bg-secondary: #141414;
  --bg-overlay: rgb(10 10 10 / 78%);
  --text-primary: #e5e5e5;
  --text-muted: #a3a3a3;
  --accent-green: #22c55e;
  --accent-red: #ef4444;
  --accent-yellow: #eab308;
  --border-color: #262626;
  --focus-color: #60a5fa;
  --radius: 8px;
}

html {
  height: 100%;
  background: var(--bg-primary);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  line-height: 1.5;
}

.container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  gap: 0.75rem;
  padding: 1rem;
}

.header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-inline: 0.5rem;
}

.status,
.stats {
  color: var(--text-muted);
}

.status {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.status-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-red);
  transition:
    background-color 0.3s,
    opacity 0.3s;
}

.status[data-state="connecting"] .status-dot,
.status[data-state="reconnecting"] .status-dot {
  background: var(--accent-yellow);
  animation: blink 1s infinite;
}

.status[data-state="connected"] .status-dot {
  background: var(--accent-green);
  animation: pulse 2s infinite;
}

.status[data-state="disconnected"] .status-dot,
.status[data-state="error"] .status-dot {
  background: var(--accent-red);
  animation: none;
}

.stats {
  display: flex;
  gap: 1rem;
  font-size: 0.75rem;
  white-space: nowrap;
}

.stats strong {
  color: var(--text-primary);
  font-weight: 600;
}

.stats strong[data-state="warning"] {
  color: var(--accent-yellow);
}

.stats strong[data-state="error"] {
  color: var(--accent-red);
}

#session-remaining {
  font-variant-numeric: tabular-nums;
}

.screen-container {
  position: relative;
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--bg-secondary);
}

#screen {
  display: none;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

#screen.visible {
  display: block;
}

.screen-message {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: var(--bg-overlay);
  color: var(--text-muted);
  font-size: 0.875rem;
  text-align: center;
  pointer-events: none;
  opacity: 1;
  visibility: visible;
  transition:
    opacity 0.2s,
    visibility 0.2s;
}

.screen-message.hidden {
  opacity: 0;
  visibility: hidden;
}

.screen-message[data-state="error"] {
  color: var(--accent-red);
}

.screen-message[data-state="warning"] {
  color: var(--accent-yellow);
}

.noscript-message {
  padding: 0.75rem;
  border: 1px solid var(--accent-red);
  border-radius: var(--radius);
  background: var(--bg-secondary);
  color: var(--accent-red);
  font-size: 0.875rem;
  text-align: center;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 3px solid var(--focus-color);
  outline-offset: 3px;
}

:focus:not(:focus-visible) {
  outline: none;
}

@keyframes pulse {
  50% {
    opacity: 0.6;
  }
}

@keyframes blink {
  50% {
    opacity: 0.3;
  }
}

@media (prefers-reduced-motion: reduce) {
  .status-dot {
    animation: none !important;
    transition: none;
  }

  .screen-message {
    transition: none;
  }
}

@media (max-width: 640px) {
  .container {
    gap: 0.5rem;
    padding: 0.5rem;
  }

  .header {
    padding-inline: 0;
  }

  .stat-secondary {
    display: none;
  }
}

@media (forced-colors: active) {
  .screen-container {
    border-color: CanvasText;
  }

  .status-dot {
    border: 1px solid CanvasText;
  }

  :focus-visible {
    outline-color: Highlight;
  }
}
