:root {
  color-scheme: dark;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #000;
  color: #e4e4e7;
  font-synthesis: none;
}

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

button,
input {
  font: inherit;
}

/* Setup */
.setup-container {
  position: relative;
  display: flex;
  min-height: 100dvh;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 24px;
  background: #0a0a0f;
}

.glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.35;
  pointer-events: none;
  animation: float 8s ease-in-out infinite;
}

.glow-1 {
  top: -80px;
  left: -60px;
  width: 400px;
  height: 400px;
  background: #6366f1;
}

.glow-2 {
  right: -40px;
  bottom: -100px;
  width: 350px;
  height: 350px;
  background: #8b5cf6;
  animation-delay: -4s;
}

.setup-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  padding: 40px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.03), 0 24px 48px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(24px);
  animation: card-in 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.card-header {
  margin-bottom: 32px;
  text-align: center;
}

.logo {
  display: inline-flex;
  margin-bottom: 16px;
}

.card-header h1 {
  color: #fff;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  margin-top: 4px;
  color: #71717a;
  font-size: 0.875rem;
}

.field {
  margin-bottom: 20px;
}

.field label {
  display: block;
  margin-bottom: 8px;
  color: #a1a1aa;
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.field input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  outline: none;
  color: #e4e4e7;
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.9375rem;
  transition: 0.2s ease;
}

.field input::placeholder {
  color: #52525b;
}

.field input:focus {
  border-color: #6366f1;
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.hint {
  display: block;
  margin-top: 6px;
  color: #52525b;
  font-size: 0.75rem;
}

#connect-btn {
  position: relative;
  width: 100%;
  margin-top: 8px;
  padding: 14px 24px;
  overflow: hidden;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.25s ease;
}

#connect-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.3);
}

#connect-btn:disabled {
  opacity: 0.6;
  cursor: wait;
  transform: none;
  box-shadow: none;
}

.btn-loader {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.status-message {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.8125rem;
  text-align: center;
}

.status-message.success {
  border: 1px solid rgba(74, 222, 128, 0.15);
  color: #4ade80;
  background: rgba(74, 222, 128, 0.08);
}

.status-message.error {
  border: 1px solid rgba(248, 113, 113, 0.15);
  color: #f87171;
  background: rgba(248, 113, 113, 0.08);
}

/* Player */
#player-view,
#player-container {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  background: #000;
}

#player-view {
  cursor: none;
}

#player-view.cursor-visible {
  cursor: default;
}

#creative-area {
  display: flex;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
}

#creative-area iframe {
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: contain;
}

#idle-screen {
  position: absolute;
  z-index: 5;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #0a0a0f 0%, #111118 50%, #0a0a0f 100%);
  transition: opacity 0.5s ease;
}

#idle-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

.idle-content {
  position: relative;
  text-align: center;
  animation: fade-in 0.8s ease;
}

.idle-content h2 {
  margin-top: 24px;
  color: #fff;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.idle-content p {
  margin-top: 8px;
  color: #71717a;
  font-size: 0.875rem;
}

.pulse-ring {
  position: absolute;
  top: 32px;
  left: 50%;
  width: 100px;
  height: 100px;
  border: 2px solid rgba(99, 102, 241, 0.2);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: pulse 2.5s ease-in-out infinite;
}

.idle-icon {
  position: relative;
  z-index: 1;
  display: inline-flex;
  width: 64px;
  height: 64px;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  color: #fff;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  font-size: 1.75rem;
}

#status-bar {
  position: fixed;
  z-index: 100;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  height: 48px;
  padding: 0 20px;
  align-items: center;
  justify-content: space-between;
  opacity: 0;
  pointer-events: none;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85), transparent);
  backdrop-filter: blur(8px);
  transform: translateY(8px);
  transition: 0.3s ease;
}

#status-bar.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.status-left,
.status-center,
.status-right {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #a1a1aa;
  font-size: 0.8125rem;
}

.status-right {
  gap: 12px;
}

.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #52525b;
  transition: 0.3s ease;
}

.connection-dot.connected {
  background: #4ade80;
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.4);
}

.connection-dot.error {
  background: #f87171;
  box-shadow: 0 0 8px rgba(248, 113, 113, 0.4);
}

.connection-dot.reconnecting {
  background: #facc15;
  animation: blink 1s ease infinite;
}

.icon-btn {
  display: flex;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: #a1a1aa;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: 0.2s ease;
}

.icon-btn:hover,
.icon-btn:focus-visible {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
}

#settings-btn:hover {
  transform: rotate(30deg);
}

.creative-fade-in {
  animation: creative-fade-in 0.4s ease forwards;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(30px, -20px) scale(1.05); }
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes spin { to { transform: rotate(360deg); } }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  from { opacity: 1; transform: translate(-50%, -50%) scale(0.8); }
  to { opacity: 0; transform: translate(-50%, -50%) scale(1.6); }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

@keyframes creative-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (max-width: 560px) {
  .setup-card { padding: 30px 24px; }
  .status-center { display: none; }
  #status-bar { padding-inline: 12px; }
  #delivery-info { max-width: 45vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
