/* Weird Baby: Baby Barista — landscape-first layout + compact cards.
 *
 * The catalog player is a short landscape iframe (~560 px tall, sometimes
 * 520 px). Cards are TOP-ALIGNED in the overlay, capped at max-height:100%
 * with internal scroll, so New Game / Play Again are always clickable without
 * scrolling and nothing ever overflows the top (Whack-A-Baby FIX B pattern).
 */

:root {
  --cream: #f6ecd9;
  --paper: #fffaf0;
  --espresso: #3f2a1a;
  --espresso-2: #5d3a1e;
  --latte: #b98e5f;
  --steel: #9aa1a8;
  --steel-dark: #596066;
  --bean: #7a4a2b;
  --cherry: #c24b3a;
  --leaf: #6fae63;
  --gold: #ffd24a;
  --mother-blue: #00b7ff;
  --ink: #2b2433;
  --cream-dark: #e8dcc0;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  background: var(--espresso);
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
  -webkit-user-select: none; user-select: none;
}

#app {
  position: relative;
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--espresso);
}

/* ------------------------------ HUD ----------------------------------- */
#hud {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  padding: 6px 10px;
  background: rgba(63, 42, 26, 0.94);
  color: var(--cream);
  border-bottom: 3px solid var(--espresso-2);
  flex: 0 0 auto;
}
#hudBadge {
  width: 34px; height: 34px;
  flex: 0 0 auto;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
}
#hud .brand {
  font-weight: 900; font-size: 14px; letter-spacing: 0.5px;
  color: var(--gold);
  white-space: nowrap;
}
#hud .brand small { display: block; font-size: 9px; letter-spacing: 2px; color: var(--cream-dark); font-weight: 700; }
#hud .stat {
  margin-left: auto; text-align: right; line-height: 1.05;
  white-space: nowrap;
}
#hud .stat small { display: block; font-size: 9px; letter-spacing: 1.5px; color: var(--cream-dark); font-weight: 700; }
#hud .stat strong { font-size: 18px; font-weight: 900; color: #fff; }
#hud .stat.urgent strong { color: var(--gold); }
#hud .spacer { flex: 1; }
button.icon {
  /* Border-box height fits the fixed HUD without shifting the play area. */
  min-width: 44px; height: 40px; min-height: 40px;
  padding: 0 6px;
  font-size: 20px; line-height: 1;
  border: 2px solid rgba(255,255,255,0.28);
  border-radius: 10px;
  background: rgba(255,255,255,0.08);
  color: var(--cream);
  cursor: pointer;
}
button.icon:hover { background: rgba(255,255,255,0.18); }
button.icon[aria-pressed="true"] { color: var(--gold); }
button.icon:focus-visible { outline-offset: -3px; }

/* ------------------------------ stage --------------------------------- */
#stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #2a1c10;
}
#game {
  display: block;
  image-rendering: auto;
  touch-action: none;
  cursor: pointer;
}
/* REVISION v2 G-1/G-2: the ONE persistent instruction line. Large fun font,
 * sits at the top of the play area, never auto-hides (text only changes when
 * the phase/step changes). The fast auto-popups are gone. */
.instruction-line {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  pointer-events: none;
  max-width: 94%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  font-family: 'Baloo 2', 'Comic Sans MS', 'Chalkboard SE', system-ui, sans-serif;
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 1px;
  color: #fff;
  text-shadow:
    0 3px 0 rgba(63, 42, 26, 0.92),
    0 0 16px rgba(0, 0, 0, 0.65),
    0 0 34px rgba(0, 0, 0, 0.45);
}
#banner {
  position: absolute;
  top: 8px; left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  pointer-events: none;
  font-weight: 900; font-size: 13px; letter-spacing: 1px;
  color: #fff;
  background: rgba(31, 18, 8, 0.72);
  border: 2px solid rgba(255, 210, 74, 0.6);
  border-radius: 999px;
  padding: 5px 14px;
  max-width: 92%;
  text-align: center;
  white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
#announcer {
  position: absolute;
  bottom: 8px; left: 50%; transform: translateX(-50%);
  z-index: 6; pointer-events: none;
  font-weight: 900; font-size: 13px; letter-spacing: 0.5px;
  color: #fff; text-align: center;
  background: rgba(31, 18, 8, 0.78);
  border-radius: 999px; padding: 5px 14px;
  opacity: 0; transition: opacity 0.18s;
  max-width: 94%;
}
#announcer.show { opacity: 1; }

/* --------------------------- overlays / cards ------------------------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-start;          /* TOP-ALIGNED: cards never overflow the top */
  justify-content: center;
  padding: 14px 14px 14px 14px;     /* bottom padding only guards letterbox bars */
  background: rgba(37, 24, 13, 0.55);
  backdrop-filter: blur(2px);
  overflow: auto;                   /* the overlay itself can scroll on tiny embeds */
}
.overlay[hidden] { display: none; }

.menuCard, .modal, .resultCard {
  max-height: 100%;                 /* never taller than the iframe */
  overflow-y: auto;                 /* internal scroll at very short embeds */
  width: min(560px, 100%);
  background: var(--paper);
  border: 4px solid var(--espresso-2);
  border-radius: 18px;
  box-shadow: 0 14px 40px rgba(0,0,0,0.5);
  padding: 16px 22px 18px;
}

.hero { text-align: center; margin-bottom: 10px; }
.hero .edition {
  font-size: 9px; letter-spacing: 3px; font-weight: 900;
  color: var(--cherry); margin-bottom: 4px;
}
#menuHero {
  display: block;
  margin: 0 auto 6px;
  width: min(180px, 46vw);
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 6px 14px rgba(63, 42, 26, 0.35));
}
.hero h1 {
  margin: 0; font-size: 30px; line-height: 0.95;
  letter-spacing: 1px; color: var(--espresso);
}
.hero h1 .blue { color: var(--mother-blue); }
.hero h2 {
  margin: 2px 0 0; font-size: 15px; letter-spacing: 4px;
  color: var(--latte); font-weight: 900;
}
.hero .sticker {
  display: inline-block; margin-top: 8px;
  background: var(--gold); color: var(--espresso);
  font-weight: 900; font-size: 10px; letter-spacing: 1px;
  border-radius: 8px; padding: 4px 10px;
}

.eyebrow {
  font-size: 9px; letter-spacing: 2.5px; font-weight: 900;
  color: var(--cherry); text-transform: uppercase; margin-bottom: 6px;
}
.modal h2 { margin: 0 0 8px; font-size: 22px; color: var(--espresso); }
.modal p { margin: 6px 0; font-size: 13px; line-height: 1.45; color: #43311f; }
.modal p.muted { color: #8a6f52; font-size: 12px; }
.modal .about {
  background: var(--cream);
  border: 2px solid var(--cream-dark);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 8px 0;
  font-size: 13px; line-height: 1.5;
  white-space: pre-wrap;
  color: var(--espresso);
}
.modal .about b { color: var(--cherry); }

.menuCopy p { margin: 5px 0; font-size: 13px; line-height: 1.4; color: #43311f; }
.menuCopy p.instruction { font-size: 12px; color: #7a5c3a; }
.asset-error {
  margin: 6px 0 !important;
  font-size: 12px !important;
  color: #a3291b !important;
  font-weight: 800;
  background: #ffe3dc;
  border: 2px solid #e8a08f;
  border-radius: 8px;
  padding: 6px 8px;
}
button.primary:disabled {
  background: #cfc4ae;
  border-color: #9b8e77;
  color: #6f6350;
  cursor: not-allowed;
  transform: none;
}

button {
  font-family: inherit;
}
button.primary, button.ghost, .secondaryRow button {
  min-height: 44px;
  border-radius: 12px;
  font-weight: 900; letter-spacing: 0.5px; cursor: pointer;
}
button.primary {
  width: 100%;
  margin-top: 10px;
  border: 3px solid var(--espresso);
  background: var(--gold);
  color: var(--espresso);
  font-size: 17px;
  border-bottom-width: 6px;
}
button.primary:hover { filter: brightness(1.06); transform: translateY(-1px); }
button.primary:active { transform: translateY(1px); border-bottom-width: 3px; }
button.primary:focus-visible { outline: 3px solid var(--mother-blue); outline-offset: 2px; }
.secondaryRow { display: flex; gap: 10px; margin-top: 10px; }
.secondaryRow button, button.ghost {
  flex: 1; border: 2px solid var(--latte); background: var(--cream);
  color: var(--espresso); font-size: 14px; min-height: 44px;
}
.secondaryRow button:hover, button.ghost:hover { background: #fff; }

.roundNote { display: block; margin-top: 10px; font-size: 11px; color: #8a6f52; text-align: center; }

.resultCard { text-align: center; }
.resultCard h2 { margin: 2px 0 2px; font-size: 26px; color: var(--espresso); }
.resultCard h2.win { color: #1c7a3d; }
.resultCard h2.lose { color: var(--cherry); }
.resultCard .subtitle { font-size: 12px; color: #7a5c3a; margin: 0 0 10px; }
.scorecard {
  display: inline-block;
  background: var(--cream); border: 2px solid var(--cream-dark);
  border-radius: 12px; padding: 8px 18px 10px; min-width: 220px;
}
.scorecard small { letter-spacing: 2px; color: #8a6f52; font-weight: 900; font-size: 10px; }
.scorecard strong { font-size: 34px; color: var(--espresso); display: block; line-height: 1.1; }
.scorecard dl { margin: 6px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; text-align: left; }
.scorecard dl div { display: contents; }
.scorecard dt { font-size: 11px; color: #8a6f52; font-weight: 700; }
.scorecard dd { margin: 0; font-size: 12px; font-weight: 900; color: var(--espresso); text-align: right; }
.resultActions { display: flex; gap: 10px; margin-top: 12px; }
.resultActions button {
  flex: 1; height: 46px; min-height: 46px; margin: 0;   /* overrides .primary margin */
  border-radius: 12px; font-weight: 900; letter-spacing: 0.5px; cursor: pointer;
}
#againButton { border: 2px solid var(--espresso); border-bottom-width: 6px; background: var(--gold); color: var(--espresso); font-size: 15px; }
#againButton:hover { filter: brightness(1.06); }
#resultMenu { border: 2px solid var(--latte); background: var(--cream); color: var(--espresso); font-size: 14px; }
#resultMenu:hover { background: #fff; }
.tr-phases { margin-top: 10px; font-size: 11px; color: #7a5c3a; }
.trophy-note { margin-top: 8px; font-size: 12px; font-weight: 800; color: #1c7a3d; }

/* --------------------------- pause card ------------------------------- */
.pauseCard {
  width: min(380px, 100%);
  background: var(--paper);
  border: 4px solid var(--espresso-2);
  border-radius: 18px;
  padding: 18px 22px;
  text-align: center;
}
.pauseCard h2 { margin: 0 0 6px; font-size: 24px; color: var(--espresso); }
.pauseCard p { margin: 4px 0 12px; font-size: 13px; color: #7a5c3a; }

/* ------------------------- keyboard focus ring ------------------------ */
button:focus-visible { outline: 3px solid var(--mother-blue); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
