:root {
  color-scheme: dark;
  --bg: #131a26;
  --panel: #1f293a;
  --surface: #262f3f;
  --surface-strong: #303d53;
  --text-primary: #eef4fb;
  --text-secondary: #9cb4d5;
  --accent: #4f7cff;
  --accent-soft: rgba(79, 124, 255, 0.14);
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 20px 50px rgba(2, 9, 24, 0.35);
  --radius: 26px;
}

* {
  box-sizing: border-box;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

input,
textarea,
button,
a {
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    Inter,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background:
    radial-gradient(circle at top, rgba(79, 124, 255, 0.16), transparent 25%),
    linear-gradient(180deg, #0f1520 0%, #111826 40%, #141c2d 100%);
  color: var(--text-primary);
}

button,
input {
  font: inherit;
}

button {
  border: none;
  cursor: pointer;
}

/* Authentication Modal Styles */
.auth-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at top, rgba(79, 124, 255, 0.16), transparent 25%),
    linear-gradient(180deg, #0f1520 0%, #111826 40%, #141c2d 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.auth-container {
  width: 100%;
  max-width: 420px;
  padding: 16px;
}

.auth-card {
  position: relative;
  width: 100%;
  background: rgba(19, 26, 38, 0.96);
  border: 1px solid rgba(79, 124, 255, 0.18);
  border-radius: calc(var(--radius) + 4px);
  padding: 42px 30px;
  box-shadow: var(--shadow);
  overflow: hidden;
  backdrop-filter: blur(16px);
}

.auth-card::before {
  content: "";
  position: absolute;
  top: -40px;
  right: -40px;
  width: 140px;
  height: 140px;
  background: radial-gradient(
    circle,
    rgba(79, 124, 255, 0.28),
    transparent 60%
  );
  pointer-events: none;
}

.auth-card::after {
  content: "";
  position: absolute;
  bottom: -44px;
  left: -44px;
  width: 200px;
  height: 200px;
  background: radial-gradient(
    circle,
    rgba(118, 241, 255, 0.14),
    transparent 58%
  );
  pointer-events: none;
}

.auth-header {
  text-align: center;
  margin-bottom: 28px;
}

/* Logo shown on auth pages */
.auth-logo {
  width: 64px;
  height: 64px;
  display: block;
  margin: 0 auto 12px;
  border-radius: 12px;
  object-fit: contain;
}

.auth-header h1 {
  margin: 0;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 0.06em;
  background: linear-gradient(135deg, #4f7cff, #76f1ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.auth-subtitle {
  color: var(--text-secondary);
  margin-top: 8px;
  font-size: 14px;
}

.auth-note {
  color: rgba(156, 180, 213, 0.75);
  margin-top: 14px;
  font-size: 13px;
  line-height: 1.7;
  max-width: 360px;
  margin-left: auto;
  margin-right: auto;
}

.auth-social {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.google-signin-button {
  width: 100%;
  max-width: 100%;
  margin-bottom: 16px;
  display: -webkit-box;
  display: -webkit-flex;
  display: -moz-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  -moz-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  -webkit-box-align: center;
  -webkit-align-items: center;
  -moz-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  min-height: 48px;
}

.google-signin-button > div {
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  display: -webkit-box !important;
  display: -webkit-flex !important;
  display: -moz-box !important;
  display: -ms-flexbox !important;
  display: flex !important;
  -webkit-box-pack: center !important;
  -webkit-justify-content: center !important;
  -moz-box-pack: center !important;
  -ms-flex-pack: center !important;
  justify-content: center !important;
}

.google-signin-button button,
.google-signin-button [role="button"] {
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  -webkit-tap-highlight-color: transparent !important;
  touch-action: manipulation !important;
  min-height: 48px !important;
  min-width: 48px !important;
}

.google-signin-button iframe {
  min-width: 0 !important;
  max-width: 100% !important;
}

.auth-divider {
  text-align: center;
  color: var(--text-secondary);
  margin: 14px 0 18px;
  font-size: 13px;
  position: relative;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 38%;
  height: 1px;
  background: rgba(156, 180, 213, 0.18);
}

.auth-divider::before {
  left: 0;
  transform: translateY(-50%);
}

.auth-divider::after {
  right: 0;
  transform: translateY(-50%);
}

.auth-form {
  display: none;
}

.auth-form.active {
  display: block;
}

.auth-form h2 {
  margin: 0 0 24px;
  font-size: 24px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.form-group label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-group input[type="email"],
.form-group input[type="text"],
.form-group input[type="password"] {
  padding: 14px 18px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
  transition: all 0.25s ease;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  accent-color: #4f7cff;
  -webkit-font-size-adjust: 100%;
  min-height: 44px;
}

.form-group input[type="email"]:focus,
.form-group input[type="text"]:focus,
.form-group input[type="password"]:focus {
  border-color: rgba(79, 124, 255, 0.4);
  background: rgba(79, 124, 255, 0.05);
}

.file-input-wrapper {
  position: relative;
  display: inline-block;
  width: 100%;
}

.file-input-wrapper input[type="file"] {
  display: none;
}

.file-name {
  display: block;
  padding: 12px 16px;
  border-radius: 12px;
  border: 2px dashed rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-secondary);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
}

.file-name:hover {
  border-color: rgba(79, 124, 255, 0.4);
  background: rgba(79, 124, 255, 0.05);
}

.image-preview {
  margin-top: 12px;
  border-radius: 12px;
  overflow: hidden;
  max-height: 200px;
}

.image-preview img {
  width: 100%;
  height: auto;
  display: block;
}

.btn-primary {
  width: 100%;
  padding: 15px;
  border-radius: 14px;
  background: linear-gradient(135deg, #4f7cff, #0099ff);
  color: white;
  font-size: 15px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
  margin-bottom: 18px;
  box-shadow: 0 16px 30px rgba(79, 124, 255, 0.18);
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  min-height: 48px;
  min-width: 48px;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 32px rgba(79, 124, 255, 0.24);
}

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

.form-message {
  min-height: 20px;
  padding: 12px;
  border-radius: 8px;
  font-size: 14px;
  text-align: center;
}

.active-users-badge {
  margin-top: 8px;
  font-size: 20px;
  color: #d83c3c;
  text-align: center;
  opacity: 0.9;
  font-weight: bold;
}

.form-message.success {
  background: rgba(59, 191, 147, 0.1);
  color: #3bbf93;
}

.form-message.error {
  background: rgba(255, 138, 167, 0.1);
  color: #ff8aa7;
}

.auth-toggle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  margin: 20px 0 0;
}

.link-btn {
  background: none;
  border: none;
  color: #4f7cff;
  cursor: pointer;
  font-weight: 600;
  text-decoration: underline;
  padding: 0;
  font-size: 14px;
  transition: color 0.2s ease;
}

.link-btn:hover {
  color: #76f1ff;
}

.verification-info {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 20px;
  text-align: center;
}

.verification-info strong {
  color: var(--text-primary);
}

/* Mobile-specific fixes for touch and rendering */
@media (max-width: 480px) {
  * {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  html,
  body {
    position: fixed;
    width: 100%;
    height: 100%;
    overflow: hidden;
    -webkit-user-select: none;
  }

  body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
  }
}

/* Responsive */
@media (max-width: 720px) {
  .auth-container {
    padding: 14px;
    max-width: 100%;
  }

  .auth-card {
    padding: 24px;
    border-radius: 20px;
  }

  .auth-header h1 {
    font-size: 24px;
  }

  .auth-subtitle,
  .auth-note,
  .auth-toggle,
  .form-group label,
  .form-message {
    font-size: 14px;
  }

  .auth-form h2 {
    font-size: 20px;
  }

  .btn-primary {
    padding: 14px;
    min-height: 48px;
    font-size: 16px;
  }

  .google-signin-button {
    max-width: 100%;
    min-height: 48px;
  }

  .form-group input[type="email"],
  .form-group input[type="text"],
  .form-group input[type="password"] {
    min-height: 48px;
    font-size: 16px;
    padding: 12px 16px;
  }

  .link-btn {
    min-height: 44px;
    display: inline-block;
    padding: 8px 12px;
  }
}

/* Tweak for very small screens: reduce padding and hide decorative overflow */
@media (max-width: 420px) {
  .auth-container {
    padding: 10px;
  }
  .auth-card {
    padding: 16px;
  }
  .auth-card::before,
  .auth-card::after {
    display: none;
  }
  .auth-header h1 {
    font-size: 20px;
  }
  .auth-logo {
    width: 56px;
    height: 56px;
    margin-bottom: 8px;
  }
}
