:root {
  --bg: #f4f8f4;
  --card: #ffffff;
  --field: #eef8f1;
  --field-alt: #fff4ea;
  --green: #07c160;
  --green-dark: #0f8b4c;
  --orange: #f97316;
  --orange-dark: #d56411;
  --white: #ffffff;
  --ink: #173027;
  --ink-soft: rgba(23, 48, 39, 0.62);
  --line: rgba(23, 48, 39, 0.12);
  --line-strong: rgba(23, 48, 39, 0.2);
  --danger: #c74646;
  --shadow: 0 14px 36px rgba(11, 29, 21, 0.08);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Avenir Next", "PingFang SC", "Helvetica Neue", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.screen {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  isolation: isolate;
}

.bg-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  opacity: 1;
}

.particle-field {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.particle {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--size);
  height: var(--size);
  border-radius: 999px;
  opacity: 0.06;
  background: rgba(7, 193, 96, 0.28);
  animation: particleFloat var(--duration) ease-in-out infinite;
  animation-delay: var(--delay);
}

.screen.is-sending .particle {
  animation-name: particleGlow;
  opacity: 0.32;
}

.stage {
  position: relative;
  min-height: 100vh;
  padding: max(28px, env(safe-area-inset-top)) 20px max(26px, env(safe-area-inset-bottom));
  display: grid;
  align-content: center;
  gap: 28px;
}

.brand {
  width: min(100%, 430px);
  margin: 0 auto;
  text-align: center;
}

.brand h1 {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", "Songti SC", serif;
  font-size: clamp(42px, 11vw, 62px);
  line-height: 1;
  letter-spacing: -0.04em;
  font-weight: 500;
  color: var(--ink);
}

.card-scene {
  width: min(100%, 430px);
  margin: 0 auto;
  perspective: 1600px;
}

.auth-card {
  position: relative;
  min-height: 470px;
  transform-style: preserve-3d;
  transition: transform 920ms cubic-bezier(0.2, 0.75, 0.18, 1);
}

.auth-card.is-flipped {
  transform: rotateY(180deg);
}

.auth-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 24px;
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.42);
  box-shadow: var(--shadow);
  backdrop-filter: blur(26px) saturate(150%);
  -webkit-backdrop-filter: blur(26px) saturate(150%);
  backface-visibility: hidden;
}

.auth-face::before {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 29px;
  border: 1px solid rgba(23, 48, 39, 0.04);
  pointer-events: none;
}

.auth-face-back {
  transform: rotateY(180deg);
  justify-content: flex-start;
}

.qr-feedback {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-height: 20px;
}

.qr-countdown-text {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 999px;
  padding: 6px 10px;
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
}

.qr-countdown-text[data-tone="expired"],
.qr-countdown-text[data-tone="retry failed"] {
  color: var(--danger);
}

.qr-countdown-text[data-tone="refreshing"] {
  color: var(--orange-dark);
}

.field-stack {
  display: grid;
  gap: 14px;
  margin: auto 0;
}

.glass-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 66px;
  padding: 9px 10px 9px 16px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.32),
    inset 0 -1px 0 rgba(255, 255, 255, 0.08);
}

.glass-field input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}

.glass-field input.is-error {
  color: var(--danger);
}

.glass-field input.is-ok {
  color: var(--ink);
}

.glass-field input::placeholder {
  color: rgba(23, 48, 39, 0.42);
}

.invite-lane {
  justify-content: center;
  padding: 0;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.invite-lane.is-expanded {
  justify-content: space-between;
  padding-left: 12px;
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.32),
    inset 0 -1px 0 rgba(255, 255, 255, 0.08);
}

.invite-field-wrap {
  flex: 0 0 0;
  width: 0;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateX(-24px);
  transition:
    max-width 420ms cubic-bezier(0.2, 0.75, 0.18, 1),
    opacity 260ms ease,
    transform 420ms cubic-bezier(0.2, 0.75, 0.18, 1);
}

.invite-field-wrap.is-visible {
  flex: 1 1 auto;
  max-width: 240px;
  opacity: 1;
  transform: translateX(0);
}

.action-button {
  flex: 0 0 100%;
  width: 100%;
  min-height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 18px;
  background: rgba(7, 193, 96, 0.7);
  color: var(--white);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  align-self: center;
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    inset 0 -1px 0 rgba(255, 255, 255, 0.08);
  transition:
    width 420ms cubic-bezier(0.2, 0.75, 0.18, 1),
    flex-basis 420ms cubic-bezier(0.2, 0.75, 0.18, 1),
    transform 200ms ease,
    opacity 200ms ease;
}

.screen.stage-invite .action-button {
  flex-basis: 102px;
  width: 102px;
  background: rgba(249, 115, 22, 0.72);
}

.action-button:disabled {
  opacity: 0.45;
}

.action-button:not(:disabled):active {
  transform: scale(0.98);
}

.ghost-button {
  margin-top: 18px;
  align-self: center;
  min-height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 1px solid var(--line);
}

.ghost-button.hidden {
  display: none;
}

.qr-shell {
  display: grid;
  place-items: center;
  margin: 18px 0 16px;
  padding: 16px;
  min-height: 286px;
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.34);
  border: 1px solid rgba(255, 255, 255, 0.54);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
}

.qr-image-link {
  display: block;
  line-height: 0;
}

.qr-shell img {
  display: block;
  width: min(100%, 292px);
  max-width: 292px;
  height: auto;
  border-radius: 12px;
  -webkit-touch-callout: default;
  -webkit-user-select: auto;
  user-select: auto;
}

.auth-face-back .ghost-button {
  margin-top: auto;
}

.hidden {
  display: none !important;
}

@keyframes particleFloat {
  0%,
  100% {
    transform: translate3d(0, 0, 0) scale(0.7);
  }
  50% {
    transform: translate3d(0, -10px, 0) scale(1);
  }
}

@keyframes particleGlow {
  0%,
  100% {
    transform: scale(0.7);
    box-shadow: 0 0 0 rgba(60, 216, 184, 0);
  }
  40% {
    transform: scale(1.26);
    box-shadow:
      0 0 12px rgba(7, 193, 96, 0.2),
      0 0 18px rgba(249, 115, 22, 0.18);
  }
}

@media (min-width: 640px) {
  .stage {
    padding-inline: 28px;
  }

  .auth-face {
    min-height: 540px;
    padding: 28px;
  }
}
