/* Nice Baby: Baby Bakery Bungle — layout, DOM UI, overlays.
 * Canvas owns the scene; this stylesheet owns menus/HUD/toast/recap.
 * Cozy pastel bakery palette: mint walls, lavender accents, cream cards.
 */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: "Trebuchet MS", "Segoe UI", Verdana, sans-serif;
  background: #b7e4d4;
  color: #4a3b52;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
#app { position: fixed; inset: 0; }
canvas#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ------------------------------- HUD ----------------------------------- */
#hud {
  position: absolute; top: 0; left: 0; right: 0;
  height: 48px; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: 6px max(10px, env(safe-area-inset-right)) 6px max(10px, env(safe-area-inset-left));
  background: linear-gradient(rgba(255,255,255,0.72), rgba(255,255,255,0.25));
  pointer-events: none;
  border-bottom: 2px solid rgba(255,255,255,0.6);
}
#hud .brand { font-weight: 800; letter-spacing: 1px; color: #6d4c8f; font-size: 14px; margin-right: auto; }
#hud .brand small { display: block; font-size: 9px; letter-spacing: 3px; color: #8a7ba0; }
#hud .stat { background: #fffaf0; border: 2px solid #e4d5f0; border-radius: 14px; padding: 2px 10px; text-align: center; min-width: 58px; }
#hud .stat small { display: block; font-size: 8px; letter-spacing: 2px; color: #8a7ba0; }
#hud .stat strong { font-size: 15px; color: #b3546d; }
#hud .stat.streak strong { color: #e08a3c; }
#hud .stat.served strong { color: #5a9e6f; }
#hud button.icon {
  pointer-events: auto; font-size: 18px; line-height: 1;
  min-width: 48px; min-height: 40px; border-radius: 14px;
  border: 2px solid #e4d5f0; background: #fffaf0; color: #6d4c8f; cursor: pointer;
}
#hud button.icon:active { transform: scale(0.94); }
#hud button[aria-pressed="true"] { background: #d9c7f0; }

/* ----------------------------- overlays -------------------------------- */
.overlay {
  position: absolute; inset: 0; z-index: 20;
  /* FIX B (Whack-A-Baby pattern): top-aligned so a card taller than the
   * viewport never clips its top; overflow-y allows scrolling to reach the
   * bottom buttons (New Game / Play Again) on short embeds. */
  display: flex; align-items: flex-start; justify-content: center;
  padding: 18px; overflow-y: auto;
  background: rgba(154, 205, 190, 0.35);
  backdrop-filter: blur(2px);
}
.overlay[hidden] { display: none; }
.menuCard, .modal, .resultCard {
  background: #fffaf0; border-radius: 26px; border: 3px solid #fff;
  box-shadow: 0 12px 40px rgba(74, 59, 82, 0.28);
  max-width: 640px; width: 100%; padding: 28px;
  text-align: center;
  /* Never taller than the embed; scroll internally when the card itself
   * overflows so every control stays reachable (FIX B). */
  max-height: 100%; overflow-y: auto;
  margin: auto;   /* centers when it fits, top-aligns + scrolls when it doesn't */
}
.menuCard .hero h1 { font-size: clamp(34px, 8vw, 58px); line-height: 0.95; color: #b3546d; letter-spacing: 1px; }
.menuCard .hero h1 em { font-style: normal; color: #6d4c8f; }
.menuCard .edition { font-size: 11px; letter-spacing: 4px; color: #8a7ba0; margin-bottom: 8px; }
.menuCard .sticker {
  display: inline-block; margin: 14px 0 18px; padding: 8px 18px;
  background: #d9c7f0; color: #4a3b52; border-radius: 18px;
  font-size: 12px; font-weight: 700; letter-spacing: 2px; line-height: 1.5;
}
.menuCopy .instruction { font-size: 14px; color: #6d5b78; margin-bottom: 18px; line-height: 1.5; }
button {
  font: inherit; font-weight: 700; cursor: pointer; color: #4a3b52;
  border-radius: 16px; border: 2px solid #e4d5f0; background: #fff;
  min-height: 48px; padding: 0 22px;
}
button.primary { background: #e99cb0; color: #fff; border-color: #e99cb0; min-width: 200px; }
button.primary:active, button:active { transform: scale(0.97); }
.secondaryRow { display: flex; gap: 12px; justify-content: center; margin-top: 12px; }
.menuCopy .roundNote { display: block; margin-top: 14px; color: #8a7ba0; font-size: 11px; }

/* --------------------------- choose-a-baker ---------------------------- */
.bakerRow { display: flex; gap: 14px; justify-content: center; margin: 18px 0 20px; flex-wrap: wrap; }
.bakerChoice { min-width: 108px; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 10px; }
.bakerChoice .swatch { width: 54px; height: 54px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.18); display: block; }
.bakerChoice .swatch.mint { background: #8fdcc2; }
.bakerChoice .swatch.sunny { background: #ffd97a; }
.bakerChoice .swatch.berry { background: #f2a6bd; }
.bakerChoice[aria-pressed="true"] { background: #d9c7f0; border-color: #6d4c8f; }

/* ------------------------------ About ---------------------------------- */
.aboutText { margin: 16px 0; font-size: 15px; line-height: 1.7; color: #5a4a66; }
.muted { color: #8a7ba0; font-size: 12px; line-height: 1.5; }

/* ------------------------------ recap ----------------------------------- */
.resultCard h2 { color: #6d4c8f; margin: 6px 0; }
.recapMsg { color: #8a7ba0; font-size: 13px; margin-bottom: 16px; }
.scorecard { margin: 12px auto 20px; max-width: 320px; }
.scoreRow { display: flex; justify-content: space-between; align-items: center; padding: 10px 6px; border-bottom: 2px dashed #e4d5f0; }
.scoreRow small { color: #8a7ba0; letter-spacing: 1px; }
.scoreRow strong { color: #b3546d; font-size: 20px; }
.resultActions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* --------------------------- milestone toast ---------------------------- */
#milestoneToast {
  position: absolute; top: 64px; left: 50%; transform: translateX(-50%);
  z-index: 25; pointer-events: none;
  background: #ffd97a; color: #6d4c8f; font-weight: 800; font-size: 16px;
  padding: 10px 22px; border-radius: 22px; border: 3px solid #fff;
  box-shadow: 0 6px 20px rgba(0,0,0,0.18);
  animation: toastIn 0.35s ease-out;
  white-space: nowrap;
}
@keyframes toastIn { from { transform: translateX(-50%) translateY(-14px); opacity: 0; } to { transform: translateX(-50%) translateY(0); opacity: 1; } }

@media (max-width: 430px) {
  /* Narrow wrapper iframes (e.g. phone 16:9 short iframe ~370 CSS px): keep
   * every HUD control on-screen (brand + 3 stats + close + mute). */
  #hud { gap: 6px; padding: 4px 8px; height: 44px; }
  #hud .brand { font-size: 11px; letter-spacing: 0; white-space: nowrap; }
  #hud .brand small { font-size: 7px; letter-spacing: 2px; }
  #hud .stat { min-width: 42px; padding: 1px 6px; }
  #hud .stat small { font-size: 7px; }
  #hud .stat strong { font-size: 13px; }
  #hud button.icon { min-width: 38px; min-height: 38px; font-size: 15px; }
}

@media (max-height: 360px) {
  /* Short embedded iframes (the site player page clips the game to a short
   * 16:9 box on phones): compress every overlay card so it fits without
   * scrolling — New Game / About / Quit, baker choices, About text, recap
   * actions all stay within the card. The HUD also slims to a 30px strip and
   * drops the streak/served tallies (hearts stays) so the canvas craving
   * bubble is never covered by the stat pills. */
  .overlay { padding: 4px; }
  #hud { height: 30px; gap: 5px; padding: 3px 6px; }
  #hud .brand { display: none; }
  #hud .stat { display: none; }
  #hud .stat.hearts { display: block; min-width: 42px; padding: 1px 7px; margin-left: auto; }
  #hud .stat.hearts small { font-size: 7px; }
  #hud .stat.hearts strong { font-size: 13px; }
  #hud button.icon { min-width: 34px; min-height: 30px; font-size: 14px; }
  .menuCard, .modal, .resultCard { padding: 10px 14px; border-radius: 18px; box-shadow: 0 6px 20px rgba(74,59,82,0.25); }
  .eyebrow { font-size: 8px; margin-bottom: 2px; }
  .menuCard .hero h1 { font-size: clamp(16px, 6vh, 26px); }
  .menuCard .edition { font-size: 8px; letter-spacing: 3px; margin-bottom: 2px; }
  .menuCard .sticker { display: none; }
  .menuCopy .instruction { font-size: 11px; line-height: 1.3; margin-bottom: 5px; }
  .modal h2, .resultCard h2 { font-size: 16px; margin: 2px 0; }
  button { min-height: 34px; padding: 0 12px; border-radius: 13px; }
  button.primary { min-width: 120px; }
  .secondaryRow { margin-top: 4px; gap: 8px; }
  .menuCopy .roundNote { display: none; }
  .bakerRow { gap: 6px; margin: 5px 0 8px; }
  .bakerChoice { min-width: 78px; padding: 6px 6px; gap: 3px; }
  .bakerChoice .swatch { width: 32px; height: 32px; }
  .aboutText { margin: 4px 0; font-size: 11px; line-height: 1.35; }
  .muted { display: none; }
  .recapMsg { display: none; }
  .scorecard { margin: 5px auto 7px; }
  .scoreRow { padding: 4px 4px; }
  .scoreRow strong { font-size: 15px; }
  .resultActions { gap: 8px; }
  #milestoneToast { font-size: 13px; padding: 7px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  #milestoneToast { animation: none; }
  button.primary:active, button:active { transform: none; }
}
