/* KG Smart Games (/kg-smart, docs/kg-smart-games.md). Big targets, no reading needed, calm motion. */
.ks-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ks-wrap { padding-bottom: 24px; }
.ks-stage { padding: clamp(12px, 3vw, 24px); min-height: 0; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
.ks-stage button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.ks-note { color: var(--muted); font-size: 14px; margin-top: 14px; }

/* round buttons */
.ks-round { width: 56px; height: 56px; flex: 0 0 56px; border-radius: 50%; border: 2px solid var(--line); background: var(--card); font-size: 26px; cursor: pointer; display: inline-grid; place-items: center; text-decoration: none; color: var(--ink); box-shadow: 0 4px 0 rgba(10, 19, 48, .1); }
.ks-round:active { transform: translateY(2px); box-shadow: none; }

/* ---------- menu ---------- */
.ks-menu-top { display: flex; align-items: center; gap: 12px; }
.ks-menu-top h1 { margin: 0; font: 700 clamp(24px, 6vw, 34px) var(--font-display); }
.ks-hello { display: flex; align-items: center; gap: 12px; margin: 14px 0 6px; }
.ks-hello .kg-bubble { font-size: clamp(16px, 4vw, 20px); }
.ks-mc { flex: 0 0 auto; display: inline-flex; width: 72px; justify-content: center; }
.ks-mc .mc { width: 64px; height: auto; }
.ks-mc-big { width: 110px; }
.ks-mc-big .mc { width: 100px; }
.ks-mc-fallback { font-size: 44px; }
.ks-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-top: 14px; }
.ks-tile { position: relative; border: 0; border-radius: 26px; padding: 18px 10px 14px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: linear-gradient(160deg, var(--c1), var(--c2)); color: var(--on-bright); font: 700 clamp(17px, 4.2vw, 21px)/1.2 var(--font-display); box-shadow: 0 7px 0 rgba(10, 19, 48, .14); transition: transform .15s; min-height: 150px; }
.ks-tile:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(10, 19, 48, .14); }
.ks-tile-art { width: 72px; height: 72px; display: grid; place-items: center; }
.ks-tile-art svg { width: 100%; height: 100%; display: block; overflow: visible; }
.ks-tile-name { text-align: center; }
.ks-tile-lv { font-size: 16px; color: #e39a00; letter-spacing: 2px; }
.ks-tile-lv i { font-style: normal; color: rgba(10, 19, 48, .18); }
.ks-tile.ks-hint { outline: 5px solid #ffc93c; }

/* ---------- playing ---------- */
.ks-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ks-dots { display: flex; gap: 6px; flex: 1; justify-content: center; min-width: 90px; }
.ks-dots span { width: 14px; height: 14px; border-radius: 50%; background: var(--line); }
.ks-dots span.done { background: var(--green); }
.ks-dots span.now { background: var(--accent); transform: scale(1.25); }
.ks-starcount { font: 700 22px var(--font-display); background: var(--card); border: 2px solid var(--line); border-radius: 999px; padding: 6px 14px; }
.ks-ask { display: flex; align-items: center; gap: 10px; margin: 12px 0 8px; }
.ks-prompt { flex: 1; margin: 0; font: 600 clamp(15px, 3.8vw, 19px)/1.35 var(--font-display); color: var(--ink); background: var(--card); border: 2px solid var(--line); border-radius: 18px; padding: 8px 12px; min-height: 48px; }
.ks-say { width: 72px; height: 72px; flex: 0 0 72px; border-radius: 50%; border: 0; background: #ffc93c; color: #1b1530; font-size: 34px; cursor: pointer; box-shadow: 0 6px 0 #d49b00; }
.ks-say:active { transform: translateY(3px); box-shadow: 0 2px 0 #d49b00; }
.ks-watch { text-align: center; font: 700 20px var(--font-display); margin: 0 0 8px; color: var(--link-strong); }
.ks-demo .ks-scene, .ks-demo .ks-choices { cursor: default; }

.ks-scene { position: relative; border-radius: 22px; overflow: hidden; background: #dff1ff; }
.ks-svg { display: block; width: 100%; height: auto; max-height: 52vh; margin: 0 auto; }
.ks-mirror .ks-svg { transform: scaleX(-1); }
.ks-choices { display: flex; justify-content: center; gap: clamp(12px, 4vw, 28px); margin-top: 14px; flex-wrap: wrap; --cs: clamp(104px, 30vw, 156px); }
.ks-choices.n3 { --cs: clamp(92px, 27vw, 146px); }
.ks-choice { width: var(--cs); height: var(--cs); border-radius: 26px; border: 3px solid var(--line); background: var(--card); cursor: pointer; padding: 10px; display: grid; place-items: center; box-shadow: 0 7px 0 rgba(10, 19, 48, .12); transition: opacity .3s, filter .3s; }
.ks-choice svg { width: 100%; height: 100%; }
.ks-choice:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(10, 19, 48, .12); }
.ks-used { opacity: .4; filter: grayscale(.7); }
.ks-right { border-color: var(--green); box-shadow: 0 0 0 5px rgba(31, 167, 116, .35); }
.ks-wobble { animation: ks-wobble .45s; }
@keyframes ks-wobble { 20% { translate: -9px 0; } 50% { translate: 9px 0; } 80% { translate: -5px 0; } }

/* hint: glow + bounce + an arrow */
.ks-hint { animation: ks-bounce .9s ease-in-out infinite; filter: drop-shadow(0 0 10px #ffc93c) drop-shadow(0 0 4px #ffc93c); }
.ks-choice.ks-hint, .ks-card.ks-hint, .ks-seat.ks-hint { border-color: #ffc93c; opacity: 1; }
svg .ks-hint { transform-box: fill-box; }
@keyframes ks-bounce { 50% { translate: 0 -10px; } }
.ks-arrow { position: absolute; z-index: 18; width: 40px; height: 48px; pointer-events: none; animation: ks-bounce .8s ease-in-out infinite; }
.ks-arrow svg { width: 100%; height: 100%; }

/* demo hand */
.ks-hand { position: absolute; left: 0; top: 0; z-index: 20; width: 58px; pointer-events: none; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .25)); }
.ks-hand svg { width: 100%; display: block; transition: transform .2s; transform-origin: 30% 10%; }
.ks-hand.press svg { transform: scale(.82); }

.ks-flyer { position: absolute; z-index: 15; pointer-events: none; margin: 0; visibility: visible !important; opacity: 1 !important; filter: none !important; transform-origin: center; }
.ks-burst { position: absolute; z-index: 16; top: 40%; left: 50%; font-size: 64px; pointer-events: none; animation: ks-burst 1.1s ease-out forwards; }
@keyframes ks-burst { from { transform: translate(-50%, 0) scale(.4); opacity: 0; } 30% { opacity: 1; transform: translate(-50%, -30px) scale(1.2); } to { transform: translate(-50%, -140px) scale(.8); opacity: 0; } }
.ks-cheer { animation: ks-jump .55s ease 2; }
@keyframes ks-jump { 40% { translate: 0 -14px; } }

/* ---------- end ---------- */
.ks-end { text-align: center; padding: 18px 0; }
.ks-end h2 { font: 700 clamp(22px, 5.5vw, 30px) var(--font-display); margin: 8px 0; }
.ks-end-btns { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.ks-big-btn { min-height: 64px; padding: 0 26px; border-radius: 999px; border: 0; background: var(--primary); color: #fff; font: 700 20px var(--font-display); cursor: pointer; box-shadow: 0 6px 0 var(--primary-dark); }
.ks-big-btn.alt { background: #ffc93c; color: #1b1530; box-shadow: 0 6px 0 #d49b00; }
.ks-big-btn:active { transform: translateY(3px); box-shadow: none; }

/* ---------- 1. bridge ---------- */
.ks-bridge { background: linear-gradient(#bfe8ff, #e6f6ff); }
.ks-carrot { transition: opacity .4s; }
.ks-carrot.ks-gone { opacity: 0; }
.ks-piece { overflow: visible; }

/* ---------- 2. puppy ---------- */
.ks-door { cursor: pointer; }
.ks-door-panel { transform-box: fill-box; transform-origin: 0 50%; transition: transform .45s ease; }
.ks-door.open .ks-door-panel { transform: scaleX(.12); }
.ks-pup-in { opacity: 0; transition: opacity .3s; }
.ks-pup-in.show { opacity: 1; }
.ks-door.ks-hint { filter: drop-shadow(0 0 8px #ffc93c) drop-shadow(0 0 3px #ffc93c); }

/* ---------- 3. picnic ---------- */
.ks-picnic { background: #a6e08c; padding: 14px 10px 10px; }
.ks-blanket { display: flex; flex-wrap: wrap; justify-content: center; gap: clamp(6px, 2vw, 14px); padding: 14px 8px; border-radius: 18px;
  background: repeating-conic-gradient(#ff8fa3 0 25%, #fff 0 50%) 0 0 / 44px 44px; }
.ks-seat { width: clamp(84px, 25vw, 128px); border: 0; background: rgba(255, 255, 255, .78); border-radius: 22px; padding: 8px 6px 6px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; border: 3px solid transparent; }
.ks-blanket.n5 .ks-seat { width: clamp(76px, 22vw, 116px); }
.ks-seat-face { width: 82%; }
.ks-seat-face svg { width: 100%; display: block; }
.ks-plate { width: 72%; height: clamp(28px, 7vw, 40px); border-radius: 50%; background: #fff; border: 3px solid #d9dbe6; display: grid; place-items: center; }
.ks-plate .ks-berry { height: 120%; width: auto; margin-top: -14px; }
.ks-fed .ks-seat-face { animation: ks-jump .5s ease; }
.ks-basket { width: min(220px, 60%); margin: 10px auto 0; position: relative; }
.ks-basket-berries { display: flex; justify-content: center; gap: 2px; margin-bottom: -16px; position: relative; z-index: 1; }
.ks-basket-berries .ks-berry { width: 34px; height: auto; }
.ks-berry.taken { visibility: hidden; }
.ks-basket-svg { width: 100%; display: block; }

/* ---------- 4. train ---------- */
.ks-scene.ks-train { background: linear-gradient(#cfe9ff, #eaf6ff); }
.ks-track { padding: clamp(18px, 5vw, 36px) 6px 14px; overflow: hidden; }
.ks-trainrow { display: flex; align-items: flex-end; justify-content: center; gap: 3px; }
.ks-eng { width: clamp(58px, 14vw, 104px); flex: 0 0 auto; }
.ks-eng svg { width: 100%; display: block; overflow: visible; }
[dir="rtl"] .ks-eng svg { transform: scaleX(-1); }
.ks-tcar { width: clamp(42px, 11vw, 80px); flex: 0 1 auto; aspect-ratio: 80 / 74; display: grid; place-items: center; }
.ks-tcar svg { width: 100%; display: block; }
.ks-tslot { border: 3px dashed #7a86b8; border-radius: 12px; background: rgba(255, 255, 255, .6); }
.ks-tslot b { font: 700 clamp(22px, 6vw, 36px) var(--font-display); color: #5b6492; }
.ks-rails { height: 10px; margin-top: 2px; border-radius: 4px; background: repeating-linear-gradient(90deg, #8b5a2b 0 8px, transparent 8px 20px), linear-gradient(#7a7f99, #7a7f99) 0 0 / 100% 4px no-repeat; }
.ks-smoke { animation: ks-smoke 1.4s ease-in-out infinite; }
@keyframes ks-smoke { 50% { translate: 0 -4px; opacity: .6; } }

/* ---------- 5. plant ---------- */
.ks-garden { position: relative; }
.ks-sky { fill: #bfe8ff; transition: fill .8s; }
.ks-garden.is-dark .ks-sky { fill: #2a3263; }
.ks-garden.is-dark.lit .ks-sky { fill: #bfe8ff; }
.ks-sunspot { opacity: 1; transition: opacity .8s; }
.ks-moon { opacity: 0; transition: opacity .8s; }
.ks-moon-cut { fill: #2a3263; }
.ks-garden.is-dark .ks-sunspot { opacity: 0; }
.ks-garden.is-dark .ks-moon { opacity: 1; }
.ks-garden.is-dark.lit .ks-sunspot { opacity: 1; }
.ks-garden.is-dark.lit .ks-moon { opacity: 0; }
.ks-night { opacity: 0; pointer-events: none; transition: opacity .8s; }
.ks-garden.is-dark .ks-night { opacity: .3; }
.ks-garden.is-dark.lit .ks-night { opacity: 0; }
.ks-stem { transform-box: fill-box; transform-origin: 50% 100%; transform: rotate(40deg); transition: transform 1.2s cubic-bezier(.3, 1.4, .5, 1); }
.ks-garden.happy .ks-stem { transform: rotate(0); }
.ks-stem.shake { animation: ks-wig .5s; }
@keyframes ks-wig { 25% { translate: -4px 0; } 75% { translate: 4px 0; } }
.ks-leaf { fill: #b7c46c; transition: fill 1s; }
.ks-garden.happy .ks-leaf { fill: #3fbf5f; }
.ks-bloom { transform: scale(0); transform-box: fill-box; transform-origin: center; transition: transform .8s .5s cubic-bezier(.3, 1.6, .5, 1); }
.ks-garden.happy .ks-bloom { transform: scale(1); }
.ks-garden.happy .ks-bud { opacity: 0; }
.ks-soil { fill: #d8b98a; transition: fill 1s; }
.ks-garden.is-dark .ks-soil, .ks-garden.wet .ks-soil { fill: #6b4226; }
.ks-garden.is-dark .ks-cracks, .ks-garden.wet .ks-cracks { opacity: 0; }
.ks-drops { opacity: 0; }
.ks-garden.watering .ks-drops { animation: ks-drops .5s linear 3; }
@keyframes ks-drops { from { opacity: 1; translate: 0 -20px; } to { opacity: 0; translate: 0 40px; } }
.ks-fx { position: absolute; left: 50%; top: 2%; width: 30%; aspect-ratio: 1; translate: -50% 0; pointer-events: none; }
.ks-fx svg { width: 100%; height: 100%; display: block; }
.ks-fx.pour svg { transform: rotate(-35deg); transition: transform .4s; }
.ks-fx.bang svg { animation: ks-bang .3s ease-in-out 3; }
.ks-fx.hug svg { animation: ks-jump .5s ease 2; }
.ks-fx.shine svg { animation: ks-spin 2s linear infinite; }
@keyframes ks-bang { 50% { transform: scale(1.15) rotate(-6deg); } }
@keyframes ks-spin { to { transform: rotate(360deg); } }

/* ---------- 6. first ---------- */
.ks-scene.ks-first { background: #fff6dc; padding: 14px 8px; }
.ks-cards, .ks-slots { display: flex; justify-content: center; align-items: center; gap: clamp(8px, 3vw, 22px); --cs: clamp(92px, 27vw, 140px); }
.ks-slots.n3, .ks-scene.ks-first:has(.n3) .ks-cards { --cs: clamp(80px, 24vw, 126px); }
.ks-slots { margin-top: 16px; gap: 4px; }
.ks-card { width: var(--cs); height: var(--cs); border-radius: 22px; border: 3px solid var(--edge-yellow); background: #fff; padding: 8px; cursor: pointer; box-shadow: 0 6px 0 rgba(10, 19, 48, .12); }
.ks-card svg, .ks-oslot-pic svg { width: 100%; height: 100%; display: block; }
.ks-oslot { width: var(--cs); height: calc(var(--cs) + 22px); border-radius: 22px; border: 3px dashed #c9a85a; background: rgba(255, 255, 255, .55); display: flex; flex-direction: column; align-items: center; padding: 4px 8px 8px; }
.ks-oslot.full { border-style: solid; border-color: var(--green); background: #fff; }
.ks-oslot-pic { flex: 1; width: 100%; }
.ks-odots { font-size: 14px; letter-spacing: 3px; color: #c27b00; }
.ks-oarrow { font-size: clamp(20px, 5vw, 30px); color: #c27b00; }
[dir="rtl"] .ks-oarrow { transform: scaleX(-1); }
.ks-glow { box-shadow: 0 0 0 6px #ffc93c; scale: 1.06; transition: scale .2s, box-shadow .2s; }

/* ---------- 7. safari ---------- */
.ks-scene.ks-safari { background: radial-gradient(120px 60px at 15% 100%, #4cb35e, transparent), radial-gradient(160px 70px at 85% 100%, #3fa152, transparent), linear-gradient(#ffe7b8, #c9efb0); }
.ks-jungle { height: clamp(150px, 32vh, 230px); display: grid; place-items: center; position: relative; }
.ks-ear { width: 120px; height: 120px; border-radius: 50%; border: 0; background: #ffc93c; box-shadow: 0 7px 0 #d49b00; font-size: 52px; cursor: pointer; position: relative; }
.ks-ear:active { transform: translateY(3px); box-shadow: 0 3px 0 #d49b00; }
.ks-waves i { position: absolute; inset: 0; border-radius: 50%; border: 4px solid #ffc93c; opacity: 0; }
.ks-ear.on .ks-waves i { animation: ks-wave 1.2s ease-out forwards; }
.ks-ear.on .ks-waves i:nth-child(2) { animation-delay: .25s; }
.ks-ear.on .ks-waves i:nth-child(3) { animation-delay: .5s; }
@keyframes ks-wave { from { opacity: .9; transform: scale(1); } to { opacity: 0; transform: scale(1.9); } }
.ks-pop { position: absolute; width: 46%; max-width: 200px; aspect-ratio: 1; opacity: 0; pointer-events: none; }
.ks-pop svg { width: 100%; }
.ks-pop.on { animation: ks-popin .5s cubic-bezier(.3, 1.6, .5, 1) forwards, ks-jump .55s ease .5s 2; }
@keyframes ks-popin { from { opacity: 0; transform: scale(.2) translateY(60px); } to { opacity: 1; transform: none; } }
.ks-bush { width: 100%; height: 100%; display: grid; place-items: center; border-radius: 20px; background: radial-gradient(circle at 50% 120%, #8fd18a 0 45%, transparent 46%); }
.ks-bush svg { width: 88%; }

/* ---------- 8. toy ---------- */
.ks-hole { cursor: pointer; }
.ks-hole.ks-used { opacity: .55; filter: none; }

/* dark mode: the cards and buttons follow the theme; the drawn scenes stay bright like picture books */
[data-theme="dark"] .ks-scene { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .06); }
[data-theme="dark"] .ks-tile-lv i { color: rgba(10, 19, 48, .25); }

/* phones */
@media (max-width: 520px) {
  .ks-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .ks-tile { min-height: 134px; padding: 14px 8px 12px; }
  .ks-tile-art { width: 60px; height: 60px; }
  .ks-round { width: 50px; height: 50px; flex-basis: 50px; font-size: 22px; }
  .ks-say { width: 64px; height: 64px; flex-basis: 64px; font-size: 30px; }
  .ks-mc { width: 54px; }
  .ks-mc .mc { width: 50px; }
  .ks-starcount { font-size: 18px; padding: 4px 10px; }
}

/* reduced motion: no bouncing; hints keep the glow and the arrow */
@media (prefers-reduced-motion: reduce) {
  .ks-hint, .ks-arrow, .ks-cheer, .ks-wobble, .ks-smoke, .ks-fx svg, .ks-pop.on { animation: none !important; }
  .ks-pop.on { opacity: 1; }
}
html.reduce-motion .ks-pop.on { opacity: 1; }

/* site icons (icons.js) in the buttons */
.ks-round .ico { width: 26px; height: 26px; }
.ks-say .ico { width: 36px; height: 36px; }
.ks-ear-ico .ico { width: 56px; height: 56px; color: #1b1530; }
.ks-starcount .ico { color: #e39a00; fill: #ffc93c; }
.ks-big-btn { display: inline-flex; align-items: center; gap: 10px; }
.ks-big-btn .ico { width: 26px; height: 26px; }
.ks-menu-top h1 { display: flex; align-items: center; gap: 8px; }
.ks-menu-top h1 .ico { color: var(--link-strong); }
.ks-oarrow .ico { width: 1em; height: 1em; vertical-align: middle; }
.ks-watch .ico { vertical-align: -.15em; }
