/* ─── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ─── Dark Theme (default) ─────────────────────────────────────── */
:root {
  --bg: #0d0d0f;
  --surface: #16161a;
  --border: rgba(255,255,255,0.07);
  --text: #f0eff4;
  --muted: #a7a9b7;
  --accent: #7f5af0;
  --accent2: #2cb67d;
  --header-grad-a: #f0eff4;
  --header-grad-b: #a78bfa;
  --card-title-blur-color: #a7a9b7;
  --face-front-bg: #16161a;
  --face-grad-end: #16161a;
  --overlay-bg: rgba(0,0,0,0.75);
  --overlay-bg-solid: rgba(6,6,8,0.96);
  --radius: 16px;
  --card-shadow: 0 4px 32px rgba(0,0,0,0.55);
  --transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Light Theme ───────────────────────────────────────────────── */
:root.light {
  --bg: #fff0f5;
  --surface: #ffffff;
  --border: rgba(236,72,153,0.12);
  --text: #3b0a24;
  --muted: #b06090;
  --accent: #ec4899;
  --accent2: #f9a8d4;
  --header-grad-a: #be185d;
  --header-grad-b: #fb7185;
  --card-title-blur-color: #b06090;
  --face-front-bg: #fff5f8;
  --face-grad-end: #fff5f8;
  --overlay-bg: rgba(255,240,245,0.72);
  --overlay-bg-solid: rgba(255,240,245,0.97);
  --card-shadow: 0 4px 24px rgba(236,72,153,0.12);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.4s ease, color 0.4s ease;
}

/* ─── Header ───────────────────────────────────────────────────── */
header {
  text-align: center;
  padding: 60px 20px 48px;
  position: relative;
}

header::after {
  content: '';
  display: block;
  width: 60px;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 2px;
  margin: 20px auto 0;
}

header h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--header-grad-a) 30%, var(--header-grad-b));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

header p {
  margin-top: 12px;
  color: var(--muted);
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}

/* ─── Masonry Grid ─────────────────────────────────────────────── */
#grid {
  columns: 3 280px;
  column-gap: 20px;
  padding: 0 40px 80px;
  max-width: 1200px;
  margin: 0 auto;
}

/* ─── Grid Card ────────────────────────────────────────────────── */
.card {
  break-inside: avoid;
  margin-bottom: 20px;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  cursor: pointer;
  border: 1px solid var(--border);
  box-shadow: var(--card-shadow);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  animation: cardIn 0.6s ease both;
}

.card:hover {
  transform: translateY(-6px) scale(1.015);
  box-shadow: 0 16px 48px color-mix(in srgb, var(--accent) 22%, transparent), var(--card-shadow);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

/* Staggered entrance */
.card:nth-child(1)  { animation-delay: 0.05s; }
.card:nth-child(2)  { animation-delay: 0.10s; }
.card:nth-child(3)  { animation-delay: 0.15s; }
.card:nth-child(4)  { animation-delay: 0.20s; }
.card:nth-child(5)  { animation-delay: 0.25s; }
.card:nth-child(6)  { animation-delay: 0.30s; }
.card:nth-child(7)  { animation-delay: 0.35s; }
.card:nth-child(8)  { animation-delay: 0.40s; }
.card:nth-child(9)  { animation-delay: 0.45s; }
.card:nth-child(10) { animation-delay: 0.50s; }
.card:nth-child(11) { animation-delay: 0.55s; }
.card:nth-child(12) { animation-delay: 0.60s; }

@keyframes cardIn {
  from { opacity: 0; transform: translateY(30px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

/* Card heights driven by the card itself */
.card:nth-child(3n+1) { height: 200px; }
.card:nth-child(3n+2) { height: 160px; }
.card:nth-child(3n)   { height: 230px; }

.card-img {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-color: #2a2a2e;
  filter: blur(24px) brightness(0.7);
  transform: scale(1.2);
  transition: none;
}

:root.light .card-img {
  background-color: #f0d8e8;
  filter: blur(24px) brightness(0.75);
}

/* Dark gradient so text is always legible */
.card-img::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0.05) 0%, rgba(0,0,0,0.55) 100%);
}

.card-body {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 16px 18px;
  z-index: 1;
  -webkit-font-smoothing: antialiased;
}

.card-number {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #ffffff;
  line-height: 1;
  text-shadow: 0 2px 16px rgba(0,0,0,0.6);
}

.card-hint {
  margin-top: 8px;
  font-size: 0.72rem;
  color: rgba(255,255,255,0.6);
  display: flex;
  align-items: center;
  gap: 5px;
}

.card-hint svg { flex-shrink: 0; }

/* ─── Overlay / Modal Backdrop ─────────────────────────────────── */
#overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  /* Top: 52px for the close button (out of flow, above the card) plus room
     to clear #top-controls, which paints over it at z-index 300.
     Bottom: clears the fixed #kb-hint (20px offset + ~33px tall). */
  padding: 116px 24px 66px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease, backdrop-filter 0.35s ease, background 0.35s ease;
}

#overlay.active {
  opacity: 1;
  background: var(--overlay-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  pointer-events: all;
}

/* ─── Flip Card Container ──────────────────────────────────────── */
#flip-container {
  perspective: 1400px;
  -webkit-perspective: 1400px;
  width: 100%;
  max-width: 680px;
  /* 250px = 116px top padding + 66px bottom padding + 24px gap + 44px nav.
     Keeps the card, its nav and both chrome elements inside the viewport. */
  height: min(560px, calc(100vh - 250px));
  height: min(560px, calc(100dvh - 250px));
  position: relative;
  will-change: transform;
  transform: translateZ(0);
}

#flip-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

#flip-inner.flipped {
  transform: rotateY(180deg);
  -webkit-transform: rotateY(180deg);
}

/* ─── Shared face styles ───────────────────────────────────────── */
.face {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,0.7);
}

/* ─── Front Face (Question) ────────────────────────────────────── */
#face-front {
  border: 1px solid var(--border);
  overflow: hidden;
  transform: rotateY(0deg);
  -webkit-transform: rotateY(0deg);
}

#face-front .face-img {
  position: absolute;
  inset: 0;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  background-color: #111;
  filter: blur(24px) brightness(0.55);
  transform: scale(1.2);
  transition: none;
}

:root.light #face-front .face-img { background-color: #2a1a22; }

#face-front .face-img::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 75% 55% at 50% 50%, rgba(0,0,0,0.5) 0%, rgba(0,0,0,0.28) 60%, rgba(0,0,0,0.45) 100%);
}

#face-front .face-body {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* Symmetric padding so `center` lands on the true optical centre. */
  padding: 28px 32px;
  text-align: center;
  z-index: 1;
}

#face-front .face-number {
  font-size: clamp(3rem, 8vw, 5rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  color: #ffffff;
  text-shadow: 0 4px 24px rgba(0,0,0,0.5);
  margin-bottom: 28px;
}

/* ─── Reveal Button ────────────────────────────────────────────── */
#btn-reveal {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  border-radius: 40px;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  box-shadow: 0 4px 20px color-mix(in srgb, var(--accent) 45%, transparent);
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}

#btn-reveal::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent);
  opacity: 0;
  transition: opacity 0.2s;
}

#btn-reveal:hover { transform: scale(1.05); box-shadow: 0 6px 28px rgba(127,90,240,0.6); }
#btn-reveal:hover::before { opacity: 1; }
#btn-reveal:active { transform: scale(0.97); }

/* ─── Back Face (Answer) ───────────────────────────────────────── */
#face-back {
  transform: rotateY(180deg);
  -webkit-transform: rotateY(180deg);
  display: flex;
  flex-direction: column;
}

#face-back .face-img {
  flex: 1;
  min-height: 0;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  background-color: #111;
  filter: none;
  position: relative;
}

:root.light #face-back .face-img { background-color: #2a1a22; }

/* No dark image overlay: the photo stays visible. */
#face-back .face-content {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 28px 32px 30px;
  background: linear-gradient(to bottom, rgba(10, 10, 12, 0.3), rgba(10, 10, 12, 0.96) 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  z-index: 1;
  -webkit-font-smoothing: antialiased;
}

#face-back .face-content::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: -24px;
  height: 24px;
  /*background: rgba(10,10,12,0.96);*/
  pointer-events: none;
}

#face-back .back-number {
  font-size: 1rem;
  font-weight: 1000;
  /*letter-spacing: 0.15em;*/
  text-transform: uppercase;
  color: #2cb67d;
  margin-bottom: 8px;
  text-shadow: 2px 2px 10px black;
}

#face-back .back-title {
  font-size: clamp(1.3rem, 3vw, 1.9rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 12px;
  color: #ffffff;
  white-space: pre-wrap;
  text-shadow: 2px 2px 10px black;
}

/* ─── Navigation Bar ───────────────────────────────────────────── */
#modal-nav {
  /* Sits in normal flow as the overlay's second column item. The 24px
     overlay gap reproduces the spacing the old absolute offset gave. */
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  white-space: nowrap;
  z-index: 1;
}

.nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  transition: background var(--transition), border-color var(--transition), transform 0.2s;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  flex: 0 0 44px;
}

.nav-btn:hover:not(:disabled) {
  background: rgba(127,90,240,0.25);
  border-color: var(--accent);
  transform: scale(1.1);
}

.nav-btn:disabled { opacity: 0.25; cursor: default; }

#nav-counter {
  font-size: 0.82rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  min-width: 60px;
  text-align: center;
}

/* ─── Close Button ─────────────────────────────────────────────── */
#btn-close {
  position: absolute;
  top: -52px;
  right: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: background 0.2s, transform 0.2s;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

#btn-close:hover { background: rgba(255,80,80,0.25); transform: scale(1.1) rotate(90deg); }

/* ─── Progress Dots ────────────────────────────────────────────── */
#progress-dots {
  display: flex;
  gap: 6px;
  align-items: center;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  transition: background 0.3s, transform 0.3s;
}

.dot.active {
  background: var(--accent);
  transform: scale(1.4);
}

/* ─── Loading State ────────────────────────────────────────────── */
#loading {
  text-align: center;
  padding: 80px 20px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid color-mix(in srgb, var(--accent) 20%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ─── Keyboard Hint ────────────────────────────────────────────── */
#kb-hint {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 30px;
  padding: 8px 18px;
  font-size: 0.75rem;
  color: var(--muted);
  display: flex;
  gap: 12px;
  /* Must stay one line: the overlay's bottom padding is sized for it. */
  white-space: nowrap;
  transition: transform 0.4s ease, opacity 0.4s;
  opacity: 0;
  pointer-events: none;
  z-index: 200;
}

#kb-hint.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.kb-key {
  display: inline-block;
  background: color-mix(in srgb, var(--muted) 15%, transparent);
  border-radius: 5px;
  padding: 1px 6px;
  font-family: monospace;
  font-size: 0.8em;
}

/* ─── Top Controls ─────────────────────────────────────────────── */
#top-controls {
  /* Absolute, not fixed: the controls sit at the top of the document and
     scroll away with it rather than floating over the content. */
  position: absolute;
  top: 20px;
  right: 24px;
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 10px;
}

#theme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 8px 10px;
  border-radius: 40px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  box-shadow: var(--card-shadow);
  transition: background var(--transition), border-color var(--transition), color var(--transition), transform 0.2s;
}

#theme-toggle:hover { transform: scale(1.05); border-color: var(--accent); }

#btn-logout {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px 8px 12px;
  border-radius: 40px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-decoration: none;
  box-shadow: var(--card-shadow);
  transition: background var(--transition), border-color var(--transition), color var(--transition), transform 0.2s;
}

#btn-logout:hover {
  transform: scale(1.05);
  border-color: #f87171;
  color: #f87171;
  background: color-mix(in srgb, #f87171 8%, var(--surface));
}

#theme-toggle .toggle-track {
  width: 34px;
  height: 18px;
  border-radius: 9px;
  background: var(--border);
  position: relative;
  transition: background var(--transition);
  flex-shrink: 0;
}

:root.light #theme-toggle .toggle-track { background: linear-gradient(90deg, var(--accent), var(--accent2)); }

#theme-toggle .toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform var(--transition), background var(--transition);
}

:root.light #theme-toggle .toggle-thumb { transform: translateX(16px); background: #fff; }

#theme-toggle .toggle-icon {
  font-size: 1rem;
  line-height: 1;
  transition: transform 0.5s ease;
}

:root.light #theme-toggle .toggle-icon { transform: rotate(360deg); }

/* ─── Responsive ───────────────────────────────────────────────── */
@media (max-width: 640px) {
  /* Still out of flow, so the header padding below reserves their space. */
  #top-controls {
    top: max(12px, env(safe-area-inset-top));
    right: 12px;
    left: 12px;
    justify-content: flex-end;
    gap: 8px;
  }

  /* Give the header enough room so the controls never overlap the title. */
  header {
    padding: 150px 16px 32px;
  }

  header h1 {
    font-size: clamp(2rem, 9vw, 3rem);
    line-height: 1.05;
  }

  header p {
    font-size: 0.98rem;
  }

  #grid {
    padding: 0 16px 60px;
    column-gap: 12px;
  }

  /* Mobile modal: the card and the nav row are stacked flex items, so the
     nav can never overlap the card's content. */
  #overlay {
    padding: 12px 12px max(12px, env(safe-area-inset-bottom));
    gap: 14px;
    overflow: hidden;
    /* Blur is disabled on mobile for performance, so the backdrop has to be
       near-opaque on its own or the grid shows through the modal. */
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  #overlay.active {
    background: var(--overlay-bg-solid);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  #flip-container {
    width: 100%;
    max-width: none;
    /* 12px top padding + 14px gap + 46px nav + bottom padding + slack */
    height: min(600px, calc(100svh - 130px));
    min-height: 0;
    /* Horizontal gestures belong to the swipe handler, not the browser. */
    touch-action: pan-y;
    transform: none;
    -webkit-transform: none;
    will-change: auto;
  }

  /* Explicit transforms + preserve-3d make the flip reliable on iOS Safari. */
  #flip-inner {
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
  }

  #flip-inner.flipped {
    transform: rotateY(180deg);
    -webkit-transform: rotateY(180deg);
  }

  .face {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
  }

  #face-front {
    transform: rotateY(0deg);
    -webkit-transform: rotateY(0deg);
  }

  #face-back {
    transform: rotateY(180deg);
    -webkit-transform: rotateY(180deg);
  }

  /* The answer text panel is slightly smaller on a phone. */
  #face-front .face-body,
  #face-back .face-content {
    padding: 20px;
  }

  #face-back .face-content {
    padding-bottom: 22px;
  }

  #face-back .back-title {
    font-size: clamp(1.2rem, 5.2vw, 1.65rem);
  }

  /* Keep close button inside the viewport on phones. */
  #btn-close {
    top: 8px;
    right: 8px;
    width: 38px;
    height: 38px;
    z-index: 5;
  }

  /* Full-width row beneath the card, spreading the controls to the edges. */
  #modal-nav {
    align-self: stretch;
    padding: 0 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .nav-btn {
    width: 46px;
    height: 46px;
    flex: 0 0 46px;
  }

  #progress-dots {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 130px;
    justify-content: center;
    gap: 5px;
    overflow: hidden;
  }

  #nav-counter {
    min-width: 48px;
    flex: 0 0 48px;
    font-size: 0.78rem;
  }

  /* Keyboard shortcuts have no value on a touch-only device. */
  #kb-hint {
    display: none !important;
  }

  #theme-toggle .toggle-label,
  #btn-logout span {
    display: none;
  }
}

/* ─── Password Gate ────────────────────────────────────────────── */
#gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse 60% 50% at 50% 40%, color-mix(in srgb, var(--accent) 12%, transparent) 0%, transparent 70%), var(--bg);
  animation: gateBgIn 1s ease both;
}

@keyframes gateBgIn { from { opacity: 0; } to { opacity: 1; } }

#gate-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 48px 40px 40px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.4), 0 0 0 1px color-mix(in srgb, var(--accent) 15%, transparent);
  text-align: center;
  animation: gateCardIn 0.6s cubic-bezier(0.4,0,0.2,1) both;
  position: relative;
}

@keyframes gateCardIn {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

#gate-icon {
  font-size: 2rem;
  line-height: 1;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 20px;
  display: block;
  animation: spin 6s linear infinite;
}

#gate-title {
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--header-grad-a) 30%, var(--header-grad-b));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 10px;
}

#gate-subtitle {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 32px;
}

.gate-field { margin-bottom: 14px; position: relative; }

#gate-input,
#gate-dob {
  width: 100%;
  padding: 14px 18px;
  border-radius: 14px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  letter-spacing: 0.05em;
  -webkit-appearance: none;
  appearance: none;
}

#gate-dob::-webkit-calendar-picker-indicator {
  opacity: 0.4;
  cursor: pointer;
  filter: var(--calendar-icon-filter, none);
}

:root.light { --calendar-icon-filter: invert(0.3) sepia(1) saturate(3) hue-rotate(280deg); }

#gate-input:focus,
#gate-dob:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

#gate-input::placeholder,
#gate-dob::placeholder { color: var(--muted); opacity: 0.6; }

.gate-field--error #gate-input,
.gate-field--error #gate-dob {
  border-color: #f87171;
  box-shadow: 0 0 0 3px rgba(248,113,113,0.15);
  animation: shake 0.4s cubic-bezier(0.4,0,0.2,1);
}

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

.gate-error {
  margin-top: 8px;
  font-size: 0.8rem;
  color: #f87171;
  text-align: left;
}

#gate-submit {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: 0.03em;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  box-shadow: 0 4px 20px color-mix(in srgb, var(--accent) 40%, transparent);
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
  position: relative;
  overflow: hidden;
}

#gate-submit::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent);
  opacity: 0;
  transition: opacity 0.2s;
}

#gate-submit:hover { transform: translateY(-2px); box-shadow: 0 8px 28px color-mix(in srgb, var(--accent) 50%, transparent); }
#gate-submit:hover::before { opacity: 1; }
#gate-submit:active { transform: translateY(0) scale(0.98); }

@media (max-width: 480px) {
  #gate-card { padding: 36px 24px 32px; }
}
