@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 700 1000;
  font-display: swap;
  src: url("fonts/nunito-latin.woff2") format("woff2");
}

:root {
  --pink: #ffb8cc;
  --deep-pink: #f0618c;
  --orange: #ff8c26;
  --blue: #599ef2;
  --red: #eb474d;
  --mint: #85dbc2;
  --ink: #3d333d;
  --grey: #b8b3bd;
  --cream: #fffaf5;
  --font: "Nunito", ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
}

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

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  font-weight: 800;
  color: var(--ink);
  background: linear-gradient(180deg, #fff2f7 0%, #edf5ff 100%);
  background-attachment: fixed;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

#app { position: fixed; inset: 0; }

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  animation: screenIn 0.25s ease-out;
}
@keyframes screenIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Buttons ---------- */
button { font-family: var(--font); cursor: pointer; border: 0; background: none; padding: 0; }

.kbtn {
  color: #fff;
  font-weight: 900;
  font-size: 22px;
  letter-spacing: 1.5px;
  padding: 12px 24px;
  border-radius: 999px;
  background: var(--c, var(--deep-pink));
  border: 3px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 5px 8px color-mix(in srgb, var(--c, var(--deep-pink)) 45%, transparent);
  transition: transform 0.2s cubic-bezier(0.3, 1.6, 0.5, 1);
  white-space: nowrap;
}
.kbtn.wide { font-size: 34px; padding: 20px 56px; }
.kbtn:active, .kbtn.pressed { transform: scale(0.92); }
.kbtn:focus-visible, .pill-btn:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }

.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  color: var(--c, var(--deep-pink));
  font-weight: 900;
  font-size: 15px;
  padding: 9px 16px;
  border-radius: 999px;
  box-shadow: 0 3px 5px rgba(0, 0, 0, 0.12);
}
.pill-btn svg { width: 18px; height: 18px; fill: currentColor; }
.pill-btn.icon { padding: 7px 12px; min-width: 38px; justify-content: center; }
.pill-btn.off { color: var(--grey); }

/* ---------- Cat ---------- */
.cat { overflow: visible; display: block; }
.cat.bob { animation: bob 2.8s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes bob {
  0%, 100% { transform: translateY(1.5%) rotate(-3.5deg); }
  50% { transform: translateY(-1.5%) rotate(3.5deg); }
}
.cat .eye {
  transform-box: fill-box;
  transform-origin: center;
  animation: blink 4s infinite;
}
@keyframes blink {
  0%, 93%, 100% { transform: scaleY(1); }
  96% { transform: scaleY(0.1); }
}

.mother { position: relative; transform-origin: 50% 100%; animation: breathe 3.2s ease-in-out infinite; }
.mother > * { position: absolute; }
.mother .m-tail {
  background: #fff;
  border-style: solid;
  border-color: rgba(61, 51, 61, 0.7);
  border-radius: 999px;
  transform-origin: 50% 100%;
  animation: tail 1.8s ease-in-out infinite;
}
.mother .m-body {
  background: #fff;
  border-style: solid;
  border-color: rgba(61, 51, 61, 0.7);
}
.mother .m-paw {
  background: #fff;
  border-style: solid;
  border-color: rgba(61, 51, 61, 0.6);
  border-radius: 50%;
}
@keyframes breathe { 0%, 100% { transform: scale(0.98); } 50% { transform: scale(1.03); } }
@keyframes tail { 0%, 100% { transform: rotate(52deg); } 50% { transform: rotate(28deg); } }

/* ---------- Home ---------- */
.home { align-items: center; overflow: auto; }
.home h1 {
  margin: 30px 0 0;
  font-weight: 900;
  font-size: clamp(34px, 7vw, 76px);
  letter-spacing: 0.08em;
  color: var(--deep-pink);
  text-shadow: 3px 3px 0 #fff, 0 6px 10px rgba(255, 184, 204, 0.6);
  text-align: center;
  line-height: 1.1;
}
.home .stage {
  position: relative;
  width: 420px;
  max-width: 100%;
  height: 340px;
  margin: auto 0;
  flex: none;
}
.home .stage .cat-wrap { position: absolute; left: 50%; top: calc(50% - 40px); transform: translate(-50%, -50%); }
.wiggle {
  position: absolute;
  left: 50%;
  top: calc(50% + 110px);
  transform: translate(-50%, -50%);
  display: flex;
  gap: 14px;
}
.wiggle .tile {
  width: 66px;
  height: 66px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 44px;
  font-weight: 900;
  border-radius: 18px;
  background: var(--tc);
  border: 3px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 5px rgba(0, 0, 0, 0.18);
  animation: wiggle var(--dur) ease-in-out infinite alternate;
  --a: 8deg; --y: -7px;
}
.wiggle .tile:nth-child(even) { --a: -8deg; --y: 7px; }
@keyframes wiggle {
  from { transform: rotate(calc(var(--a) * -1)) translateY(calc(var(--y) * -1)); }
  to { transform: rotate(var(--a)) translateY(var(--y)); }
}
.home .start-wrap { margin-bottom: 18px; flex: none; }
.intro {
  max-width: 560px;
  margin: 0 20px 52px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
  color: #8f8a96;
  flex: none;
}
.kb-note {
  display: none;
  background: #fff;
  color: var(--deep-pink);
  border-radius: 14px;
  padding: 10px 16px;
  margin: 12px 20px 0;
  font-size: 14px;
  text-align: center;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
}
@media (pointer: coarse) { .kb-note { display: block; } }

/* ---------- Menu ---------- */
.menu { overflow: auto; }
.menu-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 26px 8px;
}
.menu-top h2 {
  margin: 0;
  font-size: clamp(18px, 3vw, 26px);
  letter-spacing: 2px;
  font-weight: 900;
  color: var(--deep-pink);
}
.menu-top .ghost { visibility: hidden; }
.menu-rows { display: flex; flex-direction: column; gap: 18px; padding: 10px 26px 24px; margin: auto 0; }
.level-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-items: center;
  justify-items: center;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 28px;
  border: 3px solid color-mix(in srgb, var(--c) 45%, transparent);
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.08);
}
.level-row .lv-title { text-align: center; }
.level-row .lv-title b { display: block; font-size: clamp(24px, 3.2vw, 36px); font-weight: 900; letter-spacing: 2px; color: var(--c); }
.level-row .lv-title span { font-size: 14px; font-weight: 700; color: var(--grey); }
.level-row .kbtn { font-size: clamp(14px, 1.9vw, 22px); }
.cat-cell { height: 125px; display: grid; place-items: center; }

/* ---------- Practice ---------- */
.p-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 22px 0;
}
.p-left, .p-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.p-right { gap: 7px; }
.p-mid { text-align: center; }
.p-title { font-size: 22px; font-weight: 900; letter-spacing: 1.2px; color: var(--c); }
.p-finger { display: flex; justify-content: center; align-items: center; gap: 6px; min-height: 16px; font-size: 12px; font-weight: 900; letter-spacing: 0.8px; color: rgba(61, 51, 61, 0.65); }
.p-finger i { width: 11px; height: 11px; border-radius: 50%; border: 1.5px solid #fff; background: var(--fc); }

.mpill {
  display: flex; flex-direction: column; align-items: center;
  min-width: 62px; padding: 6px 9px;
  background: #fff; border-radius: 999px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.mpill small { font-size: 10px; font-weight: 900; letter-spacing: 0.8px; color: var(--grey); line-height: 1.1; }
.mpill b { font-size: 20px; font-weight: 900; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--c); }
.spill {
  display: flex; align-items: center; gap: 5px;
  padding: 7px 10px; background: #fff; border-radius: 999px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  font-size: 17px; font-weight: 900;
}
.spill svg { width: 20px; height: 20px; fill: var(--c); }

.carousel { position: relative; flex: 1; min-height: 150px; overflow: hidden; }
.carousel .c-cat { position: absolute; left: 70px; top: 50%; transform: translate(-50%, -50%); opacity: 0.9; }
.w {
  position: absolute; left: 50%; top: 50%;
  white-space: nowrap;
  transition: transform 0.42s cubic-bezier(0.34, 1.35, 0.5, 1), opacity 0.3s;
  will-change: transform;
}
.wi {
  padding: 18px 34px;
  font-size: 88px;
  font-weight: 900;
  letter-spacing: 6px;
  line-height: 1.15;
  border-radius: 30px;
  border: 4px solid transparent;
  background: transparent;
  transition: background 0.25s, box-shadow 0.25s, border-color 0.25s;
}
.w.cur .wi {
  background: #fff;
  border-color: var(--c);
  box-shadow: 0 6px 14px color-mix(in srgb, var(--c) 35%, transparent);
}
.w.cur.wrong .wi {
  border-color: var(--red);
  box-shadow: 0 6px 14px rgba(235, 71, 77, 0.35);
  animation: shake 0.3s linear;
}
@keyframes shake {
  0%, 100% { transform: translateX(0) scale(1.07); }
  20% { transform: translateX(-10px) scale(1.07); }
  40% { transform: translateX(10px) scale(1.07); }
  60% { transform: translateX(-10px) scale(1.07); }
  80% { transform: translateX(10px) scale(1.07); }
}

.legend { display: flex; justify-content: center; align-items: center; gap: 42px; height: 124px; padding-top: 8px; margin-bottom: 14px; }
.legend.hidden { display: none; }
.hand-box { width: 175px; height: 110px; display: grid; place-items: center; }
.hand { transform: scale(2.2); position: relative; display: flex; align-items: flex-end; gap: 5px; padding: 7px 10px 15px; background: rgba(255, 255, 255, 0.8); border-radius: 14px; }
.hand .lbl { position: absolute; left: 0; right: 0; bottom: 3px; text-align: center; font-size: 9px; font-weight: 900; letter-spacing: 1px; color: var(--grey); }
.bar {
  width: 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--fc) 30%, transparent);
  border: 1px solid rgba(255, 255, 255, 0.9);
  transform-origin: 50% 100%;
  transition: transform 0.25s cubic-bezier(0.3, 1.6, 0.5, 1), background 0.2s, box-shadow 0.2s;
}
.bar.lit { background: var(--fc); border-width: 2.5px; transform: scale(1.2); box-shadow: 0 0 6px var(--fc); }
.bar.thumb { width: 12px; height: 15px; }
.hand.left .bar.thumb { transform: rotate(28deg); margin-left: 3px; }
.hand.right .bar.thumb { transform: rotate(-28deg); margin-right: 3px; }
.hand.left .bar.thumb.lit { transform: rotate(28deg) scale(1.2); }
.hand.right .bar.thumb.lit { transform: rotate(-28deg) scale(1.2); }
.legend-mid { width: 190px; text-align: center; }
.legend-mid .t { font-size: 14px; font-weight: 900; letter-spacing: 1.1px; color: var(--grey); }
.legend-mid .h { font-size: 16px; font-weight: 900; margin-top: 4px; min-height: 22px; color: var(--fc); }

.keyboard { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 8px; height: 250px; margin: 0 auto 16px; width: calc(100% - 32px); max-width: 900px; }
.krow { display: flex; gap: 8px; justify-content: center; }
.key {
  display: grid; place-items: center;
  font-weight: 900; color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--grey);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.14);
  transition: transform 0.12s ease-out, background 0.12s;
}
.keyboard.fing .key { background: var(--fc55); border-color: var(--fc8); }
.keyboard:not(.fing) .key.hint { background: rgba(255, 184, 204, 0.35); border: 3px solid #fff; transform: scale(1.06); }
.keyboard.fing .key.hint { background: var(--fc); color: #fff; border: 3px solid #fff; transform: scale(1.06); box-shadow: 0 0 8px var(--fc); }
.key.down, .keyboard .key.down { background: var(--orange); color: #fff; border: 3px solid var(--orange); transform: scale(0.93); box-shadow: 0 2px 3px rgba(0, 0, 0, 0.14); }

/* Short windows: shrink the finger guide instead of hiding it */
@media (max-height: 800px) {
  .legend { height: 84px; gap: 28px; padding-top: 0; margin-bottom: 8px; }
  .hand-box { width: 130px; height: 80px; }
  .hand { transform: scale(1.5); }
  .legend-mid { width: 150px; }
  .legend-mid .t { font-size: 12px; }
  .legend-mid .h { font-size: 14px; margin-top: 2px; }
}
@media (max-height: 660px) {
  .legend { height: 66px; margin-bottom: 4px; }
  .hand-box { width: 104px; height: 64px; }
  .hand { transform: scale(1.15); }
}
@media (max-height: 560px) {
  .legend { display: none; }
  .keyboard { display: none; }
}

/* ---------- Game ---------- */
.game { overflow: hidden; }
.g-hud { position: absolute; top: 14px; left: 22px; right: 22px; display: flex; align-items: flex-start; justify-content: space-between; z-index: 15; pointer-events: none; }
.g-hud > * { pointer-events: auto; }
.g-left { display: flex; gap: 10px; flex: 1; }
.g-right { flex: 1; display: flex; justify-content: flex-end; }
.g-score {
  text-align: center; padding: 8px 30px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 22px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
}
.g-score small { display: block; font-size: 13px; letter-spacing: 2px; color: var(--grey); font-weight: 900; line-height: 1.2; }
.g-score b { display: block; font-size: 40px; line-height: 1.1; color: var(--deep-pink); font-weight: 900; transition: transform 0.2s cubic-bezier(0.3, 1.6, 0.5, 1); }
.g-score b.pop { transform: scale(1.22); }
.g-time {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 18px; background: rgba(255, 255, 255, 0.92);
  border-radius: 999px; box-shadow: 0 3px 6px rgba(0, 0, 0, 0.12);
  font-size: 28px; font-weight: 900; font-variant-numeric: tabular-nums;
  height: fit-content;
}
.g-time svg { width: 24px; height: 24px; fill: currentColor; }
.g-time.low { color: var(--red); }
.g-mother { position: absolute; left: 50%; bottom: -2px; transform: translateX(-50%); z-index: 2; }
.kitten {
  position: absolute; left: 0; top: 0;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  will-change: transform; z-index: 3;
}
.kitten .kw {
  display: flex; padding: 5px 10px; background: #fff;
  border-radius: 999px; border: 2px solid rgba(184, 179, 189, 0.6);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
  font-size: 22px; font-weight: 900;
}
.kitten.active .kw { border: 3px solid var(--orange); }
.kitten .kw span.done { color: var(--orange); }
.kitten.pop { animation: kpop 0.18s ease-out forwards; }
@keyframes kpop { to { opacity: 0; scale: 1.5; } }

.g-overlay {
  position: absolute; inset: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  background: rgba(255, 255, 255, 0.65);
  text-align: center; padding: 20px;
}
.g-overlay h2 { margin: 0; font-size: clamp(28px, 4vw, 40px); letter-spacing: 3px; font-weight: 900; color: var(--c); }
.g-overlay p { margin: 0; font-size: 19px; font-weight: 700; color: #8f8a96; }
.over-card {
  display: flex; align-items: center; gap: 28px; flex-wrap: wrap; justify-content: center;
  padding: 26px 40px; background: #fff; border-radius: 34px; box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}
.over-card h3 { margin: 0; font-size: clamp(32px, 5vw, 54px); letter-spacing: 3px; color: var(--red); font-weight: 900; }
.over-card .sc { font-size: 26px; font-weight: 900; margin-top: 6px; }
.over-card .best { font-size: 15px; font-weight: 800; color: var(--grey); margin-top: 2px; }

/* ---------- Footer ---------- */
.site-footer {
  position: fixed; left: 0; right: 0; bottom: 8px; z-index: 20;
  text-align: center; font-size: 12px; font-weight: 700; color: #8f8a96;
  pointer-events: none;
}
.site-footer a { color: inherit; pointer-events: auto; margin: 0 7px; white-space: nowrap; }
body.in-play .site-footer { display: none; }
.ad-slot { display: none; }  /* AdSense: see README. Only show on home / menu, never during play. */

/* ---------- Levels 4 and 5 ---------- */
.menu-rows { gap: 12px; }
.level-row { padding: 6px 12px; }
.cat-cell { height: 98px; }
.sent-area { position: relative; flex: 1; min-height: 150px; display: flex; align-items: center; justify-content: center; padding: 10px 24px; }
.sent-area .c-cat { position: absolute; left: 30px; top: 50%; transform: translateY(-50%); opacity: 0.9; }
.sent-wrap { width: 100%; max-width: min(980px, calc(100% - 260px)); text-align: center; }
.sent-card {
  background: #fff; border: 4px solid var(--c); border-radius: 30px; padding: 22px 34px;
  font-size: clamp(24px, 3.4vw, 42px); font-weight: 900; line-height: 1.55; letter-spacing: 1px;
  box-shadow: 0 6px 14px color-mix(in srgb, var(--c) 35%, transparent); transition: border-color 0.2s;
}
.sent-card.wrong { border-color: var(--red); animation: shake2 0.3s linear; }
@keyframes shake2 { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-8px); } 80% { transform: translateX(8px); } }
.sc { display: inline-block; min-width: 0.15em; border-bottom: 5px solid transparent; white-space: pre; }
.sc.sp { min-width: 0.45em; }
.sc.cur { border-bottom-color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); border-radius: 6px 6px 0 0; }
.sent-tip { min-height: 30px; margin-top: 14px; font-size: 17px; color: #8f8a96; font-weight: 800; }
.sent-next { margin-top: 4px; font-size: clamp(15px, 1.8vw, 21px); color: var(--grey); font-weight: 800; }
.key.shift { letter-spacing: 0.5px; }
@media (max-width: 900px) { .sent-area .c-cat { display: none; } .sent-wrap { max-width: 100%; } }

.kbox { display: flex; gap: 8px; }
.kbox-l { justify-content: flex-end; }
.kbox-r { justify-content: flex-start; }

.g-hint { position: absolute; left: 50%; top: 150px; transform: translateX(-50%); background: #fff; color: var(--c, #8a63d2); font-weight: 800; padding: 8px 18px; border-radius: 999px; box-shadow: 0 2px 8px rgba(0,0,0,.15); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 5; font-size: 16px; }
.g-hint.show { opacity: 1; }
.kitten.shake .kw { animation: kshake .28s; }
@keyframes kshake { 0%,100% { translate: 0 0; } 25% { translate: -5px 0; } 75% { translate: 5px 0; } }
.kitten .kw span { white-space: pre; }

/* Levels 4-5: no hand diagram (Levels 1-3 keep it) */
.sent-area + .legend { display: none !important; }
.sent-area + .legend + .keyboard { margin-top: 18px; }
