/* Mêlée Island v2 — pixel-art point-and-click */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: Georgia, "Times New Roman", serif;
  background: #100c18;
  color: #f3ede0;
  display: flex; flex-direction: column;
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
}

/* ── top objective bar ─────────────────────────────────────────── */
#topbar {
  display: flex; align-items: center; gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  background: linear-gradient(#241b33, #1a1426);
  border-bottom: 2px solid #3a2c55;
  z-index: 30;
}
#objective { flex: 1; font-size: 14.5px; line-height: 1.35; color: #ffd27f; font-style: italic; }
#objective .star { color: #ffcf7f; font-style: normal; margin-right: 4px; }
#objective.pulse { animation: objPulse 1s ease 2; }
@keyframes objPulse {
  0%, 100% { text-shadow: none; }
  50% { text-shadow: 0 0 14px #ffcf7f; color: #fff3c9; }
}
#hintbtn, #gear {
  background: none; border: 1.5px solid #3a2c55; border-radius: 10px;
  color: #b8a8d8; font-size: 17px; cursor: pointer; padding: 4px 10px;
  font-family: inherit;
}
#netdot { width: 9px; height: 9px; border-radius: 50%; background: #888; flex-shrink: 0; }
#netdot.on  { background: #7fd97f; box-shadow: 0 0 6px #7fd97f; }
#netdot.off { background: #d9707f; }

/* ── stage + scene ─────────────────────────────────────────────── */
#stage-wrap {
  flex: 1; display: flex; align-items: center; justify-content: center;
  background: #08060e; position: relative; overflow: hidden;
}
#stage {
  position: relative;
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
#stage.pan { justify-content: flex-start; }
#scene {
  position: relative;
  flex: 0 0 auto;
  background-size: contain; background-repeat: no-repeat; background-position: center;
  image-rendering: pixelated;
  overflow: hidden;
}
#scene svg { position: absolute; inset: 0; width: 100%; height: 100%; }

#scene-title {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  font-size: 12px; letter-spacing: 2.5px; color: #f3ede0aa;
  text-transform: uppercase; pointer-events: none; z-index: 8;
  text-shadow: 0 1px 4px #000;
}

/* ── hotspots ──────────────────────────────────────────────────── */
.hotspot {
  position: absolute; z-index: 9; cursor: pointer;
  border-radius: 10px;
}
.hotspot .hs-label {
  position: absolute; left: 50%; bottom: 100%;
  transform: translate(-50%, -2px);
  background: rgba(16, 11, 26, .85); color: #ffd27f;
  font-size: 11.5px; padding: 3px 9px; border-radius: 8px;
  white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity .15s;
}
.hotspot:hover .hs-label, .hotspot:active .hs-label { opacity: 1; }
.hotspot:active { background: rgba(255, 210, 127, .12); }
.hotspot.quest {
  border: none;
  background: radial-gradient(ellipse at 50% 85%, rgba(255,210,127,.28), transparent 60%);
  animation: none;
}
.hotspot.quest .hs-label { opacity: 1; }
@keyframes questGlow {
  0%, 100% { box-shadow: 0 0 4px 1px #ffd27f44; }
  50%      { box-shadow: 0 0 18px 5px #ffd27f88; }
}

/* ── sprites ───────────────────────────────────────────────────── */
.sprite {
  position: absolute; transform: translate(-50%, -100%);
  z-index: 10; pointer-events: none;
  filter: drop-shadow(0 5px 4px rgba(0,0,0,.5));
}
.sprite img {
  height: 100%; width: auto; display: block;
  image-rendering: pixelated;
}
#player.walking img { animation: walkBob .32s ease-in-out infinite; }
@keyframes walkBob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-4%); } }
#player.flip img { transform: scaleX(-1); }
#player.flip.walking img { animation: walkBobFlip .32s ease-in-out infinite; }
@keyframes walkBobFlip {
  0%, 100% { transform: scaleX(-1) translateY(0); }
  50%      { transform: scaleX(-1) translateY(-4%); }
}

/* chandelier + swinging pirate */
#chandelier {
  position: absolute; left: 41%; top: -1%;
  width: 18%; aspect-ratio: 200 / 190;
  z-index: 7; cursor: pointer;
}
#chandelier .swinger {
  transform-origin: 100px 34px;
  animation: swing 2.6s ease-in-out infinite;
}
@keyframes swing {
  0%, 100% { transform: rotate(-7deg); }
  50%      { transform: rotate(7deg); }
}

/* exits */
.exit {
  position: absolute; top: 50%; transform: translateY(-50%);
  z-index: 25; cursor: pointer; border: none;
  background: rgba(20, 14, 34, .55); color: #ffd27f;
  font-size: 30px; padding: 18px 10px; border-radius: 12px;
  backdrop-filter: blur(2px);
  animation: exitNudge 2.2s ease-in-out infinite;
}
.exit:active { background: rgba(60, 44, 90, .8); }
.exit.left  { left: 6px; }
.exit.right { right: 6px; }
@keyframes exitNudge { 0%,100% { opacity: .6; } 50% { opacity: 1; } }

#walkmark {
  position: absolute; width: 26px; height: 10px; z-index: 6;
  border: 2px solid #ffd27f; border-radius: 50%;
  transform: translate(-50%, -50%); opacity: 0; pointer-events: none;
}
#walkmark.ping { animation: ping .5s ease-out; }
@keyframes ping { 0% { opacity: .9; scale: .6; } 100% { opacity: 0; scale: 1.4; } }

/* ── verb bar ──────────────────────────────────────────────────── */
#verbbar {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  display: none; gap: 8px; align-items: center;
  background: rgba(20, 14, 34, .95); border: 1.5px solid #4a3a6a;
  padding: 8px 12px; border-radius: 16px; z-index: 28;
  max-width: 94%;
  backdrop-filter: blur(4px);
}
#verbbar.show { display: flex; animation: verbUp .18s ease; }
@keyframes verbUp { from { opacity: 0; translate: 0 14px; } to { opacity: 1; translate: 0 0; } }
#verbtarget {
  font-size: 12px; color: #b8a8d8; font-style: italic;
  padding-right: 6px; border-right: 1px solid #4a3a6a;
  white-space: nowrap; max-width: 130px; overflow: hidden; text-overflow: ellipsis;
}
.verb {
  border: none; cursor: pointer; white-space: nowrap;
  background: linear-gradient(#3a2c55, #2c2140); color: #ffd27f;
  font-family: inherit; font-size: 14px; padding: 9px 14px; border-radius: 11px;
}
.verb:active { background: linear-gradient(#ffd27f, #e8a94a); color: #3a2412; }

/* ── dialogue ──────────────────────────────────────────────────── */
#dialogue {
  position: relative; min-height: 106px;
  background: linear-gradient(#241b33, #191322);
  border-top: 2px solid #3a2c55;
  padding: 12px 16px max(12px, env(safe-area-inset-bottom));
  z-index: 30; cursor: pointer;
  display: grid; grid-template-columns: auto 1fr; gap: 0 12px;
  align-items: start;
}
#dportrait {
  grid-row: 1 / span 2; width: 0; height: 0; border-radius: 12px;
  object-fit: cover; border: 2px solid #4a3a6a; display: block;
  transition: width .15s, height .15s;
}
#dportrait.show { width: 64px; height: 64px; }
#speaker { font-size: 13px; letter-spacing: 1.5px; text-transform: uppercase; margin-bottom: 6px; grid-column: 2; }
#dtext { font-size: 16.5px; line-height: 1.45; color: #f3ede0; min-height: 44px; grid-column: 2; }
#dhint {
  position: absolute; right: 14px; bottom: max(8px, env(safe-area-inset-bottom));
  font-size: 11px; color: #b8a8d877; letter-spacing: 1px;
}
#dialogue.idle #dtext { color: #b8a8d8; font-style: italic; font-size: 14.5px; }

.sp-guybrush    { color: #7fb8ff; } .sp-sheriff  { color: #d9a05f; }
.sp-voodoo_lady { color: #c48fff; } .sp-stan     { color: #7fd9c9; }
.sp-narrator    { color: #b8a8d8; }

/* ── overlays ──────────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(10, 7, 18, .82);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.overlay.hidden { display: none; }
.panel {
  background: #241b33; border: 2px solid #4a3a6a; border-radius: 18px;
  padding: 26px 22px; max-width: 420px; width: 100%;
  box-shadow: 0 18px 60px rgba(0,0,0,.6);
  text-align: center;
}
.panel h2 { color: #ffd27f; margin-bottom: 14px; font-size: 21px; }
.panel p  { font-size: 14.5px; line-height: 1.5; color: #d8cce8; margin-bottom: 12px; }
.panel input {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid #4a3a6a; background: #14101f; color: #f3ede0;
  font-size: 14px; margin-bottom: 12px; font-family: monospace;
}
.btn {
  display: inline-block; border: none; cursor: pointer;
  background: linear-gradient(#ffd27f, #e8a94a); color: #3a2412;
  font-family: inherit; font-weight: bold; font-size: 15px;
  padding: 11px 22px; border-radius: 12px; margin: 4px 6px;
}
.btn.ghost { background: none; border: 1.5px solid #4a3a6a; color: #b8a8d8; }
.small { font-size: 12px; color: #8a7aa8; }

#win .panel { background: linear-gradient(#2e2340, #241b33); border-color: #ffd27f; }
#win h1 { font-size: 26px; color: #ffd27f; margin-bottom: 8px; text-shadow: 0 0 24px #ffcf7f66; }
#map-art { width: 200px; margin: 10px auto; display: block; }

@media (min-width: 700px) and (min-height: 500px) {
  #objective { font-size: 16px; }
  #dtext { font-size: 18px; }
}

/* rotate suggestion — portrait phones only */
#rotatehint { display: none !important; }

/* ── UNIVERSAL overlay chrome: the scene owns the whole screen, UI floats ── */
#topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 35;
  background: linear-gradient(rgba(20,14,34,.92), rgba(20,14,34,.55) 75%, transparent);
  border-bottom: none;
  padding-top: max(6px, env(safe-area-inset-top));
}
#dialogue {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 35;
  background: linear-gradient(transparent, rgba(20,14,34,.82) 30%, rgba(16,11,26,.95));
  border-top: none;
  min-height: 72px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}
#dialogue.idle { background: linear-gradient(transparent, rgba(20,14,34,.55)); }
#dialogue.idle #dtext { font-size: 12.5px; min-height: 0; }
#verbbar { bottom: 96px; }
#stage-wrap { position: absolute; inset: 0; }
body { position: relative; }

/* ── persuasion input ─────────────────────────────────────────── */
#persuade-row {
  display: none; gap: 8px; align-items: center;
  padding: 10px 14px; background: #1d1530;
  border-top: 2px solid #ffd27f66; z-index: 31;
}
#persuade-row.show { display: flex; }
#persuade-input {
  flex: 1; padding: 11px 14px; border-radius: 12px;
  border: 1.5px solid #4a3a6a; background: #14101f; color: #f3ede0;
  font-family: inherit; font-size: 15px;
}
#persuade-input:focus { outline: none; border-color: #ffd27f; }
#persuade-send {
  border: none; cursor: pointer; font-size: 19px;
  background: linear-gradient(#ffd27f, #e8a94a); color: #3a2412;
  padding: 10px 16px; border-radius: 12px;
}
#fsbtn {
  background: none; border: 1.5px solid #3a2c55; border-radius: 10px;
  color: #b8a8d8; font-size: 17px; cursor: pointer; padding: 4px 10px;
  font-family: inherit;
}
@media (orientation: landscape) and (max-height: 560px) {
  #persuade-row { position: absolute; bottom: 0; left: 0; right: 0; z-index: 36; }
}

/* NPC standing sprites — alive at their spots */
.npc-sprite {
  position: absolute; transform: translate(-50%, -100%);
  z-index: 10; cursor: pointer;
  display: flex; flex-direction: column; align-items: center;
  filter: drop-shadow(0 5px 4px rgba(0,0,0,.5));
}
.npc-sprite img {
  height: 100%; width: auto;
  image-rendering: pixelated;
  animation: npcIdle 3.2s ease-in-out infinite;
  transform-origin: bottom center;
}
.npc-sprite span { display: none; }
.npc-sprite:active img { filter: brightness(1.25); }
@keyframes npcIdle {
  0%, 100% { transform: rotate(-1.4deg) translateY(0); }
  50%      { transform: rotate(1.4deg) translateY(-2px); }
}

/* bag & map buttons */
#bagbtn, #mapbtn {
  background: none; border: 1.5px solid #3a2c55; border-radius: 10px;
  color: #b8a8d8; font-size: 16px; cursor: pointer; padding: 4px 9px;
  position: relative; font-family: inherit;
}
#bagbtn[data-count]:not([data-count=""])::after {
  content: attr(data-count);
  position: absolute; top: -7px; right: -7px;
  background: #e8a94a; color: #3a2412; font-size: 10px; font-weight: bold;
  min-width: 16px; height: 16px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
#baggrid { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 12px 0; }
.bagitem {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: #14101f; border: 1.5px solid #4a3a6a; border-radius: 14px;
  color: #d8cce8; padding: 12px 14px; cursor: pointer; font-family: inherit;
  font-size: 11.5px; min-width: 86px;
}
.bagitem:active { border-color: #ffd27f; }
.bi-emoji { font-size: 30px; }

/* island map */
.map-panel { max-width: 560px; }
#mapwrap { position: relative; border-radius: 12px; overflow: hidden; margin: 6px 0 12px; }
#mapwrap img { width: 100%; display: block; image-rendering: pixelated; }
.mappin {
  position: absolute; transform: translate(-50%, -50%);
  background: rgba(16,11,26,.82); border: 1.5px solid #ffd27f;
  border-radius: 12px; color: #ffd27f; cursor: pointer;
  font-size: 17px; padding: 6px 10px; font-family: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  animation: exitNudge 2.4s ease-in-out infinite;
}
.mappin span { font-size: 10px; }
.mappin:active { background: #ffd27f; color: #3a2412; }

/* toast */
.toast {
  position: fixed; top: 14%; left: 50%; transform: translateX(-50%) translateY(-12px);
  background: #2c2140; border: 1.5px solid #ffd27f; color: #ffd27f;
  padding: 10px 18px; border-radius: 14px; font-size: 15px; z-index: 60;
  opacity: 0; transition: all .3s ease; pointer-events: none;
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* context echo above the chat input */
#persuade-row { flex-direction: column; align-items: stretch; }
#prow-inner { display: flex; gap: 8px; align-items: center; }
#ctxline {
  font-size: 13px; color: #b8a8d8; font-style: italic;
  padding: 0 2px 7px; line-height: 1.35;
  max-height: 3.6em; overflow-y: auto;
}
#ctxline:empty { display: none; }
#logbtn {
  background: none; border: 1.5px solid #3a2c55; border-radius: 10px;
  color: #b8a8d8; font-size: 16px; cursor: pointer; padding: 4px 9px;
  font-family: inherit;
}
#loglist {
  max-height: 46vh; overflow-y: auto; text-align: left;
  display: flex; flex-direction: column; gap: 8px; margin: 10px 0 14px;
}
.logline {
  background: #14101f; border-radius: 10px; padding: 8px 11px;
  font-size: 13.5px; line-height: 1.4; color: #d8cce8;
}
.logline b { color: #ffd27f; margin-right: 6px; }
.logline.me { background: #2c2140; }
.logline.me b { color: #7fb8ff; }

/* ── title screen ─────────────────────────────────────────────── */
#title { background: radial-gradient(ellipse at 50% 30%, #2e2340 0%, #14101f 70%); z-index: 70; }
.title-inner { text-align: center; padding: 30px; }
.title-logo {
  font-size: clamp(44px, 11vw, 92px); line-height: .95; font-weight: bold;
  color: #ffd27f; letter-spacing: 4px;
  text-shadow: 0 4px 0 #8a5a33, 0 10px 40px #e8a94a55;
  margin-bottom: 10px;
}
.title-sub {
  color: #b8a8d8; font-style: italic; letter-spacing: 2px;
  margin-bottom: 30px; font-size: 15px;
}
#title .btn { display: block; margin: 10px auto; min-width: 210px; font-size: 17px; }
#title .small { margin-top: 26px; line-height: 1.6; }

/* ── suggestion chips ─────────────────────────────────────────── */
#chips { display: flex; flex-wrap: wrap; gap: 7px; padding-bottom: 7px; }
#chips:empty { display: none; }
.chip {
  border: 1.5px solid #4a3a6a; background: #221a38; color: #d8cce8;
  border-radius: 999px; padding: 8px 14px; font-family: inherit;
  font-size: 13.5px; cursor: pointer; max-width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip:active { background: #ffd27f; color: #3a2412; border-color: #ffd27f; }

/* ── duel ─────────────────────────────────────────────────────── */
.duel-panel { max-width: 480px; }
#duel-score { color: #ffd27f; font-size: 15px; letter-spacing: 1px; margin-bottom: 12px; }
.duel-insult {
  font-size: 17px; font-style: italic; color: #f3ede0;
  min-height: 58px; line-height: 1.45; margin-bottom: 12px;
}
#duel-opts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
#duel-opts .chip { white-space: normal; text-align: left; }
#prow-duel { display: flex; gap: 8px; margin-bottom: 10px; }
#prow-duel input {
  flex: 1; padding: 10px 12px; border-radius: 10px;
  border: 1.5px solid #4a3a6a; background: #14101f; color: #f3ede0;
  font-family: inherit; font-size: 14px;
}
#prow-duel button {
  border: none; cursor: pointer; font-size: 17px;
  background: linear-gradient(#ffd27f, #e8a94a); color: #3a2412;
  padding: 8px 14px; border-radius: 10px;
}

/* scenery sprites + gentle pacing */
.npc-sprite.static img { animation: npcIdle 4s ease-in-out infinite; }
.npc-sprite.wander { animation: npcWander 9s ease-in-out infinite; }
@keyframes npcWander {
  0%, 100% { margin-left: 0; }
  25% { margin-left: -1.6%; }
  60% { margin-left: 1.6%; }
}

/* monkey hop + haunted flicker */
.npc-sprite.hop img { animation: monkeyHop 3.6s ease-in-out infinite; }
@keyframes monkeyHop {
  0%, 78%, 100% { transform: translateY(0); }
  84% { transform: translateY(-14%) rotate(-3deg); }
  90% { transform: translateY(0); }
}
.npc-sprite.flicker img {
  animation: hauntFlicker 7s ease-in-out infinite;
  border-radius: 4px;
}
@keyframes hauntFlicker {
  0%, 88%, 100% { filter: brightness(1); }
  92% { filter: brightness(1.5) hue-rotate(15deg); }
  95% { filter: brightness(0.9); }
  97% { filter: brightness(1.4); }
}

/* doorway busts: no wandering, just a gentle lean */
.npc-sprite.bust { animation: none; }
.npc-sprite.bust img { animation: bustLean 4.5s ease-in-out infinite; }
@keyframes bustLean {
  0%, 100% { transform: rotate(-1deg) translateY(0); }
  50%      { transform: rotate(1.2deg) translateY(-1.5%); }
}

#verbadge {
  color: #4a3a6a; font-size: 10px; align-self: center;
  letter-spacing: 1px; user-select: none;
}

/* ── portrait: objective on its own full-width line, buttons row below ── */
@media (orientation: portrait) {
  #topbar { flex-wrap: wrap; row-gap: 6px; padding: 8px 10px; }
  #objective {
    flex: 1 1 calc(100% - 26px);       /* full row next to the net dot */
    font-size: 13.5px; line-height: 1.3;
    display: -webkit-box; -webkit-line-clamp: 2;
    -webkit-box-orient: vertical; overflow: hidden;
  }
  #verbadge { margin-left: auto; }
}

/* conversation thread above the current line */
#thread { max-height: 76px; overflow-y: auto; margin-bottom: 6px; }
#thread:empty { display: none; }
.thread-line {
  font-size: 12.5px; color: #9b8cbb; line-height: 1.4; padding: 1px 0;
}
.thread-line b { color: #c9b78a; margin-right: 5px; font-weight: 600; }

/* legend ballad */
#legendtext {
  white-space: pre-wrap; text-align: left; font-style: italic;
  color: #f3ede0; line-height: 1.7; font-size: 15.5px;
  max-height: 46vh; overflow-y: auto; margin: 12px 0;
  padding: 14px 16px; background: #14101f; border-radius: 12px;
  border: 1.5px solid #4a3a6a;
}

/* conversation mode: the dialogue becomes a readable chat */
#dialogue.convo #thread { max-height: 34vh; }
.thread-line.me b { color: #7fb8ff; }
@media (orientation: landscape) and (max-height: 560px) {
  #dialogue.convo #thread { max-height: 22vh; }
}

/* offer chip — the gold handshake */
.chip.offer {
  border-color: #ffd27f; color: #ffd27f; background: #2c2140;
  font-weight: 600;
}
.chip.offer:active { background: #ffd27f; color: #3a2412; }
.logline.notes { background: #2c2140; border: 1px solid #ffd27f55; }

/* voyage plan */
#plansteps { text-align: left; margin: 10px 0 14px; }
.plan-act {
  color: #ffd27f; font-size: 12px; letter-spacing: 2px; margin: 12px 0 5px;
  border-bottom: 1px solid #3a2c55; padding-bottom: 3px;
}
.plan-step { font-size: 14.5px; line-height: 1.55; color: #d8cce8; padding: 2px 0; }
.plan-hint { margin-top: 12px; color: #ffd27f; font-style: italic; font-size: 13.5px; }

/* ═══ dialogue screen — classic adventure, not a chat app ═══ */
#convo {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 46;
  max-height: 72vh;
  display: flex; flex-direction: column;
  background: rgba(20, 14, 32, .88);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-top: 2px solid #ffd27f88;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -12px 40px rgba(0,0,0,.55);
}
#convo.hidden { display: none; }
#dlg-stage {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 14px 16px 10px;
}
#convo-portrait {
  width: 88px; height: 88px; object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,.5));
  flex: 0 0 auto;
}
#convo-portrait[src=""] { display: none; }
#dlg-main { flex: 1; min-width: 0; }
#convo-name {
  color: #ffd27f; font-size: 15px; font-weight: 700;
  letter-spacing: .5px; margin-bottom: 4px;
}
#dlg-said {
  color: #9fc3ff; font-size: 13px; font-style: italic;
  margin-bottom: 4px; opacity: .85;
}
#dlg-said:empty { display: none; }
#dlg-line {
  color: #f3ede0; font-size: 16.5px; line-height: 1.5;
  min-height: 44px; max-height: 26vh; overflow-y: auto;
}
#dlg-line .dots i {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: #b8a8d8; margin-right: 4px;
  animation: typebounce 1.2s ease-in-out infinite;
}
#dlg-line .dots i:nth-child(2) { animation-delay: .18s; }
#dlg-line .dots i:nth-child(3) { animation-delay: .36s; }
@keyframes typebounce {
  0%, 70%, 100% { transform: translateY(0); opacity: .5; }
  35% { transform: translateY(-6px); opacity: 1; }
}
#convo.waiting #convo-portrait { animation: portraitPulse 1.4s ease-in-out infinite; }
@keyframes portraitPulse {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.07); filter: brightness(1.2); }
}
#convo-close {
  background: none; border: 1.5px solid #3a2c55; border-radius: 10px;
  color: #b8a8d8; font-size: 15px; cursor: pointer; padding: 4px 11px;
  flex: 0 0 auto;
}
/* the dialogue options list — the heart of the classic look */
#dlg-options {
  display: flex; flex-direction: column;
  border-top: 1px solid #3a2c55;
  padding: 6px 8px calc(10px + env(safe-area-inset-bottom));
  overflow-y: auto;
}
.dlg-opt {
  text-align: left; background: none; border: none; cursor: pointer;
  color: #d8cce8; font-family: inherit; font-size: 15px; line-height: 1.45;
  padding: 9px 10px; border-radius: 10px;
}
.dlg-opt::before { content: "▸ "; color: #ffd27f; }
.dlg-opt:active, .dlg-opt:hover { background: #2c2140; color: #ffe9b8; }
.dlg-opt.gold { color: #ffd27f; font-weight: 600; }
.dlg-opt.meta { color: #9b8cbb; font-size: 14px; }
#convo-inputrow {
  display: flex; gap: 8px;
  padding: 8px 14px calc(10px + env(safe-area-inset-bottom));
}
#convo-inputrow.hidden { display: none; }
#convo-input {
  flex: 1; padding: 11px 14px; border-radius: 12px;
  border: 1.5px solid #4a3a6a; background: #14101f; color: #f3ede0;
  font-family: inherit; font-size: 15px;
}
#convo-input:focus { outline: none; border-color: #ffd27f; }
#convo-send {
  border: none; cursor: pointer; font-size: 19px;
  background: linear-gradient(#ffd27f, #e8a94a); color: #3a2412;
  padding: 10px 16px; border-radius: 12px;
}
/* the old fragmented pieces stay retired */
#persuade-row { display: none !important; }


/* ── hotspot glints: the world invites your finger ─────────────── */
.hotspot::after {
  content: "✦";
  position: absolute; top: 12%; right: 14%;
  color: #ffe9a8; font-size: 15px;
  opacity: 0; pointer-events: none;
  text-shadow: 0 0 6px #ffd27f;
  animation: glint 9s ease-in-out infinite;
}
.hotspot:nth-child(odd)::after  { animation-delay: 2.5s; }
.hotspot:nth-child(3n)::after   { animation-delay: 5s; top: 60%; right: 60%; }
.hotspot:nth-child(5n)::after   { animation-delay: 7s; }
@keyframes glint {
  0%, 88%, 100% { opacity: 0; transform: scale(.4) rotate(0deg); }
  91% { opacity: .95; transform: scale(1.15) rotate(40deg); }
  94% { opacity: .4; transform: scale(.7) rotate(80deg); }
}
.hotspot.quest::after { content: "★"; animation-duration: 4s; opacity: 0; }

/* ── living wait: typing dots + pulsing portrait ───────────────── */
.msg.thinking { display: flex; gap: 5px; align-items: center; padding: 12px 14px; }
.msg.thinking i {
  width: 8px; height: 8px; border-radius: 50%;
  background: #b8a8d8; display: block;
  animation: typebounce 1.2s ease-in-out infinite;
}
.msg.thinking i:nth-child(2) { animation-delay: .18s; }
.msg.thinking i:nth-child(3) { animation-delay: .36s; }
@keyframes typebounce {
  0%, 70%, 100% { transform: translateY(0); opacity: .5; }
  35% { transform: translateY(-6px); opacity: 1; }
}
#convo.waiting #convo-portrait { animation: portraitPulse 1.4s ease-in-out infinite; }
@keyframes portraitPulse {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.09); filter: brightness(1.25); }
}

/* letterbox bands become a stage frame, never raw black */
#stage-wrap {
  background:
    radial-gradient(ellipse at 50% 45%, rgba(70,50,100,.25), transparent 65%),
    linear-gradient(#171224, #0d0a16 45%, #171224);
}
#scene { box-shadow: 0 0 60px rgba(0,0,0,.65); }

/* Island Jobs: fresh-job button + job step accent */
#btn-newjob {
  display: block; width: 100%; margin: 12px 0 0;
  background: #2c2140; border: 1.5px solid #ffd27f; color: #ffd27f;
  font-family: inherit; font-weight: 600; font-size: 13.5px;
  padding: 10px 16px; border-radius: 12px; cursor: pointer;
}
#btn-newjob:active   { background: #ffd27f; color: #3a2412; }
#btn-newjob:disabled { opacity: .55; cursor: default; }
.plan-step.job {
  border-left: 2px solid #ffd27f88; padding-left: 9px; margin: 4px 0;
}


.npc-sprite.full img { animation: npcIdle 3.6s ease-in-out infinite; }
.npc-sprite.full span { bottom: -16px; }

/* iris wipe — the classic scene transition */
#iris {
  position: fixed; inset: 0; z-index: 60; pointer-events: none;
  background: #0d0a16;
  clip-path: circle(130% at 50% 50%);
  -webkit-clip-path: circle(130% at 50% 50%);
  clip-path: circle(0% at 50% 50%);
  transition: clip-path .42s ease-in, -webkit-clip-path .42s ease-in;
}
#iris.close { clip-path: circle(130% at 50% 50%); -webkit-clip-path: circle(130% at 50% 50%); }

/* emotes over the player */
.emote {
  position: absolute; transform: translate(-50%, -100%);
  font-size: 26px; z-index: 20; pointer-events: none;
  animation: emotePop 1.4s ease-out forwards;
  text-shadow: 0 2px 8px rgba(0,0,0,.6);
}
@keyframes emotePop {
  0% { opacity: 0; transform: translate(-50%, -80%) scale(.4); }
  18% { opacity: 1; transform: translate(-50%, -120%) scale(1.1); }
  80% { opacity: 1; transform: translate(-50%, -150%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -175%) scale(.9); }
}

/* item targeting mode */
body.targeting .hotspot { outline: 1.5px dashed #ffd27f66; outline-offset: 2px; }
body.targeting { cursor: crosshair; }

/* reputation panel */
#replist { max-height: 52vh; overflow-y: auto; text-align: left; margin: 10px 0 14px; }
.rep-row {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 10px 8px; border-bottom: 1px solid #2c2140;
}
.rep-row img { width: 52px; height: 52px; object-fit: contain; flex: 0 0 auto; }
.rep-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rep-main b { color: #ffd27f; font-size: 14.5px; }
.rep-mood { color: #b8a8d8; font-size: 12.5px; font-style: italic; }
.rep-fact { color: #d8cce8; font-size: 12.5px; line-height: 1.4; }
.rep-fact.none { color: #6a5a8a; font-style: italic; }
#btn-rep {
  display: block; width: 100%; margin: 12px 0 0;
  background: #2c2140; border: 1.5px solid #9b8cbb; color: #d8cce8;
  font-family: inherit; font-weight: 600; font-size: 13.5px;
  padding: 10px 16px; border-radius: 12px; cursor: pointer;
}

/* stance tiles */
.dlg-opt.st-sincere::before { content: "▸ "; color: #7fd6a8; }
.dlg-opt.st-sly::before     { content: "▸ "; color: #c9a2ff; }
.dlg-opt.st-tough::before   { content: "▸ "; color: #ff9d7a; }
.dlg-opt.st-comic::before   { content: "▸ "; color: #ffe07a; }

/* harbor gazette */
#awaytext {
  white-space: pre-wrap; text-align: left; font-style: italic;
  color: #f3ede0; line-height: 1.65; font-size: 15px;
  padding: 12px 14px; background: #14101f; border-radius: 12px;
  border: 1.5px solid #4a3a6a; margin: 10px 0;
}
#awayevents { text-align: left; margin-bottom: 12px; }
.away-ev { color: #9b8cbb; font-size: 12.5px; line-height: 1.5; }

/* the universal command bar — a quiet pill until summoned */
#cmdbar {
  position: absolute; right: 10px;
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 34; display: flex; gap: 6px; align-items: center;
}
#cmdbar-toggle {
  border: 1.5px solid #4a3a6a; border-radius: 999px; cursor: pointer;
  background: rgba(20,14,32,.85); color: #d8cce8; font-size: 17px;
  width: 44px; height: 44px;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
#cmdbar:not(.open) #cmdbar-input,
#cmdbar:not(.open) #cmdbar-go { display: none; }
#cmdbar.open { left: 10px; }
#cmdbar.open #cmdbar-input { display: block; }
#cmdbar.open #cmdbar-go { display: block; }
#cmdbar-input {
  flex: 1; padding: 10px 14px; border-radius: 999px;
  border: 1.5px solid #4a3a6a; background: rgba(20,14,32,.85);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  color: #f3ede0; font-family: inherit; font-size: 14px;
}
#cmdbar-input:focus { outline: none; border-color: #ffd27f; }
#cmdbar-input:disabled { opacity: .6; }
#cmdbar-go {
  border: none; cursor: pointer; font-size: 16px;
  background: linear-gradient(#ffd27f, #e8a94a); color: #3a2412;
  padding: 0 16px; border-radius: 999px;
}

/* the loop HUD */
#goldbadge {
  color: #ffd27f; font-size: 13px; align-self: center;
  background: rgba(44,33,64,.7); border: 1px solid #ffd27f55;
  border-radius: 999px; padding: 3px 10px; white-space: nowrap;
}
.rank-row { color: #f3ede0; font-size: 15px; padding: 4px 0 2px; }
.rank-pts { color: #9b8cbb; font-size: 12px; margin-left: 8px; }
.rank-bar {
  height: 7px; background: #2c2140; border-radius: 4px; overflow: hidden;
  margin: 4px 0 8px;
}
.rank-bar i {
  display: block; height: 100%;
  background: linear-gradient(90deg, #e8a94a, #ffd27f); border-radius: 4px;
}
