[hidden] { display: none !important; }
/* Adelaide Mini App — dark Telegram-friendly theme, mobile first */
:root {
  --bg: var(--tg-theme-bg-color, #17212b);
  --bg-elev: var(--tg-theme-secondary-bg-color, #232e3c);
  --text: var(--tg-theme-text-color, #f5f5f5);
  --text-dim: var(--tg-theme-hint-color, #708499);
  --accent: var(--tg-theme-button-color, #2ea6ff);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --user-bubble: #2ea6ff;
  --npc-bubble: #2a3a4d;
  --meter-bg: #1c2733;
  --meter-fill: linear-gradient(90deg, #ff7a59 0%, #ffc857 50%, #57c785 100%);
  --danger: #ff6363;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  height: 100%;
  overflow: hidden;
}

#loader {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
}

#app {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
  height: 100dvh;
}

/* ------ HUD ------ */
#hud {
  display: flex;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-elev);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  align-items: center;
}

#portrait-wrap {
  width: 64px;
  height: 64px;
  border-radius: 32px;
  overflow: hidden;
  background: #0f1822;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.1);
}

#portrait {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#hud-meta {
  flex: 1;
  min-width: 0;
}

#scene-name {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meter-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.meter-label { color: var(--text-dim); }

.meter {
  flex: 1;
  height: 6px;
  background: var(--meter-bg);
  border-radius: 3px;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  background: var(--meter-fill);
  width: 50%;
  transition: width 400ms ease;
}

.meter-value {
  font-variant-numeric: tabular-nums;
  width: 28px;
  text-align: right;
  color: var(--text-dim);
}

.emotion-tag {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 8px;
  background: rgba(46, 166, 255, 0.15);
  border-radius: 10px;
  color: var(--accent);
  font-size: 11px;
  text-transform: lowercase;
}

/* ------ Chat ------ */
#chat {
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scroll-behavior: smooth;
}

.bubble {
  max-width: 78%;
  padding: 8px 12px;
  border-radius: 16px;
  word-wrap: break-word;
  white-space: pre-wrap;
  animation: bubble-in 200ms ease;
}

@keyframes bubble-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.bubble.user {
  background: var(--user-bubble);
  color: var(--accent-text);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.bubble.npc {
  background: var(--npc-bubble);
  color: var(--text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.bubble.typing {
  font-style: italic;
  color: var(--text-dim);
}

.interest-tick {
  font-size: 10px;
  margin-top: 2px;
  color: var(--text-dim);
  align-self: flex-start;
}

.interest-tick.up { color: #57c785; }
.interest-tick.down { color: var(--danger); }

/* ------ Composer ------ */
#composer {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-elev);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

#composer-input {
  flex: 1;
  padding: 10px 14px;
  border: none;
  border-radius: 20px;
  background: #1c2733;
  color: var(--text);
  font-size: 15px;
  outline: none;
}

#composer-input:focus { background: #233040; }

#send-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 20px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 20px;
  cursor: pointer;
}

#send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ------ Banners ------ */
#advance-banner {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 70px;
  background: var(--accent);
  color: var(--accent-text);
  padding: 10px 14px;
  border-radius: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

#advance-banner button {
  background: rgba(0,0,0,0.2);
  color: var(--accent-text);
  border: none;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
}

#end-banner {
  position: absolute;
  inset: 16px;
  background: var(--bg-elev);
  border-radius: 16px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
}

#end-banner button {
  margin-top: 8px;
  padding: 10px 20px;
  border-radius: 20px;
  border: none;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 15px;
  cursor: pointer;
}
