:root {
  --bg: #071824;
  --bg-soft: #0b2031;
  --surface: #0f2a3d;
  --surface-2: #12324a;
  --ink: #e8f3ff;
  --muted: #93acc3;
  --line: #214a66;
  --line-strong: #2d6185;
  --green: #64d8a5;
  --green-strong: #3dc68d;
  --gold: #f2c43f;
  --blue: #57a6ff;
  --locked: #4e6277;
  --danger: #ff8b82;
  --radius-s: 10px;
  --radius-m: 14px;
  --radius-l: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 0 -10%, #163a54 0%, transparent 35%),
    radial-gradient(circle at 100% 45%, #172740 0%, transparent 36%),
    linear-gradient(180deg, #071824 0%, #061320 100%);
}

[hidden],
.hidden {
  display: none !important;
}

.auth-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.auth-card {
  width: min(430px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  background: linear-gradient(180deg, rgb(15 42 61 / 0.95), rgb(11 33 50 / 0.98));
  box-shadow: 0 18px 38px rgb(0 0 0 / 0.35);
  padding: 1rem;
}

.auth-title {
  margin: 0;
  font-size: 1.9rem;
  line-height: 1;
}

.auth-subtitle {
  margin: 0.35rem 0 0.9rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.auth-form {
  display: grid;
  gap: 0.25rem;
}

.auth-submit {
  margin-top: 0.62rem;
}

.auth-feedback {
  margin: 0.62rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.auth-switch-row {
  margin: 0.5rem 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.auth-link-btn {
  border: 0;
  background: transparent;
  color: #a6d3ff;
  font: inherit;
  font-weight: 700;
  padding: 0;
}

.auth-register-info {
  margin: 0.15rem 0 0.5rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.app-shell {
  width: min(960px, calc(100% - 1rem));
  margin: 0 auto;
  padding: 0.8rem 0 calc(6rem + env(safe-area-inset-bottom, 0px));
  display: grid;
  gap: 0.8rem;
}

.screen {
  display: none;
}

.screen.active-screen {
  display: grid;
  gap: 0.8rem;
}

.hero {
  background: linear-gradient(140deg, #58dcb1 0%, #4ecf9e 58%, #3fb88a 100%);
  border-radius: var(--radius-l);
  border: 1px solid rgb(255 255 255 / 0.24);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.7rem;
  padding: 0.86rem;
  box-shadow: 0 16px 32px rgb(0 0 0 / 0.28);
}

.hero-copy h1 {
  margin: 0.26rem 0;
  font-size: clamp(2rem, 9vw, 2.72rem);
  line-height: 0.95;
  color: #04281d;
}

.eyebrow {
  margin: 0;
  color: #15513d;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.subtitle {
  margin: 0;
  color: #0f4b39;
  font-size: 0.85rem;
  line-height: 1.36;
}

.mascot-card {
  width: 84px;
  height: 84px;
  border-radius: 14px;
  background: rgb(255 255 255 / 0.3);
  border: 1px solid rgb(255 255 255 / 0.52);
  display: grid;
  place-items: center;
}

.mascot-emoji {
  margin: 0;
  font-size: 1.65rem;
}

.hud {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  position: sticky;
  top: max(0.35rem, env(safe-area-inset-top));
  z-index: 45;
  padding: 0.34rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgb(8 25 38 / 0.92);
  backdrop-filter: blur(10px);
}

.hud-item {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, rgb(16 43 62 / 0.96), rgb(13 36 53 / 0.96));
  padding: 0.54rem 0.62rem;
}

.hud-label {
  margin: 0;
  font-size: 0.7rem;
  color: var(--muted);
}

.hud-value {
  margin: 0.22rem 0 0;
  font-size: 1rem;
  font-weight: 700;
}

.section {
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: linear-gradient(180deg, rgb(15 42 61 / 0.95), rgb(12 34 51 / 0.95));
  padding: 0.8rem;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.section-header h2 {
  margin: 0;
  font-size: 1.08rem;
}

.label {
  display: block;
  margin: 0.32rem 0 0.42rem;
  color: var(--muted);
  font-size: 0.79rem;
}

.select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--surface-2);
  color: var(--ink);
  padding: 0.56rem 0.64rem;
  font: inherit;
  outline: none;
}

.select:focus {
  border-color: #74b2df;
  box-shadow: 0 0 0 2px rgb(87 166 255 / 0.24);
}

.language-emoji-picker {
  display: flex;
  align-items: center;
  gap: 0.42rem;
}

.lang-emoji-btn {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  border: 1px solid #2e526b;
  background: #123954;
  font-size: 1.55rem;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.lang-emoji-btn:hover {
  transform: translateY(-1px);
  border-color: #4f82aa;
}

.lang-emoji-btn.active {
  border-color: #4cbf90;
  box-shadow: 0 0 0 1px rgb(76 191 144 / 0.35);
}

.journey {
  background:
    radial-gradient(circle at 0 50%, #0d2d43 0%, transparent 35%),
    radial-gradient(circle at 100% 0, #11293d 0%, transparent 40%),
    #0a2032;
}

#overall-progress {
  color: var(--muted);
  font-size: 0.74rem;
}

.journey-hint {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.level-track {
  list-style: none;
  margin: 0.84rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.66rem;
  position: relative;
}

.level-track::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0.22rem;
  bottom: 0.22rem;
  transform: translateX(-50%);
  width: 3px;
  border-radius: 999px;
  background: linear-gradient(180deg, #3b6f93 0%, #275674 100%);
  opacity: 0.95;
  z-index: 0;
}

.journey-node {
  position: relative;
  display: grid;
  gap: 0.3rem;
  width: 100%;
  min-height: 94px;
  z-index: 1;
}

.journey-node::after {
  content: "";
  position: absolute;
  top: 34px;
  height: 3px;
  border-radius: 999px;
  background: #2d607f;
  z-index: 0;
}

.journey-node.left {
  justify-items: start;
}

.journey-node.left::after {
  left: 34px;
  width: calc(50% - 34px);
}

.journey-node.right {
  justify-items: end;
}

.journey-node.right::after {
  right: 34px;
  width: calc(50% - 34px);
}

.journey-orb {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 4px solid rgb(255 255 255 / 0.16);
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  box-shadow: inset 0 -6px 0 rgb(0 0 0 / 0.18), 0 8px 18px rgb(0 0 0 / 0.22);
  position: relative;
  z-index: 2;
}

.journey-node.complete .journey-orb {
  background: linear-gradient(180deg, #7df0b8 0%, #45cf96 100%);
}

.journey-node.enabled .journey-orb {
  background: linear-gradient(180deg, #ffe07d 0%, #f2c43f 100%);
  animation: glow 1.7s infinite;
}

.journey-node.locked .journey-orb {
  background: linear-gradient(180deg, #617387 0%, #4d5f72 100%);
  filter: grayscale(0.12);
}

.reward-node {
  list-style: none;
  justify-self: center;
  display: grid;
  justify-items: center;
  gap: 0.22rem;
}

.reward-orb {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: linear-gradient(180deg, #ffe57c 0%, #f0bd34 100%);
  border: 3px solid rgb(255 255 255 / 0.22);
  display: grid;
  place-items: center;
  font-size: 1.45rem;
  box-shadow: inset 0 -5px 0 rgb(0 0 0 / 0.14);
}

.reward-text {
  font-size: 0.68rem;
  color: var(--muted);
}

.journey-meta {
  width: min(232px, calc(50% - 0.95rem));
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgb(17 45 66 / 0.9);
  padding: 0.45rem 0.6rem;
  position: relative;
  z-index: 2;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.journey-meta.selected {
  border-color: #4cbf90;
  box-shadow: 0 0 0 1px rgb(76 191 144 / 0.3);
}

.level-label {
  display: block;
  font-size: 0.86rem;
  font-weight: 700;
}

.level-desc {
  display: block;
  margin-top: 0.18rem;
  font-size: 0.76rem;
  color: var(--muted);
}

.level-divider {
  list-style: none;
  margin: 0.2rem 0 0.12rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.24rem 0.12rem;
  color: #9ab3c9;
  font-size: 0.73rem;
  border-top: 1px solid #275574;
}

.task-node {
  min-height: 88px;
}

.task-meta {
  backdrop-filter: blur(2px);
}

.task-orb {
  cursor: pointer;
  font-size: 1.28rem;
  width: 62px;
  height: 62px;
}

.task-orb:disabled {
  cursor: not-allowed;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.14rem 0.48rem;
  font-size: 0.68rem;
  font-weight: 700;
}

.badge.basic {
  background: #214c3b;
  color: #8df0c1;
}

.badge.intermediate {
  background: #2a355f;
  color: #9fb2ff;
}

.badge.advanced {
  background: #5e4324;
  color: #ffd088;
}

.badge.status {
  margin-left: 0.3rem;
  background: #22384f;
  color: #abc3df;
}

.ghost-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #123954;
  color: #b8d4f1;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.36rem 0.68rem;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.ghost-btn:hover {
  border-color: var(--line-strong);
  background: #164566;
}

.ghost-btn:active {
  transform: translateY(1px);
}

.level-action-btn {
  background: #154a33;
  color: #8ef3c3;
  border-color: #256347;
  position: relative;
  z-index: 2;
}

.topic-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.62rem;
}

.topic-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, rgb(18 48 71 / 0.95), rgb(15 42 62 / 0.95));
  padding: 0.72rem;
  transition: transform 140ms ease, border-color 140ms ease, opacity 140ms ease, box-shadow 140ms ease;
}

.topic-card header {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem;
  align-items: center;
}

.topic-emoji {
  margin: 0;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #174362;
  border: 1px solid #2a5a79;
  display: grid;
  place-items: center;
  font-size: 1.22rem;
}

.topic-category {
  margin: 0;
  color: var(--muted);
  font-size: 0.69rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.topic-title {
  margin: 0.1rem 0 0;
  font-size: 0.97rem;
}

.topic-summary {
  margin: 0.55rem 0 0;
  color: #a2bad0;
  font-size: 0.8rem;
  line-height: 1.36;
}

.topic-card.open-module {
  cursor: pointer;
}

.topic-card.open-module:hover {
  transform: translateY(-2px);
  border-color: #407097;
  box-shadow: 0 10px 24px rgb(0 0 0 / 0.2);
}

.topic-card.active-module {
  border-color: #4cbf90;
  box-shadow: 0 0 0 1px rgb(76 191 144 / 0.35);
}

.topic-card.locked-module {
  opacity: 0.56;
  filter: saturate(0.5);
  cursor: not-allowed;
}

.topic-progress {
  margin-top: 0.62rem;
}

.topic-progress-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  color: #acc3d8;
}

.topic-progress-bar {
  margin-top: 0.26rem;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #112e43;
  border: 1px solid #234d69;
  overflow: hidden;
}

.topic-progress-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #5ad29a 0%, #8df0c1 100%);
}

.lesson-feedback {
  min-height: 1.2rem;
  margin: 0.5rem 0 0;
  color: #b7d3ec;
  font-size: 0.78rem;
}

.challenge-screen {
  position: fixed;
  inset: 0;
  z-index: 140;
  background: rgb(6 20 31 / 0.96);
  display: block;
  padding: 0;
}

.challenge-screen.is-correct .challenge-card {
  box-shadow: inset 0 0 0 2px rgb(76 191 144 / 0.45);
}

.challenge-card {
  width: 100%;
  height: 100dvh;
  border: 0;
  border-radius: 0;
  background:
    radial-gradient(circle at 100% -10%, #173a55 0%, transparent 42%),
    linear-gradient(180deg, #081f30 0%, #071824 100%);
  padding: 0.85rem;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 0.68rem;
}

.challenge-topbar {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.65rem;
}

.challenge-x-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid #2f5874;
  background: #103651;
  color: #c5ddf2;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
}

.challenge-progress-wrap {
  min-width: 0;
}

.challenge-progress {
  margin: 0;
  color: #a7bfd3;
  font-size: 0.79rem;
}

.challenge-progress-bar {
  margin-top: 0.35rem;
  width: 100%;
  height: 11px;
  border-radius: 999px;
  border: 1px solid #2d5978;
  background: #0f2d41;
  overflow: hidden;
}

#challenge-progress-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #66dfa8 0%, #9af4c8 100%);
  transition: width 220ms ease;
}

.challenge-body {
  display: grid;
  align-content: start;
  gap: 0.85rem;
  padding-top: 0.55rem;
}

.challenge-question {
  margin: 0;
  font-size: clamp(1.2rem, 5vw, 1.48rem);
  line-height: 1.32;
}

.challenge-options {
  display: grid;
  gap: 0.58rem;
}

.challenge-option-btn {
  text-align: left;
  background: #11324a;
  border-radius: 12px;
  border: 1px solid #2f5c7b;
  color: #ddecfb;
  font-size: 1rem;
  padding: 1rem 0.95rem;
}

.challenge-option-btn.is-selected {
  border-color: #69a3cf;
  box-shadow: 0 0 0 1px rgb(105 163 207 / 0.4);
  background: #1a435f;
}

.challenge-option-btn.is-correct {
  border-color: #3cab7f;
  background: #1a513e;
  color: #9ef5cb;
}

.challenge-option-btn.is-wrong {
  border-color: #88505b;
  background: #4b2830;
  color: #ffc3cf;
}

.challenge-status {
  min-height: 3rem;
  margin: 0;
  color: #bed3e6;
  font-size: 0.91rem;
  line-height: 1.46;
}

.challenge-celebration {
  font-size: 1.7rem;
  animation: celebration-pop 700ms ease;
}

.challenge-footer {
  padding-bottom: calc(0.3rem + env(safe-area-inset-bottom, 0));
}

.challenge-check-btn {
  width: 100%;
  border: 1px solid #2d5a79;
  border-radius: 12px;
  background: #173c58;
  color: #e7f3ff;
  font: inherit;
  font-size: 0.98rem;
  font-weight: 700;
  padding: 0.98rem;
}

.challenge-check-btn:disabled {
  opacity: 0.52;
}

.challenge-screen.step-animate .challenge-question,
.challenge-screen.step-animate .challenge-status {
  animation: question-in 320ms ease;
}

.challenge-screen.step-animate .challenge-option-btn {
  animation: option-in 280ms ease both;
}

.challenge-screen.step-animate .challenge-option-btn:nth-child(1) {
  animation-delay: 30ms;
}

.challenge-screen.step-animate .challenge-option-btn:nth-child(2) {
  animation-delay: 80ms;
}

.challenge-screen.step-animate .challenge-option-btn:nth-child(3) {
  animation-delay: 130ms;
}

.challenge-screen.step-animate .challenge-option-btn:nth-child(4) {
  animation-delay: 180ms;
}

.error {
  border: 1px solid #6e3d41;
  border-radius: 10px;
  background: #3b2124;
  color: var(--danger);
  padding: 0.66rem;
  font-size: 0.82rem;
}

.ranking-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.45rem;
}

.ranking-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  padding: 0.5rem 0.6rem;
  font-size: 0.81rem;
}

.profile-subtitle {
  margin: 0.72rem 0 0.2rem;
  font-size: 0.92rem;
}

.logout-btn {
  margin-top: 0.5rem;
  background: #3b2131;
  color: #ffc7d9;
  border-color: #6a3e57;
}

.bottom-menu {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(0.72rem + env(safe-area-inset-bottom, 0px));
  width: min(920px, calc(100% - 1rem));
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgb(8 25 38 / 0.94);
  backdrop-filter: blur(10px);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.35rem;
  padding: 0.35rem;
  box-shadow: 0 10px 24px rgb(0 0 0 / 0.28);
  z-index: 50;
}

.menu-btn {
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: #b8cee2;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  padding: 0.52rem 0.42rem;
}

.menu-btn.active {
  border-color: #336588;
  background: #123d59;
  color: #e3f4ff;
}

@keyframes glow {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgb(242 196 63 / 0.45);
  }
  70% {
    transform: scale(1.05);
    box-shadow: 0 0 0 14px rgb(242 196 63 / 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgb(242 196 63 / 0);
  }
}

@keyframes celebration-pop {
  0% {
    opacity: 0;
    transform: translateY(8px) scale(0.88);
  }
  55% {
    opacity: 1;
    transform: translateY(0) scale(1.06);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes question-in {
  0% {
    opacity: 0;
    transform: translateY(8px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes option-in {
  0% {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (min-width: 760px) {
  .app-shell {
    width: min(1080px, calc(100% - 2rem));
    padding-top: 1.15rem;
  }

  .topic-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

}

@media (min-width: 1040px) {
  .app-shell {
    grid-template-columns: 350px 1fr;
    align-items: start;
  }

  .hero,
  .hud,
  .screen,
  .screen.active-screen {
    grid-column: 1 / -1;
  }

  .topic-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
