:root {
  --bg: #fff8df;
  --paper: #fffdf5;
  --ink: #273047;
  --muted: #677084;
  --pink: #f6b5cf;
  --pink-dark: #d94b85;
  --yellow: #ffe28a;
  --green: #b8df9a;
  --blue: #9fd7ec;
  --shadow: 0 18px 50px rgba(39, 48, 71, .16);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: ui-rounded, "Comic Sans MS", "Trebuchet MS", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 20%, rgba(246,181,207,.45), transparent 22rem),
    radial-gradient(circle at 85% 10%, rgba(159,215,236,.4), transparent 20rem),
    linear-gradient(180deg, #fffdf0, var(--bg));
  touch-action: manipulation;
}

.app {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: clamp(16px, 3vw, 34px);
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}
.eyebrow { margin: 0 0 4px; color: var(--pink-dark); font-weight: 800; letter-spacing: .04em; }
h1 { margin: 0; font-size: clamp(38px, 7vw, 78px); line-height: .9; }
.subtitle { margin: 10px 0 0; font-size: clamp(17px, 2.5vw, 23px); color: var(--muted); max-width: 680px; }
.score-card {
  min-width: 112px;
  padding: 14px 18px;
  border: 3px solid var(--ink);
  border-radius: 24px;
  background: var(--yellow);
  box-shadow: 6px 6px 0 rgba(39,48,71,.18);
  text-align: center;
  transform: rotate(2deg);
}
.score-card span { display: block; font-weight: 800; }
.score-card strong { font-size: 42px; }

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  margin-bottom: 18px;
}
label { font-weight: 800; color: var(--muted); }
select, button {
  font: inherit;
  font-weight: 900;
  border: 3px solid var(--ink);
  border-radius: 18px;
  background: var(--paper);
  color: var(--ink);
}
select { display: block; margin-top: 5px; padding: 12px 16px; min-width: 190px; }
button { cursor: pointer; }
.secondary { padding: 13px 18px; background: var(--blue); box-shadow: 4px 4px 0 rgba(39,48,71,.16); }

.game-card {
  position: relative;
  overflow: hidden;
  padding: clamp(18px, 4vw, 40px);
  border: 4px solid var(--ink);
  border-radius: 36px;
  background: rgba(255,253,245,.94);
  box-shadow: var(--shadow);
  text-align: center;
}
.game-card:before {
  content: "";
  position: absolute;
  inset: auto -5% -25px -5%;
  height: 42%;
  background: repeating-linear-gradient(-7deg, rgba(255,226,138,.75), rgba(255,226,138,.75) 12px, rgba(255,226,138,.35) 13px, rgba(255,226,138,.35) 24px);
  z-index: 0;
}
.game-card > * { position: relative; z-index: 1; }

.target-house { width: 170px; margin: 0 auto 20px; }
.roof {
  margin: 0 auto;
  width: 150px;
  padding: 13px 10px 8px;
  background: var(--green);
  border: 4px solid var(--ink);
  border-bottom: 0;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  font-weight: 900;
}
.target {
  background: white;
  border: 4px solid var(--ink);
  border-radius: 0 0 18px 18px;
  font-size: 70px;
  font-weight: 1000;
  line-height: 1.1;
  padding: 8px;
}

.pair-wrap {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto auto;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 2vw, 18px);
  max-width: 760px;
  margin: 0 auto;
}
.cloud {
  min-height: clamp(96px, 16vw, 150px);
  display: grid;
  place-items: center;
  border: 4px solid var(--ink);
  background: var(--pink);
  border-radius: 48% 52% 45% 55% / 58% 42% 58% 42%;
  font-size: clamp(54px, 10vw, 104px);
  font-weight: 1000;
  box-shadow: 8px 8px 0 rgba(39,48,71,.12);
}
.number-cloud { transform: rotate(-2deg); }
.missing-cloud {
  width: 100%;
  color: var(--pink-dark);
  transform: rotate(2deg);
}
.heart { font-size: clamp(42px, 7vw, 76px); color: var(--pink-dark); text-shadow: 3px 3px 0 rgba(39,48,71,.12); }
.equals { font-size: clamp(34px, 6vw, 66px); font-weight: 1000; }
.sum-badge {
  min-width: clamp(72px, 12vw, 118px);
  min-height: clamp(72px, 12vw, 118px);
  display: grid;
  place-items: center;
  border: 4px solid var(--ink);
  border-radius: 999px;
  background: var(--yellow);
  font-size: clamp(42px, 7vw, 76px);
  font-weight: 1000;
}

.message { min-height: 36px; font-size: clamp(22px, 3vw, 32px); font-weight: 900; color: var(--muted); }
.message.good { color: #258352; }
.message.bad { color: #b33358; }

.number-pad {
  display: grid;
  grid-template-columns: repeat(6, minmax(48px, 1fr));
  gap: 10px;
  max-width: 700px;
  margin: 0 auto;
}
.number-pad button {
  min-height: clamp(58px, 9vw, 86px);
  background: white;
  font-size: clamp(26px, 5vw, 46px);
  box-shadow: 4px 4px 0 rgba(39,48,71,.13);
}
.number-pad button:active, .secondary:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 rgba(39,48,71,.16); }

.progress { text-align: center; font-weight: 900; font-size: 18px; color: var(--muted); }
.bar { height: 18px; border: 3px solid var(--ink); border-radius: 999px; overflow: hidden; background: white; margin-top: 18px; }
#barFill { height: 100%; width: 0%; background: var(--green); transition: width .25s ease; }

.shake { animation: shake .25s linear 2; }
.pop { animation: pop .35s ease; }
@keyframes shake { 0%,100%{transform:rotate(2deg) translateX(0)} 25%{transform:rotate(2deg) translateX(-8px)} 75%{transform:rotate(2deg) translateX(8px)} }
@keyframes pop { 0%{transform:scale(1)} 45%{transform:scale(1.12)} 100%{transform:scale(1)} }

.confetti { position: fixed; pointer-events: none; inset: 0; overflow: hidden; }
.confetti i { position: absolute; top: -20px; font-style: normal; animation: fall 900ms ease-in forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(240deg); opacity: 0; } }

@media (max-width: 680px) {
  .hero { align-items: flex-start; }
  .score-card { min-width: 88px; padding: 10px; }
  .pair-wrap { grid-template-columns: 1fr auto 1fr; }
  .equals, .sum-badge { grid-column: span 3; justify-self: center; }
  .number-pad { grid-template-columns: repeat(4, minmax(52px, 1fr)); }
}
