:root {
  --sky-top: #b9a4e8;
  --sky-mid: #e4d4f8;
  --sky-bottom: #fde8f3;
  --meadow: #7fb86d;
  --meadow-dark: #5e9a4f;
  --meadow-light: #9ed08a;
  --purple: #6b4c9a;
  --purple-deep: #53367d;
  --lilac: #a78bc8;
  --lilac-soft: #d8c4f0;
  --pink: #f4a5c2;
  --pink-soft: #ffd6e6;
  --moon: #ffe9a8;
  --moon-glow: #fff4cc;
  --cream: #fffaf3;
  --card: #fffdf9;
  --text: #3a2a55;
  --muted: #6d5b86;
  --ok: #2f9a64;
  --ok-bg: #e3f8ec;
  --bad: #d14b62;
  --bad-bg: #fde8ec;
  --shadow: 0 14px 40px rgba(83, 54, 125, 0.18);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Trebuchet MS", "Segoe UI", "Verdana", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 42%, var(--sky-bottom) 70%, #f7ecd6 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

button, input {
  font-family: inherit;
}

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

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

.star {
  position: absolute;
  width: 8px;
  height: 8px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 0 8px 2px rgba(255, 255, 255, 0.8);
  animation: twinkle 2.8s ease-in-out infinite;
}

.star.big {
  width: 11px;
  height: 11px;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.35; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.15); }
}

.moon-deco {
  position: absolute;
  top: 28px;
  right: 48px;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff8d6, var(--moon) 55%, #f3c96b);
  box-shadow: 0 0 0 10px rgba(255, 233, 168, 0.28), 0 0 40px rgba(255, 233, 168, 0.55);
}

.moon-deco::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(227, 186, 90, 0.35);
  top: 28px;
  left: 18px;
}

.meadow {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 150px;
  z-index: 1;
  pointer-events: none;
}

.hill {
  position: absolute;
  bottom: -40px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 30%, var(--meadow-light), var(--meadow) 55%, var(--meadow-dark));
}

.hill.left { width: 70vw; height: 200px; left: -18vw; }
.hill.right { width: 65vw; height: 180px; right: -16vw; background: radial-gradient(circle at 50% 30%, #8fc87c, var(--meadow-dark)); }
.hill.mid { width: 50vw; height: 140px; left: 25vw; bottom: -50px; }

.flower {
  position: absolute;
  bottom: 28px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #f7c1de;
  box-shadow: 10px 0 0 #ffd36b, -10px 0 0 #c9b4f0, 0 -10px 0 #fff, 0 10px 0 #f7c1de;
}

.flower::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 22px;
  width: 3px;
  height: 22px;
  background: #4e8a3d;
}

#app {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  padding: 20px 24px 170px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 980px;
  margin: 0 auto 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.brand-title {
  font-size: 28px;
  color: var(--purple-deep);
  line-height: 1.15;
}

.brand-sub {
  font-size: 15px;
  color: var(--muted);
  margin-top: 2px;
}

.balance {
  background: var(--cream);
  border-radius: 18px;
  padding: 10px 16px;
  box-shadow: var(--shadow);
  font-size: 18px;
  font-weight: 700;
  color: var(--purple-deep);
  white-space: nowrap;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.balance small {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.icon-btn, .btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  border-radius: 16px;
  font-weight: 700;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.icon-btn:hover, .btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.03);
}

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

.icon-btn:focus-visible, .btn:focus-visible, input:focus-visible {
  outline: 3px solid #8a6ac4;
  outline-offset: 2px;
}

.icon-btn {
  background: var(--cream);
  color: var(--purple-deep);
  min-width: 56px;
  min-height: 56px;
  font-size: 22px;
  box-shadow: var(--shadow);
  padding: 0 14px;
}

.btn {
  min-height: 58px;
  padding: 12px 22px;
  font-size: 22px;
  box-shadow: 0 8px 0 var(--purple-deep), var(--shadow);
}

.btn-primary {
  background: linear-gradient(180deg, #9a74d3, #6b4c9a);
  color: #fff;
}

.btn-ok {
  background: linear-gradient(180deg, #4cbf80, #2f9a64);
  color: #fff;
  box-shadow: 0 8px 0 #21744a, var(--shadow);
}

.btn-ghost {
  background: #fff;
  color: var(--purple);
  box-shadow: 0 8px 0 #d5c3ec, var(--shadow);
}

.btn-warm {
  background: linear-gradient(180deg, #ffd56a, #f0b42c);
  color: var(--purple-deep);
  box-shadow: 0 8px 0 #c99216, var(--shadow);
}

.btn-danger {
  background: linear-gradient(180deg, #f08a9a, #d14b62);
  color: #fff;
  box-shadow: 0 8px 0 #a3374a, var(--shadow);
}

.btn:disabled, .icon-btn:disabled {
  cursor: default;
  opacity: 0.55;
  transform: none;
  filter: none;
  box-shadow: none;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

.screen {
  max-width: 980px;
  margin: 0 auto;
}

.hero {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-bottom: 22px;
}

.hero-text h1 {
  font-size: 42px;
  color: var(--purple-deep);
  line-height: 1.15;
}

.hero-text p {
  margin-top: 8px;
  font-size: 20px;
  color: var(--muted);
  line-height: 1.45;
  max-width: 640px;
}

.mascot-wrap {
  flex: 0 0 auto;
  width: 140px;
  height: 150px;
}

.mascot-wrap svg, .mascot-inline svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.mascot-wrap.happy { animation: bounce 0.7s ease; }
.mascot-wrap.sad { animation: shake 0.5s ease; }

@keyframes bounce {
  0% { transform: translateY(0); }
  40% { transform: translateY(-10px); }
  100% { transform: translateY(0); }
}

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

.bubble {
  background: var(--cream);
  border-radius: 20px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
  font-size: 18px;
  color: var(--purple-deep);
  position: relative;
  margin-top: 6px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 18px 18px;
  box-shadow: var(--shadow);
  border: 3px solid transparent;
  text-align: left;
  min-height: 150px;
  color: inherit;
  width: 100%;
}

.card.enabled {
  cursor: pointer;
  border-color: #e3d3f7;
}

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

.card.disabled {
  cursor: default;
  opacity: 0.78;
  background: linear-gradient(180deg, #f6f1fb, #efe8f6);
}

.card-emoji {
  font-size: 36px;
  line-height: 1;
  margin-bottom: 8px;
}

.card h3 {
  font-size: 24px;
  margin-bottom: 6px;
}

.card p {
  font-size: 16px;
  color: var(--muted);
}

.badge-soon {
  display: inline-block;
  margin-top: 10px;
  background: var(--lilac-soft);
  color: var(--purple-deep);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 14px;
  font-weight: 700;
}

.panel {
  background: var(--card);
  border-radius: 28px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.panel h2 {
  font-size: 32px;
  color: var(--purple-deep);
  margin-bottom: 8px;
}

.lead {
  font-size: 19px;
  color: var(--muted);
  margin-bottom: 18px;
  line-height: 1.45;
}

.number-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin: 12px 0 18px;
}

.num-tile {
  min-height: 64px;
  font-size: 26px;
  border-radius: 16px;
  border: 3px solid #e3d3f7;
  background: #fff;
  color: var(--purple-deep);
  font-weight: 800;
  cursor: pointer;
}

.num-tile.selected {
  background: linear-gradient(180deg, #9a74d3, #6b4c9a);
  color: #fff;
  border-color: var(--purple-deep);
}

.modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.mode-card {
  text-align: left;
  background: #fff;
  border: 3px solid #e3d3f7;
  border-radius: 20px;
  padding: 16px 16px 14px;
  min-height: 110px;
  cursor: pointer;
  color: inherit;
  width: 100%;
}

.mode-card:hover, .mode-card:focus-visible {
  border-color: var(--lilac);
}

.mode-card h3 {
  font-size: 22px;
  margin-bottom: 6px;
}

.mode-card p {
  font-size: 15px;
  color: var(--muted);
  line-height: 1.4;
}

.progress {
  font-size: 16px;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 700;
}

.prompt {
  font-size: 52px;
  font-weight: 800;
  color: var(--purple-deep);
  text-align: center;
  margin: 10px 0 16px;
  letter-spacing: 1px;
}

.visual {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  margin: 12px 0 18px;
  min-height: 80px;
}

.group-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 8px 10px;
  background: rgba(167, 139, 200, 0.12);
  border-radius: 16px;
}

.dot {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
}

.visual.compact .dot {
  width: 14px;
  height: 14px;
  font-size: 12px;
}

.visual.tiny .dot {
  width: 10px;
  height: 10px;
  font-size: 9px;
}

.fact {
  font-size: 36px;
  font-weight: 800;
  color: var(--purple);
  text-align: center;
}

.hint-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 12px 0 8px;
}

.hint-chip {
  background: var(--moon);
  color: var(--purple-deep);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 22px;
  font-weight: 800;
}

.explain {
  font-size: 20px;
  line-height: 1.45;
  text-align: center;
  color: var(--text);
  max-width: 740px;
  margin: 0 auto 8px;
}

.answer-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 8px;
}

.answer-input {
  width: 180px;
  min-height: 70px;
  font-size: 40px;
  font-weight: 800;
  text-align: center;
  border-radius: 18px;
  border: 3px solid var(--lilac);
  background: #fff;
  color: var(--purple-deep);
  padding: 8px;
}

.answer-input.wrong {
  border-color: var(--bad);
  background: var(--bad-bg);
  animation: shake 0.4s ease;
}

.answer-input.right {
  border-color: var(--ok);
  background: var(--ok-bg);
}

.feedback {
  margin-top: 16px;
  border-radius: 18px;
  padding: 14px 16px;
  font-size: 20px;
  line-height: 1.45;
  text-align: center;
}

.feedback.ok { background: var(--ok-bg); color: #1d6d46; }
.feedback.bad { background: var(--bad-bg); color: #8f2d3e; }

.timer {
  font-size: 28px;
  font-weight: 800;
  color: var(--purple-deep);
  background: var(--moon);
  display: inline-block;
  padding: 6px 16px;
  border-radius: 999px;
  margin-bottom: 8px;
}

.timer.warn {
  background: #ffd0d6;
  color: #9a2438;
}

.summary {
  text-align: center;
}

.summary .big {
  font-size: 28px;
  margin: 10px 0;
  font-weight: 800;
}

.stats {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 16px 0;
}

.stat {
  background: #f4ecfb;
  border-radius: 16px;
  padding: 12px 16px;
  min-width: 140px;
}

.stat b {
  display: block;
  font-size: 28px;
  color: var(--purple-deep);
}

.history {
  margin-top: 20px;
}

.history h3 {
  font-size: 22px;
  margin-bottom: 8px;
}

.history table {
  width: 100%;
  border-collapse: collapse;
  font-size: 18px;
}

.history th, .history td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid #eadff6;
}

.password-input {
  width: 200px;
  min-height: 58px;
  font-size: 28px;
  letter-spacing: 8px;
  text-align: center;
  border-radius: 16px;
  border: 3px solid var(--lilac);
  padding: 8px;
}

.hidden { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

@media (max-width: 800px) {
  .hero { flex-direction: column; text-align: center; }
  .hero-text p { margin-left: auto; margin-right: auto; }
  .modes, .number-grid { grid-template-columns: 1fr 1fr; }
  .prompt { font-size: 40px; }
  .brand-title { font-size: 22px; }
  .panel { padding: 20px; }
  #app { padding: 14px 12px 160px; }
}

@media (max-width: 560px) {
  .topbar { flex-wrap: wrap; }
  .balance { width: 100%; align-items: flex-start; }
}
