:root {
  --pink: #ff7eb0;
  --pink-d: #c2457a;
  --ink: #8a3a63;
  --mint: #9ee6cc;
  --cream: #fff8ef;
  --yellow: #ffd970;
  --panel-slice: 170;
  --panel-w: 34px;
  --btn-slice: 150;
  --btn-w: 26px;
  --font: "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden;
  background: radial-gradient(120% 80% at 50% 10%, #fbfdff 0%, #e2efff 45%, #fff6e6 100%);
  font-family: var(--font); font-weight: 900; color: #fff;
  user-select: none; -webkit-user-select: none; touch-action: none;
}
.hidden { display: none !important; }
#stage { position: fixed; inset: 0; }
#c { width: 100%; height: 100%; display: block; }

.outline {
  color: #fff;
  text-shadow:
    -3px -3px 0 var(--ink), 3px -3px 0 var(--ink), -3px 3px 0 var(--ink), 3px 3px 0 var(--ink),
    0 -3px 0 var(--ink), 0 3px 0 var(--ink), -3px 0 0 var(--ink), 3px 0 0 var(--ink),
    0 6px 0 rgba(138, 58, 99, 0.45);
}

.panel {
  border-style: solid;
  border-width: var(--panel-w);
  border-image: url(../assets/ui-panel.webp) var(--panel-slice) fill / var(--panel-w) stretch;
  background: none;
}
.btn {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; padding: 4px 18px; margin: 0;
  border-style: solid; border-width: var(--btn-w);
  border-image: url(../assets/ui-button.webp) var(--btn-slice) fill / var(--btn-w) stretch;
  background: none; cursor: pointer; outline: none;
  font-family: inherit; font-weight: 900; font-size: 19px; color: #fff;
  text-shadow: -2px -2px 0 var(--pink-d), 2px -2px 0 var(--pink-d), -2px 2px 0 var(--pink-d), 2px 2px 0 var(--pink-d), 0 3px 0 rgba(120, 30, 70, 0.5);
  transition: transform 0.12s cubic-bezier(.3,1.6,.5,1), filter 0.12s;
}
.btn > * { margin: -18px 0; }
.btn img { width: 30px; height: 30px; object-fit: contain; filter: drop-shadow(0 2px 0 rgba(120,30,70,.35)); }
.btn:hover, .btn.focus { transform: scale(1.05); filter: brightness(1.08) drop-shadow(0 0 8px rgba(255,255,255,.9)); }
.btn:active { transform: scale(0.94, 0.9); }
.btn.pressed { animation: btnSquash 0.22s cubic-bezier(.3,1.6,.5,1); }
@keyframes btnSquash { 0% { transform: scale(0.9, 0.84); } 100% { transform: scale(1); } }
.btn.alt { filter: hue-rotate(-150deg) saturate(0.8) brightness(1.1); }
.btn.alt:hover, .btn.alt.focus { filter: hue-rotate(-150deg) saturate(0.8) brightness(1.2) drop-shadow(0 0 8px rgba(255,255,255,.9)); }
.btn.quiet { filter: grayscale(0.7) brightness(1.15); }
.btn.quiet:hover, .btn.quiet.focus { filter: grayscale(0.5) brightness(1.25) drop-shadow(0 0 8px rgba(255,255,255,.9)); }
.btn.small { min-height: 46px; font-size: 16px; padding: 2px 12px; }
.btn.disabled { opacity: 0.5; pointer-events: none; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
/* Compact HUD (the table gets the room): the score panel has the label and level on one small row over the number. */
.hud-box {
  position: absolute; left: calc(6px + env(safe-area-inset-left)); top: calc(6px + env(safe-area-inset-top));
  min-width: 92px; text-align: center; padding: 0 2px;
  --panel-w: 14px;
  display: flex; flex-flow: row wrap; justify-content: center; align-items: baseline; column-gap: 6px;
}
.hud-box > div { margin: 0; white-space: nowrap; }
.hud-lbl { order: 0; margin-top: -6px !important; font-size: 11px; line-height: 13px; color: var(--pink-d); letter-spacing: 1px; }
.hud-lvl { order: 1; margin-top: -6px !important; font-size: 11px; line-height: 13px; color: #4fae8b; }
.hud-num { order: 2; flex: 0 0 100%; margin-bottom: -6px !important; font-size: 24px; line-height: 26px; color: #fff;
  text-shadow: -2px -2px 0 var(--pink-d), 2px -2px 0 var(--pink-d), -2px 2px 0 var(--pink-d), 2px 2px 0 var(--pink-d), 0 3px 0 rgba(150,40,90,.4); }
.hud-num.bump { animation: bump 0.25s cubic-bezier(.3,1.8,.5,1); }
.hud-gold { position: absolute; left: calc(9px + env(safe-area-inset-left)); top: calc(62px + env(safe-area-inset-top));
  display: flex; align-items: center; gap: 3px; padding: 2px 10px 2px 3px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.8); box-shadow: 0 2px 0 rgba(194, 69, 122, 0.25);
  color: #c98a1a; font-size: 15px; line-height: 18px; }
.hud-gold img { width: 20px; height: 20px; }
#hud-timer { position: absolute; left: 50%; top: calc(6px + env(safe-area-inset-top)); width: 62px; height: 62px; transform: translateX(-50%);
  border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ffffff 0%, #fff1f7 55%, #ffd2e4 100%);
  box-shadow: 0 5px 0 rgba(194, 69, 122, 0.35), inset 0 -4px 8px rgba(255, 126, 176, 0.3); }
#hud-timer svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
#time-ring { fill: none; stroke: var(--mint); stroke-width: 7; stroke-linecap: round; stroke-dasharray: 276.5; stroke-dashoffset: 0; transition: stroke 0.3s; }
#time-n { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 26px; color: #fff;
  text-shadow: -2px -2px 0 var(--pink-d), 2px -2px 0 var(--pink-d), -2px 2px 0 var(--pink-d), 2px 2px 0 var(--pink-d), 0 3px 0 rgba(150,40,90,.4); z-index: 1; }
#hud-timer.low #time-n { animation: pulse 0.5s infinite; }
#hud-timer.low #time-ring { stroke: #ff5d8f; }
#hud-combo { position: absolute; left: 50%; top: calc(68px + env(safe-area-inset-top)); transform: translateX(-50%) rotate(-4deg); font-size: 19px; line-height: 22px; white-space: nowrap; }
/* The goal bar (bone coins + points to the next level): on tall phones only, right above the table (its top comes from the camera fit). */
#goal-bar { position: absolute; left: 50%; width: min(92%, 380px); height: 40px; transform: translateX(-50%);
  --panel-w: 10px; padding: 0 8px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  animation: goalIn 0.3s cubic-bezier(.2,1.6,.4,1); }
#goal-bar.solo { justify-content: center; }
#gb-gold { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; font-size: 17px; line-height: 20px; color: #ffe27a;
  text-shadow: -2px -2px 0 #b9741a, 2px -2px 0 #b9741a, -2px 2px 0 #b9741a, 2px 2px 0 #b9741a, 0 2px 0 rgba(120, 70, 10, .4); }
#gb-gold img { width: 22px; height: 22px; object-fit: contain; }
#gb-goal { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; line-height: 20px; color: #fff;
  text-shadow: -2px -2px 0 var(--pink-d), 2px -2px 0 var(--pink-d), -2px 2px 0 var(--pink-d), 2px 2px 0 var(--pink-d), 0 2px 0 rgba(150,40,90,.4); }
.gb-num.bump, #gb-goal.bump { animation: bump 0.25s cubic-bezier(.3,1.8,.5,1); }
@keyframes goalIn { 0% { opacity: 0; transform: translateX(-50%) scale(0.7, 0.5); } 100% { opacity: 1; transform: translateX(-50%); } }
#hud-combo.pop { animation: comboPop 0.3s cubic-bezier(.3,1.8,.5,1); }

@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.35, 1.2); } 100% { transform: scale(1); } }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.15); } }
@keyframes comboPop { 0% { transform: translateX(-50%) rotate(-4deg) scale(0.4); } 100% { transform: translateX(-50%) rotate(-4deg) scale(1); } }

/* ---------- floating text ---------- */
#fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 4; overflow: hidden; }
.float { position: absolute; transform: translate(-50%, -50%); font-size: 24px; white-space: nowrap; animation: floatUp 0.9s ease-out forwards; }
.float.big { font-size: 30px; }
.float.gold { color: #ffe27a; }
.float.bad { --ink: #5b4aa8; color: #d9d2ff; }
.float.danger { --ink: #7a0f2a; color: #ff4d6d; }
@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.4); }
  20% { opacity: 1; transform: translate(-50%, -70%) scale(1.2); }
  35% { transform: translate(-50%, -80%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -180%) scale(1); }
}

/* ---------- banner / subtitle / toast / tutorial ---------- */
#banner { position: fixed; left: 50%; top: 32%; z-index: 8; pointer-events: none; font-size: 46px; white-space: nowrap;
  transform: translate(-50%, -50%) rotate(-6deg); }
.balance-pop { position: absolute; left: 50%; top: 24%; transform: translate(-50%, -50%); pointer-events: none; z-index: 6; }
.balance-pop .bp-word { font-size: 34px; white-space: nowrap; color: #fff7b0; --ink: #2f9a6d; font-weight: 900;
  animation: bpPop 1.4s cubic-bezier(.2,1.6,.4,1) forwards; }
.balance-pop .bp-bit { position: absolute; left: 50%; top: 50%; font-size: 20px; opacity: 0; text-shadow: 0 2px 0 rgba(120, 40, 80, 0.35);
  animation: bpBit 1.1s ease-out forwards; }
@keyframes bpPop { 0% { transform: scale(0.2) rotate(-8deg); opacity: 0; } 18% { transform: scale(1.18) rotate(3deg); opacity: 1; }
  32% { transform: scale(0.95) rotate(-2deg); } 45% { transform: scale(1) rotate(0); } 75% { opacity: 1; transform: translateY(-6px); }
  100% { opacity: 0; transform: translateY(-22px); } }
@keyframes bpBit { 0% { transform: translate(-50%, -50%) scale(0.3); opacity: 0; } 20% { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.1); opacity: 0; } }
#banner.show { animation: slam 1.4s cubic-bezier(.2,1.5,.4,1) forwards; }
@keyframes slam {
  0% { opacity: 0; transform: translate(-50%, -50%) rotate(-6deg) scale(3); }
  15% { opacity: 1; transform: translate(-50%, -50%) rotate(-6deg) scale(0.9); }
  25% { transform: translate(-50%, -50%) rotate(-6deg) scale(1.05); }
  80% { opacity: 1; transform: translate(-50%, -50%) rotate(-6deg) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -60%) rotate(-6deg) scale(1); }
}
/* Voice subtitles sit at the very bottom, under the table's near end, so they never cover Pudding on the felt. */
#subtitle { position: fixed; left: 50%; bottom: calc(6px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 45;
  width: max-content; max-width: 94%; padding: 6px 16px; border-radius: 16px; background: rgba(138, 58, 99, 0.72); color: #fff; font-size: 15px; line-height: 1.35; text-align: center; pointer-events: none;
  animation: subIn 0.2s ease-out; }
@keyframes subIn { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%); } }
#toast { position: fixed; left: 50%; top: 40%; transform: translateX(-50%); z-index: 60; padding: 10px 20px; border-radius: 16px;
  background: rgba(138, 58, 99, 0.85); color: #fff; font-size: 17px; pointer-events: none; animation: subIn 0.2s ease-out; white-space: nowrap; }
/* The tutorial sits in the open space between the HUD and the far end of the table, so it never covers Pudding. */
#tutorial { position: fixed; left: 50%; top: calc(96px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 6; pointer-events: none; text-align: center; width: 92%; }
#tut-text { font-size: 18px; white-space: pre-line; line-height: 1.45; }
.tut-hand { width: 44px; height: 44px; margin: 0 auto 6px; border-radius: 50%; background: rgba(255,255,255,.85); border: 4px solid var(--pink);
  box-shadow: 0 0 0 8px rgba(255, 126, 176, .25); animation: pullBack 1.6s ease-in-out infinite; }
@keyframes pullBack { 0% { transform: translate(0, -20px) scale(1); opacity: 0; } 15% { opacity: 1; } 55% { transform: translate(0, 14px) scale(0.85); } 70% { transform: translate(0, 14px) scale(0.85); opacity: 1; } 100% { transform: translate(0, -40px) scale(1); opacity: 0; } }

/* ---------- title ---------- */
#title { position: fixed; inset: 0; z-index: 20; overflow: hidden; cursor: pointer; }
#title-bg { position: absolute; inset: -2%; background: url(../assets/cover-bg.webp) center / cover no-repeat; animation: bgBreath 6s ease-in-out infinite; }
@keyframes bgBreath { 0%,100% { transform: scale(1); } 50% { transform: scale(1.025); } }
#title-logo { position: absolute; left: 50%; top: 11%; width: 82%; max-height: 30%; object-fit: contain; transform: translate(-50%, 0);
  filter: drop-shadow(0 8px 0 rgba(138, 58, 99, 0.25)); animation: logoIn 0.7s cubic-bezier(.2,1.6,.4,1) both, logoFloat 3s ease-in-out 0.7s infinite; }
@keyframes logoIn { 0% { opacity: 0; transform: translate(-50%, -60px) scale(0.5, 1.4); } 60% { opacity: 1; transform: translate(-50%, 6px) scale(1.08, 0.92); } 100% { transform: translate(-50%, 0) scale(1); } }
@keyframes logoFloat { 0%,100% { transform: translate(-50%, 0) scale(1); } 50% { transform: translate(-50%, -8px) scale(1.02, 0.98); } }
#title-start { position: absolute; left: 0; right: 0; bottom: calc(7% + env(safe-area-inset-bottom)); text-align: center; pointer-events: none; }
#start-btn { display: inline-flex; min-width: 220px; min-height: 68px; font-size: 26px; padding: 6px 30px; pointer-events: auto; animation: startPulse 1.4s ease-in-out infinite; }
#start-btn > * { margin: -18px 0; }
#start-text { display: inline-block; white-space: nowrap; }
#start-key { margin-top: 10px; font-size: 15px; color: var(--ink); opacity: 0.9; }
#start-key:empty { display: none; }
@keyframes startPulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.08, 0.95); opacity: 0.8; } }
.corner-btn { position: absolute; top: calc(10px + env(safe-area-inset-top)); width: 50px; height: 50px; padding: 4px; margin: 0; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, 0.55); box-shadow: 0 3px 0 rgba(194, 69, 122, 0.25); cursor: pointer; outline: none;
  transition: transform 0.12s cubic-bezier(.3,1.6,.5,1); }
.corner-btn img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.corner-btn:hover, .corner-btn.focus { transform: scale(1.08); background: rgba(255, 255, 255, 0.85); box-shadow: 0 3px 0 rgba(194, 69, 122, 0.25), 0 0 0 3px #fff, 0 0 12px 3px rgba(255, 126, 176, 0.7); }
.corner-btn:active { transform: scale(0.9); }
#btn-trophy { right: calc(10px + env(safe-area-inset-right)); }
#btn-closet { left: calc(10px + env(safe-area-inset-left)); }

/* ---------- intro ---------- */
#intro { position: fixed; inset: 0; z-index: 40; background: #fbe7ef url(../assets/intro-poster.webp) center / cover no-repeat; transition: opacity 0.25s ease-out; }
#intro.loading { opacity: 0; }
#intro video { width: 100%; height: 100%; object-fit: cover; display: block; }
#intro-skip { position: absolute; right: calc(12px + env(safe-area-inset-right)); top: calc(12px + env(safe-area-inset-top)); min-width: 92px; }

/* ---------- modal ---------- */
#modal { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; background: rgba(120, 50, 90, 0.35);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
#modal-card { width: min(90vw, 380px); max-height: 88vh; overflow: hidden auto; color: var(--ink); text-align: center; animation: popIn 0.28s cubic-bezier(.2,1.6,.4,1); scrollbar-width: none; }
#modal-card > .inner { margin: -12px -8px; display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
@keyframes popIn { 0% { transform: scale(0.5); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.m-title { font-size: 26px; }
.m-icon { width: 96px; height: 96px; object-fit: contain; margin: 0 auto; animation: wob 1.6s ease-in-out infinite; }
@keyframes wob { 0%,100% { transform: scale(1, 1); } 50% { transform: scale(1.08, 0.92); } }
.m-text { font-size: 16px; line-height: 1.45; color: var(--ink); font-weight: 700; text-align: left; display: flex; gap: 10px; align-items: center; }
.m-text .dot { flex: 0 0 26px; height: 26px; border-radius: 50%; background: var(--pink); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 15px; }
.m-row { display: flex; gap: 10px; }
.m-row > .btn { flex: 1 1 0; min-width: 0; }
.price { display: inline-flex; align-items: center; gap: 4px; }
.price img { width: 26px; height: 26px; }

.closet-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 4px; }
.closet-grid .skin-card { padding: 6px 2px 8px; border-radius: 16px; }
.closet-grid .skin-card img.skin { width: 68px; height: 68px; }
.closet-grid .skin-card .nm { font-size: 13px; line-height: 1.15; text-align: center; min-height: 30px; display: flex; align-items: center; }
.closet-grid .skin-card .st { font-size: 13px; }
.skin-card { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 10px; border-radius: 20px; border: 3px solid #ffd2e4;
  background: rgba(255, 255, 255, 0.75); cursor: pointer; font-family: inherit; font-weight: 900; color: var(--ink); outline: none;
  transition: transform 0.12s cubic-bezier(.3,1.6,.5,1); min-height: 44px; }
.skin-card img.skin { width: 76px; height: 76px; object-fit: contain; }
.skin-card .nm { font-size: 15px; }
.skin-card .st { font-size: 14px; color: var(--pink-d); display: flex; align-items: center; gap: 3px; min-height: 24px; }
.skin-card .st img { width: 22px; height: 22px; }
.skin-card.on { border-color: var(--pink); background: #fff0f6; box-shadow: 0 0 0 3px rgba(255, 126, 176, 0.3); }
.skin-card:hover, .skin-card.focus { transform: scale(1.04); border-color: var(--pink); }
.skin-card:active, .skin-card.pressed { transform: scale(0.95); }
.bag-row { display: flex; align-items: center; justify-content: center; gap: 14px; font-size: 18px; color: var(--ink); flex-wrap: wrap; }
.bag-row span { display: inline-flex; align-items: center; gap: 4px; }
.bag-row img { width: 32px; height: 32px; object-fit: contain; }
.m-sub { font-size: 16px; color: var(--pink-d); text-align: left; }
.m-sub.center { text-align: center; }

/* ---------- food book button (under the trophy) ---------- */
#btn-dex { right: calc(10px + env(safe-area-inset-right)); top: calc(70px + env(safe-area-inset-top)); }

/* ---------- difficulty ---------- */
#modal-card > .inner { margin: -2px 0 0; padding-bottom: 4px; }
#modal-card.wide { width: min(96vw, 420px); --panel-w: 26px; }
#btn-dex { right: calc(70px + env(safe-area-inset-right)); top: calc(10px + env(safe-area-inset-top)); }
.dex-tabs > .btn { white-space: nowrap; font-size: 14px !important; }
.diff-btn { --c1: #ffb3d1; --c2: #ff7eb0; --cd: #c2457a; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 74px; padding: 8px 14px 10px; margin: 0; border: 4px solid #fff; border-radius: 26px; cursor: pointer; outline: none;
  background: radial-gradient(120% 60% at 50% 18%, rgba(255,255,255,.55), rgba(255,255,255,0) 60%), linear-gradient(var(--c1), var(--c2));
  box-shadow: 0 5px 0 var(--cd), inset 0 -6px 10px rgba(0,0,0,.08);
  font-family: inherit; font-weight: 900; color: #fff; transition: transform 0.12s cubic-bezier(.3,1.6,.5,1), filter 0.12s; }
.diff-btn.diff-easy { --c1: #b5f0de; --c2: #5fd1b3; --cd: #2f9c84; }
.diff-btn.diff-hard { --c1: #ffc2a6; --c2: #ff7a63; --cd: #c4433a; }
.diff-btn .dn { display: inline-flex; align-items: center; gap: 8px; font-size: 23px; line-height: 1.1;
  text-shadow: -2px -2px 0 var(--cd), 2px -2px 0 var(--cd), -2px 2px 0 var(--cd), 2px 2px 0 var(--cd), 0 3px 0 rgba(0,0,0,.2); }
.diff-btn .stars { font-size: 16px; color: #fff4a8; letter-spacing: 1px; }
.diff-btn .dd { font-size: 13px; line-height: 1.25; font-weight: 800;
  text-shadow: -1.5px -1.5px 0 var(--cd), 1.5px -1.5px 0 var(--cd), -1.5px 1.5px 0 var(--cd), 1.5px 1.5px 0 var(--cd); }
.diff-btn:hover, .diff-btn.focus { transform: scale(1.04); filter: brightness(1.06) drop-shadow(0 0 8px rgba(255,255,255,.95)); }
.diff-btn:active { transform: scale(0.95, 0.9); }
.diff-btn.pressed { animation: btnSquash 0.22s cubic-bezier(.3,1.6,.5,1); }
.diff-btn.on::after { content: "✓"; position: absolute; right: 8px; top: 6px; width: 24px; height: 24px; border-radius: 50%; background: #fff; color: var(--cd);
  font-size: 16px; line-height: 24px; text-shadow: none; }

/* ---------- food book ---------- */
.dex-prog { display: flex; align-items: center; gap: 10px; font-size: 16px; color: #fff; }
.dex-bar { flex: 1; height: 14px; border-radius: 8px; background: #ffe0ec; box-shadow: inset 0 2px 0 rgba(194,69,122,.25); overflow: hidden; }
.dex-fill { height: 100%; border-radius: 8px; background: linear-gradient(#ffb3d1, #ff7eb0); transition: width .4s; }
.dex-tabs > .btn { font-size: 15px; padding: 2px 6px; }
.dex-tab.bad.on { filter: hue-rotate(-20deg) saturate(1.3); }
.dex-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.dex-cell { position: relative; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 3px 8px; border-radius: 18px; border: 3px solid #ffd2e4;
  background: rgba(255, 255, 255, 0.8); font-family: inherit; font-weight: 900; color: var(--ink); outline: none; cursor: default; min-height: 44px;
  transition: transform 0.12s cubic-bezier(.3,1.6,.5,1); }
.dex-cell.bad { border-color: #ffc2c8; background: rgba(255, 244, 245, 0.85); }
.dex-cell.gold { border-color: #ffd36b; background: rgba(255, 248, 220, 0.9); }
.dex-cell.focus, .dex-cell:hover { transform: scale(1.04); border-color: var(--pink); }
.dex-cell.pressed { animation: btnSquash 0.22s cubic-bezier(.3,1.6,.5,1); }
.dex-cell .pic { position: relative; width: 58px; height: 58px; }
.dex-cell .pic img { width: 100%; height: 100%; object-fit: contain; }
.dex-cell.locked .pic img { filter: brightness(0) opacity(0.28); }
.dex-cell .nm { font-size: 14px; line-height: 1.15; }
.dex-cell .pt { font-size: 12px; line-height: 1.2; color: var(--pink-d); }
.dex-cell.bad .pt { color: #d6304f; }
.dex-cell .ds { font-size: 11px; line-height: 1.25; font-weight: 700; color: #9a6a82; }
.dex-cell.locked .nm, .dex-cell.locked .pt { color: #c9a7b8; }
.dex-cell .no { position: absolute; right: -6px; top: -6px; width: 22px; height: 22px; border-radius: 50%; border: 4px solid #ff3b5c; background: rgba(255,255,255,.9); box-sizing: border-box; }
.dex-cell .no::after { content: ""; position: absolute; left: 50%; top: 50%; width: 18px; height: 4px; margin: -2px 0 0 -9px; background: #ff3b5c; transform: rotate(-45deg); border-radius: 2px; }
.dex-cell .new { position: absolute; left: -8px; top: -6px; padding: 1px 5px; border-radius: 8px; background: #ff7eb0; color: #fff; font-size: 10px; }

/* ---------- run end ---------- */
.end-score { font-size: 48px; line-height: 1; color: #fff; }
.end-diff { font-size: 15px; color: var(--pink-d); }
.end-fresh { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
.end-fresh img { width: 44px; height: 44px; object-fit: contain; animation: wob 1.4s ease-in-out infinite; }
.end-prog { font-size: 14px; color: var(--ink); }
.m-pics { display: flex; align-items: flex-end; justify-content: center; gap: 4px; }
.m-pics .m-icon { margin: 0; }
.m-pud { width: 96px; height: 96px; object-fit: contain; animation: wob 1.8s ease-in-out infinite; transform-origin: 50% 100%; }
.end-pud { width: 104px; height: 104px; object-fit: contain; margin: -6px auto -8px; animation: wob 1.8s ease-in-out infinite; transform-origin: 50% 100%; }
.diff-close { position: absolute; right: 2px; top: 2px; width: 46px; height: 46px; border-radius: 50%; border: 3px solid #fff; padding: 0; margin: 0;
  background: linear-gradient(#ffb3d1, #ff7eb0); box-shadow: 0 3px 0 #c2457a; color: #fff; font-family: inherit; font-weight: 900; font-size: 24px; line-height: 1;
  text-shadow: 0 2px 0 #c2457a; cursor: pointer; outline: none; transition: transform 0.12s cubic-bezier(.3,1.6,.5,1); }
.diff-close:hover, .diff-close.focus { transform: scale(1.1); filter: drop-shadow(0 0 6px rgba(255,255,255,.95)); }
.diff-close.pressed { animation: btnSquash 0.22s cubic-bezier(.3,1.6,.5,1); }
.diff-head { position: relative; min-height: 46px; display: flex; align-items: center; justify-content: center; padding: 0 50px; }
.diff-tools { display: grid; grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); gap: 8px; margin-top: 2px; }
.tool-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px 6px; min-height: 76px; border-radius: 20px; border: 3px solid #ffd2e4;
  background: rgba(255, 255, 255, 0.82); font-family: inherit; font-weight: 900; color: var(--ink); cursor: pointer; outline: none; margin: 0;
  transition: transform 0.12s cubic-bezier(.3,1.6,.5,1); }
.tool-btn img { width: 44px; height: 44px; object-fit: contain; }
.tool-btn span { font-size: 13px; line-height: 1.15; white-space: nowrap; }
.tool-btn:hover, .tool-btn.focus { transform: scale(1.06); border-color: var(--pink); background: #fff0f6; }
.tool-btn.pressed { animation: btnSquash 0.22s cubic-bezier(.3,1.6,.5,1); }
.end-btns { display: flex; flex-direction: column; gap: 10px; }
.end-btns > .btn { white-space: nowrap; }
.end-btns > .btn img { width: 28px; height: 28px; }
.m-row > .btn img { width: 26px; height: 26px; }

/* ---------- ambulance ---------- */
.siren-glow { position: absolute; inset: 0; animation: sirenEdge 0.5s steps(1) infinite; transition: opacity 0.4s; }
.siren-glow.out { opacity: 0; }
@keyframes sirenEdge { 0% { box-shadow: inset 0 0 50px 18px rgba(255, 50, 80, 0.75); } 50% { box-shadow: inset 0 0 50px 18px rgba(60, 120, 255, 0.75); } }
.ambulance { position: absolute; transition: opacity 0.4s; }
.ambulance.out { opacity: 0; }
.amb-body { position: absolute; inset: 0; transform-origin: 50% 100%; }
.ambulance.flip .amb-body { transform: scaleX(-1); }
.ambulance:not(.parked) .amb-body { animation: ambDrive 0.18s ease-in-out infinite; }
.ambulance.parked .amb-body { animation: ambStop 0.45s cubic-bezier(.3,1.6,.5,1); }
.ambulance.flip.parked .amb-body { animation-name: ambStopF; }
.ambulance.flip:not(.parked) .amb-body { animation-name: ambDriveF; }
.amb-body img { width: 100%; height: 100%; object-fit: contain; display: block; filter: drop-shadow(0 3px 0 rgba(120, 30, 70, 0.25)); }
.amb-body.drawn { font-size: 80px; text-align: center; }
.amb-lights { position: absolute; left: 43%; top: 12%; width: 28%; height: 18%; pointer-events: none; }
.amb-lights .l { position: absolute; top: 0; width: 50%; height: 100%; border-radius: 50%; mix-blend-mode: screen; }
.amb-lights .r { left: 0; background: radial-gradient(circle, rgba(255, 70, 90, 0.95), rgba(255, 70, 90, 0) 70%); animation: blinkA 0.36s steps(1) infinite; }
.amb-lights .b { right: 0; background: radial-gradient(circle, rgba(70, 140, 255, 0.95), rgba(70, 140, 255, 0) 70%); animation: blinkA 0.36s steps(1) infinite reverse; animation-delay: -0.18s; }
@keyframes blinkA { 0% { opacity: 1; transform: scale(1.5); } 50% { opacity: 0.1; transform: scale(0.8); } }
.amb-shadow { position: absolute; left: 12%; right: 12%; bottom: -4px; height: 12px; border-radius: 50%; background: rgba(90, 60, 110, 0.25); z-index: -1; }
@keyframes ambDrive { 0%,100% { transform: translateY(0) scale(1, 1); } 50% { transform: translateY(-3px) scale(1.02, 0.98); } }
@keyframes ambDriveF { 0%,100% { transform: scaleX(-1) translateY(0); } 50% { transform: scaleX(-1.02) translateY(-3px) scaleY(0.98); } }
@keyframes ambStop { 0% { transform: scale(1.12, 0.88) rotate(-3deg); } 60% { transform: scale(0.96, 1.05) rotate(1deg); } 100% { transform: none; } }
@keyframes ambStopF { 0% { transform: scaleX(-1.12) scaleY(0.88) rotate(3deg); } 60% { transform: scaleX(-0.96) scaleY(1.05) rotate(-1deg); } 100% { transform: scaleX(-1); } }
