:root {
  --color-paper: #F8F9FC;
  --color-grid: #E5E7EF;
  --color-purple: #8B5CF6;
  --color-pink: #EC4899;
  --color-yellow: #eab308;
  --color-green: #16A34A;
  --color-red: #EF4444;
  --color-text: #111827;
  --color-text-muted: #6B7280;
  --color-text-light: #9CA3AF;

  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;

  --grid-size: 40px;
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);

  --r-card: 18px;
  --r-tile: 16px;
  --r-button: 10px;
  --r-input: 10px;

  --transition-fast: 150ms ease;
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-paper);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow-x: hidden;
  padding: calc(1.5rem + var(--safe-area-top)) 1.5rem calc(1.5rem + var(--safe-area-bottom));
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(to right, var(--color-grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--color-grid) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
  pointer-events: none;
  z-index: -2;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 600px 400px at 15% 10%, rgba(234, 179, 8, 0.06) 0%, transparent 70%),
    radial-gradient(ellipse 500px 350px at 85% 45%, rgba(139, 92, 246, 0.06) 0%, transparent 70%),
    radial-gradient(ellipse 400px 300px at 20% 90%, rgba(236, 72, 153, 0.04) 0%, transparent 70%);
  pointer-events: none;
  z-index: -1;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--transition-fast);
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  border: none;
  background: none;
  cursor: pointer;
}

button,
a,
input {
  touch-action: manipulation;
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--color-text);
  outline-offset: 3px;
  border-radius: 8px;
}

input:focus-visible {
  outline: none;
}

::selection {
  background-color: var(--color-text);
  color: #ffffff;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.box {
  position: relative;
  width: 100%;
  max-width: 420px;
  padding: 2.25rem 1.75rem 1.75rem;
  text-align: left;
  background: #ffffff;
  border: 2px solid var(--color-text);
  border-radius: var(--r-card);
  box-shadow: 6px 6px 0 var(--color-purple);
  animation: rise 600ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.logo-icon {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 20px;
}

.logo-icon img {
  width: 64px;
  height: 64px;
  padding: 6px;
  object-fit: cover;
  background: #ffffff;
  border: 2px solid var(--color-text);
  border-radius: var(--r-tile);
  box-shadow: 4px 4px 0 var(--color-yellow);
}

.support-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 8px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
}

.support-title::before {
  content: '';
  display: inline-block;
  width: 14px;
  height: 3px;
  background: var(--color-yellow);
  border-radius: 1px;
}

h2 {
  font-size: clamp(1.75rem, 8vw, 2.25rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.035em;
  color: var(--color-text);
}

h2 span {
  background: linear-gradient(transparent 62%, rgba(139, 92, 246, 0.4) 62%);
}

p {
  margin: 14px 0 24px;
  padding-left: 0.9rem;
  border-left: 3px solid var(--color-yellow);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

input[type="text"],
input[type="email"],
input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 10px;
  border: 2px solid var(--color-text);
  border-radius: var(--r-input);
  background: #ffffff;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--color-text);
  outline: none;
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}

input::placeholder {
  color: var(--color-text-light);
  font-weight: 400;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus {
  box-shadow: 3px 3px 0 var(--color-yellow);
  transform: translate(-1px, -1px);
}

.field-hint {
  min-height: 14px;
  margin: -6px 0 10px 4px;
  font-size: 0.6875rem;
  font-weight: 500;
  text-align: left;
  color: var(--color-text-muted);
}

.field-hint.error {
  color: #b91c1c;
  font-weight: 600;
}

.field-hint.success {
  color: #15803d;
  font-weight: 600;
}

.turnstile-wrapper {
  display: flex;
  justify-content: center;
  width: 100%;
  min-height: 65px;
  margin: 14px 0;
}

.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  background: var(--color-text);
  color: #ffffff;
  border: 2px solid var(--color-text);
  border-radius: var(--r-button);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 4px 4px 0 var(--color-yellow);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), opacity var(--transition-fast);
}

.primary-btn:hover:not(:disabled) {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 var(--color-yellow);
}

.primary-btn:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--color-yellow);
}

.primary-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.msg {
  font-size: 0.8125rem;
  font-weight: 600;
  text-align: left;
  color: #b91c1c;
}

.msg:not(:empty) {
  margin-top: 14px;
  padding: 10px 12px;
  border-left: 3px solid currentColor;
  border-radius: 0 10px 10px 0;
  background: rgba(239, 68, 68, 0.08);
  overflow-wrap: anywhere;
}

.msg.success {
  color: #15803d;
}

.msg.success:not(:empty) {
  background: rgba(34, 197, 94, 0.1);
}

.switch-link {
  display: block;
  margin-top: 20px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

.switch-link a {
  font-weight: 700;
  color: var(--color-text);
  text-decoration: underline;
  text-decoration-color: var(--color-yellow);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.otp-boxes {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.otp-boxes.shake {
  animation: shake 400ms ease;
}

.otp-boxes .otp-digit {
  flex: 1;
  min-width: 0;
  width: auto;
  aspect-ratio: 1 / 1;
  margin-bottom: 0;
  padding: 0;
  text-align: center;
  background: #ffffff;
  border: 2px solid var(--color-text);
  border-radius: var(--r-input);
  font-family: var(--font-mono);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-text);
}

.otp-boxes .otp-digit.filled {
  background: rgba(234, 179, 8, 0.18);
}

.otp-boxes .otp-digit:focus {
  box-shadow: 3px 3px 0 var(--color-yellow);
  transform: translate(-1px, -1px);
}

.resend-row {
  margin-top: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

.resend-btn {
  display: inline;
  padding: 0;
  background: none;
  border: none;
  box-shadow: none;
  font-family: var(--font-mono);
  font-size: inherit;
  font-weight: 600;
  color: var(--color-text);
  text-decoration: underline;
  text-decoration-color: var(--color-yellow);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
  cursor: pointer;
}

.resend-btn:hover:not(:disabled) {
  text-decoration-color: var(--color-text);
}

.resend-btn:disabled {
  color: var(--color-text-muted);
  text-decoration: none;
  cursor: not-allowed;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

@media (max-width: 480px) {
  body {
    padding: calc(1rem + var(--safe-area-top)) 1rem calc(1.25rem + var(--safe-area-bottom));
  }

  .box {
    padding: 1.75rem 1.25rem 1.5rem;
    box-shadow: 5px 5px 0 var(--color-purple);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-reduced-transparency: reduce) {
  body::after {
    display: none;
  }
}