/* Nice Baby: Doctor Baby Fixer — styles for DOM menus/HUD (Canvas renders the scene).
 * Pastel cozy clinic: soft mint/lavender, rounded shapes, big friendly targets.
 */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: #cfe3e0;
  overflow: hidden;
  font-family: "Comic Sans MS", "Segoe UI Rounded", "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#stage {
  position: relative;
  width: 960px;
  height: 540px;
  margin: 0 auto;
  /* letterbox: layout() computes the exact fit transform (scale =
     min(innerW/960, innerH/540)). No width/height clamp here — a CSS clamp
     would double-shrink the stage on top of the transform and clip content. */
  transform-origin: top left;
  overflow: hidden;
  background: #eef6f4;
  box-shadow: 0 6px 28px rgba(60, 90, 100, 0.35);
}

#stage.scaled {
  position: absolute;
  top: 50%;
  left: 50%;
  transform-origin: center;
}

canvas#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hidden { display: none !important; }

/* ---------------- screens (DOM menus) ---------------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: linear-gradient(160deg, #eef7f4 0%, #efeaf8 55%, #fdf2ee 100%);
  text-align: center;
  z-index: 30;
  overflow-y: auto;   /* safety: allow scrolling if menu content ever exceeds the scaled stage */
}

.screen h1 { font-size: 52px; color: #5a7d8a; letter-spacing: 1px; text-shadow: 0 2px 0 #fff; }
.screen h2 { font-size: 34px; color: #6d8f9a; }
.kicker { font-size: 18px; letter-spacing: 6px; text-transform: uppercase; color: #a8b8c0; }

#controls-line { font-size: 16px; color: #8aa0a6; margin-top: 4px; max-width: 640px; }

.big-btn {
  min-width: 240px;
  min-height: 54px;
  padding: 12px 28px;
  font-size: 22px;
  font-weight: bold;
  color: #fff;
  background: #7fb8a8;
  border: none;
  border-radius: 999px;
  box-shadow: 0 4px 0 #5d9183, 0 6px 12px rgba(90, 130, 120, 0.25);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.big-btn:hover { background: #8fc7b7; }
.big-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #5d9183; }
.big-btn.small { min-width: 150px; font-size: 17px; }

button:focus-visible { outline: 4px solid #ffd27a; outline-offset: 2px; }

#menu-art {
  width: 118px;
  height: 118px;
  object-fit: contain;
  border-radius: 20px;
  border: 4px solid #fff;
  box-shadow: 0 6px 16px rgba(90, 130, 120, 0.28);
  margin-top: 2px;
}

#menu-buttons { display: flex; flex-direction: column; gap: 14px; }

/* About */
#about-text {
  font-family: inherit;
  font-size: 20px;
  line-height: 1.65;
  color: #48636c;
  white-space: pre-line;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 22px;
  padding: 22px 34px;
}

/* Doctor grid */
#doctor-grid { display: flex; gap: 22px; }
.doctor-card {
  width: 150px;
  min-height: 190px;
  border-radius: 24px;
  border: 5px solid #e3eef0;
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 14px 8px;
  cursor: pointer;
  font-size: 20px;
  font-weight: bold;
  color: #5a7d8a;
  box-shadow: 0 4px 10px rgba(90, 130, 130, 0.15);
}
.doctor-card.selected { border-color: #ffd27a; transform: translateY(-4px); }
.doctor-card .doctor-portrait {
  width: 96px;
  height: 106px;
  object-fit: contain;
  border-radius: 14px;
  margin-bottom: 10px;
  filter: drop-shadow(0 3px 5px rgba(60, 90, 100, 0.25));
}
.doctor-card span { margin-top: 2px; }

/* Recap */
.recap-card {
  background: rgba(255,255,255,0.85);
  border-radius: 26px;
  padding: 26px 46px;
  font-size: 22px;
  line-height: 2;
  color: #48636c;
  box-shadow: 0 4px 14px rgba(90,130,130,0.18);
}
.recap-card b { color: #e07a96; font-size: 26px; }
.recap-sentiment { color: #9a7fb8; font-style: italic; margin-top: 6px; }
.recap-buttons { display: flex; gap: 16px; }

.goodbye { color: #6d9a8a; }
.goodbye-sub { font-size: 17px; color: #8aa0a6; }

/* ---------------- HUD ---------------- */
#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.55);
  border-bottom: 3px solid rgba(150, 185, 190, 0.4);
  z-index: 10;
  pointer-events: none;
}
.hud-left, .hud-right { display: flex; align-items: center; gap: 8px; }
#hud .hud-btn, .hud-right { pointer-events: auto; }
.hud-chip {
  font-size: 15px;
  font-weight: bold;
  color: #5a7d8a;
  background: #fff;
  border-radius: 999px;
  padding: 5px 12px;
  box-shadow: 0 2px 4px rgba(90,130,130,0.15);
  white-space: nowrap;
}
.hud-doctor {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  line-height: 1;
}
.hud-doctor img {
  width: 30px;
  height: 33px;
  object-fit: contain;
  border-radius: 8px;
}
.hud-btn {
  font-size: 14px;
  font-weight: bold;
  color: #5a7d8a;
  background: #fff;
  border: 2px solid #d8e6e6;
  border-radius: 999px;
  padding: 5px 12px;
  min-height: 32px;
  cursor: pointer;
}
.hud-btn:hover { background: #f4fbf8; }
.hud-btn.off { opacity: 0.55; }

/* ---------------- dialog bubble (LEFT of the patient's face) ---------------- */
#dialog {
  position: absolute;
  top: 58px;
  left: 180px;
  z-index: 11;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  max-width: 420px;
  pointer-events: none;
  text-align: left;
}
#dialog-name {
  font-size: 15px;
  font-weight: bold;
  color: #fff;
  background: #a9b8c8;
  border-radius: 999px;
  padding: 4px 14px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}
#dialog-bubble {
  font-size: 17px;
  color: #48636c;
  background: #fff;
  border: 3px solid #d8e6e6;
  border-radius: 20px;
  padding: 12px 18px;
  box-shadow: 0 4px 10px rgba(90,130,130,0.2);
  max-width: 420px;
}

/* ---------------- milestone banner ---------------- */
/* T4-V2: the banner lives in the fixed free LEFT-CENTER room rectangle
   (logical 250..584 x 220..336), below the dialogue and clear of the bell,
   tray, patient face and HUD. Exact text/counters kept; compact wrap. */
#milestone {
  position: absolute;
  left: 250px;
  top: 220px;
  width: 334px;
  max-height: 116px;
  overflow: hidden;
  z-index: 20;
  background: #ffe8a8;
  border: 3px solid #ffd27a;
  color: #8a6a20;
  font-size: 19px;
  font-weight: bold;
  line-height: 1.3;
  border-radius: 16px;
  padding: 10px 12px;
  box-shadow: 0 6px 16px rgba(190, 150, 60, 0.35);
  text-align: center;
}

/* Guarded DOM illustration fallbacks (ACC-A3 / T4-V3): local accent
   cap/heart placeholders replace a broken generated menu/choose/HUD image
   (the broken icon itself is hidden by game.js). */
.img-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  border: 3px solid #fff;
  box-shadow: 0 4px 10px rgba(90, 130, 120, 0.2);
  user-select: none;
  flex: 0 0 auto;
}
.img-fallback-menu {
  width: 118px;
  height: 118px;
  border-radius: 20px;
  font-size: 46px;
  border: 4px solid #fff;
}
.img-fallback-portrait {
  width: 96px;
  height: 106px;
  border-radius: 14px;
  font-size: 42px;
  margin-bottom: 10px;
}
.img-fallback-hud {
  width: 30px;
  height: 33px;
  border-radius: 8px;
  font-size: 17px;
  border-width: 2px;
}

/* ---------------- desk bell + baby hit zone ---------------- */
#btn-bell {
  position: absolute;
  left: 96px;
  bottom: 128px;
  width: 86px;
  height: 86px;
  border-radius: 50%;
  border: 4px solid #e8b45a;
  background: radial-gradient(circle at 35% 30%, #ffe9b8, #f4c26a 70%);
  font-size: 44px;
  cursor: pointer;
  z-index: 12;
  box-shadow: 0 5px 0 #c9934a, 0 8px 14px rgba(150,110,40,0.3);
  transition: transform 0.08s ease;
}
#btn-bell:active { transform: translateY(4px) scale(0.96); }
#btn-bell.ringing { animation: bellshake 0.35s ease; }
@keyframes bellshake {
  0% { transform: rotate(0); } 25% { transform: rotate(-8deg); }
  75% { transform: rotate(8deg); } 100% { transform: rotate(0); }
}

#btn-baby {
  position: absolute;
  left: 550px;
  top: 80px;
  width: 380px;
  height: 330px;
  background: transparent;
  border: none;
  cursor: pointer;
  z-index: 9;
}
#btn-baby:active { cursor: grabbing; }

/* ---------------- tray ---------------- */
#tray {
  position: absolute;
  left: 12px; right: 12px;
  bottom: 10px;
  height: 96px;
  display: flex;
  gap: 6px;
  align-items: stretch;
  justify-content: center;
  z-index: 12;
  padding: 8px 6px 6px;
  border-radius: 20px;
  background: linear-gradient(#dcae7c, #c99463);
  box-shadow: 0 4px 0 #a8784e, 0 8px 14px rgba(120,80,40,0.3);
}
.tray-item {
  flex: 1;
  max-width: 78px;
  min-width: 0;
  border: 3px solid #f0d3ae;
  border-radius: 14px;
  background: #fdf6ec;
  font-size: 11px;
  font-weight: bold;
  color: #7a5636;
  cursor: pointer;
  padding: 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  min-height: 46px;
  box-shadow: inset 0 -4px 0 rgba(200,150,90,0.25);
  transition: transform 0.09s ease, box-shadow 0.09s ease;
}
.tray-item .tray-icon { font-size: 26px; line-height: 1; }
/* Intrinsic item PNGs are 128x128 — constrain to ~44-48px, contain (mandatory,
   otherwise the intrinsic size overflows the rack). */
.tray-item img {
  width: 44px;
  height: 44px;
  max-width: 44px;
  max-height: 44px;
  object-fit: contain;
  flex: 0 0 auto;
  pointer-events: none;
}
.tray-item:hover { background: #fff8ee; }
.tray-item.held {
  transform: translateY(-14px) scale(1.08);
  border-color: #ffd27a;
  box-shadow: 0 8px 12px rgba(120,80,40,0.35);
  background: #fff;
  z-index: 5;
}
.tray-item:disabled { opacity: 0.75; cursor: default; }

/* ---------------- pause veil ---------------- */
#pause-veil {
  position: absolute;
  inset: 0;
  background: rgba(120, 150, 160, 0.72);
  color: #fff;
  font-size: 26px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
}

/* ---------------- reduced motion ---------------- */
@media (prefers-reduced-motion: reduce) {
  .big-btn, .tray-item, #btn-bell { transition: none; }
  #btn-bell.ringing { animation: none; }
}
