:root {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: #fff;
  background: #0f1024;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: #0f1024;
  background-image:
    linear-gradient(90deg, rgba(28, 28, 62, 0.7) 0, rgba(28, 28, 62, 0.7) 1px, transparent 1px, transparent 32px),
    linear-gradient(0deg, rgba(28, 28, 62, 0.7) 0, rgba(28, 28, 62, 0.7) 1px, transparent 1px, transparent 32px),
    radial-gradient(circle at top, #343075, #0f1024 65%);
  background-size: 32px 32px, 32px 32px, 100% 100%;
  image-rendering: pixelated;
}

.top-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: #1e1e1e;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.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;
}

.top-bar h1 {
  margin: 0;
  font-size: 1.5rem;
}

#name-form {
  display: flex;
  gap: 0.5rem;
}

#name-input {
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  border: 1px solid #333;
  background: #222;
  color: #fff;
}

#name-form button {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  background: #5a67d8;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s ease;
}

#name-form button:hover {
  background: #434190;
}

#leave-button {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  background: #e53e3e;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s ease;
}

#leave-button:hover:not(:disabled) {
  background: #9b2c2c;
}

#leave-button:disabled {
  opacity: 0.6;
  cursor: default;
}

#leave-button[hidden] {
  display: none;
}

#share-screen-button {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  background: #3182ce;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s ease;
}

#share-screen-button:hover:not(:disabled) {
  background: #2b6cb0;
}

#share-screen-button:disabled {
  opacity: 0.6;
  cursor: default;
}

#share-screen-button[hidden] {
  display: none;
}

#share-screen-button[data-state='sharing'] {
  background: #d69e2e;
  color: #1a202c;
}

#share-screen-button[data-state='sharing']:hover:not(:disabled) {
  background: #b7791f;
}

.status-select-wrapper {
  position: relative;
}

#status-select {
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  border: 1px solid #333;
  background: #222;
  color: #fff;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1rem;
}

.play-area {
  flex: 1;
  min-height: 0;
  position: relative;
  border-radius: 8px;
  background-color: #1a163d;
  background-image:
    linear-gradient(135deg, rgba(255, 255, 255, 0.04) 0, rgba(255, 255, 255, 0.04) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.04) 50%, rgba(255, 255, 255, 0.04) 75%, transparent 75%, transparent),
    linear-gradient(45deg, rgba(0, 0, 0, 0.25), rgba(0, 0, 0, 0.65));
  background-size: 24px 24px, 100% 100%;
  border: 4px solid #090b1b;
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.05), 0 12px 0 rgba(0, 0, 0, 0.45);
  overflow: hidden;
  image-rendering: pixelated;
}


.avatar {
  position: absolute;
  width: 60px;
  height: 60px;
  border-radius: 6px;
  background: var(--avatar-color, #63b3ed);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Press Start 2P', 'VT323', 'Courier New', monospace;
  color: var(--avatar-text-color, #0c2138);
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: -0.03em;
  border: 4px solid #080a1d;
  box-shadow:
    inset -4px -4px 0 rgba(0, 0, 0, 0.25),
    inset 4px 4px 0 rgba(255, 255, 255, 0.08),
    4px 4px 0 rgba(0, 0, 0, 0.45);
  transition: transform 0.1s linear;
  image-rendering: pixelated;
  text-transform: uppercase;
  filter: none;
  will-change: filter;
}

.avatar::before {
  content: '';
  position: absolute;
  inset: 6px;
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 2px;
  pointer-events: none;
}

.avatar::after {
  content: '';
  position: absolute;
  right: -12px;
  bottom: -12px;
  width: 18px;
  height: 18px;
  border-radius: 3px;
  border: 3px solid #080a1d;
  background: var(--status-color, #38a169);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.45);
}

.avatar--focused {
  animation: focusGlow 1.2s ease-in-out infinite;
  filter: drop-shadow(0 0 0 rgba(251, 211, 141, 0.2));
}

.avatar--focused::before {
  border-color: rgba(252, 211, 141, 0.9);
  box-shadow: 0 0 12px rgba(252, 211, 141, 0.6);
}

@keyframes focusGlow {
  0% {
    filter: drop-shadow(0 0 0 rgba(251, 211, 141, 0.15));
  }
  50% {
    filter: drop-shadow(0 0 22px rgba(251, 211, 141, 0.55));
  }
  100% {
    filter: drop-shadow(0 0 0 rgba(251, 211, 141, 0.15));
  }
}

.avatar.self {
  box-shadow:
    inset -4px -4px 0 rgba(0, 0, 0, 0.25),
    inset 4px 4px 0 rgba(255, 255, 255, 0.08),
    4px 4px 0 rgba(0, 0, 0, 0.45),
    0 0 18px rgba(255, 255, 255, 0.3);
}

.avatar span {
  pointer-events: none;
}

.avatar[data-status='available'] {
  --status-color: #38a169;
}

.avatar[data-status='busy'] {
  --status-color: #dd6b20;
}

.avatar[data-status='zechpreller'] {
  --status-color: #e53e3e;
}

.avatar-video-bubble {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translate(-50%, -18px);
  width: 160px;
  padding: 10px;
  border-radius: 6px;
  border: 3px solid #080a1d;
  background: rgba(22, 20, 46, 0.95);
  box-shadow:
    inset -3px -3px 0 rgba(0, 0, 0, 0.45),
    inset 3px 3px 0 rgba(255, 255, 255, 0.08),
    4px 4px 0 rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  image-rendering: pixelated;
  pointer-events: none;
  z-index: 2;
}

.avatar-video-bubble::after {
  content: '';
  position: absolute;
  bottom: -14px;
  left: 50%;
  transform: translateX(-50%);
  width: 22px;
  height: 14px;
  background: rgba(22, 20, 46, 0.95);
  border: 3px solid #080a1d;
  border-top: none;
  border-radius: 0 0 4px 4px;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.45);
}

.avatar-video {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 3px;
  background: #000;
  object-fit: cover;
  pointer-events: auto;
}

.avatar-video-bubble[data-video-kind='screen'] {
  width: clamp(220px, 28vw, 420px);
  max-width: calc(100vw - 2rem);
  padding: 12px 14px;
}

.avatar-video-bubble[data-video-kind='screen']::after {
  bottom: -18px;
  width: 28px;
  height: 16px;
}

.avatar-video-bubble[data-video-kind='screen'] .avatar-video {
  aspect-ratio: 16 / 9;
  border-radius: 6px;
}

.avatar-video-bubble.placeholder {
  padding: 14px 12px;
}

.avatar-video-bubble .video-expand-button {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 0.2rem 0.5rem;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 4px;
  background: rgba(15, 16, 36, 0.75);
  color: #e9ecff;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.avatar-video-bubble .video-expand-button:hover,
.avatar-video-bubble .video-expand-button:focus-visible {
  background: rgba(99, 102, 241, 0.8);
  color: #fff;
  outline: none;
}

.avatar-video-bubble .video-expand-button:active {
  background: rgba(76, 81, 220, 0.9);
}

.avatar-video-bubble.self-preview {
  border-color: #5a67d8;
  box-shadow:
    inset -3px -3px 0 rgba(0, 0, 0, 0.45),
    inset 3px 3px 0 rgba(164, 179, 250, 0.18),
    4px 4px 0 rgba(35, 32, 74, 0.75);
}

.avatar-video-bubble.self-preview::after {
  background: rgba(36, 35, 70, 0.95);
  border-color: #5a67d8;
}

.avatar-video-caption {
  font-size: 0.65rem;
  line-height: 1.3;
  color: #d6bcfa;
  text-align: center;
}

.avatar-video-placeholder {
  font-size: 0.68rem;
  line-height: 1.3;
  text-align: center;
  color: #fbd38d;
}

.event-log {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: min(560px, calc(100% - 2rem));
  max-height: 40vh;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: rgba(15, 16, 36, 0.9);
  border: 1px solid rgba(90, 103, 216, 0.35);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  z-index: 20;
  font-size: 0.75rem;
  line-height: 1.4;
  backdrop-filter: blur(6px);
}

.event-log__content {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-height: calc(40vh - 2.5rem);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 102, 241, 0.4) transparent;
}

.event-log__content::-webkit-scrollbar {
  width: 6px;
}

.event-log__content::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.4);
  border-radius: 999px;
}

.event-log__content::-webkit-scrollbar-track {
  background: transparent;
}

.event-log__content:empty {
  display: none;
}

.event-log__toggle {
  align-self: flex-end;
  background: transparent;
  border: none;
  color: #cbd5f5;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  transition: background 0.2s ease, color 0.2s ease;
}

.event-log__toggle:hover,
.event-log__toggle:focus-visible {
  background: rgba(99, 102, 241, 0.18);
  color: #e9ecff;
  outline: none;
}

.event-log.collapsed {
  max-height: none;
  padding: 0.4rem 0.6rem;
  width: auto;
  min-width: 120px;
  gap: 0;
}

.event-log.collapsed .event-log__toggle {
  align-self: center;
}

.event-log.collapsed .event-log__content {
  display: none;
}

.event-log--has-unread .event-log__toggle::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 6px;
  border-radius: 50%;
  background: #f6ad55;
  box-shadow: 0 0 6px rgba(246, 173, 85, 0.8);
}

.event-log-entry {
  display: flex;
  gap: 0.4rem;
  align-items: baseline;
  color: #cbd5f5;
  word-break: break-word;
}

.event-log-entry--success {
  color: #9ae6b4;
}

.event-log-entry--warning {
  color: #fbd38d;
}

.event-log-entry--error {
  color: #feb2b2;
}

.event-log-entry__time {
  font-weight: 600;
  color: rgba(226, 232, 240, 0.9);
  flex-shrink: 0;
}

.event-log-entry__time::after {
  content: '\00a0—';
  color: inherit;
}

.event-log-entry__message {
  margin: 0;
  color: inherit;
  flex: 1;
}

@media (max-width: 600px) {
  .event-log {
    width: calc(100% - 1.5rem);
    bottom: 12px;
    padding: 0.6rem 0.75rem;
    font-size: 0.7rem;
    max-height: 50vh;
  }

  .event-log__content {
    max-height: calc(50vh - 2.5rem);
  }
}

@media (max-width: 768px) {
  .screen-overlay__dialog {
    width: calc(100vw - 1rem);
    height: calc(100vh - 2rem);
    padding: 0.75rem;
  }

  .screen-overlay__video {
    border-radius: 8px;
  }
}

.proximity-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 220px;
  height: 220px;
  border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, 0.15);
}

#status {
  min-width: 180px;
}

.screen-overlay[hidden] {
  display: none;
}

.screen-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 50;
}

.screen-overlay__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 7, 18, 0.78);
  backdrop-filter: blur(4px);
}

.screen-overlay__dialog {
  position: relative;
  width: min(96vw, 1600px);
  height: min(92vh, 900px);
  background: rgba(18, 20, 38, 0.95);
  border: 1px solid rgba(120, 127, 255, 0.35);
  border-radius: 16px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.6);
  padding: 1rem 1.5rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  z-index: 1;
}

.screen-overlay__video {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  background: #000;
  border-radius: 10px;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.08);
  object-fit: contain;
}

.screen-overlay__caption {
  color: #e9ecff;
  font-size: 0.85rem;
  text-align: center;
  line-height: 1.4;
}

.screen-overlay__close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: transparent;
  font-size: 0;
  cursor: pointer;
}

.screen-overlay__close::before,
.screen-overlay__close::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 2px;
  background: #e9ecff;
  transform-origin: center;
}

.screen-overlay__close::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.screen-overlay__close::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.screen-overlay__close:hover,
.screen-overlay__close:focus-visible {
  background: rgba(76, 81, 220, 0.9);
  outline: none;
}

body.screen-overlay-open {
  overflow: hidden;
}
