/* Mean Baby: Whack-A-Baby — portrait-first layout, pastel garden, touch-first.
   No external fonts; system stack only. Overlays are DOM; the gamefield is Canvas2D. */

:root {
  --mint: #7ee0bb;
  --mint-deep: #4fc79b;
  --coral: #ff8a73;
  --lavender: #c9a4ff;
  --cream: #fff9ec;
  --ink: #3a2d22;
  --lawn-a: #ddf7e8;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Trebuchet MS", "Segoe UI", Verdana, sans-serif;
  background: linear-gradient(180deg, #c3f1d7 0%, #a7e6c0 100%);
  color: var(--ink);
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none;
  touch-action: manipulation;
}
button { font: inherit; cursor: pointer; }
#malletCursor {
  position: fixed; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 10;
}

#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 560px;
  margin: 0 auto;
}

/* ------------------------------- HUD ------------------------------------ */
#hud {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) 12px 8px;
  color: var(--cream);
  background: linear-gradient(180deg, rgba(90,170,120,0.95), rgba(78,150,106,0));
}
.brand { font-weight: 900; font-size: 14px; letter-spacing: 0.5px; color: #fff; text-shadow: 0 2px 4px rgba(40,80,55,0.4); white-space: nowrap; }
.brand small { display: block; font-size: 9px; font-weight: 700; letter-spacing: 1.4px; color: #eaffdf; }
.stat { flex: 0 0 auto; text-align: center; margin-left: auto; }
.stat small { display: block; font-size: 8px; font-weight: 700; letter-spacing: 1.2px; color: #f0ffe9; opacity: 0.85; }
.stat strong { font-size: 20px; font-weight: 900; color: #fff; text-shadow: 0 2px 4px rgba(40,80,55,0.45); font-variant-numeric: tabular-nums; }
.stat.combo strong { color: #ffe9a8; }
.stat.combo.window strong { color: #7df0c8; animation: pulse 0.5s ease-in-out infinite alternate; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.12); } }
#windowPips { display: block; font-size: 12px; letter-spacing: 1px; color: #7df0c8; min-height: 14px; }
.stat.clock { min-width: 62px; }
.stat.clock.urgent strong { color: #ffb196; }
button.icon {
  border: 0; background: rgba(255,255,255,0.22); color: #fff;
  width: 44px; height: 44px; border-radius: 12px; font-size: 19px;
  display: grid; place-items: center; margin-left: 2px;
}
button.icon:active { transform: scale(0.94); }

/* ------------------------------- stage ----------------------------------- */
#stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;          /* allow the canvas to shrink, not overflow */
  position: relative;
}
#game {
  border-radius: 20px;
  box-shadow: 0 14px 34px rgba(60,110,80,0.28), inset 0 0 0 3px rgba(255,255,255,0.35);
  touch-action: manipulation;
  display: block;
}

#announcer {
  position: absolute;
  top: 10px; left: 50%; transform: translateX(-50%);
  background: var(--cream); color: var(--ink);
  font-weight: 900; font-size: 14px; letter-spacing: 0.3px;
  padding: 8px 16px; border-radius: 999px;
  box-shadow: 0 6px 18px rgba(60,110,80,0.3);
  opacity: 0; transition: opacity 0.25s ease;
  pointer-events: none; z-index: 5;
  white-space: nowrap;
}
#announcer.show { opacity: 1; }

/* ------------------------------ overlays --------------------------------- */
/* Overlays are a column flex with `margin:auto` on the card: a card that
   fits is centered exactly as before, but a card taller than the viewport
   (short landscape embeds — the catalog player iframe is ~996x560 at 720p)
   cedes its auto margins, top-aligns and is fully reachable by scrolling.
   The old `place-items:center` grid clipped the overflowing TOP of a tall
   centered child, burying New Game below the scroll origin. */
.overlay {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  background: rgba(40,80,60,0.45);
  backdrop-filter: blur(3px);
  padding: 0 18px;
  z-index: 20;
  overflow-y: auto;
}
.overlay[hidden], #rotate[hidden] { display: none; }
.overlay > .menuCard, .overlay > .modal, .overlay > .resultCard {
  margin: auto;               /* center when it fits; reachable top when it overflows */
}

.menuCard, .modal, .resultCard {
  background: var(--cream);
  border-radius: 26px;
  box-shadow: 0 24px 60px rgba(30,60,45,0.45);
  padding: 28px;
  width: 100%;
  max-width: 430px;
}
.menuCard { display: flex; gap: 0; flex-direction: column; }
.hero {
  text-align: center;
  background: linear-gradient(160deg, #c9f3dd, #aee6c9 60%, #a8dcf0);
  border-radius: 18px 18px 34px 34px;
  padding: 22px 16px 26px;
  margin: -28px -28px 20px;
  color: #fff;
}
.hero .edition { font-size: 10px; font-weight: 900; letter-spacing: 2px; color: #3f7a5c; margin-bottom: 8px; }
.hero h1 { font-size: 44px; line-height: 0.92; font-weight: 900; text-shadow: 0 4px 0 rgba(70,130,95,0.35); }
.hero h1 em { color: #ff8a73; font-style: normal; }
.hero h2 { font-size: 20px; font-weight: 900; letter-spacing: 3px; margin-top: 6px; color: #ffeeb0; text-shadow: 0 3px 0 rgba(90,130,90,0.4); }
.hero .sticker {
  display: inline-block; margin-top: 12px;
  background: #fff6df; color: #7a5230;
  font-size: 11px; font-weight: 900; letter-spacing: 1px;
  padding: 8px 14px; border-radius: 999px;
  border: 2px solid #ffd24a;
  transform: rotate(-2deg);
}
.menuCopy .eyebrow, .modal .eyebrow, .resultCard .eyebrow {
  font-size: 10px; font-weight: 900; letter-spacing: 2px; color: #6fae8a; margin-bottom: 8px;
}
.menuCopy h3 { font-size: 22px; font-weight: 900; margin-bottom: 6px; }
.menuCopy p { font-size: 14px; color: #5a4a3a; line-height: 1.5; }
p.instruction {
  margin: 12px 0 18px;
  background: #e8f7ee; border-left: 4px solid var(--mint-deep);
  padding: 10px 12px; border-radius: 10px;
  font-weight: 700; color: var(--ink); font-size: 13px;
}
.primary {
  width: 100%;
  background: linear-gradient(180deg, #ffb196, #ff8a73);
  color: #fff; border: 0;
  font-size: 18px; font-weight: 900; letter-spacing: 0.5px;
  padding: 15px; border-radius: 16px;
  box-shadow: 0 6px 0 #d96a52;
  min-height: 52px;
}
.primary:active { transform: translateY(3px); box-shadow: 0 3px 0 #d96a52; }
.secondaryRow { display: flex; gap: 10px; margin: 12px 0 8px; }
.secondaryRow button {
  flex: 1; background: #eef5ef; color: var(--ink);
  border: 2px solid #cfdfd3; font-weight: 800; font-size: 15px;
  padding: 12px; border-radius: 14px; min-height: 48px;
}
.secondaryRow button:active { background: #e2efe6; }
.roundNote { display: block; text-align: center; font-size: 11px; color: #8a7a68; margin-top: 6px; }

.modal p { font-size: 14px; line-height: 1.55; color: #58493a; margin-bottom: 12px; }
.modal .muted { font-size: 12px; color: #9a8a78; }
.modal.compact { text-align: center; }
.modal.compact p { margin: 8px 0 18px; }

/* results */
.resultCard { text-align: center; }
.resultCard h2 { font-size: 26px; font-weight: 900; margin: 4px 0 2px; }
.resultCard > p { color: #7a6a58; font-size: 13px; margin-bottom: 14px; }
.resultBody { display: flex; gap: 12px; align-items: stretch; flex-wrap: wrap; justify-content: center; }
.scorecard {
  flex: 1 1 210px; min-width: 200px;
  background: #f0faf3; border-radius: 16px; padding: 14px;
}
.scorecard small { display: block; font-size: 9px; font-weight: 900; letter-spacing: 1.5px; color: #6fae8a; }
.scorecard strong { font-size: 32px; font-weight: 900; color: #3a7a58; }
.scorecard dl { margin-top: 10px; }
.scorecard dl div { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; border-bottom: 1px dashed #cfe6d6; }
.scorecard dt { color: #6a5c4a; }
.scorecard dd { font-weight: 800; color: var(--ink); }
#trophy {
  flex: 0 0 150px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #fff3cd, #ffe08a);
  border: 3px solid #e8b54a; border-radius: 18px; padding: 12px;
  color: #7a5520;
}
#trophy .cup { font-size: 42px; }
#trophy strong { font-size: 16px; font-weight: 900; line-height: 1.15; }
#trophy small { font-size: 9px; font-weight: 800; letter-spacing: 1px; margin-top: 6px; text-align: center; }
#noTrophy { flex: 0 0 150px; display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 18px; padding: 12px; color: #8a7a68; }
#noTrophy span { font-weight: 900; font-size: 15px; }
#noTrophy span.zoomed { color: #5a9a78; font-size: 19px; }
#noTrophy p { font-size: 11px; margin-top: 6px; color: #9a8a78; }
/* outcome panels are display:flex above; make the hidden attribute (toggled by
   game.js showResults()) actually hide them as the UA [hidden] rule is overridden */
#trophy[hidden], #noTrophy[hidden] { display: none !important; }
.resultActions { display: flex; gap: 10px; margin-top: 18px; }
.resultActions button { flex: 1; min-height: 52px; border-radius: 14px; font-weight: 900; font-size: 16px; border: 0; }
.resultActions .primary { box-shadow: 0 6px 0 #d96a52; }
#resultMenu { background: #eef5ef; color: var(--ink); border: 2px solid #cfdfd3 !important; }

/* rotate banner */
#rotate {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center; text-align: center;
  background: linear-gradient(160deg, #aee6c9, #8fd9c1);
  color: #fff;
}
#rotate .rotatePhone {
  font-size: 64px; margin: auto 0 6px; animation: spin 1.6s ease-in-out infinite;
}
#rotate h2 { font-size: 26px; font-weight: 900; }
#rotate p { font-size: 13px; margin-top: 6px; color: #eafff2; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(-90deg); } }

@media (min-width: 600px) {
  #app { max-width: 640px; }
  #hud { justify-content: space-between; }
}
@media (prefers-reduced-motion: reduce) {
  #announcer { transition: none; }
  .stat.combo.window strong, #rotate .rotatePhone, .primary { animation: none; }
}

/* Short landscape embeds (T6 restore fixes): the catalog player iframe is
   ~996x560 at a 1280x720 window, and can be as short as ~520px. Compact the
   menu/results cards so New Game / Play Again sit inside the viewport with
   no scrolling (the centering fix above keeps the TOP of any overflow
   reachable regardless). Normal sizes are untouched. */
@media (max-height: 600px) {
  .overlay { padding-top: 16px; padding-bottom: 16px; }
  .menuCard, .modal, .resultCard { padding: 20px; max-width: 420px; }
  .hero { padding: 14px 12px 16px; margin: -20px -20px 14px; border-radius: 14px 14px 26px 26px; }
  .hero .edition { font-size: 9px; margin-bottom: 6px; }
  .hero h1 { font-size: 28px; }
  .hero h2 { font-size: 16px; letter-spacing: 2px; margin-top: 4px; }
  .hero .sticker { font-size: 10px; padding: 6px 10px; margin-top: 8px; }
  .menuCopy h3 { font-size: 17px; margin-bottom: 4px; }
  .menuCopy p { font-size: 13px; line-height: 1.4; }
  /* The highlighted callout duplicates the verbatim one-line instruction in
     menuCopy p — drop the redundant block on very short embeds, keep the
     load-bearing verbatim line (G21). */
  p.instruction { display: none; }
  .primary { padding: 11px; font-size: 16px; min-height: 44px; }
  .secondaryRow { margin: 8px 0 4px; }
  .secondaryRow button { padding: 9px; min-height: 40px; font-size: 14px; }
  .roundNote { margin-top: 4px; }
  /* results card */
  .resultCard h2 { font-size: 21px; }
  .resultCard > p { margin-bottom: 10px; font-size: 12px; }
  .scorecard { padding: 10px; }
  .scorecard strong { font-size: 26px; }
  #trophy, #noTrophy { flex: 0 0 110px; padding: 8px; }
  #trophy .cup { font-size: 34px; }
  .resultActions { margin-top: 12px; }
  .resultActions button { min-height: 44px; font-size: 15px; }
  .secondaryRow button:active { background: #e2efe6; }
}
