@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;700;800&family=Nunito:wght@600;700;800&display=swap');

:root {
  --bg-top: #fff8c7;
  --bg-bottom: #d7f6ff;
  --bg-accent: #ffe2f2;
  --card: #ffffff;
  --text: #1f2a44;
  --muted: #55627c;
  --green: #1fbe7a;
  --green-dark: #149b62;
  --orange: #ffac2f;
  --blue: #2b9fe2;
  --pink: #ff6fab;
  --violet-soft: #e8d8ff;
  --red: #ef5a5a;
  --line: #dce4f1;
  --shadow: 0 12px 26px rgba(24, 42, 74, 0.14);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Baloo 2', 'Trebuchet MS', sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  min-height: 100vh;
}

main {
  max-width: 980px;
  margin: 0 auto;
  padding: 16px 12px 40px;
  position: relative;
  z-index: 1;
}

main.fullscreen-main {
  max-width: none;
  margin: 0;
  padding: 12px;
  position: fixed;
  inset: 0;
  z-index: 2;
  opacity: 0;
  transform: translate3d(0, 16px, 0) scale(0.99);
  transition: opacity 0.36s cubic-bezier(0.22, 1, 0.36, 1), transform 0.36s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: opacity, transform;
}

main.fullscreen-main.is-open {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
}

main.fullscreen-main.is-closing {
  opacity: 0;
  transform: translate3d(0, 12px, 0) scale(0.992);
  pointer-events: none;
}

.fullscreen-panel {
  height: 100%;
  max-width: 980px;
  margin: 0 auto;
  overflow: auto;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #ffffff 0%, #fcfeff 100%);
  border-radius: 22px;
  border: 3px solid #fff;
  box-shadow: var(--shadow);
  padding: 14px;
  transition: box-shadow 0.3s ease;
}

.fullscreen-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.close-lesson-btn {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: linear-gradient(180deg, #fff, #f7fbff);
  color: var(--text);
  font: inherit;
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
  box-shadow: 0 6px 12px rgba(45, 72, 113, 0.1);
}

.close-lesson-btn:hover {
  border-color: var(--red);
  transform: translateY(-1px);
}

.close-lesson-btn:active {
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  main.fullscreen-main {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

.topbar {
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.topbar.has-logo-header {
  align-items: center;
}

.app-title {
  font-size: clamp(1.45rem, 5vw, 2rem);
  margin: 0;
  line-height: 1.1;
  text-align: center;
  text-shadow: 0 1px 0 #fff;
}

.app-title.has-logo {
  width: 100%;
  text-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-title-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.app-title-logo {
  display: block;
  width: auto;
  height: clamp(44px, 10vw, 64px);
  max-width: min(90vw, 520px);
  object-fit: contain;
  mix-blend-mode: multiply;
}

.nav-links {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  width: 100%;
}

.nav-links a,
.nav-links button {
  background: linear-gradient(180deg, #fff, #f8fbff);
  border: 2px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  font: inherit;
  font-size: 1.02rem;
  font-weight: 700;
  padding: 9px 10px;
  min-height: 44px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 5px 12px rgba(41, 69, 120, 0.08);
}

.nav-links a:hover,
.nav-links button:hover {
  border-color: var(--blue);
  transform: translateY(-1px);
}

.nav-links a:active,
.nav-links button:active {
  transform: translateY(0);
}

.card {
  background: linear-gradient(180deg, #ffffff 0%, #fcfeff 100%);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 3px solid #fff;
  padding: 16px;
}

.grid {
  display: grid;
  gap: 14px;
}

.grid.modules {
  grid-template-columns: 1fr;
}

.module-card {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  align-items: flex-start;
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(165deg, #ffffff 0%, #f8fbff 70%, #fef7ff 100%);
  border: 2px solid var(--line);
  text-decoration: none;
  color: var(--text);
  box-shadow: 0 8px 20px rgba(35, 62, 103, 0.11);
}

.module-card > :last-child {
  grid-column: 1 / -1;
  text-align: left;
}

.module-card:hover {
  border-color: var(--pink);
  transform: translateY(-2px);
}

.module-icon {
  font-size: 2rem;
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(165deg, #fff4b8, #ffe5f3);
}

.badge {
  font-size: 0.88rem;
  border-radius: 999px;
  padding: 4px 11px;
  display: inline-block;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
}

.badge.available {
  background: #e1f8ed;
  color: #187a4d;
}

.badge.locked {
  background: #eef1f6;
  color: #5f6781;
}

.badge.completed {
  background: #d9f5ff;
  color: #0a678e;
}

.badge.review {
  background: #fff2d8;
  color: #8a5d0a;
}

.progress-wrap {
  width: 100%;
  background: #eaf0fa;
  border-radius: 999px;
  height: 15px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #1fbf75, #6cd85e);
  border-radius: 999px;
  transition: width 0.3s ease;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.subtitle {
  color: var(--muted);
  margin-top: 4px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
  margin-bottom: 14px;
}

.hud-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
}

.hud-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(165deg, #ffffff, #f9fcff);
  padding: 11px 12px;
}

.hud-icon {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 1.35rem;
}

.hud-item strong {
  display: block;
  font-size: 1.25rem;
  line-height: 1;
}

.hud-item span {
  color: var(--muted);
  font-size: 0.95rem;
}

.hud-item.points .hud-icon {
  background: #fff4c5;
}

.hud-item.streak .hud-icon {
  background: #ffe2d7;
}

.hud-item.goal .hud-icon {
  background: #e4f4ff;
}

.stat-box {
  border-radius: 15px;
  padding: 12px;
  background: linear-gradient(160deg, #ffffff, #f9fbff);
  border: 2px solid var(--line);
  text-align: center;
}

.stat-box strong {
  display: block;
  font-size: 1.3rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 14px;
  padding: 11px 16px;
  font: inherit;
  font-size: 1.08rem;
  font-weight: 800;
  min-height: 48px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.btn.primary {
  background: linear-gradient(180deg, #2ad58b, #1fbe7a);
  color: white;
  box-shadow: 0 8px 16px rgba(31, 190, 122, 0.35);
}

.btn.primary:hover {
  filter: brightness(0.97);
  transform: translateY(-1px);
}

.btn.secondary {
  background: linear-gradient(180deg, #fff, #f8fbff);
  border: 2px solid var(--line);
  color: var(--text);
  box-shadow: 0 6px 12px rgba(45, 72, 113, 0.1);
}

.btn.secondary:hover {
  border-color: var(--blue);
  transform: translateY(-1px);
}

.btn.warning {
  background: linear-gradient(180deg, #ffc24a, #ffac2f);
  color: #3d2a00;
  box-shadow: 0 8px 16px rgba(255, 172, 47, 0.33);
}

.btn.warning:hover {
  filter: brightness(0.97);
  transform: translateY(-1px);
}

.btn.soft-blue {
  background: linear-gradient(180deg, #ecf6ff, #dcedff);
  border: 2px solid #b9d8fb;
  color: #1d4f88;
  box-shadow: 0 6px 12px rgba(48, 112, 186, 0.16);
}

.btn.soft-blue:hover {
  border-color: #8dc1f5;
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.lesson-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.lesson-item {
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: linear-gradient(165deg, #ffffff 0%, #fbfdff 100%);
}

.lesson-item .row {
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.lesson-item .row .badge {
  align-self: flex-start;
}

.action-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.action-row .btn {
  width: 100%;
}

.question-card {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

#reviewCard {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.question {
  font-size: clamp(1.6rem, 8vw, 2.2rem);
  text-align: center;
  margin: 18px 0;
  min-height: 80px;
  line-height: 1.2;
}

.big-input {
  width: 100%;
  padding: 15px;
  border-radius: 14px;
  border: 2px solid var(--line);
  font: inherit;
  font-size: clamp(1.25rem, 6.5vw, 1.6rem);
  text-align: center;
  background: #fffdf6;
}

.feedback {
  margin-top: 12px;
  border-radius: 14px;
  padding: 12px;
  font-size: 1.14rem;
}

.feedback.ok {
  background: #e2f9eb;
  color: #196f46;
}

.feedback.bad {
  background: #ffe8e8;
  color: #8c1d1d;
}

.task-action-bar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: auto;
}

.task-action-bar .btn {
  width: 100%;
}

.hidden {
  display: none !important;
}

.form-card {
  max-width: 520px;
  margin: 5vh auto 0;
  border-top: 8px solid #ffe06b;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.field input {
  padding: 12px;
  border-radius: 12px;
  border: 2px solid var(--line);
  font: inherit;
  font-size: 1.1rem;
  background: #fffdf7;
}

.message {
  margin-top: 10px;
  border-radius: 12px;
  padding: 10px;
  font-size: 1rem;
  border: 2px solid var(--line);
  background: #fff;
}

.message.success {
  background: #e2f9eb;
  border-color: #9bddba;
  color: #196f46;
}

.message.error {
  background: #ffe8e8;
  border-color: #f2b8b8;
  color: #8c1d1d;
}

.message.info {
  background: #eef7ff;
  border-color: #bedff7;
  color: #165f8a;
}

.rewards-grid {
  display: grid;
  gap: 10px;
}

.reward-item {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 10px;
  align-items: flex-start;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(160deg, #fff 0%, #fafdff 100%);
  padding: 12px;
}

.reward-item > :last-child {
  grid-column: 1 / -1;
}

.reward-icon {
  font-size: 1.7rem;
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #fff4c8, #ffe6f3);
}

.reward-action .btn {
  width: 100%;
}

.history-list {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}

.history-item {
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 10px;
}

.settings-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
}

.setting-item {
  border: 2px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 11px 12px;
}

.setting-item strong {
  display: block;
  font-size: 1.1rem;
}

.setting-item span {
  color: var(--muted);
  font-size: 0.95rem;
}

.leave-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(21, 31, 58, 0.56);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 10020;
}

.leave-modal {
  width: min(100%, 460px);
  background: linear-gradient(180deg, #ffffff, #fbfdff);
  border-radius: 18px;
  border: 2px solid var(--line);
  box-shadow: 0 16px 34px rgba(16, 30, 57, 0.22);
  padding: 18px 16px;
}

.leave-modal h3 {
  font-size: clamp(1.35rem, 4.6vw, 1.7rem);
  margin-bottom: 8px;
}

.leave-modal p {
  color: var(--muted);
  font-size: 1.03rem;
  line-height: 1.25;
}

.leave-modal-actions {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.leave-modal .btn {
  width: 100%;
}

.confetti-layer {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 9999;
}

.confetti-piece {
  position: absolute;
  left: 50%;
  border-radius: 3px;
  opacity: 0;
  animation-duration: var(--confetti-duration, 1.8s);
  animation-delay: var(--confetti-delay, 0s);
  animation-timing-function: cubic-bezier(0.2, 0.8, 0.25, 1);
  animation-fill-mode: forwards;
  transform: translate3d(0, 0, 0);
}

.confetti-piece.confetti-from-top {
  top: -14px;
  animation-name: confetti-fall-top;
}

.confetti-piece.confetti-from-bottom {
  top: auto;
  bottom: -14px;
  animation-name: confetti-fall-bottom;
}

@keyframes confetti-fall-top {
  0% {
    opacity: 0;
    transform: translate3d(var(--confetti-start-x, 0), -2vh, 0) rotate(0deg);
  }
  12% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--confetti-end-x, 0), 108vh, 0) rotate(var(--confetti-rotation, 360deg));
  }
}

@keyframes confetti-fall-bottom {
  0% {
    opacity: 0;
    transform: translate3d(var(--confetti-start-x, 0), 2vh, 0) rotate(0deg);
  }
  12% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--confetti-end-x, 0), -108vh, 0) rotate(var(--confetti-rotation, 360deg));
  }
}

.floating-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.55;
  overflow: hidden;
}

.floating-bg svg {
  width: 100%;
  height: 100%;
}

.bubble-layer {
  transform-origin: center;
}

.bubble-layer-a {
  animation: bubble-drift-a 15s ease-in-out infinite alternate;
}

.bubble-layer-b {
  animation: bubble-drift-b 18s ease-in-out infinite alternate;
}

.bubble-layer-c {
  animation: bubble-drift-c 16s ease-in-out infinite alternate;
}

.bubble {
  animation: bubble-pulse 7s ease-in-out infinite;
}

.bubble-a { fill: rgba(255, 111, 171, 0.25); animation-delay: -0.8s; }
.bubble-b { fill: rgba(43, 159, 226, 0.24); animation-delay: -1.6s; }
.bubble-c { fill: rgba(31, 190, 122, 0.22); animation-delay: -2.2s; }
.bubble-d { fill: rgba(255, 172, 47, 0.24); animation-delay: -1.1s; }
.bubble-e { fill: rgba(167, 139, 250, 0.24); animation-delay: -0.3s; }
.bubble-f { fill: rgba(55, 199, 255, 0.22); animation-delay: -2.5s; }
.bubble-g { fill: rgba(255, 111, 171, 0.2); animation-delay: -0.7s; }
.bubble-h { fill: rgba(43, 159, 226, 0.2); animation-delay: -1.9s; }
.bubble-i { fill: rgba(31, 190, 122, 0.2); animation-delay: -2.9s; }

@keyframes bubble-drift-a {
  0% { transform: translate3d(-2vw, 1vh, 0); }
  50% { transform: translate3d(1.5vw, -2vh, 0); }
  100% { transform: translate3d(0.8vw, 2vh, 0); }
}

@keyframes bubble-drift-b {
  0% { transform: translate3d(1vw, -1vh, 0); }
  50% { transform: translate3d(-1.4vw, 1.8vh, 0); }
  100% { transform: translate3d(1.2vw, -1.6vh, 0); }
}

@keyframes bubble-drift-c {
  0% { transform: translate3d(-1vw, 1.2vh, 0); }
  50% { transform: translate3d(1.8vw, -1.4vh, 0); }
  100% { transform: translate3d(-1.2vw, 1.9vh, 0); }
}

@keyframes bubble-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

@media (max-width: 420px) {
  .app-title-logo {
    height: clamp(42px, 12vw, 52px);
    max-width: min(88vw, 360px);
  }

  .close-lesson-btn {
    width: 56px;
    height: 56px;
    font-size: 1.4rem;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .nav-links {
    grid-template-columns: 1fr;
  }

  .app-title {
    text-align: left;
  }

  .task-action-bar .btn {
    min-height: 62px;
    font-size: 1.24rem;
  }
}

@media (min-width: 580px) {
  .leave-modal-actions {
    grid-template-columns: 1fr 1fr;
  }

  .action-row .btn {
    width: auto;
  }

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

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

  .module-card {
    grid-template-columns: 56px 1fr auto;
    align-items: center;
  }

  .module-card > :last-child {
    grid-column: auto;
    text-align: right;
  }

  .lesson-item .row {
    justify-content: space-between;
    align-items: center;
    flex-direction: row;
  }

  .lesson-item .row .badge {
    align-self: auto;
  }

  .reward-item {
    grid-template-columns: 56px 1fr auto;
    align-items: center;
  }

  .reward-item > :last-child {
    grid-column: auto;
  }

  .task-action-bar {
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
  }

  .task-action-bar .btn {
    width: 100%;
  }
}

@media (min-width: 760px) {
  .topbar.has-logo-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
  }

  .topbar.has-logo-header .app-title.has-logo {
    width: auto;
    justify-content: flex-start;
  }

  .topbar.has-logo-header .nav-links {
    width: 100%;
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  main.fullscreen-main {
    padding: 20px;
  }

  .fullscreen-panel {
    padding: 20px;
  }

  .topbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .app-title {
    text-align: left;
  }

  .nav-links {
    display: flex;
    width: auto;
  }

  .grid.modules {
    grid-template-columns: 1fr 1fr;
  }

  .stats {
    grid-template-columns: repeat(4, 1fr);
  }

  main {
    padding: 24px 18px 48px;
  }
}

@media (max-width: 759px) {
  .task-action-bar {
    position: sticky;
    bottom: 0;
    z-index: 7;
    margin-left: -2px;
    margin-right: -2px;
    padding: 12px 2px calc(10px + env(safe-area-inset-bottom));
    background: linear-gradient(180deg, rgba(252, 254, 255, 0) 0%, rgba(252, 254, 255, 0.94) 28%, #fcfeff 52%);
  }

  .task-action-bar .btn {
    min-height: 60px;
    font-size: 1.2rem;
    border-radius: 18px;
  }
}
