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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #f0f2f5;
  color: #1a1a1a;
  min-height: 100vh;
}

/* Opt-in page */
.optin-bg {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
}

.optin-card {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 20px;
  padding: 48px 40px;
  max-width: 460px;
  width: 100%;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.optin-card h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
  line-height: 1.3;
  color: #1a1a1a;
}

.optin-card .subtitle {
  color: rgba(0, 0, 0, 0.5);
  font-size: 16px;
  margin-bottom: 32px;
}

.optin-card .live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #e53e3e;
  color: white;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 16px;
}

.optin-card .live-badge .dot {
  width: 8px;
  height: 8px;
  background: white;
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.form-group {
  margin-bottom: 16px;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: rgba(0, 0, 0, 0.6);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 14px 16px;
  background: #f5f5f7;
  border: 1px solid #d0d0d0;
  border-radius: 10px;
  color: #1a1a1a;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: #667eea;
}

.form-group input::placeholder {
  color: rgba(0, 0, 0, 0.3);
}

.btn-join {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 10px;
  color: white;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
  margin-top: 8px;
}

.btn-join:hover {
  transform: translateY(-1px);
  opacity: 0.95;
}

.btn-join:active {
  transform: translateY(0);
}

.btn-join:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.error-msg {
  color: #c53030;
  font-size: 14px;
  margin-top: 12px;
  display: none;
}

.countdown {
  font-size: 32px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin: 24px 0;
  color: #1a1a1a;
}

/* Watch page */
.watch-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.player-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: #ffffff;
  border-bottom: 1px solid #e0e0e0;
}

.player-header .title {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #1a1a1a;
}

.player-header .controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.player-header .badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 3px 10px;
  border-radius: 4px;
}

.badge-live {
  background: #e53e3e;
  color: white;
  animation: pulse-bg 2s infinite;
}

@keyframes pulse-bg {
  0%, 100% { background-color: #e53e3e; }
  50% { background-color: #c53030; }
}

.badge-replay {
  background: #3182ce;
  color: white;
}

.badge-scheduled {
  background: #d69e2e;
  color: white;
}

.viewer-count {
  font-size: 13px;
  color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 6px;
}

.viewer-count .dot {
  width: 6px;
  height: 6px;
  background: #48bb78;
  border-radius: 50%;
}

.btn-icon {
  background: rgba(0, 0, 0, 0.06);
  border: none;
  color: #1a1a1a;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.btn-icon:hover {
  background: rgba(0, 0, 0, 0.1);
}

.player-wrapper {
  flex: 1;
  position: relative;
  background: #000;
}

.player-wrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.player-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.8);
  z-index: 5;
}

.player-overlay p {
  font-size: 20px;
  color: rgba(255, 255, 255, 0.7);
}

/* Chat panel */
.chat-panel {
  width: 360px;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-left: 1px solid #e0e0e0;
}

.chat-header {
  padding: 14px 16px;
  border-bottom: 1px solid #e0e0e0;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #1a1a1a;
}

.chat-pinned {
  background: rgba(102, 126, 234, 0.08);
  border-bottom: 1px solid rgba(102, 126, 234, 0.2);
  padding: 10px 16px;
  font-size: 13px;
  display: none;
  color: #1a1a1a;
}

.chat-pinned .pin-label {
  font-size: 11px;
  font-weight: 600;
  color: #667eea;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 3px;
}

.chat-msg {
  font-size: 14px;
  line-height: 1.4;
  padding: 4px 0;
  color: #1a1a1a;
}

.chat-msg .name {
  font-weight: 600;
  margin-right: 6px;
}

.chat-msg.admin .name {
  color: #667eea;
}

.chat-msg.system {
  text-align: center;
  color: rgba(0, 0, 0, 0.45);
  font-style: italic;
  font-size: 13px;
}

.chat-input-bar {
  padding: 12px 16px;
  border-top: 1px solid #e0e0e0;
  display: flex;
  gap: 8px;
}

.chat-input-bar input {
  flex: 1;
  padding: 10px 14px;
  background: #f5f5f7;
  border: 1px solid #d0d0d0;
  border-radius: 8px;
  color: #1a1a1a;
  font-size: 14px;
  outline: none;
}

.chat-input-bar input:focus {
  border-color: #667eea;
}

.chat-input-bar button {
  padding: 10px 18px;
  background: #667eea;
  border: none;
  border-radius: 8px;
  color: white;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s;
}

.chat-input-bar button:hover {
  background: #5a6fd6;
}

.chat-readonly-notice {
  padding: 12px 16px;
  text-align: center;
  color: rgba(0, 0, 0, 0.4);
  font-size: 13px;
  border-top: 1px solid #e0e0e0;
}

/* Fullscreen mode */
.fullscreen-wrapper {
  position: relative;
}

.fullscreen-wrapper:-webkit-full-screen,
.fullscreen-wrapper:fullscreen {
  display: flex;
  background: #000;
}

/* Mobile */
@media (max-width: 768px) {
  .watch-container {
    flex-direction: column;
  }

  .player-section {
    flex: none;
  }

  .player-wrapper {
    aspect-ratio: 16/9;
    flex: none;
  }

  .chat-panel {
    width: 100%;
    flex: 1;
    min-height: 0;
  }

  .player-header .title {
    font-size: 14px;
    max-width: 150px;
  }
}

/* Loading spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

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

/* Toast notifications */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #1a1a1a;
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 9999;
  animation: fadeInUp 0.3s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
