:root {
  --bg: #fdf2f8;
  --accent: #ff5d8f;
  --ink: #3b2c3a;
  --card: #ffffff;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: radial-gradient(circle at 50% 0%, #ffe6f0, var(--bg));
  color: var(--ink);
  display: flex; flex-direction: column;
  height: 100dvh; overflow: hidden; user-select: none;
}
#hud {
  display: flex; justify-content: space-around; align-items: center;
  padding: 10px 8px; background: rgba(255,255,255,0.7);
  backdrop-filter: blur(6px); font-weight: 700;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}
.hud-item { display: flex; flex-direction: column; align-items: center; font-size: 18px; }
.hud-label { font-size: 11px; font-weight: 600; opacity: 0.6; }

#stage { position: relative; flex: 1; overflow: hidden; }

.person {
  position: absolute; top: 0; left: 0; width: 72px; height: 72px;
  cursor: pointer; will-change: transform;
}
.avatar {
  position: absolute; inset: 0; border-radius: 50%;
  background: hsl(var(--hue, 350) 75% 72%);
  box-shadow: 0 6px 14px rgba(0,0,0,0.15), inset 0 -6px 10px rgba(0,0,0,0.08);
}
.person:active .avatar { filter: brightness(1.06); }
.person[data-tier="3"] .avatar { box-shadow: 0 0 0 3px rgba(255,93,143,0.6), 0 6px 16px rgba(0,0,0,0.2); }

.face { position: absolute; inset: 0; }

/* eyes — two via ::before / ::after; data-style reshapes both */
.eyes { position: absolute; top: 34%; left: 0; right: 0; height: 14px; }
.eyes::before, .eyes::after {
  content: ""; position: absolute; top: 0; width: 10px; height: 10px;
  background: #2a2030; border-radius: 50%;
}
.eyes::before { left: 26%; }
.eyes::after { right: 26%; }
.eyes[data-style="wide"]::before, .eyes[data-style="wide"]::after { width: 13px; height: 13px; top: -1px; }
.eyes[data-style="sleepy"]::before, .eyes[data-style="sleepy"]::after { height: 3px; border-radius: 3px; top: 5px; }
.eyes[data-style="happy"]::before, .eyes[data-style="happy"]::after {
  width: 12px; height: 7px; background: transparent;
  border: 3px solid #2a2030; border-bottom: none; border-radius: 12px 12px 0 0;
}
.eyes[data-style="wink"]::before { height: 3px; border-radius: 3px; top: 5px; }
.eyes[data-style="cool"]::before, .eyes[data-style="cool"]::after { width: 14px; height: 4px; border-radius: 2px; top: 4px; transform: rotate(-8deg); }
.eyes[data-style="cool"]::before { left: 22%; }
.eyes[data-style="cool"]::after { right: 22%; }

/* mouth */
.mouth { position: absolute; left: 50%; top: 56%; transform: translateX(-50%); width: 20px; height: 10px; }
.mouth[data-style="smile"] { border-bottom: 3px solid #2a2030; border-radius: 0 0 20px 20px; }
.mouth[data-style="small"] { width: 8px; height: 7px; border-bottom: 3px solid #2a2030; border-radius: 0 0 8px 8px; }
.mouth[data-style="open"] { width: 13px; height: 13px; background: #80323f; border-radius: 50%; }
.mouth[data-style="flat"] { width: 16px; height: 0; border-bottom: 3px solid #2a2030; }
.mouth[data-style="grin"] { width: 22px; height: 11px; background: #2a2030; border-radius: 3px 3px 11px 11px; }
.mouth[data-style="cat"] { width: 18px; height: 8px; }
.mouth[data-style="cat"]::before, .mouth[data-style="cat"]::after {
  content: ""; position: absolute; top: 0; width: 9px; height: 8px;
  border: 2px solid #2a2030; border-top: none; border-radius: 0 0 9px 9px;
}
.mouth[data-style="cat"]::before { left: 0; }
.mouth[data-style="cat"]::after { right: 0; }
.person[data-tier="3"] .mouth[data-style="smile"] { height: 13px; width: 24px; }

/* head accessory */
.top { position: absolute; left: 50%; top: 0; transform: translateX(-50%); pointer-events: none; }
.top[data-style="tuft"] { width: 12px; height: 16px; top: -9px; background: #3a2e36; border-radius: 50% 50% 40% 40%; }
.top[data-style="antenna"] { width: 3px; height: 13px; top: -13px; background: #3a2e36; border-radius: 2px; }
.top[data-style="antenna"]::after { content: ""; position: absolute; top: -6px; left: 50%; transform: translateX(-50%); width: 8px; height: 8px; background: var(--accent); border-radius: 50%; }
.top[data-style="spike"] { top: -12px; width: 0; height: 0; border-left: 8px solid transparent; border-right: 8px solid transparent; border-bottom: 14px solid #3a2e36; }
.top[data-style="bow"] { top: -7px; width: 18px; height: 10px; }
.top[data-style="bow"]::before, .top[data-style="bow"]::after { content: ""; position: absolute; top: 0; width: 8px; height: 10px; background: var(--accent); border-radius: 50%; }
.top[data-style="bow"]::before { left: -1px; }
.top[data-style="bow"]::after { right: -1px; }
.top[data-style="cap"] { top: -7px; width: 30px; height: 13px; background: #3a2e36; border-radius: 13px 13px 0 0; }

.badge {
  position: absolute; bottom: -7px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
  padding: 1px 7px; border-radius: 10px; white-space: nowrap;
}
.meter {
  position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%);
  width: 64px; height: 15px; border-radius: 8px; overflow: hidden;
  background: #f2c7d6; box-shadow: 0 2px 5px rgba(0,0,0,0.12);
}
.meter-fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0%;
  background: linear-gradient(90deg, #ff85ab, var(--accent));
  transition: width 0.12s ease-out;
}
.meter-text {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 800; color: #fff; letter-spacing: 0.2px;
  text-shadow: 0 1px 1.5px rgba(0,0,0,0.35);
}
.name-label {
  position: absolute; bottom: -38px; left: 50%; transform: translateX(-50%);
  font-size: 12px; font-weight: 700; color: var(--ink);
  background: rgba(255,255,255,0.85); padding: 1px 8px; border-radius: 10px;
  white-space: nowrap; max-width: 100px; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.name-label:active { background: #fff; }

.toast {
  position: fixed; top: 56px; left: 50%; transform: translateX(-50%) translateY(-8px);
  background: rgba(59,44,58,0.92); color: #fff; font-size: 13px; font-weight: 700;
  padding: 8px 16px; border-radius: 20px; box-shadow: 0 6px 16px rgba(0,0,0,0.25);
  opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s; z-index: 30;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.heart-particle { position: absolute; font-size: 22px; pointer-events: none; animation: floatUp 0.9s ease-out forwards; }
@keyframes floatUp {
  0% { transform: translate(-50%, 0) scale(0.6); opacity: 0; }
  20% { opacity: 1; transform: translate(-50%, -10px) scale(1.1); }
  100% { transform: translate(-50%, -70px) scale(1); opacity: 0; }
}
.float-text { position: absolute; pointer-events: none; font-weight: 800; color: var(--accent); font-size: 16px; animation: floatText 0.8s ease-out forwards; }
@keyframes floatText {
  0% { opacity: 0; transform: translate(-50%, 0); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -48px); }
}
.levelup-ring {
  position: absolute; left: 50%; top: 50%; width: 72px; height: 72px;
  border: 3px solid var(--accent); border-radius: 50%; pointer-events: none;
  transform: translate(-50%, -50%); animation: ring 0.6s ease-out forwards;
}
@keyframes ring {
  0% { opacity: 0.9; transform: translate(-50%,-50%) scale(0.6); }
  100% { opacity: 0; transform: translate(-50%,-50%) scale(2.2); }
}

#shop {
  display: flex; gap: 8px; padding: 10px; background: rgba(255,255,255,0.8);
  backdrop-filter: blur(6px); border-top: 1px solid rgba(0,0,0,0.05);
}
.shop-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 6px; border: none; border-radius: 14px; background: var(--card);
  box-shadow: 0 3px 8px rgba(0,0,0,0.1); font-weight: 700; color: var(--ink);
  cursor: pointer; transition: transform 0.1s, opacity 0.2s;
}
.shop-btn:active { transform: translateY(2px); }
.shop-btn:disabled { opacity: 0.4; cursor: default; }
.shop-title { font-size: 13px; }
.shop-cost { font-size: 15px; color: var(--accent); }
.shop-cost::before { content: "♥ "; }

#offline-popup {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center; z-index: 10;
}
#offline-popup.hidden { display: none; }
.popup-card { background: #fff; padding: 24px 28px; border-radius: 18px; text-align: center; box-shadow: 0 12px 30px rgba(0,0,0,0.25); }
.popup-card strong { color: var(--accent); font-size: 20px; }
.popup-card button { margin-top: 12px; padding: 10px 24px; border: none; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 700; font-size: 15px; cursor: pointer; }

#profile-panel { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 20; }
#profile-panel.hidden { display: none; }
.profile-card { position: relative; background: #fff; width: 280px; max-width: 86vw; padding: 22px 22px 20px; border-radius: 20px; box-shadow: 0 14px 36px rgba(0,0,0,0.3); text-align: center; }
.profile-close { position: absolute; top: 6px; right: 10px; border: none; background: none; font-size: 24px; line-height: 1; color: #bbb; cursor: pointer; }
.profile-avatar { position: relative; width: 96px; height: 96px; margin: 8px auto 14px; }
.profile-name { width: 82%; text-align: center; font-size: 18px; font-weight: 700; color: var(--ink); border: none; border-bottom: 2px solid #f0c3d4; padding: 4px 2px; outline: none; background: transparent; }
.profile-name:focus { border-bottom-color: var(--accent); }
.profile-kizuna { margin: 12px 0 14px; font-weight: 700; color: var(--ink); }
.profile-kizuna #profile-aff { color: var(--accent); }
.editor { display: flex; flex-direction: column; gap: 8px; }
.editor-row { display: flex; align-items: center; justify-content: space-between; background: #fdeef4; border-radius: 12px; padding: 6px 10px; }
.ed-name { font-weight: 700; font-size: 14px; color: var(--ink); }
.ed-prev, .ed-next { border: none; background: var(--accent); color: #fff; width: 32px; height: 32px; border-radius: 9px; font-size: 13px; cursor: pointer; }
.ed-prev:active, .ed-next:active { transform: translateY(1px); }

.profile-story-wrap { margin-top: 16px; text-align: left; }
.profile-story-title { font-size: 12px; font-weight: 700; color: var(--accent); opacity: 0.85; margin-bottom: 6px; }
.profile-story { max-height: 120px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.story-line { font-size: 12px; line-height: 1.45; color: var(--ink); background: #faf3f6; border-radius: 8px; padding: 6px 8px; }
.story-empty { font-size: 12px; color: #b9b9b9; text-align: center; margin: 6px 0; }

/* floating speech bubble above a person */
.speech-bubble {
  position: absolute; left: 50%; bottom: 80px; transform: translateX(-50%);
  width: max-content; max-width: 156px; padding: 7px 10px;
  background: #fff; color: var(--ink); font-size: 11px; font-weight: 600; line-height: 1.35;
  border-radius: 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.18); text-align: center;
  pointer-events: none; z-index: 5;
  animation: bubbleIn 0.25s ease-out, bubbleOut 0.4s ease-in 3.6s forwards;
}
.speech-bubble::after {
  content: ""; position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%);
  border-left: 6px solid transparent; border-right: 6px solid transparent; border-top: 7px solid #fff;
}
.speech-bubble.event { background: #fff0f6; border: 2px solid var(--accent); font-weight: 700; }
.speech-bubble.event::after { border-top-color: var(--accent); bottom: -8px; }
@keyframes bubbleIn { from { opacity: 0; transform: translateX(-50%) translateY(6px) scale(0.92); } to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); } }
@keyframes bubbleOut { from { opacity: 1; } to { opacity: 0; } }

/* rewarded-ad boost button (top-right) */
.reward-btn {
  position: fixed; top: 60px; right: 10px; z-index: 8;
  border: none; border-radius: 16px; padding: 7px 12px;
  background: #fff; color: var(--accent); font-weight: 800; font-size: 12px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.15); cursor: pointer;
}
.reward-btn:active { transform: translateY(1px); }
.reward-btn.active { background: var(--accent); color: #fff; }

/* lift the shop above an AdMob banner on native */
body.has-banner #shop { margin-bottom: 60px; }
