/* ikii — in-game additions.
   Three things only: answer-bubble correct/wrong states, Kii's reaction, and the rocket
   progress panel. Nothing here touches a bubble's resting appearance — the idle bubble
   stays exactly as it is today.
   Load AFTER your existing game CSS. */

/* Hide old mountain/capybara progress panel — replaced by ikii panels */
#progressWrap, #ladderWidget { display: none !important; }

/* Override old .correct/.wrong bubble styles to prevent double-animation */
.bubble.correct, .answer.correct, .bubble.hit-correct, .answer.hit-correct {
  animation: none !important;
}
.bubble.wrong, .answer.wrong, .bubble.hit-wrong, .answer.hit-wrong {
  animation: none !important;
}

/* ============================================================
   1. ANSWER BUBBLE — correct / wrong
   Add .is-correct or .is-wrong to the bubble element you already have.
   Remove the class when the next question loads.
   ============================================================ */

.ikii-bubble { transition: background-color 140ms linear, box-shadow 140ms linear; }

/* --- correct: turns green, shows a tick, hops once --- */
.ikii-bubble.is-correct {
  background: #38C08C !important;
  box-shadow: 0 7px 0 #2A9970, inset 0 0 0 4px #FFFDF8 !important;
  animation: ikii-bubble-hop .5s cubic-bezier(.34, 1.4, .64, 1);
}
/* number stays visible on correct */
/* no tick — number stays visible and centered */
/* the burst ring that fires with it */
.ikii-bubble.is-correct::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 999px;
  border: 4px solid #38C08C;
  animation: ikii-burst .6s ease-out forwards;
  pointer-events: none;
}

/* --- wrong: greys out, shakes, stays on screen --- */
.ikii-bubble.is-wrong {
  background: #57525F !important;
  box-shadow: 0 7px 0 #2A2836, inset 0 0 0 4px rgba(255, 253, 248, .5) !important;
  color: rgba(255, 253, 248, .7) !important;
  animation: ikii-bubble-shake .5s ease-in-out;
}

@keyframes ikii-bubble-hop {
  0%, 100% { transform: translateY(0) }
  40% { transform: translateY(-14px) }
  70% { transform: translateY(-3px) }
}
@keyframes ikii-bubble-shake {
  0%, 100% { transform: translateX(0) }
  20% { transform: translateX(-7px) }
  40% { transform: translateX(6px) }
  60% { transform: translateX(-4px) }
  80% { transform: translateX(3px) }
}
@keyframes ikii-burst {
  0% { transform: scale(1); opacity: .7 }
  100% { transform: scale(1.45); opacity: 0 }
}

/* ============================================================
   2. KII REACTS
   One element, bottom-right, above the camera feed. Toggle
   .is-in plus .is-happy / .is-sad. Never blocks the answers.
   ============================================================ */

.ikii-react {
  position: fixed;
  right: 30px; bottom: 34px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 16px;
  opacity: 0;
  transform: translateX(40px);
  pointer-events: none;
  font-family: 'Fredoka', system-ui, sans-serif;
}
.ikii-react.is-in {
  animation: ikii-react-in .34s cubic-bezier(.34, 1.4, .64, 1) forwards;
}
.ikii-react.is-out {
  animation: ikii-react-out .22s ease-in forwards;
}
.ikii-react__word {
  background: #FFFDF8;
  border-radius: 999px;
  box-shadow: 0 5px 0 rgba(27, 26, 36, .35);
  padding: 14px 22px;
  font: 600 22px/1 'Fredoka', sans-serif;
  color: #1B1A24;
  white-space: nowrap;
}
.ikii-react__face {
  width: 92px; height: 92px;
  filter: drop-shadow(0 6px 0 #D64A2B);
}
.ikii-react.is-happy .ikii-react__face { animation: ikii-react-hop 1.4s ease-in-out infinite; }
.ikii-react.is-sad .ikii-react__face { animation: ikii-react-shake .6s ease-in-out infinite; }

@keyframes ikii-react-in {
  0% { opacity: 0; transform: translateX(40px) }
  100% { opacity: 1; transform: translateX(0) }
}
@keyframes ikii-react-out {
  0% { opacity: 1; transform: translateX(0) }
  100% { opacity: 0; transform: translateX(30px) }
}
@keyframes ikii-react-hop {
  0%, 100% { transform: translateY(0) }
  40% { transform: translateY(-14px) }
  70% { transform: translateY(-3px) }
}
@keyframes ikii-react-shake {
  0%, 100% { transform: translateX(0) }
  20% { transform: translateX(-7px) }
  40% { transform: translateX(6px) }
  60% { transform: translateX(-4px) }
  80% { transform: translateX(3px) }
}

/* ============================================================
   3. PROGRESS PANELS — replace the mountain / capybara panel
   Three panels share one shell (.ikii-panel) and one variable
   (--ikii-progress, 0-1): LAUNCH, SLOPE, SURFACE.
   Slope is Linear Lookout only. Launch and Surface are reusable.
   ============================================================ */

.ikii-panel {
  position: fixed;
  right: 24px; top: 24px;
  z-index: 30;
  width: 176px;
  box-sizing: border-box;
  background: #FFFDF8;
  border-radius: 28px;
  box-shadow: 0 6px 0 #E4DFD4;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  font-family: 'Fredoka', system-ui, sans-serif;
}
.ikii-panel__label {
  font: 400 10px/1 'DM Mono', ui-monospace, monospace;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #86818F;
}
.ikii-panel__count { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.ikii-panel__count b { font: 600 24px/1 'Fredoka', sans-serif; color: #1B1A24; }
.ikii-panel__count span {
  font: 400 10px/1 'DM Mono', ui-monospace, monospace;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #86818F;
}

/* ---------- shared rocket parts (LAUNCH + SLOPE) ---------- */
.ikii-ship { display: flex; flex-direction: column; align-items: center; }
.ikii-ship__body {
  position: relative;
  width: 48px; height: 62px;
  border-radius: 24px 24px 12px 12px;
  background: #FB6340;
  box-shadow: 0 5px 0 #D64A2B;
  display: grid;
  place-items: center;
}
.ikii-ship__fin { position: absolute; bottom: 2px; width: 16px; height: 24px; background: #A874E6; }
.ikii-ship__fin--l { left: -12px; border-radius: 8px 2px 8px 10px; }
.ikii-ship__fin--r { right: -12px; border-radius: 2px 8px 10px 8px; }
.ikii-ship__face { position: relative; width: 30px; height: 30px; margin-top: 4px; }
.ikii-ship__flame {
  width: 20px; height: 26px;
  margin-top: -2px;
  border-radius: 10px 10px 50% 50%;
  background: #F2C044;
  transform-origin: top center;
  animation: ikii-flame .34s ease-in-out infinite;
  display: grid;
  justify-items: center;
}
.ikii-ship__flame::after {
  content: '';
  width: 9px; height: 15px;
  margin-top: 3px;
  border-radius: 5px 5px 50% 50%;
  background: #FFFDF8;
}

/* SLOPE's ship is the dressed-up version: nose cone, porthole, hull stripe,
   nozzle and a three-jet flame. LAUNCH keeps the plain ship above. */
.ikii-ship--dressed .ikii-ship__nose {
  width: 18px; height: 14px;
  border-radius: 9px 9px 0 0;
  background: #FFFDF8;
  margin-bottom: -4px;
}
.ikii-ship--dressed .ikii-ship__stripe {
  position: absolute;
  left: 0; right: 0; bottom: 13px;
  height: 6px;
  background: #FFFDF8;
  opacity: .85;
}
.ikii-ship--dressed .ikii-ship__port {
  position: relative;
  width: 36px; height: 36px;
  border-radius: 999px;
  background: #FFFDF8;
  display: grid;
  place-items: center;
  margin-top: -5px;
}
.ikii-ship--dressed .ikii-ship__face { width: 28px; height: 28px; margin: 0; border-radius: 8px; }
.ikii-ship--dressed .ikii-ship__nozzle {
  width: 30px; height: 8px;
  border-radius: 0 0 6px 6px;
  background: #D64A2B;
}
.ikii-ship--dressed .ikii-ship__jets { display: flex; align-items: flex-start; gap: 3px; margin-top: -1px; }
.ikii-ship--dressed .ikii-ship__jets > i {
  width: 8px; height: 14px;
  border-radius: 4px 4px 50% 50%;
  background: #F2C044;
  transform-origin: top center;
  animation: ikii-flame .34s ease-in-out infinite;
}
.ikii-ship--dressed .ikii-ship__jets > i:nth-child(1) { animation-delay: .1s; }
.ikii-ship--dressed .ikii-ship__jets > i:nth-child(3) { animation-delay: .17s; }
.ikii-ship--dressed .ikii-ship__flame { width: 15px; height: 26px; margin: 0; border-radius: 8px 8px 50% 50%; }
.ikii-ship--dressed .ikii-ship__flame::after { width: 7px; height: 14px; }

/* ---------- SLOPE — Linear Lookout only ----------
   The ship rides the line the game is teaching. --ikii-progress moves it
   along the line and extends the teal trail behind it. */
.ikii-slope { position: relative; width: 108px; height: 190px; }
.ikii-slope__axis-y { position: absolute; left: 6px; top: 6px; bottom: 14px; width: 3px; border-radius: 999px; background: #F4F1EA; }
.ikii-slope__axis-x { position: absolute; left: 6px; right: 4px; bottom: 14px; height: 3px; border-radius: 999px; background: #F4F1EA; }
.ikii-slope__svg { position: absolute; left: 0; top: 0; }
.ikii-slope__planet {
  position: absolute;
  right: -2px; top: -4px;
  width: 32px; height: 32px;
  border-radius: 999px;
  background: #A874E6;
  box-shadow: 0 4px 0 #8654BE;
  display: grid;
  place-items: center;
}
/* the ship is anchored to the point on the line, then rotated to match it */
.ikii-slope__ship {
  position: absolute;
  left: calc(12px + var(--ikii-progress, 0) * 86px);
  top: calc(170px - var(--ikii-progress, 0) * 152px);
  width: 0; height: 0;
  animation: ikii-rocket-float 2.6s ease-in-out infinite;
  transition: left 420ms cubic-bezier(.34, 1.4, .64, 1), top 420ms cubic-bezier(.34, 1.4, .64, 1);
}
.ikii-slope__ship > .ikii-ship {
  transform: translate(-50%, -50%) rotate(32deg) scale(.66);
}

/* ---------- SURFACE — Kii swims up ---------- */
.ikii-surface {
  position: relative;
  width: 104px; height: 190px;
  border-radius: 20px;
  background: #2FB8C6;
  overflow: hidden;
}
.ikii-surface__sky { position: absolute; left: 0; right: 0; top: 0; height: 26px; background: #1E8F9B; }
.ikii-surface__waves { position: absolute; left: -6px; top: 20px; display: flex; }
.ikii-surface__waves > i {
  width: 30px; height: 14px;
  border-radius: 0 0 999px 999px;
  background: #1E8F9B;
}
.ikii-surface__floor { position: absolute; left: 0; right: 0; bottom: 0; height: 14px; background: #1E8F9B; }
.ikii-surface__ticks {
  position: absolute;
  right: 8px; top: 44px; bottom: 26px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
}
.ikii-surface__ticks > i { height: 3px; border-radius: 999px; background: rgba(255, 253, 248, .4); width: 14px; }
.ikii-surface__ticks > i:nth-child(even) { width: 8px; background: rgba(255, 253, 248, .28); }

.ikii-surface__kii {
  position: absolute;
  left: 26px;
  bottom: calc(22px + var(--ikii-progress, 0) * 108px);
  width: 46px; height: 46px;
  filter: drop-shadow(0 4px 0 #D64A2B);
  animation: ikii-swim 2.8s ease-in-out infinite;
  transition: bottom 420ms cubic-bezier(.34, 1.4, .64, 1);
}
.ikii-surface__bubble {
  position: absolute;
  left: 34px;
  bottom: calc(62px + var(--ikii-progress, 0) * 108px);
  width: 9px; height: 9px;
  border-radius: 999px;
  background: #FFFDF8;
  animation: ikii-bubble-up 2.6s ease-in infinite;
  transition: bottom 420ms cubic-bezier(.34, 1.4, .64, 1);
}
.ikii-surface__bubble:nth-of-type(2) { left: 50px; width: 6px; height: 6px; animation-duration: 2.2s; animation-delay: .7s; }
.ikii-surface__bubble:nth-of-type(3) { left: 43px; width: 4px; height: 4px; animation-duration: 2.9s; animation-delay: 1.3s; }

@keyframes ikii-swim {
  0%, 100% { transform: translate(0, 0) rotate(-6deg) }
  50% { transform: translate(5px, -7px) rotate(6deg) }
}
@keyframes ikii-bubble-up {
  0% { transform: translateY(0) scale(.7); opacity: 0 }
  25% { opacity: .85 }
  100% { transform: translateY(-58px) scale(1.1); opacity: 0 }
}

/* ============================================================
   3b. LAUNCH — the rocket climbs to a planet
   ============================================================ */

.ikii-rocket {
  /* LAUNCH shell — same values as .ikii-panel */
  position: fixed;
  right: 12px; top: 12px;
  z-index: 30;
  width: 90px;
  box-sizing: border-box;
  background: #FFFDF8;
  border-radius: 28px;
  box-shadow: 0 6px 0 #E4DFD4;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  font-family: 'Fredoka', system-ui, sans-serif;
}
.ikii-rocket__label {
  font: 400 10px/1 'DM Mono', ui-monospace, monospace;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #86818F;
}
.ikii-rocket__sky { position: relative; width: 56px; height: 180px; }

/* trajectory + flown portion. --ikii-progress is 0–1. */
.ikii-rocket__track {
  position: absolute;
  left: 25px; top: 4px; bottom: 12px;
  width: 4px;
  border-radius: 999px;
  background: #E4DFD4;
}
.ikii-rocket__flown {
  position: absolute;
  left: 25px; bottom: 12px;
  width: 4px;
  height: calc(var(--ikii-progress, 0) * 148px);
  border-radius: 999px;
  background: #2FB8C6;
  transition: height 420ms cubic-bezier(.34, 1.4, .64, 1);
}

/* the planet waiting at the top */
.ikii-rocket__planet {
  position: absolute;
  left: 14px; top: -6px;
  width: 26px; height: 26px;
  border-radius: 999px;
  background: #A874E6;
  box-shadow: 0 4px 0 #8654BE;
  display: grid;
  place-items: center;
}

/* stars streaking past */
.ikii-rocket__star {
  position: absolute;
  animation: ikii-streak 2.6s linear infinite;
}
.ikii-rocket__star:nth-of-type(1) { left: 8px; top: 44px; }
.ikii-rocket__star:nth-of-type(2) { right: 6px; top: 74px; animation-delay: 1.1s; }
.ikii-rocket__star:nth-of-type(3) { left: 4px; top: 104px; animation-delay: .5s; }

@keyframes ikii-streak {
  0% { transform: translateY(-14px); opacity: 0 }
  30% { opacity: .9 }
  100% { transform: translateY(26px); opacity: 0 }
}

/* the ship — rides the same --ikii-progress */
.ikii-rocket__ship {
  position: absolute;
  left: 6px;
  bottom: calc(6px + var(--ikii-progress, 0) * 120px);
  width: 42px;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: ikii-rocket-float 2.6s ease-in-out infinite;
  transition: bottom 420ms cubic-bezier(.34, 1.4, .64, 1);
}
.ikii-rocket__body {
  position: relative;
  width: 32px; height: 42px;
  border-radius: 16px 16px 8px 8px;
  background: #FB6340;
  box-shadow: 0 5px 0 #D64A2B;
  display: grid;
  place-items: center;
}
.ikii-rocket__fin {
  position: absolute;
  bottom: 2px;
  width: 12px; height: 18px;
  background: #A874E6;
}
.ikii-rocket__fin--l { left: -8px; border-radius: 6px 2px 6px 8px; }
.ikii-rocket__fin--r { right: -8px; border-radius: 2px 6px 8px 6px; }
.ikii-rocket__face { position: relative; width: 18px; height: 18px; margin-top: 2px; }

.ikii-rocket__flame {
  width: 14px; height: 18px;
  margin-top: -2px;
  border-radius: 10px 10px 50% 50%;
  background: #F2C044;
  transform-origin: top center;
  animation: ikii-flame .34s ease-in-out infinite;
  display: grid;
  justify-items: center;
}
.ikii-rocket__flame::after {
  content: '';
  width: 6px; height: 10px;
  margin-top: 3px;
  border-radius: 5px 5px 50% 50%;
  background: #FFFDF8;
}
/* one bigger kick when the ship climbs */
.ikii-rocket.is-boosting .ikii-rocket__flame { animation: ikii-flame-boost .42s ease-out; }

@keyframes ikii-flame {
  0%, 100% { transform: scaleY(1) scaleX(1) }
  50% { transform: scaleY(1.32) scaleX(.86) }
}
@keyframes ikii-flame-boost {
  0% { transform: scaleY(1) }
  40% { transform: scaleY(2.1) scaleX(.8) }
  100% { transform: scaleY(1) }
}
@keyframes ikii-rocket-float {
  0%, 100% { transform: translateY(0) }
  50% { transform: translateY(-5px) }
}

/* launch pad smoke */
.ikii-rocket__puff { position: absolute; border-radius: 999px; background: #F4F1EA; }
.ikii-rocket__puff--a { left: 22px; bottom: 6px; width: 26px; height: 26px; }
.ikii-rocket__puff--b { left: 42px; bottom: 0; width: 34px; height: 22px; }
.ikii-rocket__puff--c { right: 16px; bottom: 8px; width: 20px; height: 20px; }

.ikii-rocket__count { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.ikii-rocket__count b { font: 600 15px/1 'Fredoka', sans-serif; color: #1B1A24; }
.ikii-rocket__count span {
  font: 400 10px/1 'DM Mono', ui-monospace, monospace;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #86818F;
}

@media (max-width: 600px) {
  .ikii-rocket { width: 128px; padding: 14px 12px; border-radius: 24px; gap: 10px; }
  .ikii-rocket__sky { width: 92px; height: 150px; }
  .ikii-rocket__track, .ikii-rocket__flown { left: 43px; }
  .ikii-rocket__flown { height: calc(var(--ikii-progress, 0) * 116px); }
  .ikii-rocket__ship { left: 18px; bottom: calc(46px + var(--ikii-progress, 0) * 70px); }
  .ikii-rocket__planet { left: 28px; }
  .ikii-panel { width: 128px; padding: 14px 12px; border-radius: 24px; gap: 10px; }
  .ikii-slope { width: 92px; height: 150px; }
  .ikii-slope__ship { left: calc(10px + var(--ikii-progress, 0) * 72px); top: calc(134px - var(--ikii-progress, 0) * 120px); }
  .ikii-slope__ship > .ikii-ship { transform: translate(-50%, -50%) rotate(32deg) scale(.54); }
  .ikii-surface { width: 92px; height: 150px; }
  .ikii-surface__kii { left: 22px; width: 38px; height: 38px; bottom: calc(20px + var(--ikii-progress, 0) * 82px); }
  .ikii-surface__bubble { left: 28px; bottom: calc(52px + var(--ikii-progress, 0) * 82px); }
  .ikii-react { right: 16px; bottom: 20px; gap: 10px; }
  .ikii-react__face { width: 72px; height: 72px; }
  .ikii-react__word { font-size: 18px; padding: 11px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .ikii-bubble.is-correct, .ikii-bubble.is-wrong,
  .ikii-rocket__ship, .ikii-rocket__flame, .ikii-rocket__star,
  .ikii-slope__ship, .ikii-ship__flame, .ikii-ship__jets > i,
  .ikii-surface__kii, .ikii-surface__bubble,
  .ikii-react__face { animation: none !important; }
  .ikii-bubble.is-correct::before { display: none; }
}
