:root {
  --bg-primary: #f5f5f5;
  --bg-secondary: white;
  --bg-tertiary: #f8f8f8;
  --bg-accent: #E5E5EA;
  --text-primary: #333;
  --text-secondary: #666;
  --text-tertiary: #999;
  --text-accent: white;
  --border-color: #e0e0e0;
  --border-secondary: #d0d0d0;
  --blue-primary: #007AFF;
  --blue-secondary: #0051D5;
  --green: #34C759;
  --red: #FF3B30;
  --orange: #FF9500;
}

.dark-mode {
  --bg-primary: #1a1a1a;
  --bg-secondary: #2a2a2a;
  --bg-tertiary: #3a3a3a;
  --bg-accent: #404040;
  --text-primary: #e0e0e0;
  --text-secondary: #b0b0b0;
  --text-tertiary: #888;
  --text-accent: #e0e0e0;
  --border-color: #444;
  --border-secondary: #555;
  --blue-primary: #0A84FF;
  --blue-secondary: #0066CC;
  --green: #30D158;
  --red: #FF453A;
  --orange: #FF9F0A;
}

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

html,
body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  background: var(--bg-primary);
}

.container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 800px;
  margin: 0 auto;
  background: var(--bg-secondary);
  position: relative;
}

/* Fixed Header */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  gap: 12px;
}

.header-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-logo {
  width: 28px;
  height: 28px;
  display: block;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.theme-toggle {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  transition: background-color 0.2s;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.theme-toggle:hover {
  background: rgba(0, 0, 0, 0.1);
}

.dark-mode .theme-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
}

.online-count {
  font-size: 14px;
  font-weight: normal;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  padding: 4px 12px;
  border-radius: 12px;
  white-space: nowrap;
}

/* Connection Status */
.connection-status {
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.connection-status.connecting {
  background: var(--orange);
  color: var(--text-accent);
}

.connection-status.connected {
  background: var(--green);
  color: var(--text-accent);
}

.connection-status.disconnected {
  background: var(--red);
  color: var(--text-accent);
}

.spinner {
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid var(--text-accent);
  border-radius: 50%;
  width: 14px;
  height: 14px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* Username Screen */
.username-screen {
  display: flex;
  flex-direction: column;
  flex: 1;
  justify-content: center;
  align-items: center;
  padding: 40px 20px;
}

.username-screen h2 {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 30px;
  text-align: center;
}

.username-input-group {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

#usernameInput {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border-secondary);
  border-radius: 20px;
  font-size: 15px;
  outline: none;
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

#usernameInput:focus {
  background: var(--bg-secondary);
  border-color: var(--blue-primary);
}

.username-input-group button {
  width: 100%;
  padding: 12px 20px;
  background: var(--blue-primary);
  color: var(--text-accent);
  border: none;
  border-radius: 20px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.username-input-group button:active {
  opacity: 0.8;
}

/* Mobile Optimizations */
@media (max-width: 480px) {
  .header {
    padding: 12px 12px;
    gap: 8px;
  }

  .header-title {
    font-size: 16px;
  }

  .header-logo {
    width: 24px;
    height: 24px;
  }

  .header-right {
    gap: 8px;
  }

  .online-count {
    font-size: 13px;
    padding: 3px 10px;
  }

  .connection-status {
    font-size: 11px;
    padding: 4px 8px;
  }

  /* Hide connection text on mobile to save space */
  #connectionText {
    display: none;
  }

  .username-screen {
    padding: 30px 20px;
  }

  .username-screen h2 {
    font-size: 20px;
  }
}

/* Footer */
.footer {
  padding: 20px;
  text-align: center;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  font-size: 14px;
  flex-shrink: 0;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.footer-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.footer a {
  color: var(--blue-primary);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

/* Landscape mode on mobile */
@media (max-height: 500px) and (orientation: landscape) {
  .header {
    padding: 8px 16px;
  }

  .username-screen {
    padding: 20px;
  }

  .username-screen h2 {
    font-size: 18px;
    margin-bottom: 20px;
  }

  .username-input-group {
    gap: 12px;
  }
}

/* Footer Language Links */
.footer-lang-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 13px;
  color: var(--text-tertiary);
  line-height: 1.6;
}

.footer-lang-links .lang-link {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s ease;
}

.footer-lang-links .lang-link:hover {
  color: var(--blue-primary);
  text-decoration: underline;
}

/* Mobile adjustments for language links */
@media (max-width: 480px) {
  .footer-lang-links {
    font-size: 12px;
    gap: 6px;
  }
}