:root {
  color-scheme: light;
  --ink: #1f2732;
  --warm-sky: #ffe3b3;
  --card: rgba(255, 255, 255, 0.88);
  --vowel: #e74c3c;
  --vowel-dark: #c0392b;
  --consonant: #2e86de;
  --consonant-dark: #2168ad;
  --green: #69b347;
  --tile-size: clamp(54px, 11.5vw, 94px);
  font-family: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
    env(safe-area-inset-left);
  overflow-x: hidden;
  background:
    radial-gradient(circle at 15% 15%, rgba(255, 255, 255, 0.82), transparent 28%),
    linear-gradient(145deg, #ffe9c4, var(--warm-sky));
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

button {
  font: inherit;
}

.app-shell {
  width: min(100%, 1100px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: clamp(14px, 2.8vw, 30px);
  display: flex;
  flex-direction: column;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  margin-bottom: 14px;
}

.topbar h1 {
  grid-column: 2;
  text-align: center;
}

.topbar .sound-button {
  justify-self: end;
  white-space: nowrap;
}


.topbar .home-button {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
}

.topbar a:focus-visible {
  outline: 3px solid #236eb4;
  outline-offset: 4px;
}

h1 {
  margin: 0;
  font-size: clamp(24px, 4vw, 42px);
  line-height: 1;
}

.sound-button,
.success-card button {
  min-height: 56px;
  border: 2px solid rgba(31, 39, 50, 0.15);
  border-radius: 999px;
  padding: 0 22px;
  background: linear-gradient(#ffffff, #e6e6e6);
  color: var(--ink);
  font-weight: 800;
  box-shadow: 0 5px 0 rgba(31, 39, 50, 0.2);
  cursor: pointer;
  touch-action: manipulation;
}

.sound-button:active,
.success-card button:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 rgba(31, 39, 50, 0.2);
}

.game-card {
  flex: 1;
  min-height: 0;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 28px;
  padding: clamp(12px, 2vw, 24px);
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--card);
  box-shadow: 0 18px 45px rgba(95, 57, 20, 0.18);
}

.course-selector {
  width: min(100%, 470px);
  margin-bottom: 14px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
}

.course-button {
  min-height: 46px;
  border: 2px solid #b8c2ca;
  border-radius: 15px;
  background: linear-gradient(#ffffff, #e3e8ec);
  color: #53606b;
  font-weight: 900;
  box-shadow: 0 3px 0 #9aa6af;
  cursor: pointer;
  touch-action: manipulation;
}

.course-button.current {
  border-color: #2168ad;
  background: linear-gradient(#6db4ff, #2e86de);
  color: white;
  box-shadow: 0 3px 0 #174f85;
}

.course-button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #77838c;
}

.exercise-progress-header {
  width: min(100%, 760px);
  margin-bottom: 7px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: #59636d;
  font-size: 13px;
}

.exercise-progress-header > strong {
  color: var(--ink);
  font-size: 15px;
}

.progress-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px 13px;
}

.progress-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 11px;
  height: 11px;
  border: 1px solid rgba(31, 39, 50, 0.2);
  border-radius: 50%;
  display: inline-block;
}

.legend-dot.neutral {
  background: #e5e9ed;
}

.legend-dot.tried {
  background: #ffd76a;
}

.legend-dot.completed {
  background: #69b347;
}

.exercise-progress {
  width: min(100%, 760px);
  margin-bottom: 14px;
  display: grid;
  grid-template-columns: repeat(10, minmax(38px, 1fr));
  gap: 6px;
}

.exercise-step {
  min-width: 0;
  min-height: 44px;
  border: 2px solid #c9d0d7;
  border-radius: 12px;
  background: linear-gradient(#f6f7f8, #e5e9ed);
  color: #56616d;
  font-size: 16px;
  font-weight: 900;
  box-shadow: 0 3px 0 #aeb7bf;
  cursor: pointer;
  touch-action: manipulation;
}

.exercise-step.tried {
  border-color: #d6a63c;
  background: linear-gradient(#ffe796, #ffd76a);
  color: #594613;
  box-shadow: 0 3px 0 #b88d2f;
}

.exercise-step.completed {
  border-color: #5c9b3f;
  background: linear-gradient(#9be873, #69b347);
  color: #173117;
  box-shadow: 0 3px 0 #4d8435;
}

.exercise-step.current {
  border-color: #2168ad;
  outline: none;
  box-shadow: inset 0 0 0 3px #2e86de, 0 3px 0 #2168ad;
}

.exercise-step:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #8c969f;
}

.instruction-row {
  width: 100%;
  margin-top: 7px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

.word-progress {
  grid-column: 2;
  display: flex;
  gap: 6px;
}

.word-letter {
  width: clamp(42px, 7vw, 62px);
  aspect-ratio: 1;
  border: 3px solid #c9d0d7;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: #f2f4f6;
  color: #68727e;
  font-size: clamp(24px, 4vw, 38px);
  font-weight: 900;
  box-shadow: inset 0 -4px 0 rgba(31, 39, 50, 0.08);
}

.word-letter.done.vowel {
  border-color: var(--vowel-dark);
  background: var(--vowel);
  color: white;
}

.word-letter.done.consonant {
  border-color: var(--consonant-dark);
  background: var(--consonant);
  color: white;
}

.word-letter.next {
  border-color: #d5a42f;
  outline: none;
  box-shadow:
    inset 0 0 0 3px #ffd76a,
    inset 0 -4px 0 rgba(31, 39, 50, 0.08);
}

.score {
  grid-column: 3;
  justify-self: end;
  border-radius: 999px;
  padding: 9px 14px;
  background: #fff;
  font-size: clamp(14px, 2vw, 18px);
  white-space: nowrap;
}

.status {
  min-height: 1.4em;
  margin: 13px 0 10px;
  font-size: clamp(17px, 2.5vw, 23px);
  font-weight: 800;
  text-align: center;
}

.status.good {
  color: #397b22;
}

.status.try-again {
  color: #a64031;
}

.board {
  position: relative;
  width: min(100%, 650px);
  max-width: 100%;
  aspect-ratio: 1.35;
  isolation: isolate;
  overflow: visible;
  background:
    radial-gradient(circle at 28% 18%, rgba(255, 255, 255, 0.92), transparent 27%),
    radial-gradient(ellipse at 50% 62%, rgba(174, 224, 250, 0.92), rgba(229, 247, 255, 0.58) 46%, transparent 74%);
  outline: none;
  touch-action: pan-y pinch-zoom;
}

.board::before {
  content: "";
  position: absolute;
  z-index: -1;
  left: 15%;
  right: 15%;
  bottom: 1%;
  height: 14%;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(23, 37, 49, 0.3), rgba(31, 39, 50, 0.08) 64%, transparent 76%);
  filter: blur(15px);
  transform: translate(4%, 3%) skewX(-10deg);
}

.board:focus-visible {
  outline: 4px solid #ffd76a;
  outline-offset: 4px;
}

.tile {
  --face-top-light: #ffffff;
  --face-top: #e2e9ee;
  --face-left: #aebbc5;
  --face-right: #7f909d;
  position: absolute;
  width: clamp(64px, 20%, 104px);
  aspect-ratio: 1 / 0.86;
  color: var(--ink);
  transform: translateX(-50%);
  transform-origin: 50% 45%;
}

.tile-hit-area {
  position: absolute;
  inset: 0;
  z-index: 4;
  margin: 0;
  border: 0;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  background: transparent;
  cursor: default;
  touch-action: manipulation;
}

.tile.reachable .tile-hit-area {
  cursor: pointer;
}

.tile-hit-area:focus-visible {
  outline: 4px solid #ffd76a;
  outline-offset: -6px;
}

@media (hover: hover) {
  .tile.reachable:hover .tile-face--top {
    filter:
      brightness(1.08)
      drop-shadow(0 1px 0 rgba(255, 255, 255, 0.72))
      drop-shadow(0 2px 1px rgba(24, 37, 48, 0.16));
  }
}

.tile::before {
  content: "";
  position: absolute;
  z-index: 0;
  left: 8%;
  right: 4%;
  bottom: -1%;
  height: 30%;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(18, 31, 43, 0.24), rgba(18, 31, 43, 0.04) 62%, transparent 74%);
  filter: blur(3px);
  opacity: 0;
  transform: translate(7px, 5px) skewX(-10deg);
  transform-origin: center;
  pointer-events: none;
}

.tile[data-row="4"]::before {
  opacity: 0.78;
  filter: blur(4px);
}

.tile.vowel {
  --face-top-light: #ff8580;
  --face-top: var(--vowel);
  --face-left: #b83a30;
  --face-right: #8f2d26;
  color: white;
}

.tile.consonant {
  --face-top-light: #6db4ff;
  --face-top: var(--consonant);
  --face-left: #2168ad;
  --face-right: #174f85;
  color: white;
}

.tile.start {
  --face-top-light: #fff7c9;
  --face-top: #f0d766;
  --face-left: #c3a536;
  --face-right: #9b8129;
}

.tile-face {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.tile-face--top {
  z-index: 2;
  clip-path: polygon(50% 0, 100% 25%, 50% 50%, 0 25%);
  background:
    radial-gradient(circle at 27% 18%, rgba(255, 255, 255, 0.55), transparent 28%),
    linear-gradient(145deg, var(--face-top-light) 8%, var(--face-top) 72%);
  filter:
    drop-shadow(0 1px 0 rgba(255, 255, 255, 0.72))
    drop-shadow(0 2px 1px rgba(24, 37, 48, 0.16));
}

.tile-face--top::after {
  content: "";
  position: absolute;
  inset: 0;
  clip-path: inherit;
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.42), transparent 36%, rgba(15, 29, 42, 0.1) 86%);
}

.tile-face--left {
  z-index: 1;
  clip-path: polygon(0 25%, 50% 50%, 50% 100%, 0 75%);
  background: var(--face-left);
  background:
    linear-gradient(to bottom, rgba(12, 25, 36, 0.16), transparent 22%),
    linear-gradient(118deg, color-mix(in srgb, var(--face-left), white 9%), var(--face-left) 48%, color-mix(in srgb, var(--face-left), #17232d 28%));
  filter: drop-shadow(-1px 2px 1px rgba(21, 35, 47, 0.1));
}

.tile-face--right {
  z-index: 1;
  clip-path: polygon(50% 50%, 100% 25%, 100% 75%, 50% 100%);
  background: var(--face-right);
  background:
    linear-gradient(to bottom, rgba(10, 20, 29, 0.2), transparent 22%),
    linear-gradient(238deg, color-mix(in srgb, var(--face-right), #07111a 32%), var(--face-right) 58%, color-mix(in srgb, var(--face-right), white 5%));
  filter: drop-shadow(1px 2px 1px rgba(16, 28, 39, 0.12));
}

.tile-letter {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 25%;
  transform: translate(-50%, -50%);
  color: inherit;
  font-size: clamp(20px, 4vw, 34px);
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 2px 1px rgba(0, 0, 0, 0.22);
  pointer-events: none;
}

.tile.collected {
  --face-top-light: #c8f5a8;
  --face-top: #7ed957;
  --face-left: #4f9d37;
  --face-right: #357525;
}

.tile.correct-pop {
  animation: correct-pop 280ms ease-out;
}

.tile.wrong-shake {
  animation: wrong-shake 260ms ease-in-out;
}

.tile.landing .tile-face {
  animation: cube-face-landing 420ms cubic-bezier(0.2, 0.78, 0.24, 1);
}

.tile.landing .tile-letter {
  animation: cube-letter-landing 420ms cubic-bezier(0.2, 0.78, 0.24, 1);
}

.tile.landing::before {
  animation: cube-shadow-landing 420ms cubic-bezier(0.2, 0.78, 0.24, 1);
}

.avatar {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: -5%;
  width: 52%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #ffd76a;
  font-size: clamp(25px, 4vw, 42px);
  line-height: 1;
  filter: drop-shadow(0 5px 2px rgba(31, 39, 50, 0.3));
  transform: translateX(-50%);
  transition: transform 200ms ease;
  pointer-events: none;
}

.avatar.waiting {
  animation: avatar-waiting 3.6s ease-in-out infinite;
  transform-origin: 50% 85%;
}

.avatar.hopping {
  animation: none;
  transform: translate(-50%, -24px) scale(1.08);
}

.avatar.landing {
  animation: avatar-landing 420ms cubic-bezier(0.2, 0.78, 0.24, 1);
  transform-origin: 50% 88%;
}

.avatar.avatar--frog {
  top: -15%;
  width: 75%;
  aspect-ratio: 1.15;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 0;
  filter:
    drop-shadow(0 6px 2px rgba(25, 47, 31, 0.34))
    drop-shadow(0 1px 0 rgba(255, 255, 255, 0.28));
  overflow: visible;
}

.frog-body {
  position: absolute;
  z-index: 2;
  left: 16%;
  top: 18%;
  width: 68%;
  height: 61%;
  border: 2px solid #286d31;
  border-radius: 53% 53% 46% 46%;
  background:
    radial-gradient(circle at 29% 28%, rgba(228, 255, 197, 0.9) 0 5%, transparent 15%),
    linear-gradient(145deg, #a4ef70 3%, #69ca4d 48%, #35913d 100%);
  box-shadow:
    inset 4px 5px 5px rgba(224, 255, 195, 0.32),
    inset -5px -7px 5px rgba(22, 91, 36, 0.3),
    0 2px 0 rgba(30, 91, 39, 0.32);
  transition: transform 130ms ease-out;
}

.frog-body::before {
  content: "";
  position: absolute;
  z-index: 0;
  left: 18%;
  top: 43%;
  width: 64%;
  height: 47%;
  border-radius: 50% 50% 46% 46%;
  background: radial-gradient(ellipse at 42% 24%, #bdf08a, #7bce58 72%);
  box-shadow: inset 0 -3px 3px rgba(46, 128, 48, 0.2);
  opacity: 0.82;
}

.frog-body::after {
  content: "";
  position: absolute;
  z-index: 3;
  left: 18%;
  top: 8%;
  width: 24%;
  height: 12%;
  border-radius: 50%;
  background: rgba(239, 255, 218, 0.58);
  filter: blur(0.5px);
  transform: rotate(-20deg);
}

.frog-eye {
  z-index: 4;
  position: absolute;
  top: -24%;
  width: 31%;
  aspect-ratio: 1;
  border: 2px solid #235f2d;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 27%, #fff 0 22%, #f5f7db 68%, #bed28e 100%);
  box-shadow:
    inset -2px -3px 2px rgba(62, 105, 53, 0.18),
    0 2px 1px rgba(22, 77, 31, 0.28);
}

.frog-eye::after {
  content: "";
  position: absolute;
  left: 38%;
  top: 31%;
  width: 37%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #fff 0 12%, #17231a 14% 100%);
  box-shadow: 0 1px 1px rgba(14, 48, 23, 0.35);
}

.frog-eye--left {
  left: 8%;
}

.frog-eye--right {
  right: 8%;
}

.frog-mouth {
  z-index: 4;
  position: absolute;
  left: 31%;
  top: 43%;
  width: 38%;
  height: 24%;
  border-bottom: 2px solid #235f2d;
  border-radius: 50%;
}

.frog-leg {
  position: absolute;
  z-index: 1;
  bottom: 5%;
  width: 42%;
  height: 32%;
  border: 2px solid #286d31;
  border-radius: 65% 35% 60% 40%;
  background:
    radial-gradient(circle at 34% 25%, rgba(220, 255, 190, 0.58) 0 8%, transparent 24%),
    linear-gradient(145deg, #8ee166 4%, #55b647 54%, #34843a 100%);
  box-shadow:
    inset 3px 3px 3px rgba(225, 255, 200, 0.22),
    inset -4px -4px 3px rgba(24, 91, 36, 0.25),
    0 2px 1px rgba(27, 76, 34, 0.25);
  transition: transform 150ms ease-out;
}

.frog-leg::after {
  content: "";
  position: absolute;
  bottom: -14%;
  width: 52%;
  height: 34%;
  border-radius: 60%;
  border: 1px solid rgba(35, 95, 45, 0.65);
  background: linear-gradient(145deg, #9ae66f, #4da843);
  box-shadow: inset 0 -2px 2px rgba(29, 91, 38, 0.22);
}

.frog-leg--left {
  left: 6%;
  transform: rotate(17deg);
  transform-origin: 83% 30%;
}

.frog-leg--left::after {
  left: -9%;
  transform: rotate(-10deg);
}

.frog-leg--right {
  right: 6%;
  transform: rotate(-17deg);
  transform-origin: 17% 30%;
}

.frog-leg--right::after {
  right: -9%;
  transform: rotate(10deg);
}

.avatar--frog.hopping .frog-body {
  transform: translateY(-3px) scale(0.98, 1.04);
}

.avatar--frog.hopping .frog-leg--left {
  transform: rotate(-8deg) scale(1.04, 0.94);
}

.avatar--frog.hopping .frog-leg--right {
  transform: rotate(8deg) scale(1.04, 0.94);
}

.avatar.avatar--bird {
  top: -17%;
  width: 76%;
  aspect-ratio: 1.04;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 0;
  filter:
    drop-shadow(0 6px 2px rgba(17, 55, 67, 0.34))
    drop-shadow(0 1px 0 rgba(255, 255, 255, 0.3));
  overflow: visible;
}

.bird-body {
  position: absolute;
  z-index: 3;
  left: 19%;
  top: 9%;
  width: 62%;
  height: 69%;
  border: 2px solid #176272;
  border-radius: 49% 49% 53% 53%;
  background:
    radial-gradient(circle at 28% 23%, rgba(224, 255, 255, 0.88) 0 5%, transparent 16%),
    linear-gradient(145deg, #7de8df 3%, #38b7c3 48%, #197e9c 100%);
  box-shadow:
    inset 4px 5px 5px rgba(211, 255, 251, 0.3),
    inset -5px -7px 5px rgba(8, 80, 108, 0.3),
    0 2px 0 rgba(13, 82, 99, 0.34);
  transition: transform 170ms ease-out;
}

.bird-body::before {
  content: "";
  position: absolute;
  z-index: 0;
  left: 19%;
  top: 51%;
  width: 62%;
  height: 42%;
  border-radius: 50% 50% 48% 48%;
  background: radial-gradient(ellipse at 42% 24%, #d8fae9, #91ddcf 72%);
  box-shadow: inset 0 -3px 3px rgba(21, 118, 126, 0.2);
  opacity: 0.9;
}

.bird-body::after {
  content: "";
  position: absolute;
  z-index: 1;
  left: 18%;
  top: 8%;
  width: 25%;
  height: 12%;
  border-radius: 50%;
  background: rgba(235, 255, 255, 0.62);
  filter: blur(0.5px);
  transform: rotate(-20deg);
}

.bird-eye {
  z-index: 3;
  position: absolute;
  top: 16%;
  width: 24%;
  aspect-ratio: 1;
  border: 2px solid #176272;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 27%, #fff 0 23%, #f5f8e9 70%, #b9d8ce 100%);
  box-shadow:
    inset -2px -3px 2px rgba(43, 102, 103, 0.2),
    0 2px 1px rgba(9, 73, 87, 0.3);
}

.bird-eye::after {
  content: "";
  position: absolute;
  left: 39%;
  top: 31%;
  width: 38%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #fff 0 12%, #17252a 14% 100%);
  box-shadow: 0 1px 1px rgba(8, 56, 68, 0.34);
}

.bird-eye--left {
  left: 15%;
}

.bird-eye--right {
  right: 15%;
}

.bird-beak {
  position: absolute;
  z-index: 4;
  left: 37%;
  top: 42%;
  width: 26%;
  height: 23%;
  clip-path: polygon(50% 100%, 0 0, 100% 0);
  background: linear-gradient(145deg, #ffd45b 3%, #f4a72a 54%, #ca7117 100%);
  filter:
    drop-shadow(0 2px 0 #99510e)
    drop-shadow(1px 1px 1px rgba(83, 50, 10, 0.26));
}

.bird-beak::after {
  content: "";
  position: absolute;
  left: 18%;
  top: 12%;
  width: 43%;
  height: 18%;
  border-radius: 50%;
  background: rgba(255, 244, 169, 0.68);
  transform: rotate(10deg);
}

.bird-wing {
  position: absolute;
  z-index: 2;
  top: 29%;
  width: 48%;
  height: 38%;
  border: 2px solid #176272;
  background:
    radial-gradient(circle at 30% 24%, rgba(225, 255, 251, 0.66) 0 7%, transparent 24%),
    linear-gradient(145deg, #9af2e7 3%, #43bfca 52%, #2185a1 100%);
  box-shadow:
    inset 3px 3px 3px rgba(220, 255, 252, 0.24),
    inset -4px -4px 3px rgba(8, 82, 106, 0.25),
    0 2px 1px rgba(10, 72, 87, 0.24);
  transition: transform 130ms ease-out;
}

.bird-wing::after {
  content: "";
  position: absolute;
  left: 18%;
  right: 11%;
  bottom: 12%;
  height: 24%;
  border-bottom: 2px solid rgba(18, 103, 121, 0.48);
  border-radius: 50%;
  box-shadow: 0 3px 0 -1px rgba(213, 255, 249, 0.26);
}

.bird-wing--left {
  left: -5%;
  border-radius: 75% 25% 65% 35%;
  transform: rotate(12deg);
  transform-origin: 91% 36%;
}

.bird-wing--right {
  right: -5%;
  border-radius: 25% 75% 35% 65%;
  transform: rotate(-12deg);
  transform-origin: 9% 36%;
}

.bird-tail {
  position: absolute;
  z-index: 0;
  left: 35%;
  bottom: 1%;
  width: 30%;
  height: 31%;
  border: 2px solid #165d70;
  border-radius: 25% 25% 65% 65%;
  background:
    linear-gradient(90deg, transparent 46%, rgba(13, 82, 105, 0.38) 48% 52%, transparent 54%),
    linear-gradient(145deg, #54c8cf, #1d7f9b);
  box-shadow: inset -3px -4px 3px rgba(8, 67, 92, 0.25);
}

.bird-leg {
  position: absolute;
  z-index: 1;
  top: 66%;
  width: 6%;
  height: 30%;
  border-radius: 999px;
  border: 1px solid #aa6518;
  background: linear-gradient(90deg, #ffc34c, #e79524 62%, #b96516);
  box-shadow: inset 1px 0 1px rgba(255, 232, 142, 0.55);
  transition: transform 160ms ease-out;
}

.bird-leg::after {
  content: "";
  position: absolute;
  bottom: -2%;
  left: -115%;
  width: 250%;
  height: 20%;
  border-radius: 999px;
  border: 1px solid rgba(158, 88, 14, 0.55);
  background: linear-gradient(#ffc755, #d9861e);
  box-shadow: 0 1px 1px rgba(108, 63, 14, 0.28);
}

.bird-leg--left {
  left: 38%;
  transform: rotate(8deg);
  transform-origin: top;
}

.bird-leg--right {
  right: 38%;
  transform: rotate(-8deg);
  transform-origin: top;
}

.avatar--bird.hopping .bird-body {
  transform: translateY(-3px) scale(0.98, 1.03);
}

.avatar--bird.hopping .bird-wing--left {
  animation: bird-flap-left 110ms ease-in-out infinite alternate;
}

.avatar--bird.hopping .bird-wing--right {
  animation: bird-flap-right 110ms ease-in-out infinite alternate;
}

.avatar--bird.hopping .bird-leg--left {
  transform: rotate(-24deg) scaleY(0.92);
}

.avatar--bird.hopping .bird-leg--right {
  transform: rotate(24deg) scaleY(0.92);
}

@keyframes bird-flap-left {
  from {
    transform: rotate(-18deg) scale(1, 0.94);
  }
  to {
    transform: rotate(58deg) scale(0.97, 1.08);
  }
}

@keyframes bird-flap-right {
  from {
    transform: rotate(18deg) scale(1, 0.94);
  }
  to {
    transform: rotate(-58deg) scale(0.97, 1.08);
  }
}

@keyframes avatar-waiting {
  0%,
  11%,
  25%,
  58%,
  72%,
  100% {
    transform: translateX(-50%) translateY(0) rotate(0deg) scale(1);
  }

  15% {
    transform: translateX(-50%) translateY(-8px) rotate(-7deg) scale(1.06);
  }

  20% {
    transform: translateX(-50%) translateY(-2px) rotate(5deg) scale(1.02);
  }

  62% {
    transform: translateX(-50%) translateY(-5px) rotate(6deg) scale(1.04);
  }

  67% {
    transform: translateX(-50%) translateY(-1px) rotate(-4deg) scale(1.01);
  }
}

.direction-pad {
  margin-top: 15px;
  display: grid;
  grid-template-columns: repeat(3, 58px);
  grid-template-rows: repeat(3, 56px);
  gap: 8px;
}

.direction-pad button {
  --arrow-rotation: 0deg;
  position: relative;
  display: grid;
  place-items: center;
  width: 58px;
  height: 56px;
  border: 3px solid #afbbc5;
  border-radius: 18px;
  padding: 0;
  background: linear-gradient(#ffffff 4%, #eef2f5 58%, #d8dee3 100%);
  box-shadow:
    inset 0 2px 1px rgba(255, 255, 255, 0.92),
    0 6px 0 #87949e;
  cursor: pointer;
  touch-action: manipulation;
}

.direction-pad button[data-move-direction]::before {
  content: "";
  width: 38px;
  height: 38px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 44 44'%3E%3Cdefs%3E%3ClinearGradient id='b' x1='0' y1='0' x2='1' y2='1'%3E%3Cstop offset='0' stop-color='%23b8dcf3'/%3E%3Cstop offset='.46' stop-color='%237aa8c8'/%3E%3Cstop offset='1' stop-color='%23456f8f'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect x='2' y='2' width='40' height='40' rx='9' fill='url(%23b)' stroke='%23587b98' stroke-width='2'/%3E%3Cpath d='M7 7h22l-6 6 14 14-10 10-14-14-6 6z' fill='white'/%3E%3Cpath d='M7 7h22l-2.5 2.5H10v16.5L7 29z' fill='%23fff' opacity='.55'/%3E%3C/svg%3E") center / contain no-repeat;
  filter: drop-shadow(0 2px 1px rgba(31, 51, 68, 0.24));
  transform: rotate(var(--arrow-rotation));
  pointer-events: none;
}

.direction-pad .word-cue-button {
  border-radius: 50%;
  border-color: #d6a63c;
  background: radial-gradient(circle at 34% 28%, #fffbd8 0 16%, #ffd76a 48%, #e5aa20 100%);
  box-shadow:
    inset 0 2px 2px rgba(255, 255, 255, 0.9),
    inset 0 -4px 4px rgba(160, 106, 12, 0.2),
    0 6px 0 #b88d2f;
}

.word-cue-button span {
  font-size: 25px;
  line-height: 1;
  filter: drop-shadow(0 2px 1px rgba(77, 51, 8, 0.24));
  pointer-events: none;
}

.direction-pad button:disabled {
  opacity: 0.38;
  cursor: default;
  filter: saturate(0.45);
}

.direction-pad button:focus-visible {
  outline: 4px solid #2e86de;
  outline-offset: 3px;
}

@media (hover: hover) {
  .direction-pad button:not(:disabled):hover {
    background-color: #fff;
    filter: brightness(1.05);
  }
}

.direction-pad button:not(:disabled):active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #87949e;
}

.direction-pad .word-cue-button:active {
  box-shadow: 0 2px 0 #b88d2f;
}

.direction-pad [data-move-direction="up-left"] {
  --arrow-rotation: 0deg;
}

.direction-pad [data-move-direction="up"] {
  --arrow-rotation: 45deg;
}

.direction-pad [data-move-direction="up-right"] {
  --arrow-rotation: 90deg;
}

.direction-pad [data-move-direction="left"] {
  --arrow-rotation: -45deg;
}

.direction-pad [data-move-direction="right"] {
  --arrow-rotation: 135deg;
}

.direction-pad [data-move-direction="down-left"] {
  --arrow-rotation: -90deg;
}

.direction-pad [data-move-direction="down"] {
  --arrow-rotation: -135deg;
}

.direction-pad [data-move-direction="down-right"] {
  --arrow-rotation: 180deg;
}

.help {
  margin: 12px 0 0;
  color: #59636d;
  font-size: 14px;
  text-align: center;
}

.success {
  position: fixed;
  inset: 0;
  z-index: 10;
  padding: 20px;
  display: grid;
  place-items: center;
  background: rgba(31, 39, 50, 0.62);
}

.success[hidden] {
  display: none;
}

.success-card {
  width: min(92vw, 440px);
  border: 4px solid white;
  border-radius: 30px;
  padding: 28px;
  background: #fff8dc;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.success-star {
  color: #e4aa18;
  font-size: 72px;
  line-height: 1;
}

.success-card h2 {
  margin: 8px 0;
  font-size: 32px;
}

.success-card p {
  margin: 0 0 20px;
  font-size: 18px;
}

.success-card button {
  min-width: 170px;
  background: linear-gradient(#9be873, var(--green));
  color: #173117;
}

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

.success-card #play-again {
  background: linear-gradient(#ffffff, #e2e7eb);
  color: var(--ink);
}

@keyframes correct-pop {
  50% {
    transform: translate(-50%, -11px) scale(1.08);
  }
}

@keyframes cube-face-landing {
  0%,
  12%,
  100% {
    transform: translateY(0);
  }
  42% {
    transform: translateY(8px);
  }
  67% {
    transform: translateY(-3px);
  }
  84% {
    transform: translateY(1px);
  }
}

@keyframes cube-letter-landing {
  0%,
  12%,
  100% {
    transform: translate(-50%, -50%) scale(1);
  }
  42% {
    transform: translate(-50%, -50%) translateY(8px) scale(1);
  }
  67% {
    transform: translate(-50%, -50%) translateY(-3px) scale(1);
  }
  84% {
    transform: translate(-50%, -50%) translateY(1px) scale(1);
  }
}

@keyframes cube-shadow-landing {
  0%,
  12%,
  100% {
    opacity: 0.18;
    transform: translate(7px, 5px) skewX(-10deg) scale(1);
  }
  42% {
    opacity: 0.5;
    transform: translate(7px, 7px) skewX(-10deg) scale(1.12, 0.76);
  }
  67% {
    opacity: 0.1;
    transform: translate(7px, 4px) skewX(-10deg) scale(0.94, 1.04);
  }
  84% {
    opacity: 0.22;
    transform: translate(7px, 6px) skewX(-10deg) scale(1.02, 0.96);
  }
}

@keyframes avatar-landing {
  0%,
  12%,
  100% {
    transform: translateX(-50%) scale(1);
  }
  42% {
    transform: translateX(-50%) translateY(8px) scale(1.07, 0.91);
  }
  67% {
    transform: translateX(-50%) translateY(-3px) scale(0.97, 1.04);
  }
  84% {
    transform: translateX(-50%) translateY(1px) scale(1.015, 0.985);
  }
}

@keyframes wrong-shake {
  25%,
  75% {
    transform: translate(calc(-50% - 6px), -3px);
  }
  50% {
    transform: translate(calc(-50% + 6px), -3px);
  }
}

@media (orientation: portrait), (max-width: 700px) {
  .app-shell {
    padding: 8px;
  }

  .topbar {
    align-items: center;
    gap: 10px;
    margin-bottom: 7px;
  }

  h1 {
    font-size: clamp(22px, 5vw, 34px);
  }

  .sound-button {
    min-height: 44px;
    padding: 0 12px;
    font-size: 13px;
  }

  .game-card {
    border-radius: 20px;
    padding: 8px 6px;
  }

  .course-selector {
    margin-bottom: 8px;
  }

  .course-button {
    min-height: 40px;
  }

  .exercise-progress-header {
    margin-bottom: 4px;
    gap: 8px;
    font-size: 11px;
  }

  .exercise-progress {
    margin-bottom: 7px;
    gap: 5px;
  }

  .word-progress {
    gap: 5px;
  }

  .exercise-step {
    min-height: 38px;
    border-radius: 10px;
    font-size: 14px;
  }

  .word-letter {
    width: clamp(38px, 8vw, 52px);
    border-radius: 13px;
    font-size: clamp(22px, 5vw, 32px);
  }

  .instruction-row {
    margin-top: 8px;
  }

  .score {
    padding: 7px 11px;
  }

  .status {
    margin: 7px 0 4px;
    font-size: clamp(16px, 3.2vw, 20px);
  }

  .board {
    width: min(100%, 520px);
  }

  .direction-pad {
    margin-top: 8px;
    grid-template-columns: repeat(3, 52px);
    grid-template-rows: repeat(3, 50px);
    gap: 7px;
  }

  .direction-pad button {
    width: 52px;
    height: 50px;
    border-radius: 16px;
  }

  .direction-pad button[data-move-direction]::before {
    width: 34px;
    height: 34px;
  }

  .help {
    margin-top: 6px;
    font-size: 12px;
  }
}

@media (max-width: 520px) {
  .topbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar h1 {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .topbar .sound-button {
    grid-column: 2;
    grid-row: 2;
    justify-self: end;
  }

  .topbar .home-button {
    grid-column: 1;
    justify-self: start;
  }

  .progress-legend {
    gap: 4px 8px;
  }

  .exercise-progress {
    grid-template-columns: repeat(5, minmax(40px, 1fr));
  }
}

@media (orientation: landscape) and (min-width: 860px) {
  .app-shell {
    padding: 7px 12px;
  }

  .topbar {
    margin-bottom: 5px;
  }

  h1 {
    font-size: clamp(24px, 3vw, 34px);
  }

  .sound-button {
    min-height: 44px;
    padding: 0 16px;
    font-size: 14px;
  }

  .game-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(460px, 520px) minmax(0, 1fr);
    grid-template-rows: auto auto auto auto auto 1fr auto;
    column-gap: 12px;
    border-radius: 22px;
    padding: 7px 10px;
  }

  .course-selector,
  .exercise-progress-header,
  .exercise-progress,
  .instruction-row,
  .status {
    grid-column: 1 / 4;
  }

  .course-selector {
    grid-row: 1;
    justify-self: center;
    margin-bottom: 6px;
  }

  .instruction-row {
    margin-top: 7px;
  }

  .course-button {
    min-height: 38px;
  }

  .exercise-progress-header {
    grid-row: 2;
    justify-self: center;
    margin-bottom: 3px;
  }

  .exercise-progress {
    grid-row: 3;
    justify-self: center;
    margin-bottom: 6px;
  }

  .exercise-step {
    min-height: 36px;
  }

  .word-letter {
    width: 44px;
    border-radius: 12px;
    font-size: 27px;
  }

  .score {
    padding: 7px 11px;
  }

  .instruction-row {
    grid-row: 4;
  }

  .status {
    grid-row: 5;
    margin: 5px 0 2px;
    font-size: 18px;
  }

  .board {
    grid-column: 2;
    grid-row: 6;
    width: 100%;
    min-width: 0;
  }

  .direction-pad {
    grid-column: 3;
    grid-row: 6;
    align-self: center;
    justify-self: center;
    margin-top: 0;
  }

  .help {
    grid-column: 3;
    grid-row: 7;
    align-self: start;
    justify-self: center;
    margin-top: 5px;
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
  }

  .avatar.waiting {
    animation: none !important;
  }
}

/* 3D presentation: existing hit buttons and game logic are retained. */
.board--3d { background:radial-gradient(ellipse at 50% 65%,#e8f3e9,transparent 72%); }
.board--3d::before,.board--3d .tile::before,.board--3d .tile-face,.board--3d .avatar { display:none; }
.avahop-3d-canvas { position:absolute;inset:0;width:100%;height:100%;pointer-events:none; }
.board--3d .tile { transform:translate(-50%,-50%);aspect-ratio:auto;color:white;animation:none!important; }
.board--3d .tile-letter { top:50%;font-size:clamp(16px,3.1vw,25px);animation:none!important; }
.board--3d .tile-hit-area { clip-path:polygon(50% 0,100% 50%,50% 100%,0 50%); }
.board--3d .tile-hit-area:focus-visible { background:#ffffff65;outline:none; }

/* Bring the board closer to the prompt while preserving canvas hop clearance. */
.board--3d { margin-top:-28px; }

/* Explicit button dimensions also cover the full cube top in Firefox.
   Empty absolute buttons must not rely on inset sizing alone. */
.board--3d .tile { pointer-events:none; }
.board--3d .tile-hit-area {
  display:block;
  width:100%;
  height:100%;
  min-width:0;
  min-height:0;
  box-sizing:border-box;
  pointer-events:auto;
}
.board--3d .tile-hit-area:disabled { pointer-events:none; }

/* Landscape tablets: reserve the full pad width and include safe-area padding
   in the viewport budget instead of adding it below a full-height shell. */
.app-shell {
  min-height:calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}
@media (orientation:landscape) and (min-width:860px) {
  .game-card {
    grid-template-columns:minmax(190px,1fr) minmax(0,520px) minmax(190px,1fr);
    grid-template-rows:repeat(7,auto);
    align-content:start;
    column-gap:12px;
  }
  .board--3d { margin-top:-40px; }
  .direction-pad {
    width:190px;
    grid-template-columns:repeat(3,58px);
    grid-template-rows:repeat(3,56px);
    gap:8px;
    margin-bottom:8px;
  }
  .direction-pad button { width:58px;height:56px;min-width:58px; }
  .help {
    grid-column:1 / -1;
    grid-row:7;
    justify-self:center;
    margin:0 0 8px;
    max-width:none;
    text-align:center;
  }
}
