/* Khan el-Khalili Merchant — game styles (uses tokens from assets/css/site.css) */
@property --aw1 { syntax: "<color>"; inherits: true; initial-value: #F4E3C3; }
@property --aw2 { syntax: "<color>"; inherits: true; initial-value: #4FB3FF; }

.kb {
  --brass: #E0A526; --brass-d: #B57E14; --wood: #8B4F27; --wood-d: #5E3218; --wood-l: #C98A52;
  --night: #2B1E4F; --glow: #FFD66B;
  padding-bottom: 30px;
}
.kb-screen[hidden], .kb [hidden] { display: none !important; }
.kb button { font-family: inherit; }
.kb-mode-btn, .kb-stage, .kb-choice, .kb-den, .kb-in, .kb-icon { color: var(--ink); }

/* =================== START =================== */
.kb-hero {
  position: relative; overflow: hidden; border-radius: var(--radius-lg); color: #FFF7EC;
  background:
    radial-gradient(120% 90% at 15% 110%, rgba(255, 179, 92, .45), transparent 60%),
    radial-gradient(80% 70% at 100% 0%, rgba(167, 139, 250, .35), transparent 60%),
    linear-gradient(150deg, #2B1E4F 0%, #5B2A55 55%, #7A1F3D 100%);
  display: grid; grid-template-columns: minmax(220px, 36%) 1fr; gap: 10px 28px; align-items: center;
  padding: 52px 34px 30px; box-shadow: var(--shadow-lg); margin-top: 6px;
}
.kb-hero::after { /* mashrabiya dots */
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .09;
  background: radial-gradient(circle, #FFE7B0 2px, transparent 2.6px) 0 0/18px 18px;
}
.kb-hero-lights { position: absolute; inset: 0 0 auto 0; height: 44px; z-index: 1; }
.kb-hero-art { position: relative; z-index: 2; height: 210px; }
.kb-hero-lamp { position: absolute; top: 0; width: 64px; transform-origin: 50% 0; animation: kbSway 3.4s ease-in-out infinite alternate; }
.kb-hero-lamp:nth-child(1) { inset-inline-start: 4%; top: -14px; animation-delay: -.8s; }
.kb-hero-lamp:nth-child(2) { inset-inline-start: 38%; width: 80px; top: -24px; }
.kb-hero-lamp:nth-child(3) { inset-inline-start: 74%; top: -8px; animation-delay: -1.7s; }
.kb-hero-lamp::before { content: ""; display: block; width: 2px; height: 22px; margin: 0 auto; background: #E7B23A; }
.kb-hero-lamp .art-lantern { filter: drop-shadow(0 0 14px rgba(255, 200, 80, .85)); }
.kb-hero-goods { position: absolute; bottom: 0; inset-inline: 0; display: flex; justify-content: center; gap: 4px;
  padding: 10px 6px 6px; border-radius: 16px; background: linear-gradient(#B97644, #8B4F27); box-shadow: inset 0 4px 0 #D99A64, 0 10px 20px rgba(0, 0, 0, .25); }
.kb-hero-goods .art { width: 22%; max-width: 64px; animation: kbBob 2.6s ease-in-out infinite; }
.kb-hero-goods .art:nth-child(2) { animation-delay: -.6s; } .kb-hero-goods .art:nth-child(3) { animation-delay: -1.2s; } .kb-hero-goods .art:nth-child(4) { animation-delay: -1.8s; }
.kb-hero-text { position: relative; z-index: 2; }
.kb-hero-pill { background: rgba(255, 255, 255, .14); color: #FFE7B0; }
.kb-hero h2 { font-size: clamp(1.7rem, 4vw, 2.7rem); margin: .35em 0 .3em; color: #fff; }
.kb-hero p { color: #F6E7FF; margin-bottom: .6em; }
.kb-how { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-weight: 600; font-size: .98rem; }
.kb-how li { background: rgba(255, 255, 255, .1); border-radius: 14px; padding: .35em .8em; }

.kb-label { margin: 26px 0 12px; font-size: 1.25rem; }
.kb-mode { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 640px; }
.kb-mode-btn {
  display: flex; align-items: center; gap: 12px; text-align: start; cursor: pointer; border: 0; border-radius: var(--radius);
  padding: 14px 16px; background: var(--paper); box-shadow: inset 0 0 0 2px var(--line), var(--shadow);
  transition: transform .35s var(--spring), box-shadow .25s, background .25s;
}
.kb-mode-btn .em { font-size: 1.9rem; line-height: 1; }
.kb-mode-btn b { display: block; font-size: 1.12rem; }
.kb-mode-btn small { display: block; color: var(--muted); font-weight: 600; font-size: .85rem; line-height: 1.3; }
.kb-mode-btn:hover { transform: translateY(-2px); }
.kb-mode-btn[aria-checked="true"] { background: var(--ink); color: #fff; box-shadow: 0 8px 0 #160f24, var(--shadow); }
.kb-mode-btn[aria-checked="true"] small { color: #D9D0EE; }
.kb-mode-btn[data-mode="blitz"][aria-checked="true"] { background: linear-gradient(135deg, #FF7A59, #E0A526); color: var(--ink); box-shadow: 0 8px 0 #B5651E, var(--shadow); }
.kb-mode-btn[data-mode="blitz"][aria-checked="true"] small { color: #3d2a12; }

.kb-stages { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.kb-stage {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: start; cursor: pointer;
  border: 0; border-radius: var(--radius-lg); padding: 22px 22px 20px; min-height: 170px; overflow: hidden;
  background: var(--paper); box-shadow: var(--shadow); transition: transform .4s var(--spring), box-shadow .3s;
}
.kb-stage::before { content: ""; position: absolute; inset: auto -30px -40px auto; width: 140px; height: 140px; border-radius: 50%; background: var(--sc, var(--sun-soft)); transition: transform .5s var(--spring); }
[dir=rtl] .kb-stage::before { inset: auto auto -40px -30px; }
.kb-stage > * { position: relative; }
.kb-stage.s-p13 { --sc: var(--sun-soft); --sd: #d49c13; }
.kb-stage.s-p46 { --sc: var(--mint-soft); --sd: #2E9C78; }
.kb-stage.s-prep { --sc: var(--lav-soft); --sd: #6d4fd0; }
.kb-stage-em { font-size: 2.6rem; line-height: 1; margin-bottom: 4px; display: inline-block; transition: transform .5s var(--spring); }
.kb-stage b { font-size: 1.45rem; line-height: 1.15; }
.kb-stage small { color: var(--muted); font-weight: 600; font-size: .92rem; line-height: 1.35; max-width: 92%; }
.kb-stage:hover { transform: translateY(-5px) rotate(-.6deg); box-shadow: var(--shadow-lg); }
.kb-stage:hover::before { transform: scale(1.25); }
.kb-stage:hover .kb-stage-em { transform: rotate(-12deg) scale(1.15); }
.kb-stage:active { transform: translateY(1px) scale(.98); }
.kb-go { position: absolute !important; bottom: 16px; inset-inline-end: 18px; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  background: var(--ink); color: #fff; font-size: .9rem; transition: transform .4s var(--spring); }
[dir=rtl] .kb-go { transform: scaleX(-1); }
.kb-stage:hover .kb-go { transform: scale(1.12); }
[dir=rtl] .kb-stage:hover .kb-go { transform: scaleX(-1) scale(1.12); }
.kb-last { display: none; position: absolute !important; top: 14px; inset-inline-end: 14px; font-size: .78rem; font-weight: 800; padding: .2em .7em; border-radius: 999px; background: var(--sd); color: #fff; }
.kb-stage.is-last { box-shadow: 0 0 0 3px var(--sd), var(--shadow-lg); }
.kb-stage.is-last .kb-last { display: inline-block; }
.kb-best { margin: 18px 0 0; font-weight: 700; color: var(--muted); }

/* =================== HUD =================== */
.kb-hud { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 4px 0 12px; }
.kb-dots { display: flex; gap: 6px; list-style: none; margin: 0; padding: 6px 10px; background: var(--paper); border-radius: 999px; box-shadow: var(--shadow); }
.kb-dots li { width: 20px; height: 20px; border-radius: 50%; background: var(--cream-2); display: grid; place-items: center; font-size: .72rem; font-weight: 800; color: #fff; line-height: 1;
  transition: transform .4s var(--spring), background .3s; }
.kb-dots li.cur { background: var(--sun); transform: scale(1.25); box-shadow: 0 0 0 3px var(--sun-soft); }
.kb-dots li.ok { background: var(--mint); animation: kbPop .5s var(--spring); }
.kb-dots li.no { background: var(--coral); }
.kb-dots li.miss { background: #CFC6DC; }
.kb-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--paper); border-radius: 999px; padding: .3em .9em; font-weight: 800; box-shadow: var(--shadow); }
.kb-combo { transition: background .3s, color .3s; }
.kb-combo.hot { background: linear-gradient(135deg, #FF7A59, #FFC845); }
.kb-combo.bump { animation: kbPop .5s var(--spring); }
.kb-mult:empty { display: none; }
.kb-mult { font-style: normal; background: var(--ink); color: #fff; border-radius: 999px; padding: 0 .5em; font-size: .85em; }
.kb-timer { min-width: 150px; }
.kb-tbar { flex: 1; height: 10px; border-radius: 99px; background: var(--cream-2); overflow: hidden; min-width: 70px; }
.kb-tbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--mint), var(--sun)); transform-origin: left; transition: transform .1s linear; }
[dir=rtl] .kb-tbar i { transform-origin: right; }
.kb-timer.low { color: #C2341C; animation: kbPulse .8s ease-in-out infinite; }
.kb-timer.low .kb-tbar i { background: var(--coral); }
.kb-timer b { min-width: 2ch; text-align: center; }
.kb-hud-sp { flex: 1; }
.kb-icon { width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer; background: var(--paper); box-shadow: var(--shadow); font-size: 1.1rem; display: grid; place-items: center;
  transition: transform .3s var(--spring); }
.kb-icon:hover { transform: scale(1.1) rotate(-6deg); }

/* =================== ARENA =================== */
.kb-arena { display: grid; gap: 16px; }
@media (min-width: 1000px) {
  .kb-arena { grid-template-columns: minmax(0, 1.35fr) minmax(330px, 1fr); align-items: start; }
}

/* =================== SCENE =================== */
.kb-scene {
  --dir: 1; --awn-h: clamp(36px, 7vw, 54px); --counter-h: 33%; --cw: clamp(96px, 23%, 150px);
  --aw1: #F4E3C3; --aw2: #4FB3FF;
  position: relative; height: clamp(300px, 64vw, 430px); border-radius: var(--radius-lg); overflow: hidden; isolation: isolate;
  background: var(--night); box-shadow: var(--shadow-lg); user-select: none; -webkit-user-select: none;
}
[dir=rtl] .kb-scene { --dir: -1; }
@media (min-width: 1000px) { .kb-scene { height: 470px; } .kb-scene .kb-goods .good { width: 92px; } .kb-scene .kb-goods.many .good { width: 72px; } .kb-scene .kb-goods .money-good { width: auto; } }
.kb-scene.lvl-1 { --aw1: #FF7A59; --aw2: #FFC845; }
.kb-scene.lvl-2 { --aw1: #7A1F3D; --aw2: #E0A526; }
.kb-bk { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; }
.kb-stars-bg circle { animation: kbTwinkle 3s ease-in-out infinite; }
.kb-stars-bg circle:nth-child(2n) { animation-delay: -1.4s; }

/* string lights */
.kb-lights { position: absolute; inset-inline: -2%; top: calc(var(--awn-h) + 4px); height: 36px; z-index: 1; transform-origin: 50% 0; animation: kbSwayWide 5s ease-in-out infinite alternate; }
.kb-wire { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.kb-bulb { position: absolute; width: 9px; height: 12px; margin-left: -4.5px; border-radius: 50% 50% 45% 45%; background: var(--c); opacity: .45;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .25); transition: opacity .6s, box-shadow .6s; }
.kb-bulb::before { content: ""; position: absolute; top: -3px; left: 2.5px; width: 4px; height: 4px; background: #2B1A16; border-radius: 1px; }
.lvl-0 .kb-bulb:nth-child(3n+2), .lvl-1 .kb-bulb:nth-child(2n+1), .lvl-2 .kb-bulb, .kb-hero-lights .kb-bulb {
  opacity: 1; box-shadow: 0 0 10px 3px var(--c); animation: kbTwinkle 2.4s ease-in-out infinite; animation-delay: var(--dl);
}

/* awning (foreground, top) */
.kb-awn {
  position: absolute; inset: 0 0 auto 0; height: var(--awn-h); z-index: 7;
  background:
    linear-gradient(to bottom, rgba(255, 255, 255, .28), rgba(255, 255, 255, 0) 40%, rgba(0, 0, 0, .18)),
    repeating-linear-gradient(90deg, var(--aw1) 0 28px, var(--aw2) 28px 56px);
  box-shadow: 0 6px 14px rgba(0, 0, 0, .28);
  transition: --aw1 .9s ease, --aw2 .9s ease;
}
.kb-awn-fringe { position: absolute; left: 0; right: 0; top: 100%; height: 14px;
  background:
    radial-gradient(circle at 14px 0, var(--aw1) 13px, transparent 14px) 0 0/56px 14px repeat-x,
    radial-gradient(circle at 42px 0, var(--aw2) 13px, transparent 14px) 0 0/56px 14px repeat-x;
  filter: drop-shadow(0 3px 2px rgba(0, 0, 0, .2)); transition: --aw1 .9s ease, --aw2 .9s ease; }
.kb-tassels { position: absolute; left: 0; right: 0; top: calc(100% + 10px); height: 14px; opacity: 0; transform: translateY(-8px); transition: opacity .6s, transform .6s var(--spring);
  background: radial-gradient(circle at 28px 3px, #FFE08A 3px, transparent 3.5px) 0 0/56px 14px repeat-x,
    linear-gradient(90deg, transparent 27px, #E0A526 27px 29px, transparent 29px) 0 0/56px 10px repeat-x; }
.lvl-2 .kb-tassels { opacity: 1; transform: none; }
.kb-scene.upgrading .kb-awn { animation: kbAwn .9s var(--spring); }

/* hanging lanterns */
.kb-lamps { position: absolute; inset: 0; z-index: 6; pointer-events: none; }
.lamp { position: absolute; top: calc(var(--awn-h) - 2px); inset-inline-start: var(--x); width: clamp(24px, 5.4vw, 40px); margin-inline-start: calc(clamp(24px, 5.4vw, 40px) / -2);
  transform-origin: 50% 0; animation: kbSway 3.2s ease-in-out infinite alternate; animation-delay: var(--dl); }
.lamp::before { content: ""; display: block; width: 2px; height: var(--chain); margin: 0 auto; background: #3A2414; }
.lamp .art-lantern { display: block; width: 100%; height: auto; transition: filter .6s; }
.lamp .g1, .lamp .g2, .lamp .g3 { transition: fill .6s; }
.lamp:not(.lit) .g1 { fill: #6B4B3A; } .lamp:not(.lit) .g2 { fill: #7A5843; } .lamp:not(.lit) .g3 { fill: #5E4335; }
.lamp:not(.lit) .flame { opacity: 0; }
.lamp.lit .art-lantern { filter: drop-shadow(0 0 8px rgba(255, 205, 90, .95)) drop-shadow(0 0 18px rgba(255, 150, 60, .55)); }
.lamp.lit .flame { animation: kbFlicker 1.3s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: 50% 100%; }
.lamp.pop .art-lantern { animation: kbLampOn .8s var(--spring); }

/* customer */
.kb-cust {
  position: absolute; z-index: 3; width: var(--cw); inset-inline-start: 9%;
  bottom: calc(var(--counter-h) - var(--cw) * .42);
  transform: translateX(0); transition: transform .85s cubic-bezier(.25, .8, .35, 1);
}
.kb-cust.no-tr { transition: none; }
.kb-cust.off-start { transform: translateX(calc(var(--dir) * -170%)); }
.kb-cust.off-end { transform: translateX(calc(var(--dir) * 620%)); transition-duration: .9s; transition-timing-function: cubic-bezier(.5, 0, .75, .4); }
.kb-person { display: block; width: 100%; height: auto; overflow: visible; transform-origin: 50% 100%; animation: kbBreathe 3.2s ease-in-out infinite; }
.kb-cust.walking .kb-person { animation: kbWalk .32s ease-in-out infinite alternate; }
.kb-person .eyes { transform-box: fill-box; transform-origin: center; animation: kbBlink 4.6s infinite; }
.kb-person .m { display: none; }
.mood-calm .m-calm, .mood-happy .m-happy, .mood-oops .m-oops { display: inline; }
.kb-person .arm-b { transform-box: view-box; transform-origin: 102px 132px; transition: transform .4s var(--spring); }
.mood-happy .kb-person .arm-b { animation: kbWave .45s ease-in-out .1s 4 alternate both; }
.mood-oops .kb-person .head { transform-box: view-box; transform-origin: 70px 110px; animation: kbTilt .6s ease-in-out both; }
.kb-hearts { position: absolute; inset: 0; pointer-events: none; }
.kb-hearts i { position: absolute; top: 10%; left: 50%; font-style: normal; font-size: clamp(14px, 3vw, 22px); opacity: 0; }
.mood-happy .kb-hearts i { animation: kbHeart 1.3s ease-out both; }
.mood-happy .kb-hearts i:nth-child(1) { --hx: -40px; }
.mood-happy .kb-hearts i:nth-child(2) { --hx: 0px; animation-delay: .15s; }
.mood-happy .kb-hearts i:nth-child(3) { --hx: 40px; animation-delay: .3s; }

/* speech bubble */
.kb-bubble {
  position: absolute; z-index: 8; top: calc(var(--awn-h) + 22px);
  inset-inline-start: calc(9% + var(--cw) + 4px); max-width: calc(88% - 9% - var(--cw)); min-width: 150px;
  background: #FFFDF7; color: var(--ink); border-radius: 20px; padding: 10px 14px; box-shadow: 0 10px 24px rgba(20, 10, 40, .35);
  font-weight: 700; font-size: clamp(.84rem, 2.1vw, 1.05rem); line-height: 1.45;
  transform: scale(.3); opacity: 0; transform-origin: 0 70%; transition: transform .45s var(--spring), opacity .2s;
}
[dir=rtl] .kb-bubble { transform-origin: 100% 70%; }
.kb-bubble.show { transform: none; opacity: 1; }
.kb-bubble::before { content: ""; position: absolute; top: 46%; inset-inline-start: -12px; border: 9px solid transparent; border-inline-end: 14px solid #FFFDF7; border-inline-start: 0; }
.kb-bubble p { margin: 0; }
.kb-hi { color: var(--maroon); font-weight: 800; font-size: .92em; }
.kb-hi:empty, #kb-say:empty { display: none; }

/* counter */
.kb-counter {
  position: absolute; inset: auto 0 0 0; height: var(--counter-h); z-index: 4;
  background:
    linear-gradient(to bottom, var(--wood-l) 0 12px, #7E431F 12px 15px, transparent 15px),
    linear-gradient(to bottom, transparent 46%, rgba(224, 165, 38, .9) 46% calc(46% + 3px), transparent calc(46% + 3px) calc(46% + 22px), rgba(224, 165, 38, .9) calc(46% + 22px) calc(46% + 25px), transparent calc(46% + 25px)),
    repeating-linear-gradient(45deg, transparent 0 9px, rgba(255, 220, 150, .16) 9px 11px),
    repeating-linear-gradient(-45deg, transparent 0 9px, rgba(255, 220, 150, .16) 9px 11px),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .08) 0 2px, transparent 2px 70px),
    linear-gradient(to bottom, var(--wood), var(--wood-d));
  box-shadow: 0 -8px 20px rgba(0, 0, 0, .3);
}
.kb-goods {
  position: absolute; bottom: calc(100% - 14px); inset-inline-start: 4%; inset-inline-end: calc(3% + clamp(62px, 15%, 96px));
  display: flex; justify-content: center; align-items: flex-end; gap: clamp(6px, 2.4vw, 22px); z-index: 2;
}
.good { position: relative; width: clamp(50px, 12.5vw, 78px); display: flex; flex-direction: column; align-items: center; }
.kb-goods.many .good { width: clamp(42px, 10vw, 66px); }
.kb-goods.pop .good { animation: kbDrop .6s var(--spring) both; animation-delay: var(--d); }
.kb-goods.leaving .good { opacity: 0; transform: translateY(10px) scale(.9); transition: .35s ease; }
.good .art { width: 100%; height: auto; display: block; filter: drop-shadow(0 4px 2px rgba(0, 0, 0, .3)); }
.good.g-lantern .art { width: 70%; }
.good .tag {
  position: absolute; top: 100%; margin-top: -4px; left: 50%; transform: translateX(-50%) rotate(-4deg); transform-origin: 50% 0;
  background: #FFF6DE; color: var(--ink); border-radius: 8px; padding: 2px 8px 3px; text-align: center; white-space: nowrap; line-height: 1.15;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .25); border: 1.5px solid #C9A46A; animation: kbTag 3.2s ease-in-out infinite alternate;
}
.good:nth-child(2n) .tag { transform: translateX(-50%) rotate(4deg); animation-delay: -1.3s; }
.good .tag::before { content: ""; position: absolute; top: -9px; left: 50%; width: 2px; height: 10px; background: #8A6A3A; }
.good .tag b.t1 { display: block; font-size: clamp(.9rem, 2.4vw, 1.15rem); }
.good .tag small.t2 { display: block; font-size: clamp(.62rem, 1.6vw, .74rem); font-weight: 700; color: var(--muted); }
.good .tag s.t0 { display: block; font-size: .72rem; color: #C2341C; font-weight: 700; }
.good .qty { position: absolute; top: -8px; inset-inline-end: -10px; background: var(--maroon); color: #fff; border-radius: 999px; padding: 0 .5em; font-weight: 800; font-size: clamp(.8rem, 2.2vw, 1rem);
  box-shadow: 0 3px 0 #4f1027; animation: kbPop .6s var(--spring) .35s both; }
.good .stk { position: absolute; top: -12px; inset-inline-start: -14px; background: var(--coral); color: #fff; border-radius: 12px; padding: .15em .45em; font-weight: 800;
  font-size: clamp(.62rem, 1.7vw, .8rem); line-height: 1.1; transform: rotate(-10deg); box-shadow: 0 3px 0 #C2341C; white-space: nowrap; animation: kbWiggle 2s ease-in-out infinite; }
.good .lbl { position: absolute; top: -6px; inset-inline-start: -6px; width: 26px; height: 26px; border-radius: 50%; background: var(--ink); color: #fff; font-weight: 800; display: grid; place-items: center; font-size: .9rem; }
.money-good { width: auto !important; }
.money-good .money { transform: rotate(-6deg); }
.money-good:nth-child(2n) .money { transform: rotate(5deg); }
.money-good .paid-lbl { position: absolute; top: 100%; margin-top: 4px; font-size: .72rem; font-weight: 800; background: var(--mint); color: #fff; border-radius: 999px; padding: 0 .6em; white-space: nowrap; }
.kb-goods.many .money-good .money.note { --nw: clamp(46px, 11vw, 64px); }
.kb-goods.many .good .tag { padding: 1px 5px 2px; }
.kb-goods.many .good .tag b.t1 { font-size: clamp(.72rem, 1.9vw, 1rem); }
.kb-goods.many .good:nth-child(2n) .tag { margin-top: 34px; }

/* cash box */
.kb-cashbox { position: absolute; bottom: calc(100% - 14px); inset-inline-end: 3%; width: clamp(62px, 15%, 96px); z-index: 3; }
.kb-pile { display: block; height: 18px; margin: 0 10% -6px; border-radius: 50% 50% 0 0 / 100% 100% 0 0;
  background: radial-gradient(circle at 30% 60%, #FFF1A8 0 3px, transparent 4px), radial-gradient(circle at 65% 40%, #FFF1A8 0 3px, transparent 4px), linear-gradient(#FFD34D, #D49C13);
  transform-origin: 50% 100%; transform: scaleY(.5); transition: transform .5s var(--spring); }
.lvl-1 .kb-pile { transform: scaleY(1); } .lvl-2 .kb-pile { transform: scaleY(1.5); }
.kb-chest { position: relative; display: grid; place-items: center; height: clamp(42px, 9vw, 58px); border-radius: 8px 8px 6px 6px;
  background: linear-gradient(90deg, transparent 18%, var(--brass) 18% 24%, transparent 24% 76%, var(--brass) 76% 82%, transparent 82%), linear-gradient(#A35F2E, #6B3A1A);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, .25), 0 4px 0 #3E2010; }
.kb-chest b { background: #FFF3CC; color: var(--ink); border-radius: 6px; padding: 0 6px; font-size: clamp(.8rem, 2.2vw, 1.05rem); box-shadow: inset 0 0 0 2px var(--brass); min-width: 2.5ch; text-align: center; }
.kb-cashbox.bump .kb-chest { animation: kbBox .35s var(--spring); }

/* plaque (upgrade 2) */
.kb-plaque { position: absolute; left: 50%; bottom: 10%; transform: translateX(-50%) scale(0); z-index: 1; white-space: nowrap;
  background: linear-gradient(135deg, #FFE08A, #E0A526 45%, #FFE9A8 55%, #C98A1B); color: #4A2A08; font-weight: 800; font-size: clamp(.72rem, 2vw, .95rem);
  padding: .15em 1em; border-radius: 10px; box-shadow: 0 3px 0 #8A5A12, 0 0 18px rgba(255, 210, 100, .6); transition: transform .7s var(--spring); overflow: hidden; }
.lvl-2 .kb-plaque { transform: translateX(-50%) scale(1); }
.kb-plaque::after { content: ""; position: absolute; top: 0; bottom: 0; width: 30%; left: -40%; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .75), transparent); transform: skewX(-20deg); animation: kbShine 3.5s ease-in-out infinite 1s; }

/* upgrade sparkle burst */
.kb-upfx { position: absolute; left: 50%; top: 40%; z-index: 9; pointer-events: none; }
.kb-upfx i { position: absolute; font-style: normal; color: #FFE08A; font-size: 20px; text-shadow: 0 0 10px #FFB84A; opacity: 0; }
.kb-upfx.go i { animation: kbBurst 1s ease-out both; }

/* =================== PANEL =================== */
.kb-panel { background: var(--paper); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 18px 18px 20px; position: relative; transition: box-shadow .3s; }
.kb-panel.solved { box-shadow: 0 0 0 3px var(--mint), var(--shadow); }
.kb-panel.missed { box-shadow: 0 0 0 3px var(--sun), var(--shadow); }
.kb-qcount { margin: 0 0 2px; font-size: .85rem; font-weight: 700; color: var(--muted); }
.kb-ask { font-size: clamp(1.15rem, 2.8vw, 1.5rem); margin: 0 0 14px; min-height: 1.3em; outline: none; }
.kb-ask:focus-visible { outline: 3px solid var(--sky); }
.kb-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.kb-choices.packs { grid-template-columns: 1fr; }
.kb-choice {
  position: relative; min-height: 66px; border: 0; border-radius: 20px; cursor: pointer; padding: 10px 14px 10px 14px; padding-inline-start: 44px;
  font-size: clamp(1.1rem, 2.8vw, 1.4rem); font-weight: 800; text-align: center; line-height: 1.2;
  background: var(--cc, var(--sun-soft)); box-shadow: 0 6px 0 var(--cs, #E9CF85), inset 0 0 0 2px rgba(43, 33, 64, .06);
  transition: transform .3s var(--spring), box-shadow .2s, background .3s;
  animation: kbRise .45s var(--spring) both; animation-delay: var(--d);
}
.kb-choices.packs .kb-choice { min-height: 54px; font-size: clamp(1rem, 2.4vw, 1.15rem); }
.kb-choice.c0 { --cc: var(--sun-soft); --cs: #EBCB72; }
.kb-choice.c1 { --cc: var(--sky-soft); --cs: #A9D2F2; }
.kb-choice.c2 { --cc: var(--mint-soft); --cs: #9ED9C5; }
.kb-choice.c3 { --cc: var(--lav-soft); --cs: #C9B8F5; }
.kb-choice .k { position: absolute; inset-inline-start: 10px; top: 50%; translate: 0 -50%; width: 26px; height: 26px; border-radius: 50%; background: rgba(255, 255, 255, .8);
  font-size: .8rem; display: grid; place-items: center; color: var(--muted); }
.kb-choice .v { unicode-bidi: plaintext; }
.kb-choice:hover { transform: translateY(-3px); box-shadow: 0 9px 0 var(--cs); }
.kb-choice:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--cs); }
.kb-choice.right { --cc: var(--mint); --cs: #2E9C78; color: #fff; animation: kbPop .5s var(--spring); }
.kb-choice.right .k { background: #fff; color: #2E9C78; }
.kb-choice.right::after { content: "✓"; position: absolute; inset-inline-end: 12px; top: 50%; translate: 0 -50%; font-size: 1.3rem; }
.kb-choice.reveal { animation: kbGlow 1.2s ease-in-out 2; }
.kb-choice.wrong { --cc: var(--coral-soft); --cs: #F2A48E; color: #9A2E16; }
.shake { animation: kbShake .5s ease both !important; }

/* pay area */
.kb-tray {
  position: relative; border-radius: 50% / 34%; min-height: 128px; padding: 22px 26px; display: grid; place-items: center;
  background: radial-gradient(ellipse at 50% 45%, #F6D27A 0 38%, #E0A526 39% 41%, #F2C75F 42% 62%, #C98A1B 63% 66%, #E8B94A 67%);
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .12), 0 8px 18px rgba(120, 70, 10, .3); transition: transform .3s var(--spring), box-shadow .3s;
}
.kb-tray.hover { transform: scale(1.03); box-shadow: 0 0 0 4px var(--sky), 0 8px 18px rgba(120, 70, 10, .3); }
.kb-tray.bump { animation: kbTray .35s var(--spring); }
.kb-tray-coins { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px 2px; max-width: 100%; }
.kb-tray-empty { position: absolute; margin: 0; font-weight: 700; color: #7A4E10; font-size: .92rem; text-align: center; padding: 0 30px; }
.kb-in { border: 0; background: none; padding: 2px; cursor: pointer; border-radius: 10px; margin-inline: -4px; transition: transform .2s; }
.kb-in:hover { transform: translateY(-3px) rotate(-4deg); }
.kb-in.new { animation: kbCoinIn .45s var(--spring); }
.kb-tray-total { text-align: center; font-weight: 800; margin: 8px 0 6px; font-size: 1.05rem; }
.kb-tray-total.match { color: #2E9C78; }
.kb-tray-total.over { color: #C2341C; }
.kb-denoms { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.kb-denoms.five { grid-template-columns: repeat(5, 1fr); }
.kb-den { border: 0; cursor: grab; border-radius: 16px; padding: 10px 2px; background: var(--cream); box-shadow: inset 0 0 0 2px var(--line), 0 4px 0 var(--cream-2);
  display: grid; place-items: center; min-height: 58px; touch-action: none; transition: transform .3s var(--spring); }
.kb-den:hover { transform: translateY(-3px); }
.kb-den:active { transform: scale(.94); cursor: grabbing; }
.kb-den.dragging { opacity: .45; }
.kb-pay-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.kb-pay-actions .btn { flex: 1; justify-content: center; min-height: 50px; }
.kb-paybtn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* money (original stylised designs, not copies of real banknotes) */
.money { direction: ltr; display: inline-grid; place-items: center; position: relative; font-weight: 800; line-height: 1; flex: none; user-select: none; }
.money.coin { width: 40px; height: 40px; border-radius: 50%; color: #5A4210; font-size: 1rem;
  background: radial-gradient(circle at 50% 50%, #F1F1F6 0 52%, #B9B9C6 53% 56%, #F4D27A 57% 82%, #C99A2E 83%);
  box-shadow: 0 3px 0 #8F6A16, inset 0 0 0 1px rgba(0, 0, 0, .2); }
.money.coin b { position: relative; }
.money.note { --nw: 64px; width: var(--nw); height: calc(var(--nw) * .52); border-radius: 8px; color: #fff; justify-items: end; padding: 0 7px;
  background:
    radial-gradient(circle at 27% 50%, rgba(255, 255, 255, .5) 0 17%, transparent 18%),
    radial-gradient(circle at 27% 50%, transparent 0 24%, rgba(255, 255, 255, .35) 25% 27%, transparent 28%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, .13) 0 3px, transparent 3px 7px),
    linear-gradient(135deg, var(--nc), var(--nc2));
  box-shadow: 0 3px 0 rgba(0, 0, 0, .22), inset 0 0 0 2px rgba(255, 255, 255, .35); }
.money.note b { font-size: calc(var(--nw) * .27); text-shadow: 0 1px 0 rgba(0, 0, 0, .3); }
.money.note::after { content: ""; position: absolute; left: 27%; top: 50%; width: 15%; aspect-ratio: 1; transform: translate(-50%, -50%) rotate(45deg); border: 2px solid rgba(255, 255, 255, .8); border-radius: 2px; }
.money.n5 { --nc: #2BB3A3; --nc2: #17877B; }
.money.n10 { --nc: #FF8A6A; --nc2: #D9543A; }
.money.n20 { --nc: #6CD3A9; --nc2: #2E9C78; }
.money.n50 { --nc: #5DBBFF; --nc2: #2A86D1; }
.money.n100 { --nc: #FFD15C; --nc2: #E39B12; color: #4A2E05; }
.money.n100 b { text-shadow: 0 1px 0 rgba(255, 255, 255, .5); }
.money.n200 { --nc: #B89CFF; --nc2: #7A5BD6; }
.kb-den .money.note { --nw: clamp(54px, 13vw, 66px); }
.kb-tray .money.note { --nw: clamp(52px, 12vw, 62px); }
.kb-tray .money.coin { width: 36px; height: 36px; }
.good .money.note { --nw: clamp(50px, 12vw, 70px); }
.kb-ghost { position: fixed; left: 0; top: 0; z-index: 95; pointer-events: none; filter: drop-shadow(0 10px 12px rgba(0, 0, 0, .3)); }
.kb-ghost .money.note { --nw: 70px; }

.kb-fly { position: fixed; z-index: 90; width: 24px; height: 24px; margin: -12px 0 0 -12px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 35% 30%, #FFF6C2, #FFC845 45%, #C98A1B); box-shadow: inset 0 0 0 2px #B07A0A, 0 0 10px rgba(255, 200, 70, .7); }

/* feedback */
.kb-feedback { margin-top: 14px; min-height: 1.6em; font-weight: 700; display: flex; gap: 10px; align-items: flex-start; border-radius: 16px; }
.kb-feedback:empty { margin-top: 6px; }
.kb-feedback.ok, .kb-feedback.no, .kb-feedback.time { padding: 10px 14px; animation: kbRise .4s var(--spring) both; }
.kb-feedback.ok { background: var(--mint-soft); color: #1E6F55; }
.kb-feedback.no { background: var(--sun-soft); color: #5A3D05; }
.kb-feedback.time { background: var(--coral-soft); color: #9A2E16; }
.kb-feedback .ico { font-size: 1.2rem; line-height: 1.3; }
.kb-sol { display: inline; font-size: 1.08em; color: var(--ink); background: rgba(255, 255, 255, .7); border-radius: 8px; padding: 0 .35em; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.kb-next { margin-top: 14px; width: 100%; justify-content: center; min-height: 54px; font-size: 1.1rem; animation: kbRise .45s var(--spring) both; }

/* =================== END =================== */
.kb-end-card { position: relative; max-width: 720px; margin: 10px auto 0; text-align: center; border-radius: var(--radius-lg); overflow: hidden; padding: 96px 22px 30px;
  background: radial-gradient(120% 80% at 50% 0%, rgba(255, 200, 90, .35), transparent 60%), linear-gradient(170deg, #2B1E4F, #5B2A55 60%, #7A1F3D); color: #fff; box-shadow: var(--shadow-lg); }
.kb-end-lamps { position: absolute; inset: 0 0 auto 0; height: 90px; display: flex; justify-content: space-around; padding: 0 6%; }
.kb-end-lamps .lamp { position: relative; inset: auto; top: 0; margin: 0; width: 38px; }
.kb-end-lamps .lamp:nth-child(2n)::before { height: 26px; }
.kb-end-lamps .lamp::before { height: 10px; background: #E7B23A; }
.kb-end-card h2 { font-size: clamp(1.8rem, 5vw, 2.8rem); color: #fff; outline: none; margin-bottom: .2em; }
.kb-end-stars { display: flex; justify-content: center; gap: 10px; margin: 6px 0 4px; }
.kb-end-stars .st { width: clamp(56px, 14vw, 84px); }
.kb-end-stars .st:nth-child(2) { transform: translateY(-14px); }
.kb-end-stars svg { width: 100%; display: block; fill: rgba(255, 255, 255, .16); stroke: rgba(255, 255, 255, .35); stroke-width: 1; transition: fill .3s; }
.kb-end-stars .st.on svg { fill: var(--sun); stroke: #FFF1B8; filter: drop-shadow(0 0 12px rgba(255, 200, 69, .8)); animation: kbStar .7s var(--spring) both; }
.kb-end-msg { font-weight: 700; font-size: 1.15rem; color: #FFE7B0; margin: 6px 0 14px; }
.kb-end-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 10px; margin: 0 auto 14px; max-width: 640px; }
.kb-stat { background: rgba(255, 255, 255, .1); border-radius: 18px; padding: 10px 8px; display: grid; gap: 2px; }
.kb-stat .em { font-size: 1.3rem; } .kb-stat small { color: #E3D6F5; font-weight: 600; } .kb-stat b { font-size: 1.35rem; }
.kb-end-dots { justify-content: center; margin: 0 auto 10px; width: max-content; background: rgba(255, 255, 255, .12); box-shadow: none; }
.kb-end-dots li { background: rgba(255, 255, 255, .2); }
.kb-end-dots li.ok { background: var(--mint); } .kb-end-dots li.no { background: var(--coral); } .kb-end-dots li.miss { background: rgba(255, 255, 255, .25); }
.kb-record { display: inline-block; background: var(--sun); color: var(--ink); font-weight: 800; border-radius: 999px; padding: .3em 1.1em; margin: 4px 0 10px; animation: kbPop .7s var(--spring) both 1s; }
.kb-end-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.kb-end-actions .btn { min-height: 52px; font-size: 1.05rem; }

/* =================== KEYFRAMES =================== */
@keyframes kbSway { from { transform: rotate(-4deg); } to { transform: rotate(4deg); } }
@keyframes kbSwayWide { from { transform: rotate(-.8deg); } to { transform: rotate(.8deg); } }
@keyframes kbBob { 50% { transform: translateY(-5px); } }
@keyframes kbTwinkle { 50% { opacity: .55; } }
@keyframes kbFlicker { from { transform: scale(.85, .9); opacity: .85; } to { transform: scale(1.08, 1.12); opacity: 1; } }
@keyframes kbLampOn { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); } }
@keyframes kbAwn { 0% { transform: scaleY(1); } 35% { transform: scaleY(1.35); } 100% { transform: scaleY(1); } }
@keyframes kbBreathe { 50% { transform: scaleY(1.015) translateY(-1px); } }
@keyframes kbWalk { from { transform: translateY(0) rotate(-2.5deg); } to { transform: translateY(-7px) rotate(2.5deg); } }
@keyframes kbBlink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
@keyframes kbWave { from { transform: rotate(-120deg); } to { transform: rotate(-155deg); } }
@keyframes kbTilt { 30% { transform: rotate(-7deg); } 60% { transform: rotate(5deg); } 100% { transform: rotate(-3deg); } }
@keyframes kbHeart { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.4); } 25% { opacity: 1; } 100% { opacity: 0; transform: translate(calc(-50% + var(--hx)), -60px) scale(1.2); } }
@keyframes kbDrop { 0% { opacity: 0; transform: translateY(-40px) scale(.6); } 100% { opacity: 1; transform: none; } }
@keyframes kbTag { from { rotate: -3deg; } to { rotate: 3deg; } }
@keyframes kbPop { 0% { transform: scale(.5); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }
@keyframes kbRise { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes kbShake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-8px) rotate(-1deg); } 40% { transform: translateX(7px) rotate(1deg); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }
@keyframes kbGlow { 50% { box-shadow: 0 6px 0 var(--cs), 0 0 0 6px rgba(92, 201, 167, .45); } }
@keyframes kbWiggle { 0%, 100% { transform: rotate(-10deg); } 50% { transform: rotate(-4deg) scale(1.06); } }
@keyframes kbBox { 40% { transform: scale(1.14, .9); } 100% { transform: none; } }
@keyframes kbTray { 40% { transform: scale(1.04, .96); } 100% { transform: none; } }
@keyframes kbCoinIn { 0% { transform: translateY(-30px) scale(.5) rotate(-30deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes kbShine { 0%, 60% { left: -40%; } 100% { left: 130%; } }
@keyframes kbBurst { 0% { opacity: 0; transform: rotate(var(--a)) translateX(0) scale(.4); } 30% { opacity: 1; } 100% { opacity: 0; transform: rotate(var(--a)) translateX(var(--r)) scale(1.1); } }
@keyframes kbPulse { 50% { transform: scale(1.06); } }
@keyframes kbStar { 0% { transform: scale(.2) rotate(-40deg); } 100% { transform: scale(1) rotate(0); } }

/* =================== RESPONSIVE =================== */
@media (max-width: 860px) {
  .kb-hero { grid-template-columns: 1fr; padding: 40px 20px 22px; }
  .kb-hero-art { height: 150px; max-width: 340px; width: 100%; margin: 0 auto; }
  .kb-hero-lamp { width: 48px; } .kb-hero-lamp:nth-child(2) { width: 58px; }
  .kb-stages { grid-template-columns: 1fr; }
  .kb-stage { min-height: 0; padding: 18px 18px 18px; padding-inline-end: 70px; }
  .kb-stage-em { font-size: 2.1rem; }
  .kb-go { top: 50%; bottom: auto; translate: 0 -50%; }
}
@media (max-width: 520px) {
  .kb-mode { grid-template-columns: 1fr; }
  .kb-hud { gap: 6px; }
  .kb-dots { padding: 5px 8px; gap: 4px; }
  .kb-dots li { width: 16px; height: 16px; font-size: .6rem; }
  .kb-chip { padding: .25em .7em; }
  .kb-timer { min-width: 110px; }
  .kb-icon { width: 40px; height: 40px; }
  .kb-scene { --cw: clamp(84px, 25%, 120px); border-radius: 26px; }
  .kb-bubble { min-width: 0; padding: 8px 11px; border-radius: 16px; max-width: calc(96% - 7% - var(--cw)); }
  .kb-cust { inset-inline-start: 5%; }
  .kb-bubble { inset-inline-start: calc(5% + var(--cw) + 2px); }
  .kb-panel { padding: 14px 12px 16px; border-radius: 26px; }
  .kb-choices { gap: 9px; }
  .kb-choice { min-height: 60px; padding-inline-start: 34px; padding-inline-end: 8px; }
  .kb-choice .k { width: 20px; height: 20px; font-size: .68rem; inset-inline-start: 7px; }
  .kb-tray { min-height: 112px; padding: 18px 18px; }
  .kb-denoms, .kb-denoms.five { gap: 6px; }
  .kb-den { padding: 8px 0; min-height: 52px; border-radius: 14px; }
  .kb-denoms.five .kb-den .money.note { --nw: 50px; }
  .kb-pay-actions .btn { padding-inline: .8em; font-size: .95rem; }
  .kb-end-card { padding: 84px 14px 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .kb-cust, .kb-bubble, .kb-awn, .kb-plaque, .kb-pile { transition: none !important; }
  .kb-goods.leaving .good { transition: none; }
}
