:root {
  --ink: #07141a;
  --sea: #0b1c24;
  --foam: #e8f2ef;
  --mist: #a7c4bc;
  --saffron: #e2a63a;
  --saffron-soft: rgba(226, 166, 58, 0.18);
  --card: rgba(248, 251, 249, 0.94);
  --shadow: 0 28px 60px rgba(0, 0, 0, 0.35);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Outfit", sans-serif;
  color: var(--foam);
  background: var(--sea);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.atmosphere {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 55% at 15% 10%, rgba(46, 110, 102, 0.45), transparent 55%),
    radial-gradient(ellipse 70% 50% at 90% 85%, rgba(226, 166, 58, 0.16), transparent 50%),
    linear-gradient(160deg, #0a1820 0%, #123038 48%, #0b1c24 100%);
  animation: drift 18s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 0;
}

@keyframes drift {
  from {
    filter: hue-rotate(0deg) saturate(1);
    transform: scale(1);
  }
  to {
    filter: hue-rotate(8deg) saturate(1.08);
    transform: scale(1.03);
  }
}

.view {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  padding:
    max(1.25rem, env(safe-area-inset-top))
    1.25rem
    max(1.25rem, env(safe-area-inset-bottom));
}

.view.is-hidden {
  display: none;
}

.view--home {
  display: grid;
  grid-template-rows: 1fr auto;
  align-items: center;
  gap: 2.5rem;
}

.view--groups {
  display: grid;
  grid-template-rows: auto 1fr;
  align-items: start;
  gap: 1.25rem;
  overflow: auto;
}

.view--practice {
  display: grid;
  grid-template-rows: auto 1fr;
  align-items: center;
  gap: 0.75rem;
}

.home-brand {
  text-align: center;
  animation: rise 0.8s var(--ease) both;
  padding-top: 8dvh;
}

.home-brand__name {
  margin: 0;
  font-family: "Fraunces", serif;
  font-weight: 700;
  font-size: clamp(3rem, 12vw, 4.4rem);
  letter-spacing: -0.03em;
  line-height: 1;
}

.home-brand__tag {
  margin: 0.85rem 0 0;
  color: var(--mist);
  font-size: 1.05rem;
  font-weight: 500;
}

.levels {
  display: grid;
  gap: 0.85rem;
  width: min(100%, 22rem);
  margin: 0 auto 4dvh;
  animation: rise 0.9s var(--ease) 0.08s both;
}

.level {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  gap: 0.85rem;
  width: 100%;
  padding: 1.15rem 1.25rem;
  border: 1px solid rgba(232, 242, 239, 0.16);
  border-radius: 1rem;
  background: rgba(232, 242, 239, 0.06);
  color: var(--foam);
  text-align: left;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    transform 0.2s var(--ease);
}

.level:hover {
  background: rgba(226, 166, 58, 0.14);
  border-color: rgba(226, 166, 58, 0.35);
}

.level:active {
  transform: scale(0.985);
}

.level__code {
  font-family: "Fraunces", serif;
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--saffron);
}

.level__desc {
  font-size: 1rem;
  font-weight: 500;
  color: var(--mist);
}

.level__count {
  font-size: 0.88rem;
  color: rgba(167, 196, 188, 0.75);
}

.sub-top,
.practice-top {
  display: grid;
  grid-template-columns: 2.75rem 1fr 2.75rem;
  align-items: center;
  animation: rise 0.6s var(--ease) both;
}

.back {
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid rgba(232, 242, 239, 0.18);
  border-radius: 999px;
  background: rgba(232, 242, 239, 0.06);
  color: var(--foam);
  font-size: 1.15rem;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.back:active {
  transform: scale(0.96);
}

.sub-heading,
.practice-heading {
  text-align: center;
}

.sub-heading__title,
.practice-heading__level {
  margin: 0;
  font-family: "Fraunces", serif;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sub-heading__meta,
.practice-heading__meta {
  margin: 0.2rem 0 0;
  color: var(--mist);
  font-size: 0.88rem;
  font-weight: 500;
}

.sub-top__spacer,
.practice-top__spacer {
  width: 2.75rem;
  height: 2.75rem;
}

.groups {
  display: grid;
  gap: 0.75rem;
  width: min(100%, 22rem);
  margin: 0 auto;
  padding-bottom: 1.5rem;
  animation: rise 0.8s var(--ease) 0.06s both;
}

.group {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 0.75rem;
  width: 100%;
  padding: 1rem 1.15rem;
  border: 1px solid rgba(232, 242, 239, 0.14);
  border-radius: 0.95rem;
  background: rgba(232, 242, 239, 0.05);
  color: var(--foam);
  text-align: left;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    transform 0.2s var(--ease);
}

.group:hover {
  background: rgba(226, 166, 58, 0.12);
  border-color: rgba(226, 166, 58, 0.3);
}

.group:active {
  transform: scale(0.985);
}

.group--done {
  border-color: rgba(74, 168, 120, 0.35);
  background: rgba(74, 168, 120, 0.08);
}

.group__num {
  font-family: "Fraunces", serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--saffron);
  min-width: 2.5rem;
  line-height: 1.3;
}

.group__body {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
}

.group__range {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--mist);
}

.group__progress {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.85rem;
  font-size: 0.82rem;
}

.group__done {
  color: #7dcea0;
}

.group__todo {
  color: rgba(232, 198, 120, 0.9);
}

.group--done .group__todo {
  color: rgba(167, 196, 188, 0.65);
}

.group__count {
  font-size: 0.85rem;
  color: rgba(167, 196, 188, 0.75);
  line-height: 1.3;
}

.groups-loading {
  margin: 2rem 0;
  text-align: center;
  color: var(--mist);
  font-size: 0.95rem;
}

.deck {
  position: relative;
  display: grid;
  width: min(100%, 28rem);
  margin: 0 auto;
  touch-action: none;
  isolation: isolate;
  padding-bottom: 0.9rem;
}

.deck__shadow {
  grid-area: 1 / 1;
  z-index: 0;
  border-radius: 1.35rem;
  box-shadow: var(--shadow);
  pointer-events: none;
}

.card {
  position: relative;
  width: 100%;
  min-height: min(58dvh, 28rem);
  padding: 2rem 1.6rem 1.8rem;
  border-radius: 1.35rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(236, 245, 241, 0.94)),
    var(--card);
  color: var(--ink);
  box-shadow: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.85rem;
  user-select: none;
  will-change: transform;
  overflow: hidden;
}

.card--stub {
  grid-area: 1 / 1;
  z-index: 1;
  transform: translateY(14px);
  pointer-events: none;
}

.card--under {
  grid-area: 1 / 1;
  z-index: 2;
  transform: none;
  pointer-events: none;
}

.card--front {
  --master: 0;
  grid-area: 1 / 1;
  z-index: 3;
  cursor: grab;
  touch-action: none;
  transition: none;
}

.card--front::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    165deg,
    rgba(72, 180, 120, 0.08),
    rgba(46, 160, 100, 0.72)
  );
  opacity: var(--master, 0);
  pointer-events: none;
  z-index: 1;
}

.card--front > * {
  position: relative;
  z-index: 2;
}

.card--front:active,
.card--front.is-dragging {
  cursor: grabbing;
}

.card--front.is-returning {
  transition:
    transform 0.28s var(--ease),
    opacity 0.28s ease,
    --master 0.28s ease;
}

.card--front.is-exit-left {
  transition: transform 0.3s var(--ease), opacity 0.26s ease;
  transform: translateX(-120%) rotate(-10deg);
  opacity: 0;
}

.card--front.is-exit-right {
  transition: transform 0.3s var(--ease), opacity 0.26s ease;
  transform: translateX(120%) rotate(10deg);
  opacity: 0;
}

.card--front.is-exit-up {
  transition: transform 0.32s var(--ease), opacity 0.28s ease;
  transform: translateY(-130%) rotate(-4deg);
  opacity: 0;
  --master: 1;
}

.card.is-boot {
  animation: rise 0.7s var(--ease) both;
}

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

.card__es {
  margin: 0;
  font-family: "Fraunces", serif;
  font-size: clamp(2.6rem, 11vw, 3.8rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
  word-break: break-word;
}

.card__pos {
  margin: 0;
  color: #3f635c;
  font-size: 1rem;
  font-weight: 500;
}

.card__senses {
  margin-top: 0.6rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(15, 40, 36, 0.1);
  display: grid;
  gap: 0.85rem;
}

.card__sense {
  display: grid;
  gap: 0.3rem;
}

.card__sense + .card__sense {
  padding-top: 0.75rem;
  border-top: 1px dashed rgba(15, 40, 36, 0.1);
}

.card__sense-pos {
  margin: 0;
  color: #5a7a72;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.card__zh {
  margin: 0;
  font-size: clamp(1.25rem, 4.5vw, 1.55rem);
  font-weight: 600;
  line-height: 1.35;
}

.card__en {
  margin: 0;
  color: #4a6660;
  font-size: 1.05rem;
  line-height: 1.4;
}

@media (max-width: 420px) {
  .card {
    min-height: min(54dvh, 26rem);
    padding: 1.6rem 1.25rem 1.4rem;
  }
}
