* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #f9dcc0;
  font-family: 'Jua', system-ui, sans-serif;
  color: #4a2c1a;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#stage { position: fixed; inset: 0; width: 100vw; height: 100vh; touch-action: none; display: block; }
button { font: inherit; color: inherit; cursor: pointer; }

#hud { position: fixed; top: 14px; left: 14px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.card {
  background: rgba(255, 252, 247, 0.88); backdrop-filter: blur(6px);
  border: 3px solid #4a2c1a; border-radius: 18px; padding: 10px 14px 12px;
  box-shadow: 0 4px 0 #4a2c1a; width: 230px;
}
.title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
#catName { background: none; border: none; padding: 0; font-size: 22px; }
#catName:hover { text-decoration: underline wavy #f7a94e; }
#moodLabel { font-size: 14px; opacity: 0.8; white-space: nowrap; }
.bar { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 14px; }
.bar label { width: 30px; }
.track { flex: 1; height: 12px; background: #f1e1d1; border-radius: 99px; overflow: hidden; border: 2px solid #4a2c1a; }
.fill { height: 100%; width: 50%; border-radius: 99px; transition: width 0.25s; }
.fill.happy { background: linear-gradient(90deg, #ff8fb1, #ff5c8a); }
.fill.energy { background: linear-gradient(90deg, #9be564, #3cc47c); }
.fill.anger { background: linear-gradient(90deg, #ffb35c, #e23b3b); }

#achBtn {
  background: #fff6d6; border: 3px solid #4a2c1a; border-radius: 99px; padding: 4px 12px;
  box-shadow: 0 3px 0 #4a2c1a; font-size: 15px;
}
#achPanel { display: none; background: rgba(255, 252, 247, 0.95); border: 3px solid #4a2c1a; border-radius: 16px; padding: 8px; max-height: 50vh; overflow: auto; width: 260px; }
#achPanel.open { display: block; }
#achList { list-style: none; margin: 0; padding: 0; }
#achList li { display: flex; gap: 10px; align-items: center; padding: 6px; opacity: 0.5; }
#achList li.on { opacity: 1; }
#achList span { font-size: 22px; }
#achList small { display: block; font-size: 12px; opacity: 0.75; }

#toolbar {
  position: fixed; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; gap: 10px; padding: 8px; border-radius: 22px;
  background: rgba(255, 252, 247, 0.9); border: 3px solid #4a2c1a; box-shadow: 0 4px 0 #4a2c1a;
}
#toolbar button {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 60px; height: 56px; font-size: 24px; line-height: 1;
  background: #fff; border: 2px solid #4a2c1a; border-radius: 14px; box-shadow: 0 3px 0 #4a2c1a;
  transition: transform 0.08s;
}
#toolbar button small { font-size: 12px; margin-top: 4px; }
#toolbar button:active { transform: translateY(3px); box-shadow: 0 0 0 #4a2c1a; }
#toolbar button.on { background: #ffe0e8; }
#btnSound { min-width: 48px !important; }

#hint {
  position: fixed; top: 22%; left: 50%; transform: translateX(-50%);
  background: rgba(74, 44, 26, 0.88); color: #fff; padding: 14px 20px; border-radius: 18px;
  display: flex; flex-direction: column; gap: 6px; text-align: center; font-size: 16px;
  transition: opacity 0.6s; pointer-events: none; width: max-content; max-width: calc(100vw - 32px);
}
#hint b { font-size: 20px; color: #ffd27a; }
#hint.hidden { opacity: 0; }

#toasts { position: fixed; top: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast {
  background: #fff; border: 3px solid #4a2c1a; border-radius: 14px; padding: 8px 14px; box-shadow: 0 3px 0 #4a2c1a;
  animation: pop 0.35s cubic-bezier(.2, 1.6, .4, 1); transition: opacity 0.5s, transform 0.5s;
}
.toast.gold { background: #fff3c4; }
.toast.out { opacity: 0; transform: translateY(-10px); }
@keyframes pop { from { transform: scale(0.5); opacity: 0; } }

@media (max-width: 600px) {
  #hud { top: 10px; left: 10px; }
  .card { width: 190px; padding: 8px 10px 10px; }
  #catName { font-size: 18px; }
  #moodLabel { font-size: 12px; }
  #toolbar button { min-width: 54px; height: 50px; font-size: 21px; }
  #toasts { top: auto; bottom: 90px; right: 50%; transform: translateX(50%); align-items: center; }
  #hint { top: 30%; font-size: 14px; }
}
