:root {
  --bg: #000000;
  --bg-soft: #1a1a1a;
  --bg-alt: #2d2d2d;
  --fg: #ffffff;
  --fg-soft: #e5e5e5;
  --fg-alt: #999999;
  --accent: #ffffff;
  --accent-soft: #cccccc;
  --accent-dark: #666666;
  --border: #404040;
  --placeholder: #777777;
  --error: #ffffff;
  --success: #ffffff;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(-45deg, var(--bg), #111111, var(--bg-soft), #222222);
  background-size: 400% 400%;
  animation: gradientFlow 15s ease infinite;
  color: var(--fg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;
  /* Support for safe areas on mobile */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

@keyframes gradientFlow {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.floating-particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.particle-dot {
  position: absolute;
  width: 2px;
  height: 2px;
  background: var(--accent);
  border-radius: 50%;
  opacity: 0.3;
  animation: float 20s infinite linear;
}

@keyframes float {
  0% { transform: translateY(100vh) rotate(0deg); opacity: 0; }
  10% { opacity: 0.3; }
  90% { opacity: 0.1; }
  100% { transform: translateY(-100vh) rotate(360deg); opacity: 0; }
}

.page-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  position: relative;
  z-index: 2;
  transition: opacity 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.content-wrapper {
  width: 100%;
  max-width: 420px;
  background: rgba(45, 45, 45, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 
    0 20px 40px rgba(0,0,0,0.8),
    0 0 0 1px rgba(255, 255, 255, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  animation: slideInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.content-wrapper::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: shimmer 3s ease-in-out infinite;
}

@keyframes slideInUp {
  0% {
    opacity: 0;
    transform: translateY(40px) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes shimmer {
  0%, 100% { opacity: 0; }
  50% { opacity: 0.8; }
}

.header-section {
  padding: 2rem 1.5rem 1.25rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, var(--bg-soft), var(--bg-alt));
  position: relative;
  overflow: hidden;
}

.header-section::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
  animation: rotate 20s linear infinite;
}

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

.icon-container {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--bg), var(--bg-soft));
  border: 2px solid var(--border);
  border-radius: 12px;
  color: var(--accent);
  margin-bottom: 1.25rem;
  position: relative;
  z-index: 1;
  animation: iconPulse 2s ease-in-out infinite;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes iconPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(255, 255, 255, 0); }
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
  position: relative;
  z-index: 1;
  animation: textSlideIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.2s both;
}

.subtitle {
  font-size: 0.85rem;
  color: var(--fg-alt);
  font-weight: 400;
  line-height: 1.4;
  position: relative;
  z-index: 1;
  animation: textSlideIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.4s both;
}

@keyframes textSlideIn {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.form-container {
  padding: 2rem 1.5rem;
  animation: formSlideIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.6s both;
}

@keyframes formSlideIn {
  0% {
    opacity: 0;
    transform: translateY(30px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.input-group {
  margin-bottom: 1.25rem;
  position: relative;
}

.input-group:last-of-type {
  margin-bottom: 1.75rem;
}

.input-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 0.5rem;
  letter-spacing: 0.01em;
  transition: all 0.3s ease;
}

.form-input {
  width: 100%;
  height: 48px;
  padding: 0 1rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 16px; /* Prevents zoom on iOS */
  font-family: inherit;
  font-weight: 500;
  background: rgba(0, 0, 0, 0.8);
  color: var(--fg);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
  position: relative;
  backdrop-filter: blur(10px);
  /* Better touch targets */
  touch-action: manipulation;
}

.form-input::placeholder {
  color: var(--placeholder);
  transition: all 0.3s ease;
}

.form-input:hover {
  border-color: var(--fg-alt);
  background: rgba(0, 0, 0, 0.9);
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 
    0 0 0 3px rgba(255, 255, 255, 0.15),
    0 4px 15px rgba(0,0,0,0.1);
  background: rgba(0, 0, 0, 1);
}

.form-input:focus::placeholder {
  opacity: 0.6;
  transform: translateX(4px);
}

.form-input.error {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.15);
  animation: shake 0.5s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* Checkbox Styles - Enhanced for mobile */
.checkbox-group {
  margin-bottom: 1.5rem;
}

.checkbox-container {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  cursor: pointer;
  position: relative;
  line-height: 1.4;
  transition: all 0.3s ease;
  /* Better touch target */
  min-height: 44px;
  align-items: center;
}

.checkbox-container input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.checkmark {
  position: relative;
  height: 20px;
  width: 20px;
  background: rgba(0, 0, 0, 0.8);
  border: 2px solid var(--border);
  border-radius: 4px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  backdrop-filter: blur(10px);
}

.checkbox-container:hover .checkmark {
  border-color: var(--fg-alt);
  background: rgba(0, 0, 0, 0.9);
}

.checkbox-container input:checked ~ .checkmark {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 
    0 0 0 3px rgba(255, 255, 255, 0.15),
    0 4px 12px rgba(255, 255, 255, 0.2);
}


.checkmark:after {
  content: "✓";
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  color: var(--bg);
  line-height: 1;
  opacity: 0;
  transform: scale(0);
  pointer-events: none;
}

.checkbox-container input:checked ~ .checkmark:after {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* Remove the old checkmarkPop animation and replace with this simpler one */
@keyframes checkmarkPop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.2);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

.checkbox-text {
  font-size: 0.8rem;
  color: var(--fg-soft);
  font-weight: 400;
  transition: color 0.3s ease;
  line-height: 1.4;
}

.checkbox-container:hover .checkbox-text {
  color: var(--fg);
}

.terms-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  position: relative;
  transition: all 0.3s ease;
  /* Better touch target for links */
  padding: 2px 0;
  margin: -2px 0;
}

.terms-link:hover {
  color: var(--accent-soft);
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
}

.terms-link::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 1px;
  bottom: 0;
  left: 0;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.terms-link:hover::after {
  transform: scaleX(1);
  transform-origin: left;
}

.checkbox-container.error .checkmark {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.15);
  animation: shake 0.5s ease-in-out;
}

.error-message {
  display: none;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--error);
  font-weight: 500;
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.error-message.show {
  display: flex;
  opacity: 1;
  transform: translateY(0);
  animation: errorSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes errorSlideIn {
  0% {
    opacity: 0;
    transform: translateY(-10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.error-message svg {
  flex-shrink: 0;
  animation: errorIconPulse 0.6s ease-in-out;
}

@keyframes errorIconPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

.submit-button {
  width: 100%;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-soft));
  color: var(--bg);
  border: none;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
  position: relative;
  overflow: hidden;
  box-shadow: 
    0 4px 15px rgba(255, 255, 255, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  /* Better touch interaction */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.submit-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: all 0.6s;
}

.submit-button:hover::before {
  left: 100%;
}

.submit-button:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--accent-soft), #dddddd);
  transform: translateY(-1px);
  box-shadow: 
    0 6px 20px rgba(255, 255, 255, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.submit-button:active {
  transform: translateY(0);
  box-shadow: 
    0 2px 10px rgba(255, 255, 255, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.submit-button:disabled {
  background: linear-gradient(135deg, var(--placeholder), #555);
  cursor: not-allowed;
  color: var(--bg);
  transform: none;
  box-shadow: none;
}

.submit-button:focus-visible {
  box-shadow: 
    0 0 0 3px var(--bg), 
    0 0 0 6px var(--accent),
    0 4px 15px rgba(255, 255, 255, 0.3);
}

.submit-button svg {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.submit-button:hover svg {
  transform: translateX(2px);
}

.footer-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--fg-alt);
  opacity: 0.8;
  transition: opacity 0.3s ease;
  text-align: center;
}

.footer-note:hover {
  opacity: 1;
}

.footer-note svg {
  opacity: 0.6;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.footer-note:hover svg {
  opacity: 1;
  transform: scale(1.1);
}

.kanji-credit {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  font-size: 0.65rem;
  color: var(--fg-alt);
  opacity: 0.6;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-family: 'Noto Sans JP', 'Yu Gothic', 'Meiryo', sans-serif;
  letter-spacing: 0.1em;
  transition: opacity 0.3s ease;
  z-index: 1000;
  user-select: none;
}

.kanji-credit:hover {
  opacity: 1;
}

.twitter-icon {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  width: 44px;
  height: 44px;
  background: rgba(45, 45, 45, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  text-decoration: none;
  font-size: 18px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000;
  box-shadow: 
    0 4px 12px rgba(0,0,0,0.3),
    0 0 0 1px rgba(255, 255, 255, 0.1);
}

.twitter-icon:hover {
  transform: translateX(-50%) translateY(-2px) scale(1.1);
  background: rgba(60, 60, 60, 0.95);
  border-color: var(--accent);
  box-shadow: 
    0 8px 25px rgba(0,0,0,0.4),
    0 0 0 1px rgba(255, 255, 255, 0.2);
  color: var(--fg);
}

.twitter-icon:active {
  transform: translateX(-50%) translateY(0) scale(1.05);
}

.submit-button.loading {
  position: relative;
  pointer-events: none;
}

.submit-button.loading span {
  opacity: 0;
}

.submit-button.loading::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(0, 0, 0, 0.3);
  border-top: 2px solid var(--bg);
  border-radius: 50%;
  animation: buttonSpin 1s linear infinite;
}

@keyframes buttonSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Success/Error overlays */
.success-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.98);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  animation: successFadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  padding: 2rem;
}

.success-content {
  text-align: center;
  padding: 2rem;
  position: relative;
  transform: translateY(40px) scale(0.9);
  animation: successSlideUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.3s forwards;
  opacity: 0;
  max-width: 400px;
  width: 100%;
}

.checkmark-container {
  margin-bottom: 1.5rem;
  position: relative;
}

.success-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 0.5rem;
  opacity: 0;
  animation: successTextFade 0.6s cubic-bezier(0.4, 0, 0.2, 1) 2s forwards;
  letter-spacing: -0.01em;
}

.success-message {
  font-size: 0.85rem;
  color: var(--fg-alt);
  opacity: 0;
  animation: successTextFade 0.6s cubic-bezier(0.4, 0, 0.2, 1) 2.2s forwards;
  line-height: 1.4;
}

@keyframes successFadeIn {
  to { opacity: 1; }
}

@keyframes successSlideUp {
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes successTextFade {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Mobile-specific optimizations */
@media (max-width: 480px) {
  body {
    font-size: 14px;
  }
  
  .page-container {
    padding: 0.75rem;
    align-items: flex-start;
    padding-top: max(2rem, env(safe-area-inset-top) + 1rem);
    min-height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }

  .content-wrapper {
    border-radius: 12px;
    margin-top: 0;
  }

  .header-section {
    padding: 1.5rem 1.25rem 1rem;
  }

  .form-container {
    padding: 1.5rem 1.25rem;
  }

  .icon-container {
    width: 40px;
    height: 40px;
    margin-bottom: 1rem;
  }

  .icon-container svg {
    width: 20px;
    height: 20px;
  }

  h1 {
    font-size: 1.35rem;
    margin-bottom: 0.4rem;
  }

  .subtitle {
    font-size: 0.8rem;
  }

  .input-label {
    font-size: 0.75rem;
    margin-bottom: 0.4rem;
  }

  .form-input {
    height: 44px;
    padding: 0 0.875rem;
  }

  .submit-button {
    height: 48px;
    font-size: 0.85rem;
  }

  .checkbox-text {
    font-size: 0.75rem;
  }

  .checkmark {
    height: 18px;
    width: 18px;
  }

  /* Keep checkmark positioning consistent on mobile */
  .checkmark:after {
    left: 5.5px;
    top: 1.5px;
    width: 3.5px;
    height: 7px;
  }

  .footer-note {
    font-size: 0.7rem;
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    flex-wrap: wrap;
    gap: 0.25rem;
  }

  .kanji-credit {
    bottom: 0.75rem;
    right: 0.75rem;
    font-size: 0.6rem;
  }

  .success-content {
    padding: 1.5rem;
  }
  
  .success-title {
    font-size: 1.25rem;
  }
  
  .success-message {
    font-size: 0.8rem;
  }

  .error-message {
    font-size: 0.7rem;
    margin-top: 0.4rem;
  }

  /* Reduce motion on mobile for battery */
  .floating-particles {
    display: none;
  }

  .content-wrapper::before,
  .header-section::before {
    animation-duration: 30s;
  }
}

/* Extra small screens */
@media (max-width: 360px) {
  .page-container {
    padding: 0.5rem;
  }

  .content-wrapper {
    border-radius: 8px;
  }

  .header-section {
    padding: 1.25rem 1rem 0.75rem;
  }

  .form-container {
    padding: 1.25rem 1rem;
  }

  h1 {
    font-size: 1.25rem;
  }

  .submit-button {
    height: 44px;
  }

  .form-input {
    height: 42px;
  }

  .twitter-icon {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }
}

/* Landscape mobile optimization */
@media (max-height: 600px) and (orientation: landscape) {
  .page-container {
    padding: 1rem 0.75rem;
  }

  .header-section {
    padding: 1rem 1.5rem 0.75rem;
  }

  .form-container {
    padding: 1.25rem 1.5rem;
  }

  .icon-container {
    margin-bottom: 0.75rem;
  }

  h1 {
    margin-bottom: 0.25rem;
  }

  .input-group {
    margin-bottom: 1rem;
  }

  .input-group:last-of-type {
    margin-bottom: 1.25rem;
  }

  .footer-note {
    margin-top: 1rem;
    padding-top: 1rem;
  }

  .twitter-icon {
    bottom: 1rem;
  }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  body {
    background: var(--bg);
  }

  .content-wrapper::before,
  .header-section::before,
  .floating-particles {
    display: none;
  }

  .form-input.error {
    animation: none !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .form-input {
    border-width: 3px;
  }

  .submit-button {
    border: 2px solid transparent;
  }

  .checkmark {
    border-width: 3px;
  }

  .terms-link {
    text-decoration: underline;
  }
}

/* Dark mode adjustments for better contrast */
@media (prefers-color-scheme: dark) {
  :root {
    --placeholder: #888888;
    --fg-alt: #aaaaaa;
  }
}

.turnstile-widget {
  margin: 1rem 0;
  display: flex;
  justify-content: center;
}

.turnstile-widget iframe {
  max-width: 100%;
}

.success-content .checkmark {
  width: 200px;
  height: 200px;
}

@media (max-width: 480px) {
  .success-content .checkmark {
    width: 160px;
    height: 160px;
  }
}
