/* Mean Baby: Cupcake Chaos — responsive HUD/UI skin (sibling-game style). */

:root {
  --pink: #f0709a;
  --pink-dark: #c94f78;
  --cream: #fff6e8;
  --ink: #2a2018;
  --gold: #ffd166;
  --teal: #4a90d9;
  --panel: rgba(42, 32, 24, 0.72);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: #1a1410;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  color: var(--cream);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
#viewport {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #bfd9ee;
  touch-action: none;
}
#gl {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

/* ------------------------------- screens ------------------------------- */
.cc-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cc-screen {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: flex-start;   /* FIX B: top-aligned so the top never clips */
  flex-direction: column;
  gap: 14px;
  text-align: center;
  padding: 18px;
  pointer-events: auto;   /* overlays must be clickable, not click-through */
  overflow-y: auto;        /* scroll to reach bottom buttons on short embeds */
  background: radial-gradient(120% 120% at 50% 30%, rgba(255, 214, 102, 0.12), rgba(26, 20, 16, 0.85));
}
.cc-screen.cc-visible { display: flex; }
.cc-screen.cc-pause, .cc-screen.cc-portrait { background: rgba(26, 20, 16, 0.88); }

.cc-title {
  font-size: clamp(34px, 7vw, 76px);
  margin: 0;
  letter-spacing: 0.02em;
  color: var(--gold);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.35), 0 6px 14px rgba(0, 0, 0, 0.4);
}
.cc-subtitle {
  font-size: clamp(13px, 2vw, 18px);
  opacity: 0.85;
  margin: 0 0 10px;
}
.cc-menu-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: min(260px, 70vw);
}
.cc-menu-item {
  font-size: clamp(17px, 2.6vw, 22px);
  padding: 13px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.10);
  border: 2px solid rgba(255, 255, 255, 0.22);
  color: var(--cream);
  cursor: pointer;
  transition: transform 0.08s ease, background 0.12s ease;
}
.cc-menu-item.cc-selected, .cc-menu-item:active {
  background: var(--pink);
  border-color: var(--pink);
  transform: scale(1.03);
}
.cc-menu-hint { font-size: 12px; opacity: 0.62; }
.cc-control-hint { max-width: 580px; font-size: 15px; line-height: 1.35; color: var(--gold); }

.cc-about-body {
  white-space: pre-wrap;
  font-size: clamp(14px, 2.2vw, 18px);
  line-height: 1.5;
  background: var(--panel);
  padding: 16px 22px;
  border-radius: var(--radius);
  max-width: 420px;
}

/* buttons */
.cc-btn {
  font-size: clamp(16px, 2.4vw, 20px);
  padding: 13px 22px;
  min-height: 48px;
  border-radius: 999px;
  border: 0;
  cursor: pointer;
  color: #fff;
}
.cc-btn-primary { background: var(--pink); }
.cc-btn-primary:active { background: var(--pink-dark); }
.cc-btn-secondary { background: rgba(255, 255, 255, 0.16); }
.cc-btn:disabled { opacity: 0.35; cursor: default; }
.cc-res-buttons { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

.cc-rating {
  font-size: clamp(24px, 4vw, 40px);
  font-weight: 800;
  color: var(--gold);
}
.cc-res-score { font-size: clamp(20px, 3.4vw, 32px); }
.cc-res-cakes, .cc-res-girls { font-size: clamp(15px, 2.4vw, 20px); opacity: 0.9; }

.cc-loadbar {
  width: min(280px, 60vw);
  height: 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.18);
  overflow: hidden;
}
.cc-loadfill {
  height: 100%;
  width: 4%;
  background: var(--gold);
  border-radius: 8px;
  transition: width 0.3s ease;
}
.cc-loading-sub { opacity: 0.75; font-size: 14px; }

.cc-rotate-icon { font-size: 48px; animation: rotate-pulse 1.6s ease-in-out infinite; }
@keyframes rotate-pulse { 0%, 100% { transform: rotate(-90deg); } 50% { transform: rotate(90deg); } }

/* ------------------------------- HUD ------------------------------- */
.cc-hud {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: none;
  pointer-events: none;
}
.cc-hud.cc-visible { display: block; }

.cc-hud-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px 10px;
  gap: 8px;
  pointer-events: none;
}
.cc-hud-left, .cc-hud-center, .cc-hud-right {
  background: var(--panel);
  border-radius: 12px;
  padding: 6px 12px;
  pointer-events: auto;
}
.cc-score, .cc-cakes { font-size: clamp(12px, 2vw, 16px); font-weight: 700; white-space: nowrap; }
.cc-object { font-size: clamp(12px, 2vw, 16px); font-weight: 700; color: var(--gold); }
.cc-hud-center { min-width: 0; text-align: center; }
.cc-pips { letter-spacing: 3px; font-size: 12px; color: var(--gold); }

.cc-hud-right { display: flex; gap: 8px; }
.cc-ctl {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.18);
  color: var(--cream);
  font-size: 20px;
  cursor: pointer;
}

.cc-hud-bottom {
  position: absolute;
  /* The spare upper wall is clear of both the target party and physical props. */
  top: 64px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 12px 10px 16px;
  pointer-events: none;
}
.cc-hud-bottom .cc-btn { pointer-events: auto; box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3); }
.cc-throw { min-width: 150px; font-weight: 800; letter-spacing: 0.08em; }
.cc-skip { display: none; }
.cc-restart { display: none; width: 52px; }

/* Named pickups stay reachable even when world props look like spent clutter. */
.cc-inventory {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: min(720px, calc(100% - 12px));
  padding: 6px;
  border-radius: 12px;
  background: var(--panel);
  pointer-events: auto;
}
.cc-inventory-header { display: flex; align-items: center; justify-content: center; gap: 12px; }
.cc-inventory-title { font-size: 12px; color: var(--gold); text-align: center; }
.cc-inventory-items { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.cc-pickup, .cc-inventory-change {
  min-height: 44px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, .5);
  border-radius: 8px;
  background: #493c32;
  color: var(--cream);
  font-family: inherit;
  font-size: 12px;
  font-weight: bold;
  line-height: 1.2;
  cursor: pointer;
}
.cc-pickup[aria-pressed="true"] { background: var(--pink-dark); border-color: var(--gold); }
.cc-pickup:focus-visible, .cc-inventory-change:focus-visible { outline: 3px solid var(--gold); outline-offset: 1px; }
.cc-pickup[hidden], .cc-inventory-change[hidden] { display: none; }

/* crosshair */
.cc-crosshair {
  position: absolute;
  width: 14px;
  height: 14px;
  margin: 0;
  transform: translate(-50%, -50%);
  z-index: 25;
  pointer-events: none;
  border: 1px solid rgba(0, 0, 0, 0.75);
  border-radius: 50%;
  display: none;
}
.cc-crosshair::before, .cc-crosshair::after {
  content: "";
  position: absolute;
  background: rgba(0, 0, 0, 0.65);
}
.cc-crosshair::before { left: 50%; top: -4px; width: 1px; height: 22px; transform: translateX(-50%); }
.cc-crosshair::after { top: 50%; left: -4px; height: 1px; width: 22px; transform: translateY(-50%); }
.cc-laser-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 4px;
  margin: -2px 0 0 -2px;
  background: #ff2b2b;
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(255, 40, 40, 0.9);
}
.cc-laser-dot::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border: 1px solid rgba(255, 40, 40, 0.65);
  border-radius: 50%;
}

/* complaint bubbles */
.cc-bubbles {
  position: absolute;
  inset: 0;
  z-index: 26;
  pointer-events: none;
}
.cc-bubble {
  position: absolute;
  display: none;
  max-width: min(260px, 60vw);
  background: #fff;
  color: var(--ink);
  font-size: clamp(12px, 2.2vw, 16px);
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 12px;
  transform: translate(-50%, -100%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  animation: bubble-in 0.16s ease;
}
.cc-bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 7px solid #fff;
  transform: translateX(-50%);
}
.cc-bubble.cc-visible { display: block; }
@keyframes bubble-in { from { opacity: 0; transform: translate(-50%, -90%); } to { opacity: 1; transform: translate(-50%, -100%); } }

/* Awards live outside the core/replay clock and never intercept input. */
.cc-feedback { position: absolute; inset: 0; z-index: 19; pointer-events: none; overflow: hidden; }
.cc-feedback[hidden], .cc-award[hidden], .cc-throw-summary[hidden] { display: none; }
.cc-award {
  position: absolute; top: 0; left: 0; font-size: 26px; line-height: 32px;
  font-weight: 900; text-shadow: 0 2px 2px #211524, 1px 0 2px #211524;
  will-change: transform;
}
.cc-throw-summary {
  position: absolute; right: 76px; top: 68px; padding: 7px 9px;
  border-radius: 10px; background: var(--panel); font-size: 13px;
  line-height: 1.35; font-weight: bold;
}
.cc-throw-title { color: var(--gold); }

/* mobile */
@media (max-width: 720px) {
  .cc-hud-top { padding: 6px; }
  .cc-hud-left, .cc-hud-center, .cc-hud-right { padding: 4px 8px; }
  .cc-throw { min-width: 120px; }
  .cc-menu-hint { display: none; }
}

@media (max-height: 450px) {
  .cc-screen { gap: 8px; padding: 10px; }
  .cc-title { font-size: 38px; }
  .cc-menu-item { padding: 8px 18px; min-height: 44px; }
  .cc-menu-hint { display: none; }
  .cc-subtitle { margin: 0; }
  .cc-hud-top { padding: 4px; }
  .cc-hud-right { padding: 2px 6px; }
  .cc-hud-bottom { padding: 6px; }
  .cc-about-body { margin: 0; font-size: 14px; padding: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
