/* Hand-inked look borrowed from the ICAS Penny set: thick ink outlines, flat fills, hard offset shadows. */
:root {
  --ink: #1A1A1A;
  --yellow: #FFDD00;
  --yellow-pale: #FFF3A6;
  --cream: #F2EEDA;
  --paper: #FFFDF4;
  --teal: #DFF1F2;
  --lav: #DBCFFA;
  --green: #CEF7C7;
  --blush: #FFB3A7;
  --line: 0.7vmin;
  --shadow: 0 1.1vmin 0 var(--ink);
  --wobble: 3.2vmin 2.4vmin 3.6vmin 2.2vmin / 2.4vmin 3.4vmin 2.2vmin 3.2vmin;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--cream);
  color: var(--ink);
  font-family: "Zen Kaku Gothic New", "Hiragino Kaku Gothic Pro", "Arial Rounded MT Bold", system-ui, sans-serif;
  font-weight: 700;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
  overscroll-behavior: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  touch-action: none;
}

svg { display: block; width: 100%; height: 100%; overflow: visible; }

#app { position: fixed; top: 0; left: 0; right: 0; bottom: 0; }

.screen {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.bg-cream { background: var(--cream); }
.bg-lav { background: var(--lav); }
.bg-teal { background: var(--teal); }

/* paper dots texture */
.screen::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background-image: radial-gradient(rgba(26, 26, 26, .08) 0.25vmin, transparent 0.3vmin);
  background-size: 4vmin 4vmin;
  pointer-events: none;
}

/* ---------- top bar ---------- */
.topbar {
  position: relative; z-index: 2;
  display: flex; align-items: center;
  height: 15vmin; padding: 2.5vmin 3.5vmin 0;
  flex: 0 0 auto;
}
.spacer { flex: 1; }
.round-btn {
  width: 12vmin; height: 12vmin; padding: 2vmin;
  border-radius: 50%;
  background: #fff; border: var(--line) solid var(--ink); box-shadow: var(--shadow);
}
.round-btn:active { transform: translateY(0.8vmin); box-shadow: 0 0.3vmin 0 var(--ink); }
.mute-btn { margin-right: 2.5vmin; padding: 2.2vmin; }
.mute-btn .cross { display: none; }
.mute-btn.off .cross { display: inline; }
.mute-btn.off .wave { display: none; }
.top-slot { display: flex; align-items: center; }
.starbox {
  display: flex; align-items: center;
  height: 11vmin; padding: 0 3vmin 0 1.4vmin;
  background: #fff; border: var(--line) solid var(--ink); border-radius: 6vmin; box-shadow: var(--shadow);
  font-size: 6.5vmin; font-weight: 900;
}
.starbox svg { width: 8vmin; height: 8vmin; margin-right: 1.2vmin; }
.starbox.pulse { animation: pulse .5s ease; }

/* ---------- Penny ---------- */
.penny { position: relative; z-index: 1; }
.penny-inner { width: 100%; height: 100%; transform-origin: 50% 95%; animation: sway 3.2s ease-in-out infinite; }
.penny-svg { width: 100%; height: 100%; }
.penny-eyes { transform-origin: 150px 262px; animation: blink 4.6s infinite; }
.penny.hop { animation: hop .26s ease-out; }
.penny.jump { animation: jump .7s cubic-bezier(.3, 1.6, .5, 1) 2; }
.penny.shake { animation: shake .5s ease; }

/* ---------- splash ---------- */
.splash { align-items: center; justify-content: center; cursor: pointer; }
.splash .penny.big { width: 44vmin; height: 40vmin; }
.title {
  position: relative;
  font-size: 10vmin; font-weight: 900; letter-spacing: -0.02em;
  margin: 1vmin 0 4vmin; text-align: center;
}
.title span {
  display: inline-block; padding: 0 2vmin;
  background: var(--yellow); border: var(--line) solid var(--ink); border-radius: var(--wobble);
  transform: rotate(-3deg); box-shadow: var(--shadow);
}
.big-play {
  position: relative;
  width: 22vmin; height: 22vmin; padding: 4.5vmin 4vmin 4.5vmin 5.5vmin;
  border-radius: 50%; background: #3CC77A; border: 0.9vmin solid var(--ink); box-shadow: 0 1.4vmin 0 var(--ink);
  animation: breathe 1.6s ease-in-out infinite;
}

/* ---------- menu ---------- */
.tiles {
  position: relative; flex: 1;
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr));
  grid-gap: 3.5vmin; padding: 3vmin 5vmin 7vmin; min-height: 0;
  max-width: 180vmin; width: 100%; margin: 0 auto;
}
.tile {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: var(--line) solid var(--ink); border-radius: var(--wobble); box-shadow: var(--shadow);
  padding: 2vmin;
}
.tile:active { margin-top: 0.8vmin; box-shadow: 0 0.3vmin 0 var(--ink); }
.tile-icon { width: 20vmin; height: 17vmin; }
.tile-label { font-size: 5.2vmin; font-weight: 900; margin-top: 1vmin; }
.tile.soon .tile-icon, .tile.soon .tile-label { opacity: .4; }
.soon-tag {
  position: absolute; top: -2.2vmin; right: -1.5vmin;
  padding: .4vmin 2vmin; font-size: 3.2vmin;
  background: #fff; border: 0.5vmin solid var(--ink); border-radius: 3vmin;
  transform: rotate(6deg);
}
.tile.wobble { animation: wobble .45s ease; }
.penny.corner { position: absolute; right: 1vmin; bottom: -3vmin; width: 22vmin; height: 20vmin; }

/* ---------- game frame ---------- */
.game-body { position: relative; flex: 1; min-height: 0; }
.game-body > * { position: absolute; top: 0; left: 0; right: 0; bottom: 0; }

/* ---------- piano ---------- */
.piano { display: flex; flex-direction: column; }
.piano-stage {
  position: relative; flex: 0 0 34%;
  display: flex; align-items: center; padding: 0 4vmin;
}
.piano-penny { width: 26vmin; height: 24vmin; flex: 0 0 auto; }
.sheet { flex: 1; display: flex; align-items: center; justify-content: center; height: 12vmin; }
.dot {
  width: 5vmin; height: 5vmin; margin: 0 1vmin; border-radius: 50%;
  border: 0.55vmin solid var(--ink); flex: 0 0 auto;
}
.dot.now { width: 9vmin; height: 9vmin; box-shadow: 0 0.8vmin 0 var(--ink); animation: bob .7s ease-in-out infinite alternate; }
.songs { display: flex; flex: 0 0 auto; }
.song-btn {
  width: 14vmin; height: 14vmin; margin-left: 2.5vmin; padding: 2.2vmin;
  background: #fff; border: var(--line) solid var(--ink); border-radius: var(--wobble); box-shadow: var(--shadow);
}
.song-btn:active { transform: translateY(0.8vmin); box-shadow: 0 0.3vmin 0 var(--ink); }

.keys {
  position: relative; flex: 1;
  display: flex; padding: 0 3vmin 5vmin;
}
.key {
  position: relative; flex: 1; margin: 0 0.7vmin;
  border: var(--line) solid var(--ink); border-radius: 1.6vmin 1.6vmin 3.5vmin 3.5vmin;
  box-shadow: 0 1.4vmin 0 var(--ink);
  transition: transform .06s, box-shadow .06s;
}
.key.down { transform: translateY(1.1vmin); box-shadow: 0 0.3vmin 0 var(--ink); }
.key.down::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; border-radius: inherit;
  background: rgba(255, 255, 255, .35);
}
.syll {
  position: absolute; left: 50%; bottom: 3vmin;
  width: 11vmin; height: 11vmin; margin-left: -5.5vmin; line-height: 9.6vmin;
  text-align: center; font-size: 5.4vmin; font-weight: 900;
  background: #fff; border: 0.55vmin solid var(--ink); border-radius: 50%;
  pointer-events: none;
}
.key.next { box-shadow: 0 1.4vmin 0 var(--ink), 0 0 0 1.2vmin #fff; }
.key-star {
  position: absolute; left: 50%; top: 2.5vmin;
  width: 11vmin; height: 11vmin; margin-left: -5.5vmin;
  display: none; pointer-events: none;
}
.key.next .key-star { display: block; animation: glow .5s ease-in-out infinite alternate; }
.float-note {
  position: absolute; width: 12vmin; height: 12vmin; margin-left: -6vmin;
  pointer-events: none; z-index: 3;
  animation: floatUp 1.25s ease-out forwards;
}

/* ---------- colours & shapes ---------- */
.shapes { display: flex; flex-direction: column; }
.ask {
  flex: 0 0 38%;
  display: flex; align-items: center; justify-content: center;
  padding: 0 6vmin;
}
.bubble {
  position: relative;
  display: flex; align-items: center;
  height: 24vmin; padding: 2vmin 5vmin 2vmin 3vmin;
  background: #fff; border: var(--line) solid var(--ink); border-radius: var(--wobble); box-shadow: var(--shadow);
}
.bubble::after { /* tail pointing at Penny */
  content: ''; position: absolute; right: -3.4vmin; top: 50%;
  width: 5vmin; height: 5vmin; margin-top: -2.5vmin;
  background: #fff; border-top: var(--line) solid var(--ink); border-right: var(--line) solid var(--ink);
  transform: rotate(45deg) skew(12deg, 12deg);
}
.bubble.pop-in { animation: popIn .35s cubic-bezier(.3, 1.6, .5, 1); }
.bubble-art { width: 17vmin; height: 17vmin; flex: 0 0 auto; }
.bubble-word {
  margin-left: 3vmin; font-size: 9vmin; font-weight: 900;
  -webkit-text-stroke: 0.35vmin var(--ink);
}
.ask-penny { width: 28vmin; height: 26vmin; margin-left: 4vmin; flex: 0 0 auto; }
.opts {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding-bottom: 6vmin;
}
.opt {
  width: 25vmin; height: 25vmin; margin: 0 2.5vmin; padding: 2.5vmin;
  background: var(--paper); border: var(--line) solid var(--ink); border-radius: var(--wobble); box-shadow: var(--shadow);
  animation: popIn .4s cubic-bezier(.3, 1.6, .5, 1) both;
}
.opt.yay { animation: yay .8s cubic-bezier(.3, 1.6, .5, 1); background: var(--yellow-pale); }
.opt.wobble { animation: wobble .45s ease; }

.bg-pink { background: #FFE9E4; }
.bg-peach { background: #FFF0DD; }
.bg-green { background: #E3F8DE; }
.bg-grass { background: #8ED97A; }

/* ---------- letters ---------- */
.letters { display: flex; align-items: center; justify-content: center; padding: 0 4vmin 4vmin; }
.trace-box {
  width: 74vmin; height: 74vmin; max-width: 56vw; max-height: 56vw; flex: 0 0 auto;
  background: var(--paper); border: var(--line) solid var(--ink); border-radius: var(--wobble); box-shadow: var(--shadow);
  padding: 2vmin; cursor: crosshair;
}
.trace-box.yay { animation: yay .8s cubic-bezier(.3, 1.6, .5, 1); }
.letter-side {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  margin-left: 6vmin; min-width: 40vmin;
}
.letter-word { display: flex; flex-direction: column; align-items: center; }
.big-letter { font-size: 20vmin; line-height: 1; font-weight: 900; -webkit-text-stroke: 0.5vmin var(--ink); }
.big-letter small { font-size: 13vmin; margin-left: 1vmin; }
.letter-word .word {
  font-size: 8vmin; font-weight: 900; margin-top: 1vmin;
  padding: 0 3vmin; background: #fff; border: var(--line) solid var(--ink); border-radius: var(--wobble);
  visibility: hidden;
}
.letter-word.show .word { visibility: visible; animation: popIn .4s cubic-bezier(.3, 1.6, .5, 1); }
.letter-penny { width: 22vmin; height: 20vmin; margin: 1vmin 0; }
.letter-nav { display: flex; }
.nav-btn {
  width: 13vmin; height: 13vmin; margin: 0 1.5vmin; padding: 2.5vmin;
  background: #fff; border: var(--line) solid var(--ink); border-radius: 50%; box-shadow: var(--shadow);
}
.nav-btn:active { transform: translateY(0.8vmin); box-shadow: 0 0.3vmin 0 var(--ink); }

/* ---------- numbers ---------- */
.numbers { display: flex; flex-direction: column; }
.num-top { flex: 0 0 23%; display: flex; align-items: center; justify-content: center; }
.num-bubble { height: 18vmin; }
.num-bubble .bubble-art { width: 12vmin; height: 12vmin; }
.num-bubble .bubble-word { -webkit-text-stroke: 0; font-size: 9vmin; }
.num-penny { width: 22vmin; height: 20vmin; margin-left: 4vmin; flex: 0 0 auto; }
.num-field { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; }
.group {
  display: flex; flex-wrap: wrap; justify-content: center; align-content: center;
  max-width: 64vmin; padding: 1.5vmin;
  background: rgba(255, 255, 255, .55); border: 0.5vmin dashed rgba(26, 26, 26, .35); border-radius: 4vmin;
}
.plus { font-size: 14vmin; font-weight: 900; margin: 0 3vmin; }
.count-item {
  position: relative; width: 17vmin; height: 17vmin; margin: 0.6vmin 1vmin; padding: 1vmin;
  animation: popIn .4s cubic-bezier(.3, 1.6, .5, 1) both;
}
.count-item.bounce { animation: yay .5s cubic-bezier(.3, 1.6, .5, 1); }
.count-item.counted svg { opacity: .9; }
.badge {
  position: absolute; right: -1vmin; top: -1vmin;
  width: 7vmin; height: 7vmin; line-height: 5.8vmin; text-align: center;
  font-size: 4.6vmin; font-weight: 900; color: #fff;
  background: var(--ink); border: 0.5vmin solid #fff; border-radius: 50%;
}
.num-choices { flex: 0 0 30%; display: flex; align-items: center; justify-content: center; padding-bottom: 2vmin; visibility: hidden; }
.num-choices.show { visibility: visible; }
.num-choice {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 20vmin; height: 20vmin; margin: 0 2.5vmin;
  background: var(--paper); border: var(--line) solid var(--ink); border-radius: var(--wobble); box-shadow: var(--shadow);
  animation: popIn .4s cubic-bezier(.3, 1.6, .5, 1) both;
}
.num-choice.yay { animation: yay .8s cubic-bezier(.3, 1.6, .5, 1); background: var(--yellow-pale); }
.num-choice.wobble { animation: wobble .45s ease; }
.numeral { font-size: 13vmin; line-height: 1; font-weight: 900; -webkit-text-stroke: 0.45vmin var(--ink); }
.pips { display: flex; flex-wrap: wrap; justify-content: center; max-width: 16vmin; margin-top: 0.6vmin; }
.pips i { width: 2vmin; height: 2vmin; margin: 0.3vmin; border-radius: 50%; background: var(--ink); }

/* ---------- puzzle ---------- */
.puzzle { overflow: hidden; }
.board {
  position: absolute; background: #fff;
  border: var(--line) solid var(--ink); box-shadow: var(--shadow); box-sizing: content-box;
  margin: calc(-1 * var(--line)) 0 0 calc(-1 * var(--line));
}
.ghost { position: absolute; top: 0; left: 0; right: 0; bottom: 0; opacity: .22; filter: grayscale(.4); }
.slot-line { position: absolute; border: 0 dashed rgba(26, 26, 26, .45); }
.slot-line.v { top: 0; bottom: 0; border-left-width: 0.5vmin; margin-left: -0.25vmin; }
.slot-line.h { left: 0; right: 0; border-top-width: 0.5vmin; margin-top: -0.25vmin; }
.piece {
  position: absolute; overflow: hidden; z-index: 5;
  box-shadow: 0 1vmin 0 rgba(26, 26, 26, .9);
  animation: popIn .4s cubic-bezier(.3, 1.6, .5, 1) both;
  transition: transform .15s;
}
.piece::after {
  content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  border: 0.6vmin solid var(--ink); pointer-events: none;
}
.piece-art { position: absolute; pointer-events: none; }
.piece.lift { box-shadow: 0 2.2vmin 0 rgba(26, 26, 26, .35); }
.piece.back { transition: left .3s ease, top .3s ease, transform .3s; }
.piece.placed { box-shadow: none; pointer-events: none; transition: left .12s, top .12s; }
.puzzle.complete .piece::after { border-color: transparent; transition: border-color .4s; }
.puzzle.complete .board { animation: yay .8s cubic-bezier(.3, 1.6, .5, 1); }
.level-btn {
  display: flex; align-items: center; height: 11vmin; padding: 0 2.5vmin 0 1.2vmin;
  background: #fff; border: var(--line) solid var(--ink); border-radius: 6vmin; box-shadow: var(--shadow);
}
.level-icon { width: 8vmin; height: 8vmin; display: block; }
.level-num { font-size: 5.5vmin; font-weight: 900; margin-left: 1vmin; }
.level-menu {
  position: absolute; top: 1vmin; left: 50%; z-index: 30;
  display: none; padding: 1.5vmin;
  transform: translateX(-50%);
  background: var(--paper); border: var(--line) solid var(--ink); border-radius: var(--wobble); box-shadow: var(--shadow);
}
.level-menu.show { display: flex; }
.level-opt {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 12vmin; height: 15vmin; margin: 0 0.7vmin;
  background: #fff; border: 0.5vmin solid var(--ink); border-radius: 2vmin;
}
.level-opt.on { background: var(--yellow); }
.level-opt .level-icon { width: 9vmin; height: 9vmin; }
.level-opt .level-num { margin-left: 0; font-size: 4.5vmin; }
.puzzle-penny { position: absolute; right: 1vmin; bottom: -2vmin; width: 18vmin; height: 16vmin; pointer-events: none; }

/* ---------- cars ---------- */
.race { overflow: hidden; touch-action: none; }
.race::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background-image: radial-gradient(#6CC459 1vmin, transparent 1.1vmin);
  background-size: 9vmin 9vmin;
  pointer-events: none;
}
.road {
  position: absolute; top: 0; bottom: 0; left: 50%;
  width: 66vmin; max-width: 62vw; margin-left: -33vmin;
  background: #6B6B6B; border-left: 1.4vmin solid #fff; border-right: 1.4vmin solid #fff;
  box-shadow: -0.8vmin 0 0 var(--ink), 0.8vmin 0 0 var(--ink);
  overflow: hidden;
}
@media (max-aspect-ratio: 66/62) { .road { margin-left: -31vw; } }
.lane-line {
  position: absolute; top: 0; bottom: 0; width: 1.4vmin; margin-left: -0.7vmin;
  background-image: linear-gradient(#FFFFFF 50%, transparent 50%);
  background-size: 100% 14vmin;
}
.lane-line.l1 { left: 33.333%; }
.lane-line.l2 { left: 66.666%; }
.car { position: absolute; top: 0; left: 0; z-index: 3; }
.car.spin svg { animation: spin .6s ease; }
.road-obj { position: absolute; top: 0; left: 0; z-index: 2; }
.road-obj.knock svg { animation: knock .5s ease-out forwards; }
.race-slots {
  position: absolute; top: 1.5vmin; left: 50%; z-index: 4;
  display: flex; padding: 1vmin 2vmin;
  transform: translateX(-50%);
  background: #fff; border: var(--line) solid var(--ink); border-radius: 5vmin; box-shadow: var(--shadow);
}
.slot { width: 5.2vmin; height: 5.2vmin; margin: 0 0.3vmin; opacity: .22; filter: grayscale(1); }
.slot.got { opacity: 1; filter: none; animation: pulse .4s ease; }
.race-penny { position: absolute; left: 2vmin; bottom: 0; width: 22vmin; height: 20vmin; pointer-events: none; }
.race-overlay {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0; z-index: 10;
  display: none; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(242, 238, 218, .82);
}
.race-overlay.show { display: flex; }
.race-title {
  font-size: 9vmin; font-weight: 900; margin-bottom: 5vmin; padding: 0 3vmin;
  background: var(--yellow); border: var(--line) solid var(--ink); border-radius: var(--wobble); box-shadow: var(--shadow);
  transform: rotate(-2deg);
}
.car-pick { display: flex; }
.pick-btn {
  width: 20vmin; height: 30vmin; margin: 0 2.5vmin; padding: 2.5vmin 4vmin;
  background: #fff; border: var(--line) solid var(--ink); border-radius: var(--wobble); box-shadow: var(--shadow);
  animation: popIn .4s cubic-bezier(.3, 1.6, .5, 1) both;
}
.pick-btn:active { transform: translateY(0.8vmin); box-shadow: 0 0.3vmin 0 var(--ink); }

.race::before { background-image: radial-gradient(var(--dot, #6CC459) 1vmin, transparent 1.1vmin); }
.theme-night .road { box-shadow: -0.8vmin 0 0 #FFF3A6, 0.8vmin 0 0 #FFF3A6; }
.theme-night .race-penny { filter: brightness(.9); }
.horn-btn {
  position: absolute; right: 3vmin; bottom: 4vmin; z-index: 5;
  width: 20vmin; height: 20vmin; padding: 3.5vmin;
  background: #FF5A4E; border: 0.8vmin solid var(--ink); border-radius: 50%; box-shadow: 0 1.2vmin 0 var(--ink);
}
.horn-btn.bounce { animation: yay .4s cubic-bezier(.3, 1.6, .5, 1); }
.car.honk svg { animation: hop .25s ease-out 2; }
.road-obj.float-away svg { animation: floatAway .7s ease-out forwards; }
@keyframes floatAway { to { transform: translate(-30%, -120%) scale(.7) rotate(-20deg); opacity: 0; } }
.race-cue {
  position: absolute; left: 50%; top: 22%; z-index: 8;
  display: flex; align-items: center; padding: 1vmin 4vmin 1vmin 1vmin;
  transform: translateX(-50%);
  background: #fff; border: var(--line) solid var(--ink); border-radius: var(--wobble); box-shadow: var(--shadow);
  font-size: 9vmin; font-weight: 900; -webkit-text-stroke: 0.4vmin var(--ink);
  animation: popIn .4s cubic-bezier(.3, 1.6, .5, 1);
}
.race-cue svg { width: 14vmin; height: 14vmin; margin-right: 2vmin; }
@media (orientation: portrait) { .horn-btn { width: 16vmin; height: 16vmin; padding: 3vmin; } }
@keyframes spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
@keyframes knock { to { transform: translate(40%, -60%) rotate(80deg); opacity: 0; } }

.bg-sky { background: #E7F5FF; }

/* letters: case toggle + picture */
.case-btn {
  height: 13vmin; padding: 0 3vmin; margin: 0 1.5vmin;
  font-size: 5.5vmin; font-weight: 900;
  background: var(--yellow); border: var(--line) solid var(--ink); border-radius: 7vmin; box-shadow: var(--shadow);
}
.case-btn:active { transform: translateY(0.8vmin); box-shadow: 0 0.3vmin 0 var(--ink); }
.letter-word .word { display: flex; align-items: center; }
.word-pic { width: 10vmin; height: 10vmin; margin-right: 1.5vmin; }

/* sounds (phonics) */
.sounds { display: flex; flex-direction: column; }
.sound-bubble { padding-right: 4vmin; }
.sound-letter { font-size: 16vmin; line-height: 1; font-weight: 900; -webkit-text-stroke: 0.5vmin var(--ink); }
.sound-letter small { font-size: 11vmin; margin-left: 1vmin; }
.sound-speaker { width: 10vmin; height: 10vmin; margin-left: 3vmin; animation: bob .6s ease-in-out infinite alternate; }
.word-card { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 30vmin; width: 27vmin; }
.card-pic { width: 18vmin; height: 18vmin; }
.card-word { font-size: 5vmin; font-weight: 900; margin-top: 1vmin; }
.card-word b { color: #FF5A4E; }

/* blend (phonics) */
.bg-rose { background: #FFF1F6; }
.blend { display: flex; flex-direction: column; align-items: center; }
.blend-top { flex: 0 0 34%; display: flex; align-items: center; justify-content: center; }
.blend-pic {
  position: relative; width: 26vmin; height: 26vmin; padding: 2vmin;
  background: #fff; border: var(--line) solid var(--ink); border-radius: var(--wobble); box-shadow: var(--shadow);
}
.pic-q {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 15vmin; font-weight: 900; color: #CFCCBF;
}
.pic-img { display: block; width: 100%; height: 100%; opacity: 0; transform: scale(.4); transition: opacity .3s, transform .45s cubic-bezier(.3, 1.6, .5, 1); }
.blend-pic.reveal .pic-q { display: none; }
.blend-pic.reveal .pic-img { opacity: 1; transform: scale(1); }
.blend-penny { width: 22vmin; height: 20vmin; margin-left: 5vmin; }
.blend-word { display: flex; justify-content: space-around; width: 78vmin; max-width: 92vw; flex: 0 0 auto; margin: 1vmin 0 3vmin; }
.btile {
  width: 21vmin; height: 24vmin;
  font-size: 17vmin; line-height: 1; font-weight: 900; color: #fff; -webkit-text-stroke: 0.6vmin var(--ink);
  border: var(--line) solid var(--ink); border-radius: var(--wobble); box-shadow: var(--shadow);
  opacity: .55; animation: popIn .4s cubic-bezier(.3, 1.6, .5, 1) both;
}
.btile.lit { opacity: 1; }
.btile.glow { opacity: 1; animation: glowTile .7s ease-in-out infinite alternate; }
.btile.bounce { animation: yay .5s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes glowTile { from { transform: scale(1); } to { transform: scale(1.08) rotate(-3deg); } }
.blend-track { position: relative; width: 78vmin; max-width: 92vw; height: 14vmin; flex: 0 0 auto; opacity: .35; }
.blend-track.ready { opacity: 1; }
.track-line {
  position: absolute; left: 0; right: 5vmin; top: 50%; height: 2.2vmin; margin-top: -1.1vmin;
  background: var(--ink); border-radius: 2vmin;
}
.track-head {
  position: absolute; right: 0; top: 50%; margin-top: -4vmin;
  border-left: 7vmin solid var(--ink); border-top: 4vmin solid transparent; border-bottom: 4vmin solid transparent;
}
.knob {
  position: absolute; left: 0; top: 50%; width: 11vmin; height: 11vmin; margin: -5.5vmin 0 0 -5.5vmin;
  background: var(--yellow); border: var(--line) solid var(--ink); border-radius: 50%; box-shadow: 0 0.8vmin 0 var(--ink);
}
.blend-track.ready .knob { animation: breathe 1s ease-in-out infinite; }
.knob.back { transition: left .35s ease; }

/* rhymes */
.rhyme-word { margin-left: 3vmin; font-size: 10vmin; font-weight: 900; }
.rhyme-word b, .card-word b { -webkit-text-stroke: 0.25vmin var(--ink); }
.rhymes .card-word b { color: inherit; }

/* word families (c + at) */
.bg-mint { background: #ECFAF5; }
.families { display: flex; flex-direction: column; align-items: center; }
.fam-top { flex: 0 0 34%; display: flex; align-items: center; justify-content: center; }
.fam-pic .pic-q { display: none; }
.fam-row { display: flex; align-items: stretch; margin: 1vmin 0 3vmin; }
.fam-slot, .fam-rime {
  display: flex; align-items: center; justify-content: center;
  height: 24vmin; font-size: 17vmin; line-height: 1; font-weight: 900; color: #fff; -webkit-text-stroke: 0.6vmin var(--ink);
  border: var(--line) solid var(--ink); box-shadow: var(--shadow);
}
.fam-slot {
  width: 22vmin; border-style: dashed; border-radius: 3vmin 0 0 3vmin; background: #fff; color: #CFCCBF; -webkit-text-stroke: 0;
}
.fam-slot.filled { border-style: solid; background: #FFDD00; color: #fff; -webkit-text-stroke: 0.6vmin var(--ink); }
.fam-slot.bounce, .fam-rime.bounce { animation: yay .5s cubic-bezier(.3, 1.6, .5, 1); }
.fam-rime { padding: 0 4vmin; border-left: 0; border-radius: 0 3vmin 3vmin 0; }
.fam-choices { display: flex; justify-content: center; }
.fam-letter { margin: 0 2.5vmin; opacity: 1; }
.fam-letter.used { opacity: .45; }
@media (orientation: portrait) {
  .fam-slot, .fam-rime { height: 20vmin; font-size: 14vmin; }
  .fam-slot { width: 18vmin; }
}

/* piano song book */
.song-menu {
  position: absolute; left: 3vmin; right: 3vmin; top: 2vmin; bottom: 4vmin; z-index: 6;
  display: none; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); grid-gap: 2.5vmin;
  padding: 3vmin;
  background: var(--paper); border: var(--line) solid var(--ink); border-radius: var(--wobble); box-shadow: var(--shadow);
}
.song-menu.show { display: grid; animation: popIn .3s cubic-bezier(.3, 1.6, .5, 1); }
.song-card {
  display: flex; align-items: center; padding: 1.5vmin 2vmin; text-align: left; min-width: 0; min-height: 0; overflow: hidden;
  background: #fff; border: 0.55vmin solid var(--ink); border-radius: var(--wobble); box-shadow: 0 0.8vmin 0 var(--ink);
}
.song-card:active { transform: translateY(0.6vmin); box-shadow: 0 0.2vmin 0 var(--ink); }
.song-card.free { background: var(--yellow-pale); }
.song-icon { width: 11vmin; height: 11vmin; flex: 0 0 auto; margin-right: 2vmin; }
.song-name { font-size: 3.8vmin; font-weight: 900; line-height: 1.15; min-width: 0; overflow-wrap: break-word; }

/* ---------- SATPIN sound groups ---------- */
.sg-btn .level-num { margin-left: 1vmin; letter-spacing: .08em; }
.sg-menu { flex-direction: column; }
.sg-opt { width: auto; height: 11vmin; margin: 0.7vmin 0; padding: 0 3vmin; }
.sg-opt .level-num { font-size: 5vmin; letter-spacing: .1em; }
.newsounds {
  position: absolute; top: 4%; left: 50%; z-index: 30; width: 80vmin; max-width: 92vw;
  display: flex; flex-direction: column; align-items: center; padding: 3vmin 3vmin 4vmin;
  transform: translateX(-50%);
  background: var(--paper); border: var(--line) solid var(--ink); border-radius: var(--wobble); box-shadow: var(--shadow);
  animation: popIn .4s cubic-bezier(.3, 1.6, .5, 1);
}
.ns-title { font-size: 9vmin; font-weight: 900; margin-bottom: 2vmin; }
.ns-letters { display: flex; flex-wrap: wrap; justify-content: center; }
.ns-letter {
  width: 11vmin; height: 13vmin; margin: 0.8vmin; line-height: 12vmin; text-align: center;
  font-size: 10vmin; font-weight: 900; color: #fff; -webkit-text-stroke: 0.45vmin var(--ink);
  border: 0.55vmin solid var(--ink); border-radius: 2vmin; box-shadow: 0 0.8vmin 0 var(--ink);
  animation: popIn .4s cubic-bezier(.3, 1.6, .5, 1) both;
}
.ns-letter.bounce { animation: yay .5s cubic-bezier(.3, 1.6, .5, 1); }

/* ---------- controller highlight (D-pad + A) ---------- */
body.pad-mode #app { pointer-events: none; }
.pad-focus {
  z-index: 20;
  box-shadow: 0 0 0 1vmin #FFFFFF, 0 0 0 2.4vmin #FFDD00, 0 0 0 2.9vmin #1A1A1A !important;
  animation: padPulse .9s ease-in-out infinite alternate !important;
}
@keyframes padPulse { from { transform: scale(1); } to { transform: scale(1.06); } }

/* ---------- captions: Penny's words on screen when the device has no voice (e.g. the Switch) ---------- */
.caption {
  position: fixed; left: 50%; bottom: 3vmin; z-index: 40; max-width: 86vw;
  padding: 1.6vmin 4vmin; transform: translateX(-50%);
  font-size: 5vmin; font-weight: 900; text-align: center;
  background: #fff; border: var(--line) solid var(--ink); border-radius: var(--wobble); box-shadow: var(--shadow);
  pointer-events: none; opacity: 0; transition: opacity .2s;
}
.caption.show { opacity: 1; }

/* ---------- confetti ---------- */
.spark {
  position: fixed; width: 2.4vmin; height: 2.4vmin; margin: -1.2vmin 0 0 -1.2vmin;
  border: 0.4vmin solid var(--ink); border-radius: 0.5vmin;
  pointer-events: none; z-index: 50;
  transition: transform .9s cubic-bezier(.15, .7, .3, 1), opacity .9s ease-in;
}
.spark.round { border-radius: 50%; }

/* ---------- motion ---------- */
@keyframes sway { 0%, 100% { transform: rotate(-2deg); } 50% { transform: rotate(2deg); } }
@keyframes blink { 0%, 94%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.1); } }
@keyframes hop { 0% { transform: translateY(0); } 40% { transform: translateY(-2.4vmin); } 100% { transform: translateY(0); } }
@keyframes jump { 0%, 100% { transform: translateY(0) scale(1); } 40% { transform: translateY(-6vmin) scale(1.05); } }
@keyframes shake { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }
@keyframes wobble { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-7deg); } 40% { transform: rotate(6deg); } 60% { transform: rotate(-4deg); } 80% { transform: rotate(2deg); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 40% { transform: scale(1.25); } }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.07); } }
@keyframes bob { from { transform: translateY(0); } to { transform: translateY(-1.2vmin); } }
@keyframes glow { from { transform: scale(.85); } to { transform: scale(1.15); } }
@keyframes popIn { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes yay { 0% { transform: scale(1); } 40% { transform: scale(1.22) rotate(-6deg); } 100% { transform: scale(1); } }
@keyframes floatUp {
  0% { transform: translateY(0) scale(.6); opacity: 1; }
  100% { transform: translateY(-30vmin) scale(1.1) rotate(14deg); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .penny-inner, .big-play, .dot.now { animation: none; }
}

/* portrait tablets / phones */
@media (orientation: portrait) {
  .tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(5, minmax(0, 1fr));
    grid-gap: 3vmin; padding: 2vmin 5vmin 6vmin; min-height: 0;
  }
  .tile { min-height: 0; padding: 1vmin; }
  .tile-icon { width: 16vmin; height: 11vmin; }
  .tile-label { font-size: 4.6vmin; margin-top: .5vmin; }
  .song-menu { grid-template-columns: repeat(2, minmax(0, 1fr)); overflow-y: auto; }
  .letter-side { flex-wrap: wrap; justify-content: center; }
  .letter-penny { width: 16vmin; height: 15vmin; }
  .letter-nav { width: 100%; justify-content: center; margin-top: 1vmin; }
  .big-letter { font-size: 14vmin; }
  .big-letter small { font-size: 9vmin; }
  .letter-word .word { font-size: 6vmin; }
  .ask { flex-direction: column-reverse; }
  .ask-penny { margin: 0 0 2vmin; }
  .bubble::after { display: none; }
  .opts { flex-wrap: wrap; align-content: center; }
  .opt { margin: 2vmin; }
  .piano-stage { flex-wrap: wrap; flex-basis: 40%; }
  .letters { flex-direction: column; }
  .trace-box { max-width: 84vw; max-height: 84vw; }
  .letter-side { flex-direction: row; margin: 3vmin 0 0; }
  .num-choice { width: 20vmin; height: 20vmin; margin: 0 1.5vmin; }
}
