/* Scamper — the play surface is a fixed logical world scaled to fit, so the
   physics are identical on every device (same reasoning as Brick Blaster). */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  background: #0c4a6e; color: #e0f2fe;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  height: 100vh; height: 100dvh;   /* fallback first: dvh is Safari 15.4+ */
  user-select: none; -webkit-user-select: none; touch-action: none;
}
#app { display: flex; flex-direction: column; height: 100%; }
#hdr {
  flex: 0 0 auto; display: flex; align-items: center; gap: 6px;
  padding: calc(6px + env(safe-area-inset-top)) 10px 6px;
  background: #082f49; font-weight: 700; font-size: 14px;
}
/* Reserved space so a changing score can never reflow the header. */
#hudLevel, #hudScore, #hudLives {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
#hudLevel { flex: 1 1 0; }
#hudScore { flex: 0 0 auto; }
#hudLives { flex: 0 0 auto; letter-spacing: -1px; }
.pill {
  background: #0e7490; color: inherit; border: 0; border-radius: 10px;
  min-width: 34px; height: 32px; font-size: 15px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
/* R-C5: the 44px floor, which this game had been under since it shipped.
   Scoped to the header so a .pill used elsewhere keeps its own size. */
#hdr .pill { min-width: 44px; min-height: 44px; height: auto; }
.pill:active { transform: scale(.94); }

.scr { display: none; flex: 1 1 auto; min-height: 0; flex-direction: column; }
.scr.on { display: flex; }
/* R-C15b: centred AND scrolling. At 375x620 — a phone with its URL bar showing
   — the menu overflowed by 32px and its first child started 18px ABOVE the top
   edge, where no scrollbar reaches. Auto margins on the end children centre
   exactly as justify-content did while the content fits, and collapse to zero
   once it does not. */
#scr-menu, #scr-how {
  align-items: center; gap: 10px;
  padding: 14px; overflow-y: auto; overscroll-behavior: contain;
}
#scr-menu > :first-child, #scr-how > :first-child { margin-top: auto; }
#scr-menu > :last-child, #scr-how > :last-child { margin-bottom: auto; }
#scr-menu h1 { font-size: 30px; }
.sub { color: #7dd3fc; font-size: 14px; text-align: center; max-width: 340px; line-height: 1.45; }
.pickLabel { color: #bae6fd; font-size: 13px; font-weight: 700; margin-top: 4px; }
.pickRow { display: flex; gap: 8px; width: 100%; max-width: 380px; }
.pick {
  flex: 1 1 0; min-width: 0;
  background: #075985; color: inherit; border: 2px solid transparent;
  border-radius: 14px; padding: 9px 6px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center;
}
.pick .te { font-size: 20px; }
.pick b { font-size: 13px; }
.pick small { color: #7dd3fc; font-size: 10px; line-height: 1.25; }
.pick.sel { border-color: #38bdf8; background: #0c4a6e; }
.big {
  width: 100%; max-width: 380px;
  background: #075985; color: inherit; border: 0; border-radius: 14px;
  padding: 13px; font-size: 16px; font-weight: 700; cursor: pointer;
}
.big.primary { background: #38bdf8; color: #04283a; }
.big:active { transform: translateY(2px); }
#statsLine { color: #7dd3fc; font-size: 13px; text-align: center; min-height: 18px; }
.card {
  background: #075985; border-radius: 14px; padding: 12px 14px;
  width: 100%; max-width: 380px; font-size: 14px; line-height: 1.5;
}
.card h2 { font-size: 15px; margin-bottom: 5px; }

#stageWrap {
  flex: 1 1 auto; min-height: 0; position: relative;
  display: flex; align-items: center; justify-content: center;
  background: #0c4a6e; overflow: hidden;
}
canvas#stage { display: block; touch-action: none; }
#touchHint {
  position: absolute; left: 0; right: 0; bottom: calc(6px + env(safe-area-inset-bottom));
  text-align: center; font-size: 11px; color: rgba(255,255,255,.55); pointer-events: none;
}

/* ---- the shop ---- */
#shop { width: 100%; }
#shopBank { font-weight: 700; font-size: 14px; margin: 2px 0 8px; color: #fde047; }
#shopItems { display: flex; flex-direction: column; gap: 7px; }
.shopBtn {
  display: flex; align-items: center; gap: 9px; width: 100%;
  min-height: 52px; padding: 8px 10px; text-align: left;
  font: 600 13px/1.25 inherit; color: #e0f2fe;
  background: rgba(255,255,255,.07); border: 1px solid rgba(224,242,254,.3);
  border-radius: 11px; cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
.shopBtn .te { font-size: 20px; flex: 0 0 auto; }
.shopBtn .txt { flex: 1 1 auto; min-width: 0; }
.shopBtn .txt small { display: block; font-weight: 400; font-size: 11px; opacity: .78; }
.shopBtn .cost { flex: 0 0 auto; font-weight: 700; color: #fde047; }
/* Affordable / not is carried by OPACITY AND the word on the button, never by
   colour alone. A greyed-out control that is only greyer is a control a
   colour-blind child cannot tell from an active one. */
.shopBtn:disabled { opacity: .45; cursor: default; }
.shopBtn.bought { border-color: #4ade80; }
.shopBtn.bought .cost { color: #4ade80; }

/* ---- settings disclosure ---- */
#settings {
  width: 100%; max-width: 380px;
  background: #075985; border-radius: 14px; padding: 4px 12px 2px;
}
#settings > summary {
  cursor: pointer; padding: 9px 0; font-weight: 700; font-size: 14px;
  list-style: none;
}
#settings > summary::-webkit-details-marker { display: none; }
#settings[open] > summary { border-bottom: 1px solid rgba(224,242,254,.2); }
.optRow { padding: 10px 0; }
.optRow > .optLabel { font-size: 13px; color: #7dd3fc; margin-bottom: 6px; }
.optChoices { display: flex; gap: 8px; }
.optBtn {
  flex: 1 1 0; min-height: 44px; padding: 7px 8px;
  font: 600 13px/1.25 inherit; color: #e0f2fe; text-align: center;
  background: rgba(255,255,255,.06); border: 1px solid rgba(224,242,254,.3);
  border-radius: 10px; cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
.optBtn[aria-checked="true"] { background: #0369a1; border-color: #7dd3fc; }
.optBtn small { display: block; font-weight: 400; font-size: 11px; opacity: .8; margin-top: 3px; }

/* ---- on-screen controls ----
   Visible, with edges. What these replace was a virtual analog stick painted
   nowhere: the left half of the canvas, position within it deciding left or
   right, and a 10% dead band in the middle you could neither see nor feel.
   Reported as "hard to use / not very intuitive", which was the control being
   invisible rather than the player being wrong.

   `#pads` is a pass-through layer: it covers the stage so the buttons can be
   positioned against it, but only the buttons themselves take pointers, so a
   tap anywhere else still reaches the canvas and still means jump. */
#pads {
  position: absolute; inset: 0; z-index: 20; pointer-events: none;
}
.pad { position: absolute; inset: 0; }
.padGroup { position: absolute; left: 0; bottom: 0; display: flex; gap: 10px;
  padding: 0 0 calc(10px + env(safe-area-inset-bottom)) 10px; }
.padBtn {
  pointer-events: auto;
  /* 56px, not 44: the floor is a tap target, and these are HELD while the
     player is also watching the level. diner-dash's 44px minimum is the floor
     for something you aim at once, not for something a thumb rests on. */
  min-width: 56px; min-height: 56px;
  font: 700 22px/1 inherit; color: #e0f2fe;
  background: rgba(8, 47, 73, .62);
  border: 2px solid rgba(224, 242, 254, .45);
  border-radius: 16px;
  -webkit-appearance: none; appearance: none;
  touch-action: none; -webkit-tap-highlight-color: transparent;
  user-select: none; -webkit-user-select: none;
  transition: background-color .08s linear, transform .06s linear;
}
.padBtn:active, .padBtn.on {
  background: rgba(56, 189, 248, .55); border-color: #e0f2fe; transform: scale(.96);
}
#pad-runner .padBtn {
  position: absolute; left: 10px; bottom: calc(10px + env(safe-area-inset-bottom));
}
.padJump {
  position: absolute; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom));
  min-width: 72px; min-height: 72px; font-size: 26px;
}

.ovl {
  position: absolute; inset: 0; z-index: 30;
  display: none; align-items: center; justify-content: center; padding: 18px;
  background: rgba(8, 47, 73, .93);
}
.ovl.on { display: flex; }
.ovlCard {
  background: #075985; border-radius: 18px; padding: 20px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  width: 100%; max-width: 330px; text-align: center;
}
#ovlTitle { font-size: 23px; font-weight: 800; }
#ovlSub { color: #7dd3fc; font-size: 15px; }

.toast-host {
  position: fixed; left: 50%; transform: translateX(-50%);
  top: calc(10px + env(safe-area-inset-top));
  z-index: 9000; display: flex; flex-direction: column; gap: 8px;
  align-items: center; pointer-events: none; width: max-content;
  max-width: calc(100vw - 24px);
}
.toast {
  pointer-events: auto; cursor: pointer;
  padding: 10px 15px; border-radius: 12px;
  background: #f0f9ff; color: #0c4a6e;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
  font-size: 14px; font-weight: 700;
  opacity: 0; transform: translateY(-10px);
  transition: opacity .2s ease, transform .2s ease;
}
.toast.in { opacity: 1; transform: translateY(0); }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
