@import url('https://fonts.googleapis.com/css2?family=Courier+Prime:wght@400;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  color-scheme: dark;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #1a1a1a;
  color: #ffffff;
  --bg-dark: #1a1a1a;
  --bg-darker: #0f0f0f;
  --bg-panel: #2a2a2a;
  --text-primary: #ffffff;
  --text-secondary: #cccccc;
  --text-muted: #888888;
  --text-faded: #666666;
  --accent: #0078d4;
  --accent-light: #1084e0;
  --error: #ff6b6b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-dark);
  color: var(--text-primary);
}

/* ==================== Pairing Fullscreen View ==================== */

.pairing-fullscreen {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-dark);
  padding: 0;
  margin: 0;
  overflow: hidden;
}

.pairing-container {
  width: 100%;
  height: 100%;
  padding: clamp(40px, 8vw, 80px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.pairing-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(40px, 10vw, 80px);
  max-width: 100%;
  width: 100%;
}

/* Title */
.pairing-title {
  margin: 0;
  font-size: clamp(36px, 12vw, 72px);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

/* Loading state */
.pairing-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(20px, 5vw, 40px);
}

.pairing-spinner {
  width: clamp(48px, 12vw, 96px);
  height: clamp(48px, 12vw, 96px);
  border: 4px solid rgba(0, 120, 212, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.pairing-status-text {
  margin: 0;
  font-size: clamp(18px, 4vw, 28px);
  color: var(--text-secondary);
  text-align: center;
}

/* Pairing Code Section */
.pairing-code-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(30px, 8vw, 60px);
  width: 100%;
  max-width: 900px;
}

.pairing-instruction {
  margin: 0;
  font-size: clamp(20px, 5vw, 32px);
  color: var(--text-secondary);
  text-align: center;
}

.pairing-code-box {
  background: var(--bg-panel);
  border-radius: 16px;
  padding: clamp(30px, 8vw, 60px);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pairing-code {
  margin: 0;
  font-size: clamp(64px, 20vw, 140px);
  font-weight: 700;
  font-family: "Courier Prime", monospace;
  color: var(--accent);
  letter-spacing: 0.15em;
  text-align: center;
  word-break: break-all;
  line-height: 1.2;
}

/* Expiry and status info */
.pairing-expiry {
  margin: 0;
  font-size: clamp(12px, 2.5vw, 16px);
  color: var(--text-faded);
  text-align: center;
}

.hidden {
  display: none !important;
}

/* ==================== Player View ==================== */

.app {
  padding: 32px;
}

.player {
  height: calc(100vh - 64px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 16px;
  background: var(--bg-dark);
  padding: 32px;
}

.player-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-secondary);
}

.player-top > div:first-child {
  font-size: 14px;
}

#player-screen {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

#player-state {
  color: var(--text-muted);
}

.player-status {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 14px;
  color: var(--text-muted);
}

.player-status button {
  background: var(--bg-panel);
  color: var(--text-secondary);
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.2s;
}

.player-status button:hover {
  background: #353535;
}

.stage {
  position: relative;
  border-radius: 16px;
  border: 1px solid rgba(0, 120, 212, 0.2);
  background: var(--bg-darker);
  overflow: hidden;
}

.stage-content {
  height: 100%;
  width: 100%;
}

.stage-content > * {
  width: 100%;
  height: 100%;
}

.stage-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text-secondary);
  font-size: 18px;
  background: rgba(15, 15, 15, 0.85);
  text-align: center;
  padding: 16px;
}

.player-footer {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Offline indicator */
.offline-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  background: rgba(255, 193, 7, 0.15);
  color: #ffc107;
  font-size: 12px;
  font-weight: 500;
  margin-top: 8px;
}

.offline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ffc107;
  animation: pulse-offline 1.5s ease-in-out infinite;
}

@keyframes pulse-offline {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.2); }
}

/* Emergency broadcast alert */
.broadcast-alert {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  background: rgba(255, 107, 107, 0.15);
  color: #ff6b6b;
  font-size: 12px;
  font-weight: 500;
  margin-top: 8px;
}

.broadcast-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff6b6b;
  animation: pulse-broadcast 0.6s ease-in-out infinite;
}

@keyframes pulse-broadcast {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(1.4); }
}

.token-status {
  font-size: 12px;
  color: var(--text-muted);
}

/* Persistent error overlay */
.stage-overlay.persistent-error {
  position: fixed;
  inset: 0;
  border-radius: 0;
  z-index: 1000;
  background: rgba(15, 15, 15, 0.95);
  color: var(--error);
}

@media (max-width: 900px) {
  .app {
    padding: 20px;
  }
  .card {
    padding: 20px;
  }
  .token-row {
    flex-direction: column;
  }
  .player {
    height: auto;
  }
}
