:root {
  --text: #14161a;
  --text-secondary: rgba(20, 22, 26, 0.72);
  --surface: #eef0f3;
  --font-display: "DM Sans", -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  --ease-out: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-spring: cubic-bezier(0.34, 1.45, 0.64, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: var(--font-display);
  background: var(--surface);
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

body {
  height: 100dvh;
  height: 100svh;
}

body.is-booting .cards {
  opacity: 0;
  pointer-events: none;
}

body.is-ready .cards {
  animation: fadeUp 0.55s var(--ease-out) forwards;
}

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

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

/* ---- Background ---- */
.bg-layer {
  position: fixed;
  inset: 0;
  background-color: var(--surface);
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 0.55s ease;
  will-change: transform, opacity;
}

.bg-layer.is-visible {
  opacity: 1;
  animation: kenBurns 22s ease-out forwards;
}

@keyframes kenBurns {
  from { transform: scale(1); }
  to { transform: scale(1.07); }
}

.bg-blur {
  position: fixed;
  inset: 0;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  mask-image: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.15) 35%, rgba(0,0,0,0.6) 70%, #000 100%);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.15) 35%, rgba(0,0,0,0.6) 70%, #000 100%);
  pointer-events: none;
  transition: backdrop-filter 0.3s ease;
}

body.sheet-open .bg-blur {
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

.bg-scrim {
  position: fixed;
  inset: 0;
  background: linear-gradient(to bottom, rgba(255,255,255,0) 38%, rgba(255,255,255,0.32) 100%);
  pointer-events: none;
}

body.sheet-open .bg-scrim {
  background: linear-gradient(to bottom, rgba(255,255,255,0) 20%, rgba(255,255,255,0.45) 100%);
}

/* ---- Loader ---- */
.loader {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  background: var(--surface);
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.loader.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader__skeleton {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  width: min(208px, 36vw, 19dvh);
}

.loader__card {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 28px;
  background: linear-gradient(90deg, #e4e7ec 25%, #f0f2f5 50%, #e4e7ec 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

.loader__btn {
  width: 55%;
  height: 44px;
  border-radius: 999px;
  background: linear-gradient(90deg, #dde3f7 25%, #ecf0fb 50%, #dde3f7 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  animation-delay: 0.15s;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- Empty ---- */
.empty {
  display: none;
}

/* ---- Carousel ---- */
.cards {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.cards__track {
  display: flex;
  height: 100%;
  will-change: transform;
}

.card-slide {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  overflow: hidden;
  color: var(--text);
}

.card-slide::before {
  content: "";
  flex: 618 1 0;
  min-height: 0;
}

.card-slide::after {
  content: "";
  flex: 382 1 0;
  min-height: 0;
}

.stage__group {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  gap: 12px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.hero__card {
  position: relative;
  width: min(208px, 36vw, 19dvh);
  aspect-ratio: 1 / 1;
  margin-bottom: 0;
  border-radius: min(28px, 5vw);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.45);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.12) inset,
    0 0 48px 8px rgba(255, 255, 255, 0.1),
    0 28px 60px rgba(0, 0, 0, 0.28),
    0 8px 20px rgba(0, 0, 0, 0.14);
  transition: transform 0.36s var(--ease-out);
  will-change: transform;
}

.cards.is-dragging .hero__card {
  transition: none;
}

.hero__card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.stage__head {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 320px;
  margin: 0 28px;
  text-align: center;
  transition: transform 0.36s var(--ease-out);
  will-change: transform;
}

.cards.is-dragging .stage__head {
  transition: none;
}

.stage__title {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin: 0 0 2px;
  font-size: clamp(28px, 7.5vw, 34px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--text);
}

.stage__title:empty { display: none; }

.stage__desc {
  width: 100%;
  min-height: 22px;
  margin: 0;
  font-size: 15px;
  line-height: 22px;
  color: var(--text-secondary);
  overflow: hidden;
  white-space: nowrap;
}

/* ---- Buttons ---- */
.btn-gradient {
  background: linear-gradient(180deg, #5480ff, #3557f0) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 10px 28px rgba(53, 87, 240, 0.45),
    0 3px 8px rgba(0, 0, 0, 0.12) !important;
}

.btn-join {
  display: inline-block;
  padding: 15px 56px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(180deg, #5480ff, #3557f0);
  color: #fff;
  font-family: inherit;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.5px;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 10px 28px rgba(53, 87, 240, 0.45),
    0 3px 8px rgba(0, 0, 0, 0.12);
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s var(--ease-spring), box-shadow 0.2s ease;
}

.btn-join:active {
  transform: scale(0.97);
}

/* ---- Bottom sheet ---- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.32s ease, backdrop-filter 0.32s ease;
  z-index: 10;
}

body.sheet-open .sheet-backdrop {
  opacity: 1;
  pointer-events: auto;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 11;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 22px 22px 0 0;
  padding: 10px 24px calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translateY(100%);
  transition: transform 0.38s var(--ease-spring);
  max-height: 86dvh;
  overflow-y: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.12);
}

.sheet::-webkit-scrollbar { display: none; }

body.sheet-open .sheet {
  transform: translateY(0);
}

.sheet__handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: #dddde2;
  margin: 8px auto 18px;
}

.sheet__close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 32px;
  height: 32px;
  border: none;
  background: #f2f2f5;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  color: #666;
  cursor: pointer;
  transition: background 0.15s ease;
}

.sheet__close:active { background: #e8e8ec; }

.sheet__title {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #111;
}

.sheet__desc {
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.5;
  color: #888;
}

.field { display: block; margin-bottom: 16px; }

.field__label {
  display: block;
  font-size: 13px;
  color: #666;
  margin-bottom: 6px;
}

.field__input {
  width: 100%;
  border: 1px solid #e4e4e8;
  background: #f8f8fa;
  border-radius: 12px;
  padding: 13px 14px;
  font-size: 16px;
  color: #111;
  font-family: inherit;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.field__input:focus {
  outline: none;
  border-color: #3d6bff;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(53, 87, 240, 0.12);
}

.field__error {
  min-height: 18px;
  margin: -8px 0 12px;
  font-size: 13px;
  color: #e0483d;
}

.btn-submit {
  width: 100%;
  padding: 15px 0;
  border: none;
  border-radius: 999px;
  color: #fff;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s var(--ease-spring), opacity 0.2s ease;
}

.btn-submit:active:not(:disabled) { transform: scale(0.98); }
.btn-submit:disabled { opacity: 0.6; cursor: not-allowed; }

/* ---- Success ---- */
.success {
  text-align: center;
  padding: 24px 0 10px;
}

.success__svg {
  display: block;
  margin: 0 auto 16px;
}

.success__circle {
  stroke: #2fb35d;
  stroke-dasharray: 151;
  stroke-dashoffset: 151;
  animation: drawCircle 0.5s ease forwards;
}

.success__check {
  stroke: #2fb35d;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: drawCheck 0.35s 0.35s ease forwards;
}

@keyframes drawCircle {
  to { stroke-dashoffset: 0; }
}

@keyframes drawCheck {
  to { stroke-dashoffset: 0; }
}

.success p {
  color: #333;
  font-size: 15px;
  line-height: 1.5;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .bg-layer.is-visible { animation: none; }
}
