:root {
  --sky: #d8f5ed;
  --water: #28c7b7;
  --deep: #164b45;
  --navy: #102c2f;
  --aqua: #4fe3d1;
  --bluepop: #0f8f83;
  --inkpop: #123d38;
  --pink: #0f8f83;
  --lime: #28c76f;
  --grass: #2fbf71;
  --dirt: #7a5635;
  --stone: #8c9aa2;
  --diamond: #68fff0;
  --ruby: #2bc5a6;
  --coal: #26313f;
  --white: #fffaf0;
  --panel: rgba(255, 250, 240, 0.92);
  --line: rgba(22, 75, 69, 0.38);
  --shadow: rgba(16, 44, 47, 0.2);
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--sky);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--navy);
  font-family: "Nunito", Verdana, sans-serif;
  background:
    radial-gradient(circle at 14% 12%, rgba(255,255,255,.72), transparent 16rem),
    radial-gradient(circle at 88% 16%, rgba(79,227,209,.26), transparent 22rem),
    linear-gradient(145deg, #e8fff8 0%, #bceee4 48%, #eaf8ee 100%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  height: 154px;
  pointer-events: none;
  background:
    linear-gradient(180deg, #32d978 0 24px, #9a6239 24px 100%);
  box-shadow: 0 -8px 0 rgba(22,75,69,.22), inset 0 12px 0 rgba(255,255,255,.18);
}

body::after {
  content: "";
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  height: 154px;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent 0 6vw, rgba(82,48,28,.38) 6vw 12vw, transparent 12vw 25vw, rgba(62,37,24,.32) 25vw 31vw, transparent 31vw 43vw, rgba(82,48,28,.38) 43vw 49vw, transparent 49vw 62vw, rgba(62,37,24,.32) 62vw 68vw, transparent 68vw 81vw, rgba(82,48,28,.38) 81vw 87vw, transparent 87vw),
    linear-gradient(180deg, transparent 0 24px, rgba(75,44,27,.28) 24px 56px, transparent 56px 88px, rgba(75,44,27,.22) 88px 120px, transparent 120px);
}

#numberCanvas,
#cursorTrail {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

#numberCanvas { z-index: 0; }
#cursorTrail { z-index: 6; }

.block-world {
  position: fixed;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
}

.block-cloud {
  position: absolute;
  width: 156px;
  height: 58px;
  background:
    linear-gradient(#f7fdff, #e6f8ff);
  box-shadow:
    44px -22px 0 #f7fdff,
    86px 0 0 #eefbff,
    128px -14px 0 #f7fdff,
    10px 10px 0 rgba(22,75,69,.12);
  border: 4px solid rgba(22,75,69,.18);
  opacity: .86;
}

.cloud-a { left: 8vw; top: 42px; }
.cloud-b { right: 18vw; top: 58px; transform: scale(.72); }
.cloud-c { left: 50vw; top: 158px; transform: scale(.58); opacity: .68; }

.voxel {
  position: absolute;
  width: 82px;
  height: 82px;
  image-rendering: pixelated;
  filter: drop-shadow(10px 16px 0 rgba(7,90,158,.18));
  animation: voxelFloat 5.5s ease-in-out infinite;
}

.grass-block {
  background: url("../assets/grass-block.svg") center / contain no-repeat;
}

.dirt-block,
.stone-block,
.diamond-block,
.ruby-block,
.coal-block {
  border: 5px solid var(--deep);
  border-radius: 4px;
  transform: rotate(8deg);
  background-size: auto;
  box-shadow: inset 0 0 0 5px rgba(255,255,255,.22);
}

.dirt-block {
  background:
    radial-gradient(circle at 22px 20px, rgba(255,255,255,.15) 0 8px, transparent 9px),
    radial-gradient(circle at 56px 52px, rgba(64,35,20,.22) 0 10px, transparent 11px),
    linear-gradient(180deg, #a86e40, #6f4328);
}

.stone-block {
  background:
    radial-gradient(circle at 20px 20px, rgba(255,255,255,.24) 0 9px, transparent 10px),
    radial-gradient(circle at 58px 54px, rgba(37,55,70,.18) 0 11px, transparent 12px),
    linear-gradient(180deg, #c5d0db, #8292a2);
}

.diamond-block {
  background:
    radial-gradient(circle at 24px 24px, #e9ffff 0 7px, transparent 8px),
    radial-gradient(circle at 58px 50px, #68fff0 0 12px, transparent 13px),
    linear-gradient(180deg, #a9fff6, #28c7b7);
}

.ruby-block {
  background:
    radial-gradient(circle at 22px 24px, #cafff6 0 8px, transparent 9px),
    radial-gradient(circle at 58px 52px, #2bc5a6 0 12px, transparent 13px),
    linear-gradient(180deg, #78f0cf, #0f8f83);
}

.coal-block {
  background:
    radial-gradient(circle at 24px 24px, #5b6878 0 9px, transparent 10px),
    radial-gradient(circle at 58px 54px, #161d28 0 12px, transparent 13px),
    linear-gradient(180deg, #647181, #26313f);
}

.block-a { left: 3vw; top: 130px; }
.block-b { right: 6vw; top: 92px; animation-delay: -.9s; }
.block-c { left: 7vw; bottom: 142px; animation-delay: -1.8s; }
.block-d { right: 10vw; bottom: 170px; animation-delay: -2.6s; }
.block-e { right: 25vw; top: 250px; animation-delay: -3.1s; transform: rotate(-9deg); }
.block-f { left: 22vw; bottom: 198px; animation-delay: -4s; transform: rotate(5deg); }

.app-shell {
  position: relative;
  z-index: 2;
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 34px;
}

.main-menu,
.activity-card {
  border: 7px solid #164b45;
  border-radius: 2px;
  background: var(--panel);
  box-shadow:
    12px 12px 0 rgba(16,44,47,.24),
    0 22px 60px var(--shadow),
    inset 0 0 0 5px rgba(255,255,255,.62);
  backdrop-filter: blur(14px);
}

.main-menu {
  position: relative;
  padding: clamp(18px, 4vw, 34px);
}

.main-menu::before,
.activity-card::before {
  content: "";
  display: block;
  height: 30px;
  margin: calc(clamp(18px, 4vw, 34px) * -1) calc(clamp(18px, 4vw, 34px) * -1) 18px;
  border-bottom: 5px solid var(--deep);
  background: linear-gradient(180deg, #32d978 0 13px, #21b661 13px 30px);
}

.activity-card::before {
  margin: calc(clamp(18px, 4vw, 30px) * -1) calc(clamp(18px, 4vw, 30px) * -1) 18px;
}

.brand-cube {
  width: 104px;
  height: 104px;
  image-rendering: pixelated;
  filter: drop-shadow(10px 12px 0 rgba(7,90,158,.18));
}

.eyebrow {
  margin: 12px 0 10px;
  color: var(--deep);
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-size: clamp(16px, 2vw, 24px);
  line-height: 1.1;
  text-transform: uppercase;
  letter-spacing: .08em;
}

h1 {
  margin: 0;
  display: grid;
  gap: 0;
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-size: clamp(58px, 11vw, 138px);
  line-height: .74;
  letter-spacing: -.045em;
  color: var(--bluepop);
  -webkit-text-stroke: 0;
  text-shadow:
    4px 4px 0 #fffaf0,
    9px 9px 0 rgba(18,61,56,.18),
    0 0 22px rgba(79,227,209,.48);
  animation: titleBreath 2.8s ease-in-out infinite, titleColor 5.2s ease-in-out infinite;
  transform-origin: left center;
}

h1 span:first-child {
  color: var(--inkpop);
}

.block-badge {
  width: fit-content;
  margin: 18px 0 0;
  padding: 9px 14px;
  border: 4px solid #164b45;
  border-radius: 2px;
  background: linear-gradient(180deg, #32d978 0 32%, #9a6239 32% 100%);
  color: #fff;
  font-weight: 1000;
  text-shadow: 2px 2px 0 #164b45;
  box-shadow: 6px 6px 0 rgba(22,75,69,.22);
}

.tagline {
  max-width: 880px;
  margin: 18px 0 0;
  font-size: clamp(18px, 2.8vw, 25px);
  line-height: 1.3;
  font-weight: 1000;
  color: #285f85;
}

.status-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 240px));
  gap: 14px;
  margin: 24px 0;
}

.score-card,
.qr-mini,
.voice-indicator {
  border: 5px solid #164b45;
  border-radius: 2px;
  background: linear-gradient(180deg, #fffaf0, #dcf6ee);
  box-shadow: 7px 7px 0 rgba(22,75,69,.2);
}

.score-card,
.qr-mini {
  padding: 14px;
  text-align: center;
  font-weight: 1000;
}

.score-card span,
.qr-mini span {
  display: block;
  color: var(--deep);
}

.score-card strong {
  display: block;
  margin: 4px 0;
  color: #0f8f83;
  font-size: 56px;
  line-height: 1;
}

.mode-card strong {
  color: var(--deep);
  font-size: 42px;
}

.mode-card small {
  display: block;
  color: #285f85;
  font-size: 16px;
  line-height: 1.15;
}

.qr-mini img {
  width: 140px;
  height: 140px;
  margin: 10px auto 0;
  display: block;
  border: 4px solid var(--deep);
  border-radius: 10px;
  background: #fff;
  image-rendering: pixelated;
}

button {
  border: 5px solid #164b45;
  border-radius: 2px;
  background: linear-gradient(180deg, #8ff7df, #28c7b7);
  color: #102c2f;
  font: inherit;
  font-weight: 1000;
  cursor: pointer;
  box-shadow: 0 7px 0 #0b6f66;
  transition: transform .08s ease, box-shadow .08s ease, filter .12s ease;
}

button:hover,
button:focus-visible {
  filter: brightness(1.08) saturate(1.1);
  outline: none;
}

button:active {
  transform: translateY(5px);
  box-shadow: 0 2px 0 #0b6f66;
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.menu-btn {
  min-height: 104px;
  padding: 16px;
  font-size: clamp(18px, 2.2vw, 27px);
  text-align: left;
  background: linear-gradient(180deg, #a7fff0 0 24%, #28c7b7 24% 100%);
  text-shadow: 1px 1px 0 rgba(255,255,255,.55);
}

.menu-btn:nth-child(2n) {
  background: linear-gradient(180deg, #38d97c 0 24%, #9a6239 24% 100%);
  color: #fff;
  text-shadow: 2px 2px 0 #50301d;
}

.menu-btn:nth-child(3n) {
  background: linear-gradient(180deg, #cbd8e2, #8292a2);
  color: #fff;
  border-color: #4b6174;
  box-shadow: 0 7px 0 #4b6174;
}

.menu-btn:nth-child(4n) {
  background: linear-gradient(180deg, #a7fff0 0 26%, #0f8f83 26% 100%);
}

.menu-btn:nth-child(5n) {
  background: linear-gradient(180deg, #8c9aa2 0 26%, #26313f 26% 100%);
  color: #fff;
  border-color: #102c2f;
  box-shadow: 0 7px 0 #102c2f;
  text-shadow: 2px 2px 0 #102c2f;
}

.inventory-bar {
  display: grid;
  grid-template-columns: repeat(9, minmax(42px, 1fr));
  gap: 8px;
  margin-top: 18px;
  padding: 10px;
  border: 6px solid #164b45;
  background: rgba(38,49,63,.9);
  box-shadow: inset 0 0 0 4px rgba(255,255,255,.08), 8px 8px 0 rgba(22,75,69,.2);
}

.inventory-bar span {
  min-height: 52px;
  display: grid;
  place-items: center;
  border: 4px solid #0b2035;
  background: linear-gradient(180deg, #fffaf0, #a7fff0);
  color: #123d38;
  font-size: 24px;
  font-weight: 1000;
  box-shadow: inset 0 0 0 3px rgba(255,255,255,.42);
}

.menu-btn.wide {
  grid-column: 1 / -1;
  text-align: center;
  min-height: 78px;
}

.voice-toggle,
.back-btn,
.mini-action {
  margin-top: 18px;
  min-height: 54px;
  padding: 12px 18px;
}

.voice-toggle.muted,
.voice-indicator.muted {
  filter: grayscale(.65);
  opacity: .72;
}

.voice-indicator {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 10px 12px;
}

.voice-bars {
  display: flex;
  align-items: end;
  gap: 4px;
  height: 30px;
}

.voice-bars span {
  width: 7px;
  height: 12px;
  display: block;
  border-radius: 99px;
  background: var(--pink);
  box-shadow: 0 0 12px rgba(255,91,189,.6);
}

.voice-indicator.speaking .voice-bars span {
  animation: voiceBounce .42s ease-in-out infinite alternate;
}

.voice-indicator.speaking .voice-bars span:nth-child(2) { animation-delay: .07s; }
.voice-indicator.speaking .voice-bars span:nth-child(3) { animation-delay: .14s; }
.voice-indicator.speaking .voice-bars span:nth-child(4) { animation-delay: .21s; }
.voice-indicator.speaking .voice-bars span:nth-child(5) { animation-delay: .28s; }

.section-view {
  display: grid;
  gap: 16px;
}

.hidden { display: none !important; }

.activity-card {
  min-height: 560px;
  padding: clamp(18px, 4vw, 30px);
}

.activity-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
  margin-bottom: 20px;
}

.activity-head h2 {
  margin: 0;
  color: var(--deep);
  font-size: clamp(34px, 5vw, 60px);
  line-height: .95;
}

.activity-head p,
.feedback,
.challenge-note {
  margin: 8px 0 0;
  color: #285f85;
  font-size: 20px;
  font-weight: 1000;
}

.challenge-note {
  display: inline-block;
  margin-bottom: 14px;
  padding: 8px 12px;
  border: 4px solid #164b45;
  background: #dcf6ee;
  box-shadow: 5px 5px 0 rgba(22,75,69,.16);
}

.calc-display,
.number-input,
.answer-input {
  width: 100%;
  border: 4px solid var(--deep);
  border-radius: 14px;
  background: #fffaf0;
  color: #0f8f83;
  font: 1000 clamp(32px, 6vw, 58px) "Nunito", sans-serif;
  box-shadow: inset 0 0 0 4px #dcf6ee;
}

.calc-display {
  min-height: 92px;
  padding: 16px;
  overflow-x: auto;
  text-align: right;
}

.calc-grid,
.choice-grid,
.prime-grid,
.base-grid,
.pattern-grid {
  display: grid;
  gap: 12px;
}

.calc-grid {
  grid-template-columns: repeat(5, 1fr);
  margin-top: 16px;
}

.calc-grid button,
.choice-grid button,
.prime-grid button {
  min-height: 72px;
  padding: 10px;
  font-size: clamp(22px, 4vw, 34px);
}

.choice-grid {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-top: 18px;
}

.prime-grid {
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
}

.prime-grid button.selected {
  background: linear-gradient(180deg, #8ff7df, #0f8f83);
  color: #fff;
  border-color: #164b45;
  box-shadow: 0 7px 0 #164b45;
}

.number-input,
.answer-input {
  min-height: 80px;
  padding: 12px 16px;
  text-align: center;
}

.base-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-top: 16px;
}

.base-box,
.result-box,
.qr-station {
  border: 4px solid var(--deep);
  border-radius: 6px;
  background: rgba(255,255,255,.78);
  padding: 16px;
  text-align: center;
  box-shadow: 6px 6px 0 rgba(7,90,158,.16);
}

.base-box span,
.result-box span {
  display: block;
  color: #285f85;
  font-weight: 1000;
}

.base-box strong,
.result-box strong {
  display: block;
  margin-top: 8px;
  color: var(--deep);
  font-size: clamp(24px, 4vw, 38px);
  overflow-wrap: anywhere;
}

.magic-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(70px, 120px));
  justify-content: center;
  gap: 12px;
  margin: 22px auto;
}

.magic-grid input {
  height: 92px;
  border: 4px solid var(--deep);
  border-radius: 14px;
  color: var(--pink);
  background: #fffaf0;
  text-align: center;
  font: 1000 38px "Nunito", sans-serif;
  box-shadow: inset 0 0 0 4px #dcf6ee;
}

.cursor-pop {
  position: fixed;
  z-index: 7;
  color: #0f8f83;
  font-size: 32px;
  font-weight: 1000;
  text-shadow: 2px 2px 0 #fffaf0, 0 0 20px rgba(79,227,209,.9);
  pointer-events: none;
  animation: cursorFloat .8s ease-out forwards;
}

.qr-station img {
  width: min(320px, 90%);
  display: block;
  margin: 16px auto;
  border: 6px solid var(--deep);
  border-radius: 18px;
  image-rendering: pixelated;
}

.page-link {
  color: var(--deep);
  font-size: 22px;
  font-weight: 1000;
  overflow-wrap: anywhere;
}

@keyframes titleBreath {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.025); filter: brightness(1.18); }
}

@keyframes titleColor {
  0%, 100% {
    color: #0f8f83;
    text-shadow: 4px 4px 0 #fffaf0, 9px 9px 0 rgba(18,61,56,.18), 0 0 22px rgba(79,227,209,.48);
  }
  50% {
    color: #123d38;
    text-shadow: 4px 4px 0 #fffaf0, 9px 9px 0 rgba(15,143,131,.18), 0 0 26px rgba(40,199,183,.5);
  }
}

@keyframes voiceBounce {
  to { height: 30px; background: var(--lime); }
}

@keyframes voxelFloat {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-20px) rotate(6deg); }
}

@keyframes cursorFloat {
  to {
    opacity: 0;
    transform: translate(var(--dx), -86px) rotate(16deg) scale(.7);
  }
}

@media (max-width: 850px) {
  .status-row,
  .menu-grid,
  .calc-grid {
    grid-template-columns: 1fr 1fr;
  }

  .inventory-bar {
    grid-template-columns: repeat(5, 1fr);
  }

  .activity-head {
    display: block;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 18px, 1180px);
    padding-bottom: 90px;
  }

  .status-row,
  .menu-grid,
  .calc-grid {
    grid-template-columns: 1fr;
  }

  .inventory-bar {
    grid-template-columns: repeat(3, 1fr);
  }

  h1 {
    font-size: clamp(48px, 18vw, 90px);
  }

  .voice-indicator {
    left: 10px;
    right: 10px;
    justify-content: center;
  }
}
