/* Shared styles for Kittelfdora game engines (jigsaw v2 + memory) */

/* player pages scroll the board into view on load/selection (B9);
   leave room for the sticky site header */
.demo-game {
  scroll-margin-top: 4.75rem;
}

.kf-jigsaw,
.kf-memory {
  background: #fff;
  border-radius: 22px;
  box-shadow: 0 4px 20px rgba(45, 27, 78, 0.1);
  padding: 12px;
  margin: 24px 0;
}

.kf-jigsaw:fullscreen {
  border-radius: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
}
.kf-jigsaw:fullscreen .kfj-stage {
  flex: 1;
  height: auto;
}

/* Full-bleed player mode: table spans the page, toolbar stays aligned
   with the site header content (logo + menu). */
.kf-jigsaw--full {
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  margin: 12px 0 0;
}
.kf-jigsaw--full .kfj-bar {
  max-width: 72rem;
  margin: 0 auto 10px;
  padding: 0 1.5rem;
  box-sizing: border-box;
}
.kf-jigsaw--full .kfj-stage {
  height: clamp(440px, 76vh, 1000px);
}
.kf-jigsaw--full .kfj-canvas {
  border-radius: 0;
}
.kf-jigsaw--full:fullscreen {
  background: #fff;
}
.kf-jigsaw--full:fullscreen .kfj-bar {
  padding-top: 10px;
}

/* Embed mode (/embed/jigsaw/, D-020): the game owns the whole frame, however
   tall the host site made it. The table takes all the room the toolbar and the
   piece pills leave over. */
.kf-jigsaw--embed {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 0;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
}
/* basis 0 + min-height 0: the table takes the leftover space instead of growing
   from the canvas it just drew, which would push the frame into a scrollbar */
.kf-jigsaw--embed .kfj-stage {
  flex: 1 1 0;
  height: auto;
  min-height: 0;
  overflow: hidden;
}

/* ---- toolbar ---- */
.kfj-bar,
.kfm-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.kfj-title,
.kfm-title {
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-weight: 700;
  color: #2d1b4e;
  font-size: 1.02rem;
}
.kfj-progress,
.kfm-progress {
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  color: #1e8d82;
  background: #dff6f4;
  border-radius: 999px;
  padding: 2px 12px;
}
.kfj-clock {
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  color: #2d1b4e;
  background: #ede6f5;
  border-radius: 999px;
  padding: 2px 12px;
  min-width: 3.4em;
  text-align: center;
}
.kfj-spacer,
.kfm-spacer {
  flex: 1;
}
.kfj-btn,
.kfm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem; /* 44px touch floor */
  min-width: 2.75rem;
  box-sizing: border-box;
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  color: #2d1b4e;
  background: #ede6f5;
  border: 2px solid #b8a0d2;
  border-radius: 999px;
  padding: 6px 13px;
  cursor: pointer;
  transition: background 0.25s ease, transform 0.25s ease;
  white-space: nowrap;
}
.kfj-btn:hover,
.kfm-btn:hover {
  background: #fff;
  transform: translateY(-1px);
}
.kfj-ghost.off,
.kfj-timer.off {
  opacity: 0.5;
}

/* piece-count pills: big numerals, 44px+ tall, current level pressed in teal */
.kfj-levels {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 10px;
}
.kfj-levels-label {
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  color: #4a3f66;
  margin-right: 3px;
}
.kfj-level {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3rem;
  min-height: 2.75rem; /* 44px touch floor */
  box-sizing: border-box;
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-weight: 700;
  font-size: 1.15rem;
  color: #2d1b4e;
  background: #ede6f5;
  border: 2px solid #b8a0d2;
  border-radius: 999px;
  padding: 4px 12px;
  cursor: pointer;
  transition: background 0.25s ease, transform 0.25s ease;
}
.kfj-level:hover {
  background: #fff;
  transform: translateY(-1px);
}
.kfj-level[aria-pressed='true'] {
  background: #2ec4b6;
  border-color: #2ec4b6;
  color: #0f0a24;
}
.kf-jigsaw--full .kfj-levels {
  max-width: 72rem;
  margin: 0 auto 10px;
  padding: 0 1.5rem;
  box-sizing: border-box;
}

/* share dropdown */
.kfj-share-wrap {
  position: relative;
}
.kfj-share-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 30px rgba(45, 27, 78, 0.25);
  padding: 6px;
  display: flex;
  flex-direction: column;
  min-width: 12rem;
  z-index: 40;
}
.kfj-share-menu[hidden] {
  display: none !important;
}
.kfj-share-menu button {
  min-height: 2.75rem; /* 44px touch floor */
  box-sizing: border-box;
  font-family: 'Nunito', system-ui, sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  color: #2d1b4e;
  background: transparent;
  border: 0;
  border-radius: 9px;
  text-align: left;
  padding: 10px 12px;
  cursor: pointer;
}
.kfj-share-menu button:hover {
  background: #ede6f5;
}

/* ---- jigsaw stage ---- */
.kfj-stage {
  position: relative;
  height: clamp(430px, 74vh, 950px);
}
.kfj-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  border-radius: 14px;
  cursor: grab;
}
.kfj-pausedveil {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(150deg, #2d1b4e 0%, #4a2d78 100%);
  border-radius: 14px;
}
.kfj-pausedveil[hidden] {
  display: none !important;
}
.kfj-pausedveil p {
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
  color: #ffe9a8;
}
.kfj-win,
.kfm-win {
  text-align: center;
}
.kfj-win,
.kfj-error,
.kfj-invite {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(45, 27, 78, 0.45);
  border-radius: 14px;
}
.kfj-error,
.kfj-invite {
  text-align: center;
}
/* the invite must be seen without scrolling even on short screens:
   anchor it near the top of the table instead of the center */
.kfj-invite {
  align-items: flex-start;
  padding-top: clamp(18px, 6vh, 70px);
}
.kfj-win[hidden],
.kfj-error[hidden],
.kfj-invite[hidden],
.kfm-win[hidden] {
  display: none !important;
}
.kfj-invite-card {
  background: #fdfaf4;
  border-radius: 18px;
  padding: 26px 30px;
  max-width: 24rem;
  box-shadow: 0 8px 30px rgba(45, 27, 78, 0.3);
}
.kfj-invite-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.kfj-error-card {
  background: #fdfaf4;
  border-radius: 18px;
  padding: 26px 30px;
  max-width: 24rem;
  box-shadow: 0 8px 30px rgba(45, 27, 78, 0.3);
}
.kfj-error-big {
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: #2d1b4e;
  margin: 0 0 14px;
}
.kfj-win-card,
.kfm-win {
  background: #fdfaf4;
  border-radius: 18px;
  padding: 26px 30px;
  box-shadow: 0 8px 30px rgba(45, 27, 78, 0.3);
}
.kfm-win {
  margin-top: 12px;
  box-shadow: 0 4px 20px rgba(45, 27, 78, 0.12);
}
.kfj-win-big,
.kfm-win-big {
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-weight: 700;
  font-size: 1.35rem;
  color: #2d1b4e;
  margin: 0 0 4px;
}
.kfj-win-small,
.kfm-win-small {
  color: #4a3f66;
  margin: 0 0 14px;
  font-size: 0.95rem;
}
/* Rule 32: brand art replacing emoji illustrations in wordsearch */
.kfw-chipart {
  width: 1.4em;
  height: 1.4em;
  object-fit: cover;
  border-radius: 6px;
  vertical-align: -0.35em;
  margin-right: 0.25em;
}

/* D-011: elapsed time line on the memory win card */
.kfm-win-time {
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  color: #b8860b;
  margin: 0 0 6px;
}

/* ---- memory grid ---- */
.kfm-grid {
  display: grid;
  grid-template-columns: repeat(var(--kfm-cols, 4), 1fr);
  gap: 10px;
}
.kfm-card {
  position: relative;
  aspect-ratio: 4 / 5;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  perspective: 700px;
  -webkit-tap-highlight-color: transparent;
}
.kfm-inner {
  position: absolute;
  inset: 0;
  transition: transform 0.45s ease;
  transform-style: preserve-3d;
}
@media (prefers-reduced-motion: reduce) {
  .kfm-inner {
    transition: none;
  }
}
.kfm-card.open .kfm-inner,
.kfm-card.matched .kfm-inner {
  transform: rotateY(180deg);
}
.kfm-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}
.kfm-back {
  background: linear-gradient(150deg, #2d1b4e 0%, #4a2d78 100%);
  border: 2px solid #b8a0d2;
  font-size: 1.9rem;
  box-shadow: 0 3px 10px rgba(45, 27, 78, 0.25);
}
.kfm-front {
  transform: rotateY(180deg);
  background: #ede6f5;
  border: 2px solid #b8a0d2;
}
.kfm-front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.kfm-card.matched .kfm-front {
  border-color: #d4a843;
  box-shadow: 0 0 0 3px rgba(212, 168, 67, 0.45);
}
.kfm-card.matched {
  cursor: default;
}
.kfm-card:not(.matched):hover .kfm-inner {
  transform: translateY(-2px);
}
.kfm-card.open:not(.matched):hover .kfm-inner {
  transform: rotateY(180deg);
}

/* ---- memory fullscreen ----
   A fixed overlay does the real work (so iPhone Safari, which has no element
   Fullscreen API, gets the same experience); the engine layers the real
   Fullscreen API on top where it exists. Only the toolbar and the board are
   visible; the engine computes --kfm-cols and --kfm-size so every card fits
   the viewport with no scrolling, even at 15 and 20 pairs. */
body.kf-fs-lock {
  overflow: hidden;
}
.kf-memory--fs {
  position: fixed;
  inset: 0;
  z-index: 1200; /* above the sticky site header */
  margin: 0;
  border-radius: 0;
  padding: 12px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  background: #fff;
  overflow: hidden;
}
.kf-memory--fs:fullscreen {
  background: #fff;
}
.kf-memory--fs .kfm-full {
  display: none; /* already in full screen */
}
.kf-memory--fs .kfm-grid {
  flex: 1;
  min-height: 0;
  gap: 8px;
  grid-template-columns: repeat(var(--kfm-cols, 4), var(--kfm-size, 1fr));
  justify-content: center;
  align-content: center;
}
/* Big obvious way out, top-right corner of the toolbar (56px+ target). */
.kfm-exit-full {
  min-height: 3.5rem;
  min-width: 3.5rem;
  font-size: 1.05rem;
  background: #d4a843;
  border-color: #d4a843;
  color: #0f0a24;
}
.kfm-exit-full:hover {
  background: #ffe9a8;
  border-color: #d4a843;
}
.kfm-exit-full[hidden] {
  display: none !important; /* .kfm-btn's display would beat the hidden attr */
}
/* The win card floats over the board instead of pushing below the fold. */
.kf-memory--fs .kfm-win {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  width: min(26rem, calc(100% - 40px));
  box-sizing: border-box;
  box-shadow: 0 8px 30px rgba(45, 27, 78, 0.3);
  z-index: 2;
}

/* ---- Firefly Word Hunt (gentle hangman) ---- */
.kf-hangman {
  background: #fff;
  border-radius: 22px;
  box-shadow: 0 4px 20px rgba(45, 27, 78, 0.1);
  padding: 12px;
  margin: 24px 0;
}
.kfh-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.kfh-title {
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-weight: 700;
  color: #2d1b4e;
  font-size: 1.02rem;
}
.kfh-score {
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  color: #1e8d82;
  background: #dff6f4;
  border-radius: 999px;
  padding: 2px 12px;
}
.kfh-spacer { flex: 1; }
/* Rule 44: category pills + mute share one row; icons are brand images */
.kfh-bar-cats { margin-bottom: 10px; }
.kfh-cat-ico {
  width: 1.55em;
  height: 1.55em;
  object-fit: cover;
  border-radius: 50%;
  margin-right: 0.45em;
  flex: none;
}
.kfh-mute {
  margin-left: auto;
  padding: 6px;
}
.kfh-mute-ico { display: block; }
/* D-005: shared inline SVG mute bell used by every non-hangman engine. */
.kf-mute-ico { display: block; margin: 0 auto; }
.kfh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem; /* 44px touch floor */
  min-width: 2.75rem;
  box-sizing: border-box;
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  color: #2d1b4e;
  background: #ede6f5;
  border: 2px solid #b8a0d2;
  border-radius: 999px;
  padding: 6px 13px;
  cursor: pointer;
  transition: background 0.25s ease, transform 0.25s ease;
  white-space: nowrap;
}
.kfh-btn:hover { background: #fff; transform: translateY(-1px); }
.kfh-cat.active {
  background: #2ec4b6;
  border-color: #2ec4b6;
  color: #0f0a24;
}
.kfh-stage {
  background: linear-gradient(180deg, #2d1b4e 0%, #1a0f30 100%);
  border-radius: 14px;
  padding: 22px 16px 26px;
  text-align: center;
}
.kfh-fireflies {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 10px;
}
.kfh-fly {
  width: 52px;
  height: 52px;
  display: inline-block;
  animation: kfh-bob 3.4s ease-in-out infinite;
  animation-delay: var(--bob, 0s);
  transition: filter 0.8s ease, opacity 0.8s ease, transform 0.8s ease;
}
.kfh-fly svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}
.kfh-fly .glowhalo {
  animation: kfh-pulse 3s ease-in-out infinite;
  animation-delay: var(--bob, 0s);
}
.kfh-fly.asleep {
  filter: grayscale(0.75) brightness(0.55);
  opacity: 0.6;
  transform: translateY(6px) rotate(14deg);
  animation: none;
}
.kfh-fly.asleep .glowhalo {
  opacity: 0.12;
  animation: none;
}
.kfh-fly.asleep .wings {
  opacity: 0.35;
}
.kfh-fly.asleep .zz {
  opacity: 1;
  transition: opacity 0.8s ease 0.4s;
}
.kfh-fly.dance {
  animation: kfh-dance 1.4s ease-in-out infinite;
}
@keyframes kfh-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
@keyframes kfh-pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}
@keyframes kfh-dance {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-9px) rotate(4deg); }
}
@media (prefers-reduced-motion: reduce) {
  .kfh-fly,
  .kfh-fly.dance,
  .kfh-fly .glowhalo { animation: none; }
}
.kfh-stage {
  position: relative;
  overflow: hidden;
}
.kfh-confetti {
  position: absolute;
  top: -14px;
  border-radius: 2px;
  pointer-events: none;
  animation: kfh-fall linear forwards;
}
@keyframes kfh-fall {
  to {
    transform: translate(var(--drift, 0px), 620px) rotate(var(--spin, 540deg));
    opacity: 0.9;
  }
}
/* Word + clue card share one row: there is empty space beside the letters, so
   the clue lives there instead of needing its own button underneath. */
.kfh-wordrow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
/* Closed: an invitation. Open: the picture, big enough to read without
   squinting (it used to be a 56px thumbnail). */
.kfh-cluecard {
  width: 9.5rem;
  height: 9.5rem;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 10px;
  box-sizing: border-box;
  border-radius: 18px;
  border: 2px dashed rgba(184, 160, 210, 0.7);
  background: rgba(184, 160, 210, 0.12);
  color: #f2edfa;
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.25;
  cursor: pointer;
  overflow: hidden;
  transition: background 0.2s ease, transform 0.2s ease;
}
.kfh-cluecard:hover {
  background: rgba(212, 168, 67, 0.25);
  transform: translateY(-2px);
}
.kfh-cluecard.is-open {
  padding: 0;
  cursor: default;
  border-style: solid;
  border-color: rgba(184, 160, 210, 0.35);
  background: rgba(184, 160, 210, 0.08);
}
.kfh-cluecard.is-open:hover {
  transform: none;
  background: rgba(184, 160, 210, 0.08);
}
.kfh-cluecard.is-text {
  padding: 12px;
  font-size: 1rem;
}
.kfh-clue-art {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 16px;
  display: block;
}
@media (prefers-reduced-motion: reduce) {
  .kfh-cluecard,
  .kfh-cluecard:hover {
    transform: none;
    transition: none;
  }
}
.kfh-word {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.kfh-slot {
  width: 2.3rem;
  height: 2.8rem;
  border-bottom: 4px solid #b8a0d2;
  border-radius: 6px 6px 0 0;
  background: rgba(255, 255, 255, 0.07);
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-weight: 700;
  font-size: 1.8rem;
  color: #ffe9a8;
  display: flex;
  align-items: center;
  justify-content: center;
}
.kfh-slot.shown {
  background: rgba(46, 196, 182, 0.18);
  border-bottom-color: #2ec4b6;
}
.kfh-msg {
  color: #e8e1f5;
  font-size: 1.15rem;
  line-height: 1.45;
  min-height: 1.4em;
  margin: 18px 0 26px;
}
.kfh-msg.hint { color: #ffe9a8; }
.kfh-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 14px;
}
.kfh-line {
  display: block;
  margin-bottom: 7px;
}
.kfh-line:last-child {
  margin-bottom: 0;
}
.kfh-line strong {
  color: #ffe9a8;
}
.kfh-msg.win { color: #ffe9a8; font-family: 'Baloo 2', system-ui, sans-serif; font-weight: 700; }
.kfh-msg.lost { color: #e3d9f5; font-weight: 700; }
.kfh-keys {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  max-width: 34rem;
  margin: 0 auto 6px;
}
.kfh-keys button {
  width: 2.75rem; /* 44px touch floor */
  height: 2.75rem;
  border-radius: 10px;
  border: 2px solid #b8a0d2;
  background: #ede6f5;
  color: #2d1b4e;
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease;
}
.kfh-keys button:hover:not(:disabled) { transform: translateY(-2px); background: #fff; }
.kfh-keys button.good { background: #2ec4b6; border-color: #2ec4b6; color: #0f0a24; }
.kfh-keys button.off { opacity: 0.35; }
.kfh-keys button:disabled { cursor: default; }
.kfh-next { margin-top: 8px; background: #d4a843; border-color: #d4a843; }

/* ---- Word Search ---- */
.kf-wordsearch {
  background: #fff;
  border-radius: 22px;
  box-shadow: 0 4px 20px rgba(45, 27, 78, 0.1);
  padding: 12px;
  margin: 24px 0;
}
.kfw-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.kfw-title {
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-weight: 700;
  color: #2d1b4e;
  font-size: 1.02rem;
}
.kfw-progress {
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  color: #1e8d82;
  background: #dff6f4;
  border-radius: 999px;
  padding: 2px 12px;
}
.kfw-spacer { flex: 1; }
.kfw-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem; /* 44px touch floor */
  min-width: 2.75rem;
  box-sizing: border-box;
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  color: #2d1b4e;
  background: #ede6f5;
  border: 2px solid #b8a0d2;
  border-radius: 999px;
  padding: 6px 13px;
  cursor: pointer;
  transition: background 0.25s ease, transform 0.25s ease;
  white-space: nowrap;
}
.kfw-btn:hover { background: #fff; transform: translateY(-1px); }
.kfw-cat.active { background: #2ec4b6; border-color: #2ec4b6; color: #0f0a24; }
.kfw-size.active { background: #d4a843; border-color: #d4a843; color: #0f0a24; }
.kfw-layout {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(11rem, 1fr);
  gap: 14px;
  align-items: start;
}
@media (max-width: 640px) {
  .kfw-layout { grid-template-columns: 1fr; }
}
.kfw-gridwrap {
  background: linear-gradient(180deg, #2d1b4e 0%, #1a0f30 100%);
  border-radius: 14px;
  padding: 12px;
}
.kfw-grid {
  display: grid;
  grid-template-columns: repeat(var(--kfw-n, 8), 1fr);
  gap: 4px;
  touch-action: none;
  user-select: none;
}
.kfw-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 9px;
  color: #f2edfa;
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-weight: 700;
  font-size: clamp(0.9rem, 3.2vw, 1.3rem);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}
.kfw-cell.sel {
  background: rgba(255, 233, 168, 0.55);
  color: #2d1b4e;
  transform: scale(1.06);
}
.kfw-cell.locked {
  background: var(--lock, rgba(46, 196, 182, 0.5));
  color: #0f0a24;
}
.kfw-words {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
@media (max-width: 640px) {
  .kfw-words { flex-direction: row; flex-wrap: wrap; }
}
.kfw-chip {
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  color: #2d1b4e;
  background: #fdfaf4;
  border: 2px solid #b8a0d2;
  border-left: 12px solid;
  border-left-color: var(--chip, #b8a0d2);
  border-radius: 12px;
  padding: 6px 12px;
}
.kfw-chip.found {
  text-decoration: line-through;
  opacity: 0.55;
  background: var(--chip);
}
.kfw-win {
  text-align: center;
  background: #fdfaf4;
  border-radius: 18px;
  padding: 22px;
  margin-top: 12px;
  box-shadow: 0 4px 20px rgba(45, 27, 78, 0.12);
}
.kfw-win[hidden] { display: none !important; }
.kfw-win-big {
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-weight: 700;
  font-size: 1.35rem;
  color: #2d1b4e;
  margin: 0 0 4px;
}
.kfw-win-small { color: #4a3f66; margin: 0 0 14px; font-size: 0.95rem; }

/* ---- Mini Crossword ---- */
.kf-crossword {
  background: #fff;
  border-radius: 22px;
  box-shadow: 0 4px 20px rgba(45, 27, 78, 0.1);
  padding: 12px;
  margin: 24px 0;
}
.kfc-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.kfc-title {
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-weight: 700;
  color: #2d1b4e;
  font-size: 1.02rem;
}
.kfc-progress {
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  color: #1e8d82;
  background: #dff6f4;
  border-radius: 999px;
  padding: 2px 12px;
}
.kfc-spacer { flex: 1; }
.kfc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem; /* 44px touch floor */
  min-width: 2.75rem;
  box-sizing: border-box;
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  color: #2d1b4e;
  background: #ede6f5;
  border: 2px solid #b8a0d2;
  border-radius: 999px;
  padding: 6px 13px;
  cursor: pointer;
  transition: background 0.25s ease, transform 0.25s ease;
  white-space: nowrap;
}
.kfc-btn:hover { background: #fff; transform: translateY(-1px); }
.kfc-cat.active { background: #2ec4b6; border-color: #2ec4b6; color: #0f0a24; }
.kfc-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(15rem, 1.1fr);
  gap: 14px;
  align-items: start;
}
@media (max-width: 680px) {
  .kfc-layout { grid-template-columns: 1fr; }
}
.kfc-gridwrap {
  background: linear-gradient(180deg, #2d1b4e 0%, #1a0f30 100%);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  justify-content: center;
}
.kfc-grid {
  display: grid;
  grid-template-columns: repeat(var(--kfc-cols, 5), minmax(2.4rem, 3.4rem));
  gap: 5px;
}
.kfc-void { }
.kfc-cell {
  position: relative;
  aspect-ratio: 1;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}
.kfc-cell i {
  position: absolute;
  top: 2px;
  left: 5px;
  font-style: normal;
  font-size: 0.6rem;
  font-weight: 700;
  color: #8a76ad;
}
.kfc-cell b {
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-weight: 700;
  font-size: 1.4rem;
  color: #2d1b4e;
}
.kfc-cell.inword {
  background: #ffe9a8;
}
.kfc-cell.cursor {
  box-shadow: 0 0 0 3px #2ec4b6;
}
.kfc-cell.locked {
  background: #bdeee9;
}
.kfc-cell.locked b { color: #14655d; }
.kfc-cell.oops {
  background: #f6d7dd;
}
.kfc-side { min-width: 0; }
.kfc-active-clue {
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-weight: 700;
  color: #2d1b4e;
  background: #ede6f5;
  border-radius: 12px;
  padding: 10px 14px;
  margin: 0 0 10px;
  min-height: 2.4em;
}
.kfc-clues {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.kfc-clue {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  background: #fdfaf4;
  border: 2px solid #ede6f5;
  border-radius: 12px;
  padding: 7px 10px;
  cursor: pointer;
  font-family: 'Nunito', system-ui, sans-serif;
  font-size: 0.92rem;
  color: #4a3f66;
  transition: border-color 0.2s ease;
}
.kfc-clue:hover { border-color: #b8a0d2; }
.kfc-clue.active { border-color: #2ec4b6; background: #dff6f4; }
.kfc-clue.done {
  opacity: 0.55;
  text-decoration: line-through;
}
.kfc-clue-emoji { font-size: 1.5rem; }
/* wrong-word reassurance: shows while the letters fade, with breathing room */
.kfc-msg {
  min-height: 1.5em;
  margin: 16px 8px;
  text-align: center;
  font-family: 'Nunito', system-ui, sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.45;
  color: #4a3f66;
}
.kfc-keys {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
}
.kfc-keys button {
  width: 2.75rem; /* 44px touch floor */
  height: 2.75rem;
  border-radius: 10px;
  border: 2px solid #b8a0d2;
  background: #ede6f5;
  color: #2d1b4e;
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease;
}
.kfc-keys button:hover { transform: translateY(-2px); background: #fff; }
.kfc-keys .kfc-back { width: 3.8rem; background: #f8efdb; border-color: #d4a843; }
.kfc-win {
  text-align: center;
  background: #fdfaf4;
  border-radius: 18px;
  padding: 22px;
  margin-top: 12px;
  box-shadow: 0 4px 20px rgba(45, 27, 78, 0.12);
}
.kfc-win[hidden] { display: none !important; }
.kfc-win-big {
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-weight: 700;
  font-size: 1.35rem;
  color: #2d1b4e;
  margin: 0 0 4px;
}
.kfc-win-small { color: #4a3f66; margin: 0 0 14px; font-size: 0.95rem; }

/* ============ Emotion Quest (kf-emotion) ============ */
.kfe {
  position: relative;
  font-family: 'Nunito', system-ui, sans-serif;
}
.kfe-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.7rem;
}
.kfe-ghostbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem; /* 44px touch floor */
  min-width: 2.75rem;
  box-sizing: border-box;
  border: 2px solid rgba(45, 27, 78, 0.25);
  background: #fff;
  color: #2d1b4e;
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  cursor: pointer;
}
.kfe-ghostbtn:hover { border-color: #2ec4b6; }
.kfe-dots { display: flex; gap: 0.45rem; }
.kfe-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(45, 27, 78, 0.18);
}
.kfe-dot.now { background: #d4a843; transform: scale(1.25); }
.kfe-dot.done { background: #2ec4b6; }

.kfe-panel {
  display: grid;
  grid-template-columns: 6fr 5fr;
  gap: 1.4rem;
  align-items: start;
  background: linear-gradient(160deg, #22b3a6 0%, #1d9c95 100%);
  border-radius: 26px;
  padding: 1.6rem;
  box-shadow: 0 14px 40px rgba(15, 10, 36, 0.22);
}
.kfe-question {
  color: #fff;
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-size: clamp(1.35rem, 2.6vw, 1.9rem);
  margin: 0 0 1rem;
  text-shadow: 0 2px 10px rgba(15, 10, 36, 0.25);
}
/* the Listen pill reuses .kfs-listen looks; here it sits under the question */
.kfe-listen { margin: -0.3rem 0 1rem; }
.kfe-options { display: flex; flex-direction: column; gap: 0.7rem; margin-bottom: 0.9rem; }
.kfe-opt {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  border: 3px solid transparent;
  background: linear-gradient(180deg, #ffd94d 0%, #f7c832 100%);
  color: #2d1b4e;
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 1.08rem;
  text-align: left;
  border-radius: 14px;
  padding: 0.7rem 1rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(15, 10, 36, 0.18);
  transition: transform 0.15s ease, border-color 0.15s ease, filter 0.2s ease;
}
.kfe-opt:hover:not(.locked) { transform: translateY(-2px); }
.kfe-opt.picked { border-color: #fff; }
.kfe-opt.locked { cursor: default; }
.kfe-opt.locked:not(.right):not(.wrong) { filter: saturate(0.55) opacity(0.8); }
.kfe-check { width: 1.2rem; font-size: 1rem; flex-shrink: 0; }
.kfe-opt.right .kfe-check::before { content: '✓'; color: #14655d; font-weight: 900; }
.kfe-opt.wrong .kfe-check::before { content: '✗'; color: #c0392b; font-weight: 900; }
.kfe-opt-emoji { font-size: 1.25rem; }
/* ---- brand art in games (rule 32: emoji are never illustrations) ----
   Square rounded thumbs; the span shows the emoji fallback only when the
   image fails to load. Fixed box sizes + width/height attrs = zero CLS. */
.kfe-opt-art {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 4.5rem;
  height: 4.5rem;
  flex-shrink: 0;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.4);
  font-size: 2.2rem; /* emoji fallback size */
  line-height: 1;
}
.kfe-opt-art img {
  width: 100%;
  height: 100%;
  object-fit: cover; /* sources are square 512x512: no crop */
  display: block;
}
.kfe-art-big {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 9rem;
  height: 9rem;
  border-radius: 18px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.5);
  font-size: 5rem; /* emoji fallback size */
  line-height: 1;
}
.kfe-art-big img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.kfe-feedback {
  min-height: 1.6rem;
  color: #fff;
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1.4;
  margin: 0 0 0.4rem;
  text-shadow: 0 1px 6px rgba(15, 10, 36, 0.3);
}
.kfe-cheer {
  color: #eafff9;
  font-weight: 700;
  font-size: 1.02rem;
  margin: 0 0 0.7rem;
  text-shadow: 0 1px 6px rgba(15, 10, 36, 0.3);
}
.kfe-cheer[hidden] { display: none !important; }
.kfe-feedback.yes { color: #eafff9; }
.kfe-feedback.oops { color: #ffe9a8; }
.kfe-send {
  min-height: 2.75rem; /* 44px touch floor */
  box-sizing: border-box;
  border: 0;
  background: #fff;
  color: #14655d;
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 1.05rem;
  border-radius: 999px;
  padding: 0.6rem 1.8rem;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(15, 10, 36, 0.2);
  transition: transform 0.15s ease, opacity 0.2s ease;
}
.kfe-send:disabled { opacity: 0.45; cursor: default; }
.kfe-send:not(:disabled):hover { transform: translateY(-2px); }

.kfe-clue { position: relative; margin-top: 1.2rem; display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }
.kfe-clue-title {
  color: #fff;
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 1.15rem;
}
.kfe-clue-btn {
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffd94d 0%, #f7c832 100%);
  color: #2d1b4e;
  font-size: 1.6rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(15, 10, 36, 0.25);
}
.kfe-clue-bubble {
  flex-basis: 100%;
  background: #fff;
  color: #2d1b4e;
  border-radius: 16px;
  padding: 0.9rem 1.1rem;
  box-shadow: 0 8px 24px rgba(15, 10, 36, 0.25);
  line-height: 1.45;
  max-width: 34ch;
}
.kfe-clue-bubble[hidden] { display: none !important; }

.kfe-photo {
  background: #d8f3ef;
  border-radius: 20px;
  padding: 0.9rem;
}
.kfe-photo img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 14px;
}

/* menu + end screens */
.kfe-menu, .kfe-end {
  text-align: center;
  background: linear-gradient(160deg, #22b3a6 0%, #1d9c95 100%);
  border-radius: 26px;
  padding: 2.2rem 1.6rem;
  box-shadow: 0 14px 40px rgba(15, 10, 36, 0.22);
}
.kfe-title, .kfe-end h2 {
  color: #fff;
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  margin: 0 0 0.4rem;
  text-shadow: 0 2px 12px rgba(15, 10, 36, 0.3);
}
.kfe-sub, .kfe-end p {
  color: #eafff9;
  font-weight: 600;
  margin: 0 auto 1.4rem;
  max-width: 46ch;
}
.kfe-menu-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 15rem));
  gap: 1rem;
  justify-content: center;
}
.kfe-menu-card {
  border: 4px solid #fff;
  border-radius: 20px;
  background: #d8f3ef;
  padding: 0.8rem;
  cursor: pointer;
  transition: transform 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}
.kfe-menu-card:hover { transform: translateY(-4px); }
/* Principle 36 (Deniz): FACES WIN over uniform-fill. The quest covers are
   500x700 portrait face art; the frame matches the source aspect exactly,
   so the whole face shows and nothing is ever cut. */
.kfe-menu-card img {
  width: 100%;
  aspect-ratio: 5 / 7;
  height: auto;
  object-fit: cover;
  border-radius: 12px;
  display: block;
}
.kfe-menu-name {
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 1.15rem;
  color: #2d1b4e;
}
.kfe-menu-go {
  background: linear-gradient(180deg, #ffd94d 0%, #f7c832 100%);
  color: #2d1b4e;
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-weight: 800;
  border-radius: 999px;
  padding: 0.35rem 1.6rem;
}
.kfe-end-stars { color: #ffd94d; font-size: 1.8rem; margin-bottom: 0.4rem; }
.kfe-end-btns { display: flex; gap: 0.7rem; justify-content: center; flex-wrap: wrap; }
.kfe-again, .kfe-other, .kfe-more {
  border: 0;
  background: #fff;
  color: #14655d;
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 1rem;
  border-radius: 999px;
  padding: 0.6rem 1.5rem;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(15, 10, 36, 0.2);
  transition: transform 0.15s ease;
}
.kfe-again:hover, .kfe-other:hover, .kfe-more:hover { transform: translateY(-2px); }
.kfe-other { background: linear-gradient(180deg, #ffd94d 0%, #f7c832 100%); color: #2d1b4e; }

.kfe-confetti {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  border-radius: 26px;
}
.kfe-confetti span {
  position: absolute;
  top: -14px;
  width: 10px;
  height: 14px;
  border-radius: 3px;
  animation: kfe-fall 1.8s ease-in forwards;
}
@keyframes kfe-fall {
  to { transform: translateY(110vh) rotate(540deg); opacity: 0.2; }
}

@media (max-width: 700px) {
  .kfe-panel { grid-template-columns: 1fr; }
  .kfe-photo { order: -1; max-width: 17rem; margin: 0 auto; }
  .kfe-menu-cards { grid-template-columns: 1fr; }
}

/* ============ Riddles + Echo Rhymes extras (share kfe-*) ============ */
.kfe-bartitle {
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-weight: 800;
  color: #2d1b4e;
  font-size: 1.05rem;
}
.kfe-mystery {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  min-height: 15rem;
}
.kfe-bigmoji {
  font-size: 5.2rem;
  line-height: 1;
}
.kfe-mystery-label {
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 1.2rem;
  color: #14655d;
}
.kfe-question strong { color: #ffe9a8; }
.kfe-clue-bubble strong { color: #14655d; }

/* ============ Magic Letter Builder (kf-spell) ============ */
.kfs { position: relative; font-family: 'Nunito', system-ui, sans-serif; }
.kfs-panel {
  background: linear-gradient(160deg, #22b3a6 0%, #1d9c95 100%);
  border-radius: 26px;
  padding: 1.6rem;
  box-shadow: 0 14px 40px rgba(15, 10, 36, 0.22);
  text-align: center;
}
.kfs-target {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
/* Deniz (design tour): BIG word image on one SIDE, play area beside it. */
@media (min-width: 700px) {
  .kfs-panel {
    display: grid;
    grid-template-columns: minmax(15rem, 21rem) 1fr;
    grid-template-areas:
      'art slots'
      'art msg'
      'art bank'
      'art next';
    column-gap: 1.6rem;
    align-items: center;
  }
  .kfs-target { grid-area: art; margin-bottom: 0; }
  .kfs-slots { grid-area: slots; }
  .kfs-msg { grid-area: msg; }
  .kfs-bank { grid-area: bank; }
  .kfs-next { grid-area: next; justify-self: center; }
}
.kfs-emoji { font-size: 4.6rem; line-height: 1; } /* legacy fallback text size */
/* spell word illustration: brand art (rule 32), emoji only as fallback.
   Large by design (Deniz: "resmi büyük kullan"). */
.kfs-art {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: min(100%, 21rem);
  aspect-ratio: 1;
  height: auto;
  border-radius: 18px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.35);
  font-size: 7rem; /* emoji fallback size */
  line-height: 1;
}
@media (max-width: 699.9px) {
  .kfs-art { width: min(72vw, 16rem); }
}
.kfs-art img {
  width: 100%;
  height: 100%;
  object-fit: cover; /* sources are square 512x512: no crop */
  display: block;
}
.kfs-listen {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem; /* 44px touch floor */
  box-sizing: border-box;
  border: 0;
  background: #fff;
  color: #14655d;
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 1rem;
  border-radius: 999px;
  padding: 0.55rem 1.3rem;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(15, 10, 36, 0.2);
  transition: transform 0.15s ease;
}
.kfs-listen:hover { transform: translateY(-2px); }
.kfs-slots {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.kfs-slot {
  width: 3.2rem;
  height: 3.6rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.25);
  border-bottom: 4px solid rgba(255, 255, 255, 0.6);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 1.9rem;
  color: #fff;
}
.kfs-slot.filled {
  background: #fff;
  color: #14655d;
  border-bottom-color: #d4a843;
  animation: kfs-pop 0.3s ease;
}
@keyframes kfs-pop {
  0% { transform: scale(0.7); }
  60% { transform: scale(1.12); }
  100% { transform: scale(1); }
}
.kfs-msg {
  min-height: 1.6rem;
  color: #fff;
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1.4;
  margin: 0 0 1.1rem;
  text-shadow: 0 1px 6px rgba(15, 10, 36, 0.3);
}
.kfs-bank {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.55rem;
  margin-bottom: 0.4rem;
}
.kfs-tile {
  width: 3rem;
  height: 3.3rem;
  border: 3px solid transparent;
  border-radius: 12px;
  background: linear-gradient(180deg, #ffd94d 0%, #f7c832 100%);
  color: #2d1b4e;
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(15, 10, 36, 0.18);
  transition: transform 0.15s ease, opacity 0.2s ease;
}
.kfs-tile:hover:not(:disabled) { transform: translateY(-3px); }
.kfs-tile.used { opacity: 0.25; cursor: default; }
.kfs-tile.nope { animation: kfs-wiggle 0.4s ease; }
@keyframes kfs-wiggle {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px) rotate(-3deg); }
  75% { transform: translateX(5px) rotate(3deg); }
}
.kfs-next {
  border: 0;
  background: #fff;
  color: #14655d;
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 1.05rem;
  border-radius: 999px;
  padding: 0.6rem 1.8rem;
  margin-top: 0.8rem;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(15, 10, 36, 0.2);
}
.kfs-next:hover { transform: translateY(-2px); }

@media (prefers-reduced-motion: reduce) {
  .kfs-slot.filled, .kfs-tile.nope { animation: none; }
}

/* ============ Melo's Music Grove (kf-melody) ============
   Night-grove purple panel (the other games own teal); soft glows only,
   every lit state fades over 300ms+ - never a strobe. */
.kf-melody {
  position: relative;
  font-family: 'Nunito', system-ui, sans-serif;
}
.kfmel-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.kfmel-title {
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-weight: 700;
  color: #2d1b4e;
  font-size: 1.02rem;
}
.kfmel-status {
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  color: #4a3f66;
}
.kfmel-spacer { flex: 1; }
.kfmel-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.75rem; /* 44px touch floor */
  min-width: 2.75rem;
  box-sizing: border-box;
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  color: #2d1b4e;
  background: #ede6f5;
  border: 2px solid #b8a0d2;
  border-radius: 999px;
  padding: 6px 13px;
  cursor: pointer;
  transition: background 0.25s ease, transform 0.25s ease;
  white-space: nowrap;
}
.kfmel-btn:hover {
  background: #fff;
  transform: translateY(-1px);
}

/* mode menu */
.kfmel-menu {
  text-align: center;
  background: linear-gradient(160deg, #43306e 0%, #2d1b4e 100%);
  border-radius: 26px;
  padding: 2rem 1.6rem;
  box-shadow: 0 14px 40px rgba(15, 10, 36, 0.22);
}
.kfmel-menu-lead {
  color: #efe9fb;
  font-weight: 700;
  font-size: 1.12rem;
  margin: 0 auto 1.3rem;
  max-width: 44ch;
  text-shadow: 0 1px 6px rgba(15, 10, 36, 0.3);
}
.kfmel-menu-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 15rem));
  gap: 1rem;
  justify-content: center;
}
.kfmel-menu-card {
  border: 4px solid #fff;
  border-radius: 20px;
  background: #ede6f5;
  padding: 1rem 0.8rem;
  cursor: pointer;
  transition: transform 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}
.kfmel-menu-card:hover { transform: translateY(-4px); }
.kfmel-menu-art {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 5.5rem;
  height: 5.5rem;
  border-radius: 50%;
  background: linear-gradient(180deg, #2ec4b6 0%, #22a397 100%);
  overflow: hidden;
}
.kfmel-menu-art svg { width: 3.4rem; height: 3.4rem; }
/* Pip: a face always beats an icon. Give Free Play a warm gold bloom so the
   young-band card holds its own next to Melo's photo. */
.kfmel-menu-card[data-mode='free'] .kfmel-menu-art {
  background: linear-gradient(180deg, #ffd94d 0%, #f7c832 100%);
}
.kfmel-menu-melo { background: #2d1b4e; }
.kfmel-menu-melo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.kfmel-menu-name {
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 1.2rem;
  color: #2d1b4e;
}
.kfmel-menu-hint {
  font-weight: 600;
  font-size: 0.92rem;
  color: #4a3f66;
  max-width: 22ch;
}

/* stage */
.kfmel-stage {
  text-align: center;
  background: linear-gradient(160deg, #43306e 0%, #2d1b4e 100%);
  border-radius: 26px;
  padding: 1.6rem 1.4rem 1.3rem;
  box-shadow: 0 14px 40px rgba(15, 10, 36, 0.22);
}
.kfmel-say {
  min-height: 1.7rem;
  color: #fff;
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 1.25rem;
  margin: 0 0 0.9rem;
  text-shadow: 0 1px 6px rgba(15, 10, 36, 0.3);
}
.kfmel-dots {
  display: flex;
  justify-content: center;
  gap: 0.45rem;
  margin-bottom: 1rem;
  min-height: 12px;
}
.kfmel-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  transition: background 0.3s ease;
}
.kfmel-dot.done { background: #d4a843; }
.kfmel-pads {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: clamp(0.7rem, 2.5vw, 1.3rem);
  margin: 0 auto 1.1rem;
  max-width: 34rem;
}
.kfmel-pad {
  width: clamp(5rem, 24vw, 8rem);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.55);
  background: var(--pad-color, #2ec4b6);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(15, 10, 36, 0.35);
  transition: filter 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.kfmel-pad svg {
  width: 58%;
  height: 58%;
  pointer-events: none;
}
/* Do Re Mi board: 8 smaller pads with solfege names (4+4 rows) */
.kfmel-pads[data-count='8'] {
  max-width: 30rem;
}
.kfmel-pads[data-count='8'] .kfmel-pad {
  width: clamp(3.6rem, 19vw, 5.8rem);
  border-width: 3px;
}
.kfmel-pad-label {
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-weight: 800;
  font-size: clamp(1.05rem, 3.6vw, 1.5rem);
  color: #2d1b4e;
  pointer-events: none;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
}
.kfmel-pad:hover { filter: brightness(1.08); }
/* the glow: a slow swell, never a flash (300ms in, 300ms out) */
.kfmel-pad.lit {
  filter: brightness(1.3) saturate(1.15);
  box-shadow: 0 0 0 8px rgba(255, 255, 255, 0.3), 0 0 34px 6px var(--pad-color), 0 6px 18px rgba(15, 10, 36, 0.35);
  transform: scale(1.06);
}
.kfmel-pads.listening .kfmel-pad { cursor: default; }
.kfmel-actions {
  display: flex;
  justify-content: center;
  gap: 0.7rem;
  flex-wrap: wrap;
  min-height: 2.75rem;
  margin-bottom: 0.9rem;
}
.kfmel-actions .kfmel-btn {
  background: #fff;
  border-color: #fff;
  color: #43306e;
}

/* grove strip: one flower blooms per completed round */
.kfmel-garden {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  min-height: 2rem;
}
.kfmel-flower {
  display: inline-flex;
  width: 2rem;
  height: 2rem;
  animation: kfmel-bloom 0.5s ease;
}
.kfmel-flower svg { width: 100%; height: 100%; }
@keyframes kfmel-bloom {
  from { transform: scale(0.3) rotate(-40deg); opacity: 0; }
  to { transform: scale(1) rotate(0); opacity: 1; }
}

/* end card */
.kfmel-end {
  text-align: center;
  background: linear-gradient(160deg, #43306e 0%, #2d1b4e 100%);
  border-radius: 26px;
  padding: 2.2rem 1.6rem;
  box-shadow: 0 14px 40px rgba(15, 10, 36, 0.22);
}
.kfmel-end-big {
  color: #fff;
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-weight: 800;
  font-size: clamp(1.5rem, 3.4vw, 2.1rem);
  margin: 0 0 0.5rem;
  text-shadow: 0 2px 12px rgba(15, 10, 36, 0.3);
}
.kfmel-end-small {
  color: #efe9fb;
  font-weight: 600;
  margin: 0 auto 1.4rem;
  max-width: 44ch;
}
.kfmel-end-btns {
  display: flex;
  justify-content: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}
.kfmel-end-btns .kfmel-big {
  background: #fff;
  border-color: #fff;
  color: #43306e;
  font-size: 1.02rem;
  padding: 0.6rem 1.4rem;
}
.kfmel-end-btns .kfmel-new {
  background: linear-gradient(180deg, #ffd94d 0%, #f7c832 100%);
  border-color: #f7c832;
  color: #2d1b4e;
}

@media (max-width: 620px) {
  .kfmel-menu-cards { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .kfmel-pad, .kfmel-pad.lit { transform: none; }
  .kfmel-flower { animation: none; }
  .kfmel-menu-card:hover, .kfmel-btn:hover { transform: none; }
}
