html, body {
  height: 100%;
}

body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-family);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header ─────────────────────────────────────── */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 var(--stage-padding);
  border-bottom: 1px solid var(--color-border);
  background-color: rgba(2, 1, 5, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 100;
}

.header-spacer {
  /* first column — keeps logo centered */
}

.header-logo-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-header .logo {
  height: clamp(26px, 3.8vh, 40px);
  width: auto;
  display: block;
}

/* ── Progress ────────────────────────────────────── */
.progress-container {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: clamp(8px, 1.5vw, 16px);
}

.progress-track {
  width: clamp(80px, 12vw, 160px);
  height: 3px;
  background: var(--color-border);
  border-radius: 99px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 99px;
  transition: width 0.45s cubic-bezier(0.4, 0, 0.2, 1);
  width: 0%;
}

.progress-label {
  font-size: var(--font-sm);
  color: var(--color-muted);
  white-space: nowrap;
  min-width: 48px;
  text-align: right;
}

/* ── Main stage ──────────────────────────────────── */
.app-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: calc(var(--header-height) + 6vh) var(--stage-padding) calc(34px + 8vh);
  position: relative;
  overflow: hidden;
}

/* ── Fields container ────────────────────────────── */
.fields-container {
  position: relative;
  width: min(90vw, 680px);
  min-height: clamp(320px, 50vh, 520px);
}

/* ── End screen ──────────────────────────────────── */
.end-screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: clamp(16px, 3vh, 28px);
  width: min(90vw, 480px);
  animation: fadeInScale var(--transition) forwards;
}

.end-screen.visible {
  display: flex;
}

.end-screen .end-icon {
  width: clamp(56px, 8vw, 76px);
  height: clamp(56px, 8vw, 76px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(24px, 3.5vw, 36px);
  font-weight: 700;
}

.end-screen .end-icon.success {
  background: rgba(76, 217, 123, 0.12);
  color: var(--color-success);
}

.end-screen .end-icon.error {
  background: var(--color-error-dim);
  color: var(--color-error);
}

.end-screen h2 {
  font-size: clamp(1.4rem, 3.5vw, 2rem);
  font-weight: 600;
  line-height: 1.3;
}

.end-screen p {
  font-size: clamp(0.875rem, 1.5vw, 1.05rem);
  color: var(--color-muted);
  line-height: 1.7;
}

/* ── Footer ──────────────────────────────────────── */
.app-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 var(--stage-padding);
  border-top: 1px solid var(--color-border);
  background: rgba(2, 1, 5, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 90;
  flex-wrap: wrap;
  overflow: hidden;
}

.footer-legal,
.footer-sep {
  font-size: 10px;
  color: rgba(236, 240, 241, 0.22);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  color: rgba(236, 240, 241, 0.22);
}

.footer-links a {
  color: rgba(236, 240, 241, 0.35);
  transition: color var(--transition-fast);
  white-space: nowrap;
}

.footer-links a:hover {
  color: rgba(236, 240, 241, 0.65);
}

/* ── Keyboard hint ───────────────────────────────── */
.keyboard-hint {
  position: fixed;
  bottom: calc(34px + clamp(10px, 1.5vh, 18px));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--font-sm);
  color: var(--color-muted);
  pointer-events: none;
  transition: opacity var(--transition);
  white-space: nowrap;
}

.keyboard-hint.hidden {
  opacity: 0;
}

.key-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 7px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 11px;
  font-family: inherit;
  line-height: 1.6;
}

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 600px) {
  .app-header {
    padding: 0 5vw;
  }

  .app-stage {
    padding-left: 5vw;
    padding-right: 5vw;
    align-items: flex-start;
    padding-top: calc(var(--header-height) + 8vh);
  }

  .fields-container {
    min-height: clamp(280px, 60vh, 480px);
  }

  .keyboard-hint {
    display: none;
  }

  .footer-sep,
  .footer-legal {
    display: none;
  }

  .app-footer {
    justify-content: center;
  }
}

@media (max-height: 600px) {
  .app-stage {
    align-items: flex-start;
    padding-top: calc(var(--header-height) + 4vh);
  }
}
