* {
  box-sizing: border-box;
}

:root {
  --ink: #2b2b3a;
  --card: #ffffff;
  --yellow: #ffd23f;
  --pink: #ff6fa5;
  --green: #5ec94b;
  --blue: #3fb8ff;
  --purple: #9b7ede;
  --orange: #ff9b3d;
  --red: #ff5a5a;
  --shadow: 0 10px 0 rgba(43, 43, 58, 0.18);
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Baloo 2', 'SN Pro', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: linear-gradient(#8fe4ff 0%, #dff8ff 55%, #c9f4a6 100%);
  overflow-x: hidden;
}

button {
  font-family: inherit;
}

/* ---------- фон ---------- */
.sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.sun {
  position: absolute;
  top: -50px;
  right: -50px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff6b0, #ffd23f 70%);
  box-shadow: 0 0 60px rgba(255, 210, 63, 0.8);
  animation: sun-spin 24s linear infinite;
}

.cloud {
  position: absolute;
  width: 140px;
  height: 46px;
  border-radius: 50px;
  background: rgba(255, 255, 255, 0.92);
  animation: drift 40s linear infinite;
}

.cloud::before,
.cloud::after {
  content: '';
  position: absolute;
  background: inherit;
  border-radius: 50%;
}

.cloud::before {
  width: 64px;
  height: 64px;
  top: -30px;
  left: 24px;
}

.cloud::after {
  width: 46px;
  height: 46px;
  top: -20px;
  right: 26px;
}

.cloud--1 {
  top: 8%;
  left: -160px;
}

.cloud--2 {
  top: 24%;
  left: -160px;
  transform: scale(0.7);
  animation-duration: 58s;
  animation-delay: -18s;
}

.cloud--3 {
  top: 45%;
  left: -160px;
  transform: scale(0.5);
  animation-duration: 72s;
  animation-delay: -40s;
}

.hill {
  position: absolute;
  bottom: -160px;
  border-radius: 50%;
}

.hill--back {
  left: -10%;
  width: 70%;
  height: 340px;
  background: #a8e57c;
}

.hill--front {
  right: -12%;
  width: 78%;
  height: 300px;
  background: #7ed957;
}

@keyframes drift {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(calc(100vw + 320px));
  }
}

@keyframes sun-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- верхняя панель ---------- */
.topbar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
}

.topbar__title {
  font-weight: 800;
  font-size: 1.05rem;
  color: #1c4a63;
  text-shadow: 0 2px 0 #fff;
}

.icon-btn {
  width: 46px;
  height: 46px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: var(--card);
  font-size: 1.3rem;
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(43, 43, 58, 0.25);
  transition: transform 0.12s;
}

.icon-btn:hover {
  transform: translateY(-2px);
}

.icon-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(43, 43, 58, 0.25);
}

/* ---------- экраны ---------- */
#app {
  position: relative;
  z-index: 2;
  max-width: 900px;
  margin: 0 auto;
  padding: 8px 16px 48px;
}

.screen {
  display: none;
  animation: screen-in 0.35s ease-out;
}

.screen.is-active {
  display: block;
}

@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.screen-title {
  text-align: center;
  font-size: 1.7rem;
  margin: 10px 0 20px;
  text-shadow: 0 2px 0 #fff;
}

/* ---------- герой / меню ---------- */
.hero {
  text-align: center;
}

.hero__cast {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 2px;
  margin-bottom: 4px;
}

.hero__cast .smesharik {
  width: 74px;
  height: 78px;
  cursor: pointer;
  animation: bob 2.4s ease-in-out infinite;
  transition: transform 0.15s;
}

.hero__cast .smesharik:hover {
  transform: scale(1.14) rotate(-4deg);
}

@keyframes bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.hero__title {
  margin: 0;
  font-size: clamp(2rem, 7vw, 3.2rem);
  font-weight: 800;
  line-height: 1.1;
  text-shadow: 0 3px 0 #fff;
}

.hero__title span {
  color: #ff5fa2;
}

.hero__lead {
  margin: 6px 0 22px;
  font-size: 1.05rem;
  color: #1c4a63;
  font-weight: 700;
}

/* ---------- карточки режимов ---------- */
.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.mode-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 22px 16px;
  border: 4px solid var(--ink);
  border-radius: 26px;
  background: var(--card);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
}

.mode-card:hover {
  transform: translateY(-6px) rotate(-1deg);
  box-shadow: 0 16px 0 rgba(43, 43, 58, 0.18);
}

.mode-card:active {
  transform: translateY(4px);
  box-shadow: 0 4px 0 rgba(43, 43, 58, 0.18);
}

.mode-card__icon {
  font-size: 3rem;
  line-height: 1;
}

.mode-card__name {
  font-size: 1.4rem;
  font-weight: 800;
}

.mode-card__desc {
  font-size: 0.95rem;
  color: #6b6b80;
  font-weight: 600;
}

.mode-card--quiz {
  background: linear-gradient(#ffffff, #eaf7ff);
}

.mode-card--hero {
  background: linear-gradient(#ffffff, #fff2f8);
}

.mode-card--game {
  background: linear-gradient(#ffffff, #f2ffe8);
}

.records {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.record-chip {
  background: rgba(255, 255, 255, 0.85);
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 700;
  font-size: 0.92rem;
}

/* ---------- кнопки ---------- */
.btn {
  display: inline-block;
  padding: 13px 26px;
  border: 4px solid var(--ink);
  border-radius: 18px;
  background: var(--yellow);
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 7px 0 rgba(43, 43, 58, 0.25);
  transition: transform 0.12s;
}

.btn:hover {
  transform: translateY(-3px);
}

.btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 rgba(43, 43, 58, 0.25);
}

.btn--ghost {
  background: #fff;
  display: block;
  margin: 0 auto;
}

/* ---------- тест ---------- */
.quiz {
  background: var(--card);
  border: 4px solid var(--ink);
  border-radius: 28px;
  padding: 18px 20px 24px;
  box-shadow: var(--shadow);
}

.quiz__top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.quiz__progress {
  flex: 1;
  height: 16px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: #eef0f6;
  overflow: hidden;
}

.quiz__progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--green), var(--yellow));
  transition: width 0.4s ease;
}

.quiz__counter,
.quiz__score {
  font-weight: 800;
  font-size: 0.95rem;
  white-space: nowrap;
}

.quiz__score {
  color: #d39b00;
}

.quiz__picture {
  display: flex;
  justify-content: center;
  min-height: 0;
}

.quiz__picture:empty {
  display: none;
}

.quiz__picture .smesharik {
  width: 150px;
  height: 160px;
  animation: pop-in 0.4s ease-out;
}

.quiz__question {
  text-align: center;
  font-size: clamp(1.15rem, 3.4vw, 1.5rem);
  margin: 12px 0 18px;
  line-height: 1.3;
}

.quiz__answers {
  display: grid;
  gap: 12px;
}

.answer-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  border: 4px solid var(--ink);
  border-radius: 18px;
  background: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 6px 0 rgba(43, 43, 58, 0.2);
  transition: transform 0.12s, background 0.15s;
}

.answer-btn:hover:not(:disabled) {
  transform: translateY(-3px);
  background: #fffbe8;
}

.answer-btn:disabled {
  cursor: default;
}

.answer-btn__key {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--yellow);
  font-weight: 800;
}

.answer-btn__text {
  flex: 1;
}

.answer-btn__thumb {
  flex: 0 0 auto;
  width: 66px;
  height: 70px;
}

.answer-btn.is-correct {
  background: #dcffd2;
  border-color: #2f9c1d;
  animation: nudge 0.4s;
}

.answer-btn.is-correct .answer-btn__key {
  background: var(--green);
}

.answer-btn.is-wrong {
  background: #ffe0e0;
  border-color: var(--red);
  animation: shake 0.4s;
}

.answer-btn.is-muted {
  opacity: 0.5;
}

.quiz__feedback {
  min-height: 54px;
  margin-top: 16px;
  text-align: center;
  font-weight: 700;
  color: #4a4a60;
}

.quiz__feedback.is-good {
  color: #2f9c1d;
}

.quiz__feedback.is-bad {
  color: #e04747;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-8px);
  }
  75% {
    transform: translateX(8px);
  }
}

@keyframes nudge {
  50% {
    transform: scale(1.03);
  }
}

@keyframes pop-in {
  from {
    transform: scale(0.5);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* ---------- результат ---------- */
.result {
  background: var(--card);
  border: 4px solid var(--ink);
  border-radius: 28px;
  padding: 26px 22px;
  text-align: center;
  box-shadow: var(--shadow);
  max-width: 560px;
  margin: 0 auto 20px;
}

.result__face {
  width: 150px;
  height: 160px;
  margin: 0 auto;
}

.result__title {
  font-size: 1.7rem;
  margin: 8px 0 4px;
}

.result__score {
  font-size: 1.15rem;
  font-weight: 800;
  color: #d39b00;
  margin: 0 0 8px;
}

.result__text {
  margin: 0;
  color: #5a5a70;
  font-weight: 600;
}

.result__record {
  display: inline-block;
  margin-top: 12px;
  padding: 6px 14px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: var(--yellow);
  font-weight: 800;
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.result-actions .btn--ghost {
  margin: 0;
}

/* ---------- мини-игра ---------- */
.hud {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.hud__pill {
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 6px 16px;
  font-weight: 800;
  box-shadow: 0 5px 0 rgba(43, 43, 58, 0.18);
}

.canvas-wrap {
  position: relative;
  max-width: 800px;
  margin: 0 auto;
  border: 5px solid var(--ink);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: #bfeaff;
}

#game-canvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
}

.game-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(30, 40, 60, 0.55);
  padding: 16px;
}

.game-overlay[hidden] {
  display: none;
}

.game-overlay__box {
  background: #fff;
  border: 4px solid var(--ink);
  border-radius: 24px;
  padding: 20px 22px;
  max-width: 460px;
  text-align: center;
  box-shadow: 0 10px 0 rgba(0, 0, 0, 0.25);
}

.game-overlay__box h3 {
  margin: 0 0 8px;
  font-size: 1.5rem;
}

.game-overlay__box p {
  margin: 0 0 12px;
  color: #5a5a70;
  font-weight: 600;
}

.game-overlay__rules {
  text-align: left;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
  font-weight: 700;
}

.game-overlay__rules li {
  margin-bottom: 4px;
}

.game-hint {
  text-align: center;
  font-weight: 700;
  color: #1c4a63;
}

/* ---------- конфетти ---------- */
.confetti {
  position: fixed;
  z-index: 50;
  width: 12px;
  height: 16px;
  border-radius: 3px;
  pointer-events: none;
  animation: confetti-fall 1.4s ease-in forwards;
}

@keyframes confetti-fall {
  from {
    transform: translateY(0) rotate(0);
    opacity: 1;
  }
  to {
    transform: translateY(340px) rotate(720deg);
    opacity: 0;
  }
}

@media (max-width: 560px) {
  .hero__cast .smesharik {
    width: 54px;
    height: 58px;
  }

  .quiz {
    padding: 14px 12px 18px;
  }
}
