/* Bloomburb — cozy, chunky, kid-friendly UI */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --pink: #ff8fab;
  --pink-deep: #fb6f92;
  --mint: #9ef0c9;
  --sky: #a7d8ff;
  --sun: #ffd166;
  --cream: #fff7ec;
  --ink: #4a3f56;
  --card: #ffffff;
  --shadow: 0 8px 0 rgba(74, 63, 86, .15);
  --radius: 22px;
}

html, body { height: 100%; overflow: hidden; touch-action: none; }
body {
  font-family: "Comic Sans MS", "Chalkboard SE", "Baloo 2", "Nunito", sans-serif;
  background: var(--sky);
  color: var(--ink);
  user-select: none;
}

#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.hidden { display: none !important; }

/* ---------- screens ---------- */
.screen {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #a7d8ff 0%, #cdeffd 45%, #b8f0d2 100%);
  overflow-y: auto;
}

.title-card { text-align: center; padding: 24px; max-width: 480px; width: 92%; }
.title-logo {
  font-size: clamp(44px, 9vw, 76px); font-weight: 900; color: var(--pink-deep);
  text-shadow: 0 5px 0 #fff, 0 9px 0 rgba(74,63,86,.12);
  animation: bounce-in .7s ease;
}
.title-tag { font-size: clamp(16px, 3vw, 24px); margin: 6px 0 26px; color: var(--ink); opacity: .8; }
.title-footer { margin-top: 28px; font-size: 12px; opacity: .55; }

@keyframes bounce-in {
  0% { transform: scale(.3); opacity: 0; }
  60% { transform: scale(1.12); }
  100% { transform: scale(1); opacity: 1; }
}

.big-btn {
  display: block; width: 100%; margin: 10px auto; padding: 16px 24px;
  font: inherit; font-size: 22px; font-weight: 800; color: #fff;
  background: var(--pink-deep); border: none; border-radius: var(--radius);
  box-shadow: var(--shadow); cursor: pointer; transition: transform .1s;
}
.big-btn:active { transform: translateY(4px); box-shadow: 0 4px 0 rgba(74,63,86,.15); }

.mini-btn {
  font: inherit; font-size: 14px; font-weight: 700; padding: 8px 14px; margin-top: 8px;
  border: none; border-radius: 14px; background: var(--sun); color: var(--ink);
  box-shadow: 0 4px 0 rgba(74,63,86,.15); cursor: pointer;
}
.mini-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(74,63,86,.15); }

.profile-btn {
  display: flex; align-items: center; gap: 12px; width: 100%; margin: 8px 0;
  padding: 12px 18px; font: inherit; font-size: 20px; font-weight: 800;
  background: var(--card); color: var(--ink); border: none; border-radius: var(--radius);
  box-shadow: var(--shadow); cursor: pointer;
}
.profile-btn:active { transform: translateY(3px); box-shadow: 0 4px 0 rgba(74,63,86,.15); }
.profile-btn .pav { width: 46px; height: 46px; border-radius: 50%; background: var(--cream); flex: none; }
.profile-btn .pdel { margin-left: auto; opacity: .45; font-size: 16px; padding: 6px; }

/* ---------- avatar studio ---------- */
.studio-wrap {
  display: flex; gap: 18px; align-items: stretch; flex-wrap: wrap; justify-content: center;
  width: 94%; max-width: 900px; padding: 16px;
}
.studio-left {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; text-align: center; flex: 0 1 390px;
}
#studio-canvas { width: 100%; max-width: 360px; background: linear-gradient(180deg,#fdeff5,#fff7ec); border-radius: 16px; }
.studio-name { font-size: 24px; font-weight: 900; margin-top: 8px; color: var(--pink-deep); }
.studio-right { flex: 1 1 380px; display: flex; flex-direction: column; min-width: 300px; }

.studio-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.studio-tab {
  font: inherit; font-weight: 800; font-size: 15px; padding: 9px 14px; border: none;
  border-radius: 14px; background: #ffffffaa; color: var(--ink); cursor: pointer;
}
.studio-tab.active { background: var(--pink-deep); color: #fff; box-shadow: 0 4px 0 rgba(74,63,86,.15); }

.studio-options {
  flex: 1; display: flex; flex-wrap: wrap; gap: 10px; align-content: flex-start;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; margin-bottom: 12px; overflow-y: auto; max-height: 46vh; min-height: 180px;
}
.opt-swatch, .opt-tile {
  border: 4px solid transparent; border-radius: 14px; cursor: pointer; padding: 0;
  background: var(--cream);
}
.opt-swatch { width: 44px; height: 44px; border-radius: 50%; }
.opt-tile { width: 74px; height: 74px; display: flex; align-items: center; justify-content: center; position: relative; }
.opt-tile canvas { pointer-events: none; }
.opt-swatch.sel, .opt-tile.sel { border-color: var(--pink-deep); }
.opt-lock {
  position: absolute; right: 3px; bottom: 3px; font-size: 15px;
  filter: drop-shadow(0 1px 1px #fff);
}

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 15; pointer-events: none; }
#hud-top { display: flex; gap: 8px; padding: 10px; align-items: center; }
.hud-spacer { flex: 1; }
.hud-pill {
  pointer-events: auto; background: #ffffffee; padding: 8px 16px; border-radius: 999px;
  font-weight: 900; font-size: 18px; box-shadow: 0 4px 0 rgba(74,63,86,.12);
}
.hud-btn {
  pointer-events: auto; width: 48px; height: 48px; font-size: 22px; border: none;
  border-radius: 50%; background: #ffffffee; box-shadow: 0 4px 0 rgba(74,63,86,.12);
  cursor: pointer;
}
.hud-btn:active { transform: translateY(2px); }

#interact-prompt {
  position: fixed; bottom: 116px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; font-weight: 800; font-size: 17px;
  padding: 10px 20px; border-radius: 999px; pointer-events: none; white-space: nowrap;
}

#joystick {
  position: fixed; bottom: 26px; left: 26px; width: 120px; height: 120px;
  border-radius: 50%; background: #ffffff55; border: 3px solid #ffffffaa;
  pointer-events: auto;
}
#joystick-knob {
  position: absolute; left: 35px; top: 35px; width: 50px; height: 50px;
  border-radius: 50%; background: #ffffffdd; box-shadow: 0 3px 0 rgba(74,63,86,.15);
}
#btn-action {
  position: fixed; bottom: 44px; right: 30px; width: 84px; height: 84px;
  border-radius: 50%; border: none; background: var(--sun); font-size: 34px;
  box-shadow: 0 6px 0 rgba(74,63,86,.2); pointer-events: auto; cursor: pointer;
}

/* ---------- wheels ---------- */
.wheel {
  position: fixed; z-index: 25; right: 12px; top: 68px; display: flex; flex-wrap: wrap;
  gap: 8px; width: 232px; background: #ffffffee; border-radius: var(--radius);
  padding: 12px; box-shadow: var(--shadow);
}
.wheel button {
  font: inherit; border: none; background: var(--cream); border-radius: 12px;
  padding: 9px 10px; font-size: 15px; font-weight: 700; cursor: pointer; color: var(--ink);
}
.wheel button.emo { font-size: 26px; width: 48px; height: 48px; padding: 0; }
.wheel button:active { transform: scale(.94); }

/* ---------- dialog ---------- */
#dialog-backdrop {
  position: fixed; inset: 0; z-index: 30; background: rgba(74,63,86,.35);
  display: flex; align-items: center; justify-content: center;
}
#dialog-box {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  width: 92%; max-width: 430px; max-height: 84vh; overflow-y: auto; padding: 22px;
  animation: bounce-in .35s ease;
}
#dialog-title { font-size: 24px; font-weight: 900; color: var(--pink-deep); margin-bottom: 10px; text-align: center; }
#dialog-body { font-size: 17px; line-height: 1.45; }
#dialog-body input {
  width: 100%; font: inherit; font-size: 20px; font-weight: 800; text-align: center;
  padding: 12px; margin: 10px 0; border: 3px solid var(--sky); border-radius: 14px;
  text-transform: uppercase; color: var(--ink); background: var(--cream); outline: none;
}
#dialog-body input:focus { border-color: var(--pink-deep); }
#dialog-buttons { display: flex; gap: 10px; margin-top: 16px; }
#dialog-buttons button {
  flex: 1; font: inherit; font-size: 18px; font-weight: 800; padding: 13px; border: none;
  border-radius: 16px; cursor: pointer; background: var(--cream); color: var(--ink);
  box-shadow: 0 4px 0 rgba(74,63,86,.12);
}
#dialog-buttons button.primary { background: var(--pink-deep); color: #fff; }
#dialog-buttons button:active { transform: translateY(2px); }

.shop-row {
  display: flex; align-items: center; gap: 10px; padding: 8px; margin: 6px 0;
  background: var(--cream); border-radius: 14px;
}
.shop-row canvas { flex: none; border-radius: 10px; background: #fff; }
.shop-row .grow { flex: 1; font-weight: 800; }
.shop-row small { display: block; font-weight: 600; opacity: .6; }
.shop-row button {
  font: inherit; font-weight: 800; border: none; border-radius: 12px; padding: 9px 13px;
  background: var(--mint); cursor: pointer; color: var(--ink); box-shadow: 0 3px 0 rgba(74,63,86,.12);
}
.shop-row button:disabled { opacity: .45; cursor: default; }

/* ---------- home designer ---------- */
#home-panel {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 18;
  background: #fffffff2; border-radius: 22px 22px 0 0; box-shadow: 0 -6px 20px rgba(74,63,86,.15);
  padding: 10px 12px 14px;
}
#home-tabs { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
#home-tabs button {
  font: inherit; font-weight: 800; font-size: 14px; border: none; padding: 8px 13px;
  border-radius: 12px; background: var(--cream); cursor: pointer; color: var(--ink);
}
#home-tabs button.active { background: var(--pink-deep); color: #fff; }
#home-catalog { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.cat-item {
  flex: none; width: 86px; border: 3px solid transparent; border-radius: 14px;
  background: var(--cream); text-align: center; cursor: pointer; padding: 6px; position: relative;
}
.cat-item.sel { border-color: var(--pink-deep); }
.cat-item .cname { font-size: 11px; font-weight: 800; line-height: 1.15; }
.cat-item .ccost { font-size: 11px; font-weight: 700; color: var(--pink-deep); }

/* ---------- toasts ---------- */
#toast-holder { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 40; pointer-events: none; }
.toast {
  background: var(--ink); color: #fff; font-weight: 800; font-size: 16px; text-align: center;
  padding: 11px 22px; border-radius: 999px; margin-bottom: 8px; animation: toast-pop .3s ease;
  box-shadow: 0 6px 14px rgba(74,63,86,.3); white-space: nowrap;
}
.toast.happy { background: var(--pink-deep); }
@keyframes toast-pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

@media (max-width: 640px) {
  .studio-options { max-height: 34vh; }
  .wheel { right: 6px; width: 208px; }
}
