/* Reino do Disparate — ecrãs, HUD e interface por cima do 3D.
   Usa os tokens do hub (/assets/base.css): caixa de brinquedos à luz do dia. */

html, body.reino { height: 100%; height: 100dvh; overscroll-behavior: none; }
body.reino { overflow: hidden; background: #cfe9ff; }
.screen { position: fixed; inset: 0; height: 100dvh; }
/* margens do notch / barras do sistema (ecrã inteiro no telemóvel) */
.reino { --sa-t: env(safe-area-inset-top, 0px); --sa-r: env(safe-area-inset-right, 0px); --sa-b: env(safe-area-inset-bottom, 0px); --sa-l: env(safe-area-inset-left, 0px); }
.screen.hidden { display: none !important; }
kbd {
  display: inline-block; min-width: 20px; padding: 0 5px; border-radius: 6px; text-align: center;
  font: 700 12px/1.6 var(--font); background: #fff; border: 2px solid var(--line-strong); box-shadow: 0 2px 0 var(--line-strong);
}
.btn.big { font-size: 18px; padding: 15px 26px; border-radius: 18px; box-shadow: 0 6px 0 var(--edge); }
.btn.big:active { transform: translateY(6px); box-shadow: 0 0 0 var(--edge); }

/* ───────────────────────── Título ───────────────────────── */
.title-screen {
  background:
    linear-gradient(180deg, #8fd0ff 0%, #bfe6ff 55%, #e9f7ff 100%);
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 600px); align-items: center;
  padding: 0 max(24px, 5vw);
}
.title-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 3;
  display: flex; justify-content: space-between; align-items: center; padding: 14px max(16px, 3vw);
}
.back-hub { color: var(--ink); font-weight: 800; text-decoration: none; background: #fff; padding: 8px 14px; border-radius: 12px; box-shadow: 0 3px 0 var(--line-strong);
  font-size: clamp(13px, 3.4vw, 16px); white-space: nowrap; }
.title-stage { position: absolute; inset: 0; z-index: 0; }
.title-stage canvas { display: block; width: 100%; height: 100%; }
.title-copy {
  position: relative; z-index: 2; grid-column: 2; padding: 26px 28px;
  background: rgba(255, 255, 255, 0.82); border-radius: 30px; box-shadow: 0 8px 0 rgba(23, 21, 59, 0.1);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.logo { margin: 0 0 16px; line-height: .98; letter-spacing: -0.04em; }   /* "Reino do" não pode ficar debaixo de "Disparate" */
.logo span { display: block; }
.logo-l1 { font-size: clamp(26px, 3.4vw, 42px); color: var(--blue); transform: rotate(-3deg); transform-origin: left; }
.logo-l2 {
  font-size: clamp(40px, 4.4vw, 80px); font-weight: 900; color: #fff;
  -webkit-text-stroke: 3px var(--ink);
  text-shadow: 0 6px 0 var(--pink), 0 10px 0 var(--ink);
  animation: wobble 3.2s ease-in-out infinite;
}
@keyframes wobble { 0%, 100% { transform: rotate(-1.5deg); } 50% { transform: rotate(1.5deg) translateY(-3px); } }
.tagline { font-size: 19px; color: var(--ink-2); max-width: 34ch; margin: 18px 0 26px; font-weight: 500; }
.title-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.title-note { color: var(--ink-2); font-size: 14px; margin-top: 16px; }
@media (max-width: 860px) {
  .title-screen { grid-template-columns: 1fr; align-items: end; padding: 0 20px 28px; }
  .title-copy { grid-column: 1; padding: 20px; border-radius: 24px; }
  .logo-l2 { font-size: clamp(38px, 11vw, 64px); }
  .tagline { font-size: 16px; margin: 12px 0 18px; }
}
/* Telemóvel deitado: o cartão encolhe para não ficar por baixo da barra de cima. */
@media (orientation: landscape) and (max-height: 540px) {
  .title-screen { align-items: end; padding: 0 16px 12px; }
  .title-top { padding: 8px 12px; }
  .title-copy { padding: 12px 16px; border-radius: 20px; max-height: calc(100dvh - 60px); overflow-y: auto; }
  .logo { margin-bottom: 6px; }
  .logo-l1 { font-size: 20px; }
  .logo-l2 { font-size: 36px; }
  .tagline { font-size: 14px; margin: 6px 0 12px; max-width: 46ch; }
  .title-note { font-size: 12px; margin-top: 8px; }
  .btn.big { font-size: 15px; padding: 10px 18px; border-radius: 14px; }
}

/* ───────────────────────── Escolha de poder ─────────────────────────
   Regra: cabe sempre num ecrã (100dvh), sem scroll da página. */
html:has(body.reino) { overflow: hidden; }
.select-screen { background: var(--paper); display: flex; flex-direction: column; overflow: hidden; }
.select-head {
  flex: none; display: flex; align-items: center; gap: 14px;
  padding: clamp(8px, 1.6vh, 14px) max(16px, 3vw, var(--sa-l));
  background: #fff; border-bottom: 1px solid var(--line);
}
.select-head h2 { margin: 0; font-size: clamp(17px, 2.2vw, 26px); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.select-user { color: var(--muted); font-weight: 700; font-size: 14px; white-space: nowrap; }
.select-body {
  flex: 1; min-height: 0; width: 100%; max-width: 1400px; margin: 0 auto;
  display: grid; grid-template-columns: clamp(220px, 26vw, 340px) minmax(0, 1fr); gap: clamp(10px, 1.6vw, 22px);
  padding: clamp(10px, 2vh, 22px) max(16px, 3vw, var(--sa-r)) max(clamp(10px, 2vh, 22px), var(--sa-b)) max(16px, 3vw, var(--sa-l));
}
.class-list {
  display: grid; grid-auto-rows: minmax(52px, 96px); align-content: start; gap: clamp(6px, 1.2vh, 12px); min-height: 0;
  /* com muitas personagens num ecrã baixo, a lista desliza por dentro (a página nunca) */
  overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; padding: 2px 2px 6px;
}
.class-card {
  --c: #999; --ce: #666;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; text-align: left;
  padding: clamp(6px, 1.2vh, 12px) 12px; border-radius: 16px; background: #fff; border: 2px solid var(--line); cursor: pointer;
  box-shadow: 0 4px 0 var(--line-strong); font: inherit; color: var(--ink); min-height: 0;
  transition: border-color .12s, box-shadow .12s;
}
.class-card[aria-selected="true"] { border-color: var(--c); box-shadow: 0 5px 0 var(--c); }
.class-card .ic { width: clamp(36px, 6vh, 52px); height: clamp(36px, 6vh, 52px); border-radius: 14px; display: grid; place-items: center; font-size: clamp(20px, 3.4vh, 28px); background: var(--c); box-shadow: 0 3px 0 var(--ce); }
.class-card strong { display: block; font: 700 clamp(13px, 1.1vw, 16px)/1.2 var(--display);
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.class-card small { display: block; color: var(--muted); font-weight: 600; font-size: var(--fs-2xs); line-height: 1.2;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.class-card .lvl { font: 700 12px/1 var(--font); padding: 5px 8px; border-radius: 9px; background: #fff1c7; white-space: nowrap; }
.class-card .lvl.new { background: var(--surface-2); color: var(--muted); }

.class-detail {
  min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: clamp(10px, 1.6vw, 20px);
  background: #fff; border: 2px solid var(--line); border-radius: 24px; padding: clamp(10px, 1.6vw, 20px); box-shadow: var(--shadow);
}
.class-preview { position: relative; min-height: 0; border-radius: 18px; background: var(--table); overflow: hidden; }
.class-preview canvas { display: block; width: 100%; height: 100%; }
.class-info { min-height: 0; display: flex; flex-direction: column; gap: clamp(4px, 1vh, 10px); }
.class-power { margin: 0; font-weight: 800; color: var(--blue); font-size: clamp(13px, 1.6vh, 16px); }
.class-name { font-size: clamp(22px, 3.4vh, 36px); margin: 0; }
.class-role { margin: 0; color: var(--muted); font-weight: 700; font-size: clamp(13px, 1.6vh, 16px); }
.class-blurb { margin: 0; font-size: clamp(14px, 1.8vh, 16px); }
.skill-list { list-style: none; margin: 0; padding: 0; display: grid; gap: clamp(4px, 0.8vh, 8px); min-height: 0; }
.skill-list li {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: center;
  padding: clamp(4px, 0.8vh, 8px) 10px; border-radius: 12px; background: var(--surface-2); cursor: default;
}
.skill-list .sk-ic { width: clamp(30px, 4.4vh, 40px); height: clamp(30px, 4.4vh, 40px); border-radius: 10px; display: grid; place-items: center; font-size: clamp(16px, 2.4vh, 20px); background: #fff; box-shadow: 0 2px 0 var(--line-strong); position: relative; }
.skill-list .sk-key { position: absolute; right: -5px; bottom: -5px; font: 800 10px/1 var(--font); background: var(--ink); color: #fff; border-radius: 5px; padding: 2px 4px; }
.skill-list .sk-txt { min-width: 0; }
.skill-list b { display: block; font-size: 14px; line-height: 1.2; }
.skill-list em { font-style: normal; font-size: 11px; font-weight: 800; color: var(--muted); margin-left: 6px; }
.skill-list .sk-desc { font-size: var(--fs-2xs); color: var(--ink-2); line-height: 1.2;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.skill-tip { margin: 0; background: var(--ink); color: #fff; font: 600 13px/1.35 var(--font); padding: 8px 11px; border-radius: 12px; }
.class-cta { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.class-save { margin: 0; color: var(--muted); font-weight: 700; font-size: 14px; min-width: 0; }
.class-cta .btn.big { flex: none; }

/* ecrãs baixos (portátil pequeno, telemóvel deitado): menos texto */
@media (max-height: 720px) {
  .class-blurb { display: none; }
  .skill-list .sk-desc { display: none; }
  .class-card small { display: none; }
}
@media (max-height: 460px) {
  .class-list { grid-auto-rows: minmax(40px, 64px); }
  .name-field label { display: none; }
  /* nova personagem em ecrã baixo: ataques em fila de ícones para caber o nome */
  .mode-create .skill-list { grid-template-columns: repeat(5, 1fr); gap: 6px; }
  .mode-create .skill-list li { place-items: center; padding: 3px 0; background: none; cursor: pointer; grid-template-columns: auto; }
  .mode-create .skill-list .sk-txt { display: none; }
  .mode-create .skill-list li[aria-pressed="true"] .sk-ic { outline: 3px solid var(--blue); }
  .mode-create .skill-list .sk-ic { width: 34px; height: 34px; font-size: 17px; }
  .mode-create .skill-tip { position: absolute; z-index: 5; left: 12px; right: 12px; bottom: 64px; }
  .class-detail { position: relative; }
  .field-err:empty { display: none; }
  .select-head { padding-block: 6px; }
  .select-head .btn.small { padding: 5px 10px; }
  .class-card .lvl { display: none; }
  .class-card { padding: 4px 8px; gap: 8px; border-radius: 12px; }
  .class-card .ic { width: 30px; height: 30px; font-size: 17px; border-radius: 9px; }
  .class-role { display: none; }
  .skill-list li { padding: 3px 8px; }
  .skill-list .sk-ic { width: 26px; height: 26px; font-size: 14px; }
  .skill-list b { font-size: 12.5px; }
  .class-cta .btn.big { font-size: 15px; padding: 10px 16px; }
  .class-save { font-size: 12px; }
}

/* telemóvel de pé: pré-visualização em cima, fila de classes a deslizar, botão fixo em baixo */
@media (orientation: portrait) and (max-width: 760px) {
  .select-head h2 { font-size: 17px; }
  .select-user { display: none; }
  .select-body { display: flex; flex-direction: column; gap: 10px; padding: 10px 12px max(10px, var(--sa-b)); }
  .class-detail { order: 1; flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 20px; }
  .class-preview { flex: 1; min-height: 120px; }
  .class-info { flex: none; gap: 6px; }
  .class-titles { display: grid; grid-template-columns: 1fr; }
  .class-name { font-size: clamp(20px, 6vw, 26px); }
  .class-blurb, .class-role { display: none; }
  .skill-list { grid-template-columns: repeat(5, 1fr); gap: 8px; }
  .skill-list li { display: grid; place-items: center; padding: 6px 0; background: none; cursor: pointer; }
  .skill-list li[aria-pressed="true"] .sk-ic { outline: 3px solid var(--blue); }
  .skill-list .sk-ic { width: 44px; height: 44px; font-size: 22px; }
  .skill-list .sk-txt { display: none; }
  .class-cta { display: none; }
  .class-list {
    order: 2; flex: none; display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory;
    padding: 2px 2px 6px; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; scrollbar-width: none;
  }
  .class-list::-webkit-scrollbar { display: none; }
  .class-card { flex: 0 0 auto; grid-template-columns: auto; justify-items: center; gap: 4px; padding: 8px 10px; scroll-snap-align: center; width: 92px; }
  .class-card small, .class-card .lvl { display: none; }
  .class-card strong { font-size: 11.5px; max-width: 76px; }
  .class-card .ic { width: 44px; height: 44px; font-size: 24px; }
  .select-cta-mobile { order: 3; display: flex !important; }
  .char-slot { flex: 0 0 auto; }
  .char-slot .class-card { padding-right: 10px; width: 108px; }
  .char-slot .del { display: none; }
  .mode-chars .del-sel { display: inline-flex; }
  .class-card .short { max-width: 92px; overflow: hidden; text-overflow: ellipsis; }
  .name-field label { display: none; }
  .field-err:empty { display: none; }
}
.class-card .short { display: none; }
.name-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.name-line .class-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.del-sel { display: none; font-size: 13px; padding: 4px 8px; }
.class-card:disabled { opacity: .5; cursor: not-allowed; }
.char-slot { position: relative; min-height: 0; display: grid; }
.char-slot .class-card { padding-right: 46px; }
.char-slot .lvl { display: none; }
.char-slot .del {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; border-radius: 10px;
  border: 2px solid var(--line-strong); background: #fff; cursor: pointer; font-size: 14px; opacity: .55; transition: opacity .12s;
}
.char-slot .del:hover, .char-slot .del:focus-visible { opacity: 1; border-color: var(--pink); }
.new-card { border-style: dashed; box-shadow: none; }
.new-card .ic { background: var(--surface-2) !important; box-shadow: none !important; color: var(--blue); font-weight: 900; }
.name-field { display: grid; gap: 4px; }
.name-field label { font-size: 13px; font-weight: 800; color: var(--ink-2); }
.name-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.name-row input { font-size: 16px; font-weight: 700; padding: 9px 12px; }
.name-row .btn { font-size: 18px; padding: 6px 12px; }
.field-err { margin: 0; min-height: 1.2em; font-size: 13px; font-weight: 700; color: var(--danger); }
.del-card { display: grid; gap: 10px; text-align: left; width: min(420px, 92vw); }
.del-card input { font-size: 16px; }
.del-actions { justify-content: flex-end; }
.select-screen .overlay { z-index: 20; }
@media (orientation: portrait) and (max-width: 760px) {
  .class-card strong { display: none; }
  .class-card .short { display: block; font: 700 12.5px/1.2 var(--display); white-space: nowrap; }
}
.select-cta-mobile { display: none; flex: none; align-items: center; justify-content: space-between; gap: 10px; }
.select-cta-mobile .btn { flex: 1; }
.select-cta-mobile p { margin: 0; font-size: 13px; color: var(--muted); font-weight: 700; }

/* ───────────────────────── Jogo ───────────────────────── */
.game-screen { background: #9fd67c; touch-action: none; user-select: none; -webkit-user-select: none; }
#game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.hud { position: absolute; z-index: 5; }

/* etiquetas sobre entidades */
.lbl { position: absolute; left: 0; top: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; transform: translate(-50%, -100%); will-change: transform; }
.lbl .nm { font: 700 12px/1.1 var(--font); color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.7), 0 0 3px rgba(0,0,0,.5); white-space: nowrap; }
.lbl.is-mob .nm { color: #ffe3ea; }
.lbl.is-boss .nm { font: 800 15px/1.1 var(--display); color: #fff; }
.lbl.is-me .nm { color: var(--yellow); }
.lbl .hpb { width: 48px; height: 6px; border-radius: 4px; background: rgba(23,21,59,.55); overflow: hidden; border: 1px solid rgba(255,255,255,.6); }
.lbl.is-boss .hpb { width: 150px; height: 10px; }
.lbl .hpb i { display: block; height: 100%; width: 100%; background: var(--mint); transform-origin: left; }
.lbl.is-mob .hpb i { background: var(--pink); }
.lbl .st { font-size: 13px; line-height: 1; min-height: 13px; }
.lbl.is-npc .nm { font: 700 13px/1.1 var(--display); }
.lbl.is-npc .ttl { font: 600 11px/1 var(--font); color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.7); }
.lbl .mark { font: 900 26px/1 var(--display); color: var(--yellow); -webkit-text-stroke: 2px var(--ink); animation: bob 1s ease-in-out infinite; }
.lbl .mark.ready { color: var(--mint); }
.lbl.is-portal .nm { background: rgba(51, 85, 255, .9); padding: 4px 9px; border-radius: 9px; text-shadow: none; }
@keyframes bob { 50% { transform: translateY(-5px); } }
.bubble {
  position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); max-width: 200px;
  background: #fff; color: var(--ink); font: 700 13px/1.3 var(--font); padding: 7px 10px; border-radius: 12px;
  box-shadow: 0 3px 0 var(--line-strong); animation: pop .25s cubic-bezier(.2,1.6,.4,1);
}
.bubble::after { content: ""; position: absolute; left: 50%; bottom: -7px; border: 7px solid transparent; border-top-color: #fff; border-bottom: 0; transform: translateX(-50%); }
.num {
  position: absolute; left: 0; top: 0; font: 800 18px/1 var(--display); color: #fff; white-space: nowrap;
  -webkit-text-stroke: 1.5px var(--ink); animation: float-up 1s ease-out forwards; pointer-events: none;
}
.num.crit { font-size: 26px; color: var(--yellow); }
.num.heal { color: var(--mint); }
.num.miss { color: #ddd; font-size: 15px; }
.num.me-hurt { color: var(--pink); }
.num.absorbed { color: #bcd0ff; font-size: 14px; }
@keyframes float-up {
  0% { opacity: 0; transform: translate(-50%, 0) scale(.6); }
  15% { opacity: 1; transform: translate(-50%, -16px) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -60px) scale(1); }
}
@keyframes pop { from { transform: translate(-50%, -100%) scale(.6); } to { transform: translate(-50%, -100%) scale(1); } }

/* barras do jogador */
.hud-me {
  top: calc(10px + var(--sa-t)); left: calc(10px + var(--sa-l)); display: grid; grid-template-columns: 58px 220px; gap: 4px 10px;
  background: rgba(255,255,255,.92); padding: 8px 12px 8px 8px; border-radius: 18px; box-shadow: 0 4px 0 rgba(23,21,59,.18);
}
.me-portrait { width: 58px; height: 58px; border-radius: 16px; display: grid; place-items: center; font-size: 32px; background: var(--blue); grid-row: span 2; box-shadow: inset 0 -4px 0 rgba(0,0,0,.18); }
.me-name { font-size: 14px; line-height: 1.2; }
.me-name strong { font-family: var(--display); }
.me-level { color: var(--muted); font-weight: 700; }
.bar { position: relative; height: 16px; border-radius: 8px; background: #e6e8f6; overflow: hidden; margin-top: 3px; }
.bar i { position: absolute; inset: 0; transform-origin: left; transition: transform .15s; }
.bar.hp i { background: linear-gradient(#ff7ab3, var(--pink)); }
.bar.en i { background: linear-gradient(#6e8bff, var(--blue)); }
.bar.xp { height: 6px; }
.bar.xp i { background: var(--yellow); }
.bar span { position: absolute; inset: 0; display: grid; place-items: center; font: 800 var(--fs-3xs)/1 var(--font); color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.45); }
.me-status { grid-column: 2; display: flex; gap: 4px; font-size: 15px; min-height: 0; }
.me-status span { position: relative; }
.me-status small { position: absolute; right: -4px; bottom: -4px; font: 800 9px/1 var(--font); background: var(--ink); color: #fff; border-radius: 4px; padding: 1px 3px; }

/* mapa, ouro, missões */
.hud-map { top: calc(10px + var(--sa-t)); right: calc(10px + var(--sa-r)); display: grid; gap: 8px; justify-items: end; width: 220px; }
.minimap-wrap { position: relative; }
#minimap { width: 160px; height: 160px; border-radius: 20px; background: #fff; border: 3px solid #fff; box-shadow: 0 4px 0 rgba(23,21,59,.18); image-rendering: pixelated; display: block; }
.zone-name { position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%); background: var(--ink); color: #fff; font: 700 11px/1 var(--display); padding: 5px 8px; border-radius: 8px; white-space: nowrap; }
.gold { background: rgba(255,255,255,.92); border-radius: 12px; padding: 5px 10px; font-weight: 800; box-shadow: 0 3px 0 rgba(23,21,59,.15); margin-top: 6px; }
.quest-tracker { display: grid; gap: 6px; width: 100%; }
.qt-item {
  display: grid; gap: 1px; text-align: left; width: 100%; cursor: pointer; font: inherit; color: var(--ink);
  background: rgba(255,255,255,.93); border: 2px solid transparent; border-radius: 12px; padding: 7px 10px; font-size: 13px;
  box-shadow: 0 3px 0 rgba(23,21,59,.15);
}
.qt-item b { display: block; font-size: 12px; color: var(--muted); font-weight: 800; }
.qt-item .qt-obj { font-weight: 800; font-size: 13.5px; line-height: 1.25; }
.qt-item .qt-where { color: var(--ink-2); font-weight: 600; font-size: var(--fs-3xs); line-height: 1.25; }
.qt-item .qt-where:empty { display: none; }
.qt-item.tracked { border-color: var(--yellow); }
.qt-item.tracked b::before { content: "★ "; color: var(--yellow-edge); }
.qt-item.ready .qt-obj { color: var(--mint-edge); }

/* seta da missão seguida */
.quest-arrow {
  position: absolute; left: 0; top: 0; z-index: 4; pointer-events: none;
  display: grid; place-items: center; width: 54px; height: 54px; border-radius: 50%;
  background: var(--yellow); box-shadow: 0 4px 0 var(--yellow-edge), 0 8px 20px rgba(23,21,59,.3);
}
.quest-arrow .qa-ptr { font-size: 24px; line-height: 1; color: var(--ink); display: block; }
.quest-arrow .qa-dist { position: absolute; bottom: -18px; font: 800 12px/1 var(--font); color: #fff; background: var(--ink); padding: 3px 6px; border-radius: 7px; white-space: nowrap; }
.quest-arrow.onscreen { width: 40px; height: 40px; animation: qa-bob 1s ease-in-out infinite; }
.quest-arrow.onscreen .qa-ptr { font-size: 18px; }
@keyframes qa-bob { 50% { margin-top: -8px; } }

/* diário de missões */
.journal {
  position: absolute; z-index: 10; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 20px)); max-height: calc(100dvh - 24px); display: flex; flex-direction: column;
  background: #fff; border-radius: 24px; padding: 16px; box-shadow: 0 8px 0 rgba(23,21,59,.2), 0 24px 60px -20px rgba(23,21,59,.5);
}
.journal-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: grid; gap: 8px; margin-top: 10px; }
.journal-body h4 { margin: 6px 0 0; font: 700 14px/1.2 var(--display); }
.journal .dq { text-align: left; width: 100%; font: inherit; color: var(--ink); border: 2px solid transparent; cursor: pointer; }
.journal .dq.tracked { border-color: var(--yellow); }
.journal .jq-obj { font-weight: 800; color: var(--ink); }
.jq-done { margin: 0; padding-left: 4px; list-style: none; color: var(--muted); font-weight: 700; font-size: 14px; }

/* itens no chão: nome só ao passar o rato (no toque, sempre) */
.lbl.is-item .hpb { display: none; }
.lbl.is-item .nm { background: var(--yellow); color: var(--ink); padding: 3px 8px; border-radius: 9px; text-shadow: none; font-weight: 800; box-shadow: 0 2px 0 var(--yellow-edge); }
.lbl.is-item.faded .nm { opacity: 0; }
.lbl.is-item.faded.hover .nm { opacity: .8; background: rgba(23,21,59,.7); color: #fff; box-shadow: none; }

/* poderes */
.hud-skills { left: 50%; bottom: calc(12px + var(--sa-b)); transform: translateX(-50%); display: flex; gap: 12px; align-items: flex-end; }
.skillbar, .potions { display: flex; gap: 8px; background: rgba(255,255,255,.9); padding: 8px; border-radius: 20px; box-shadow: 0 4px 0 rgba(23,21,59,.18); }
.skill {
  --c: var(--blue);
  position: relative; width: 60px; height: 60px; border-radius: 16px; border: 0; padding: 0; cursor: pointer;
  background: var(--c); box-shadow: 0 4px 0 rgba(0,0,0,.25); font-size: 28px; color: #fff; overflow: hidden;
  transition: transform .06s;
}
.skill:active, .skill.pressed { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.25); }
.skill .key { position: absolute; left: 4px; top: 3px; font: 800 11px/1 var(--font); color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.5); }
.skill .cost { position: absolute; right: 4px; bottom: 3px; font: 800 10px/1 var(--font); color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.5); }
.skill .cd { position: absolute; inset: 0; background: conic-gradient(rgba(23,21,59,.62) var(--p, 0%), transparent 0); pointer-events: none; }
.skill .cdt { position: absolute; inset: 0; display: grid; place-items: center; font: 800 18px/1 var(--display); color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.7); pointer-events: none; }
.skill.locked { filter: grayscale(1); opacity: .45; cursor: not-allowed; }
.skill.locked::after { content: "🔒"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 22px; }
.skill.noen { filter: saturate(.3) brightness(.85); }
.skill.flash { animation: sk-flash .3s; }
@keyframes sk-flash { 50% { transform: scale(1.12); } }
.skill .tip {
  position: absolute; bottom: 72px; left: 50%; transform: translateX(-50%); width: 230px; display: none;
  background: var(--ink); color: #fff; font: 500 13px/1.35 var(--font); padding: 10px 12px; border-radius: 12px; text-align: left; pointer-events: none;
}
.skill .tip b { display: block; font-size: 14px; margin-bottom: 3px; }
.skillbar { overflow: visible; }
.skill { overflow: visible; }
.skill .cd, .skill .cdt { border-radius: 16px; overflow: hidden; }
@media (hover: hover) { .skill:hover .tip { display: block; } }
.potion { --c: #fff; position: relative; width: 48px; height: 48px; border-radius: 14px; border: 2px solid var(--line-strong); background: #fff; font-size: 24px; cursor: pointer; box-shadow: 0 4px 0 var(--line-strong); padding: 0; }
.potion:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line-strong); }
.potion b { position: absolute; right: -5px; top: -6px; min-width: 20px; height: 20px; border-radius: 10px; background: var(--pink); color: #fff; font: 800 11px/20px var(--font); }
.potion .key { position: absolute; left: 3px; bottom: 2px; font: 800 10px/1 var(--font); color: var(--muted); }
.potion:disabled { opacity: .45; }

/* chat */
.chat { left: calc(10px + var(--sa-l)); bottom: calc(12px + var(--sa-b)); width: min(340px, 30vw); display: grid; gap: 6px; }
.chat-toggle { display: none; }
.chat-log { list-style: none; margin: 0; padding: 8px 10px; max-height: 150px; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; background: rgba(23,21,59,.38); border-radius: 14px; color: #fff; font-size: 13px; }
.chat-log:empty { display: none; }
.chat-log li { text-shadow: 0 1px 2px rgba(0,0,0,.6); overflow-wrap: anywhere; }
.chat-log li b { color: var(--yellow); }
.chat-log li.sys { color: #d6fff3; font-style: italic; }
.chat-form input { width: 100%; background: rgba(255,255,255,.92); border-color: transparent; font-size: 14px; padding: 8px 11px; }

/* banner de zona, toasts, popups */
.zone-banner { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); z-index: 6; text-align: center; pointer-events: none; animation: banner 3.2s ease forwards; }
.zone-banner small { display: block; font: 700 14px/1 var(--font); color: #fff; text-shadow: 0 2px 4px rgba(0,0,0,.5); }
.zone-banner strong { display: block; font: 900 clamp(30px, 5vw, 56px)/1.05 var(--display); color: #fff; -webkit-text-stroke: 2.5px var(--ink); text-shadow: 0 5px 0 var(--ink); }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, 16px) scale(.9); } 12%, 75% { opacity: 1; transform: translate(-50%, 0) scale(1); } 100% { opacity: 0; transform: translate(-50%, -10px); } }
.toasts { position: absolute; left: 50%; top: 88px; transform: translateX(-50%); z-index: 8; display: grid; gap: 6px; justify-items: center; pointer-events: none; }
.toast { background: var(--ink); color: #fff; font: 700 14px/1.3 var(--font); padding: 8px 14px; border-radius: 12px; animation: toast 2.8s ease forwards; max-width: 80vw; text-align: center; }
.toast.err { background: var(--pink); }
@keyframes toast { 0% { opacity: 0; transform: translateY(-8px); } 10%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; } }
.popups { position: absolute; inset: 0; pointer-events: none; z-index: 6; }
.pop {
  position: absolute; left: 50%; bottom: 150px; transform: translateX(-50%); font: 800 16px/1 var(--display); color: #fff; white-space: nowrap;
  -webkit-text-stroke: 1.2px var(--ink); animation: loot 1.6s ease-out forwards;
}
.pop.xp { color: var(--yellow); }
.pop.gold { color: #ffe27a; }
.pop.item { color: #fff; }
@keyframes loot { 0% { opacity: 0; transform: translate(-50%, 10px); } 15% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; transform: translate(-50%, -70px); } }

/* diálogo */
.dialog {
  position: absolute; z-index: 9; left: 50%; bottom: 110px; transform: translateX(-50%); width: min(560px, calc(100vw - 20px));
  max-height: calc(100vh - 150px); overflow: auto;
  background: #fff; border-radius: 24px; padding: 18px; box-shadow: 0 8px 0 rgba(23,21,59,.2), 0 24px 60px -20px rgba(23,21,59,.5);
  animation: dlg-in .25s cubic-bezier(.2,1.4,.4,1);
}
@keyframes dlg-in { from { opacity: 0; transform: translate(-50%, 20px) scale(.96); } }
.dlg-head { display: grid; grid-template-columns: 54px 1fr auto; gap: 12px; align-items: center; }
.dlg-head h3 { margin: 0; font-size: 20px; }
.dlg-head p { margin: 0; color: var(--muted); font-weight: 700; font-size: 14px; }
.dlg-avatar { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; font-size: 30px; background: var(--surface-2); }
.dlg-close { width: 40px; height: 40px; border-radius: 12px; border: 2px solid var(--line-strong); background: #fff; font-size: 16px; cursor: pointer; box-shadow: 0 3px 0 var(--line-strong); }
.dlg-text { font-size: 16px; margin: 14px 0; }
.dlg-quests, .dlg-shop { display: grid; gap: 8px; }
.dq { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 12px; border-radius: 16px; background: var(--surface-2); }
.dq b { font-size: 15px; }
.dq p { margin: 0; grid-column: 1 / -1; font-size: 14px; color: var(--ink-2); }
.dq .rw { grid-column: 1 / -1; font-size: 13px; font-weight: 700; color: var(--muted); }
.dq .state { font-size: 13px; font-weight: 800; color: var(--muted); }
.dq.ready { background: #dcf7ef; }
.dq.done { opacity: .6; }
.shop-item { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 16px; background: var(--surface-2); }
.shop-item .ic { font-size: 26px; text-align: center; }
.shop-item span { display: block; font-size: 13px; color: var(--ink-2); }

/* overlays */
.overlay { position: absolute; inset: 0; z-index: 12; display: grid; place-items: center; background: rgba(23,21,59,.45); }
.overlay-card { background: #fff; border-radius: 26px; padding: 26px 28px; text-align: center; max-width: 92vw; box-shadow: 0 8px 0 rgba(23,21,59,.25); }
.overlay-card .big { font: 800 26px/1.2 var(--display); margin: 0 0 6px; }
.overlay-card .btn { margin-top: 16px; }
.death { background: rgba(120, 20, 60, .35); }
.levelup {
  position: absolute; z-index: 7; left: 50%; top: 30%; transform: translateX(-50%); text-align: center; pointer-events: none;
  animation: lvl 3s ease forwards;
}
.levelup strong { display: block; font: 900 clamp(38px, 7vw, 76px)/1 var(--display); color: var(--yellow); -webkit-text-stroke: 3px var(--ink); text-shadow: 0 6px 0 var(--ink); }
.levelup span { display: inline-block; margin-top: 10px; font: 700 16px/1.3 var(--font); background: var(--ink); color: #fff; padding: 7px 12px; border-radius: 12px; }
.levelup span:empty { display: none; }
@keyframes lvl { 0% { opacity: 0; transform: translateX(-50%) scale(.5) rotate(-8deg); } 15% { opacity: 1; transform: translateX(-50%) scale(1.1) rotate(2deg); } 25%, 80% { transform: translateX(-50%) scale(1); opacity: 1; } 100% { opacity: 0; transform: translateX(-50%) translateY(-20px); } }

.hud-buttons { top: calc(10px + var(--sa-t)); left: 50%; transform: translateX(-50%); display: flex; gap: 8px; }
.round-btn { width: 44px; height: 44px; border-radius: 14px; border: 0; background: rgba(255,255,255,.92); font-size: 20px; cursor: pointer; box-shadow: 0 4px 0 rgba(23,21,59,.18); color: var(--ink); }
.round-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(23,21,59,.18); }
.fs .round-btn#btn-fullscreen { background: var(--yellow); }
.ios-hint {
  position: absolute; z-index: 13; left: 50%; bottom: calc(14px + var(--sa-b)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 24px);
  background: var(--ink); color: #fff; font: 600 13px/1.3 var(--font); padding: 9px 10px 9px 14px; border-radius: 14px;
}
.ios-hint button { border: 0; background: rgba(255,255,255,.15); color: #fff; width: 28px; height: 28px; border-radius: 8px; cursor: pointer; flex: none; }
.menu { position: absolute; z-index: 11; top: calc(64px + var(--sa-t)); left: 50%; transform: translateX(-50%); width: min(330px, 92vw); display: grid; gap: 10px; background: #fff; border-radius: 20px; padding: 16px; box-shadow: 0 8px 0 rgba(23,21,59,.2); }
.menu-help { font-size: 13px; margin: 4px 0 0; }

/* joystick (toque) */
.joystick {
  position: absolute; z-index: 6; left: calc(22px + var(--sa-l)); bottom: calc(22px + var(--sa-b)); width: 136px; height: 136px; border-radius: 50%;
  background: rgba(255,255,255,.35); border: 3px solid rgba(255,255,255,.75); touch-action: none;
}
.joy-knob { position: absolute; left: 50%; top: 50%; width: 60px; height: 60px; margin: -30px 0 0 -30px; border-radius: 50%; background: #fff; box-shadow: 0 4px 0 rgba(23,21,59,.25); }

/* ───────────── Toque / ecrãs pequenos ───────────── */
.touch .joystick { display: block; }
.touch .hud-skills { left: auto; right: calc(12px + var(--sa-r)); transform: none; flex-direction: column-reverse; align-items: flex-end; gap: 8px; }
.touch .skillbar {
  display: grid; grid-template-columns: 62px 62px 84px; grid-template-rows: 62px 62px 84px; gap: 6px; background: none; box-shadow: none; padding: 0;
}
.touch .skill { width: 62px; height: 62px; border-radius: 50%; font-size: 26px; }
.touch .skill .cd, .touch .skill .cdt { border-radius: 50%; }
.touch .skill[data-slot="basic"] { grid-column: 3; grid-row: 3; width: 84px; height: 84px; font-size: 38px; }
.touch .skill[data-slot="q"] { grid-column: 2; grid-row: 3; align-self: end; }
.touch .skill[data-slot="w"] { grid-column: 2; grid-row: 2; }
.touch .skill[data-slot="e"] { grid-column: 3; grid-row: 2; justify-self: end; }
.touch .skill[data-slot="r"] { grid-column: 3; grid-row: 1; justify-self: end; }
.touch .skill .key { display: none; }
.touch .potions { background: none; box-shadow: none; padding: 0; }
.touch .potion .key { display: none; }
.touch .chat { width: auto; left: calc(10px + var(--sa-l)); bottom: auto; top: calc(118px + var(--sa-t)); }
.touch .chat-toggle {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; border: 0; background: rgba(255,255,255,.92); font-size: 20px; box-shadow: 0 3px 0 rgba(23,21,59,.18);
}
.touch .chat:not(.open) .chat-log, .touch .chat:not(.open) .chat-form { display: none; }
.touch .chat.open { width: min(320px, calc(100vw - 20px)); }
.touch .chat-log { max-height: 120px; }
.touch .dialog { bottom: 12px; }
@media (max-width: 760px) {
  .hud-me { grid-template-columns: 44px 150px; padding: 6px 10px 6px 6px; gap: 2px 8px; border-radius: 14px; }
  .me-portrait { width: 44px; height: 44px; font-size: 24px; border-radius: 12px; }
  .me-name { font-size: 12px; }
  .bar { height: 12px; }
  .bar span { font-size: 11px; }
  .hud-map { width: 120px; }
  #minimap { width: 104px; height: 104px; border-radius: 16px; }
  .quest-tracker { width: 190px; }
  .qt-item { padding: 5px 8px; }
  .qt-item .qt-obj { font-size: 12px; }
  .qt-item .qt-where { font-size: 11px; }
  .gold { font-size: 13px; }
  .hud-buttons { left: auto; right: calc(138px + var(--sa-r)); transform: none; }
  .zone-name { font-size: 11px; }
}
@media (max-height: 480px) and (orientation: landscape) {
  .hud-me { transform: scale(.85); transform-origin: top left; }
  .hud-map { transform: scale(.85); transform-origin: top right; }
  .touch .skillbar { grid-template-columns: 54px 54px 72px; grid-template-rows: 54px 54px 72px; }
  .touch .skill { width: 54px; height: 54px; }
  .touch .skill[data-slot="basic"] { width: 72px; height: 72px; }
  .joystick { width: 116px; height: 116px; }
}
.lbl.hostile .nm { color: #ff9fb0; }
.lbl.hostile .hpb i { background: var(--pink); }

/* botões do topo no telemóvel de pé: por baixo do minimapa, em coluna */
@media (max-width: 760px) {
  .hud-buttons { left: auto; right: calc(10px + var(--sa-r)); top: calc(168px + var(--sa-t)); transform: none; flex-direction: column; }
  .menu { top: calc(120px + var(--sa-t)); }
}
/* telemóvel deitado (pouca altura): HUD compacto para não tapar os botões */
@media (max-height: 500px) {
  .hud-me { grid-template-columns: 40px 150px; padding: 5px 9px 5px 5px; gap: 1px 8px; border-radius: 14px; transform: none; }
  .me-portrait { width: 40px; height: 40px; font-size: 22px; border-radius: 11px; }
  .me-name { font-size: 11px; }
  .bar { height: 11px; margin-top: 2px; }
  .bar span { font-size: 11px; }
  .hud-map { width: auto; transform: none; gap: 4px; }
  #minimap { width: 92px; height: 92px; border-radius: 14px; }
  .zone-name { display: none; }
  .gold { font-size: 12px; padding: 3px 8px; margin-top: 0; }
  /* ecrã baixo: só a missão seguida, compacta, ao lado do minimapa */
  .hud-map { grid-template-columns: auto auto; align-items: start; justify-items: end; }
  .minimap-wrap { grid-column: 2; grid-row: 1 / span 2; }
  .gold { grid-column: 1; grid-row: 2; }
  .quest-tracker { display: grid; grid-column: 1; grid-row: 1; width: 176px; }
  .quest-tracker .qt-item:not(:first-child) { display: none; }
  .qt-item { padding: 4px 8px; border-radius: 10px; }
  .qt-item b { display: none; }
  .qt-item .qt-obj { font-size: 12px; }
  .qt-item .qt-where { font-size: 11px; }
  .quest-arrow { width: 44px; height: 44px; }
  .quest-arrow .qa-ptr { font-size: 19px; }
  .hud-buttons { left: 50%; right: auto; top: calc(8px + var(--sa-t)); transform: translateX(-50%); flex-direction: row; }
  .round-btn { width: 38px; height: 38px; font-size: 17px; border-radius: 12px; }
  .touch .hud-skills { flex-direction: row; align-items: flex-end; bottom: calc(8px + var(--sa-b)); }
  .touch .potions { flex-direction: column; }
  .touch .skillbar { grid-template-columns: 52px 52px 70px; grid-template-rows: 52px 52px 70px; gap: 5px; }
  .touch .skill { width: 52px; height: 52px; font-size: 22px; }
  .touch .skill[data-slot="basic"] { width: 70px; height: 70px; font-size: 32px; }
  .touch .potion { width: 40px; height: 40px; font-size: 20px; }
  .joystick { width: 112px; height: 112px; bottom: calc(14px + var(--sa-b)); }
  .joy-knob { width: 50px; height: 50px; margin: -25px 0 0 -25px; }
  .touch .chat { top: calc(70px + var(--sa-t)); }
  .dialog { bottom: 8px; max-height: calc(100dvh - 16px); }
  .zone-banner { top: 16%; }
}

/* Botão contextual para falar com NPCs */
.talk-btn {
  position: absolute; z-index: 7; left: 50%; bottom: calc(max(14px, var(--sa-b, 0px)) + 96px); transform: translateX(-50%);
  padding: 12px 20px; border-radius: 16px; border: 2px solid var(--yellow-edge); background: var(--yellow); color: var(--ink);
  font: 800 16px/1.1 var(--font); box-shadow: 0 5px 0 var(--yellow-edge); cursor: pointer; white-space: nowrap;
  animation: talk-in .25s ease-out;
}
.talk-btn:active { transform: translateX(-50%) translateY(4px); box-shadow: 0 1px 0 var(--yellow-edge); }
@keyframes talk-in { from { opacity: 0; transform: translateX(-50%) translateY(10px); } }
@media (max-height: 460px) { .talk-btn { bottom: calc(max(10px, var(--sa-b, 0px)) + 74px); padding: 10px 16px; font-size: 15px; } }

/* Recolha de item de missão bem visível */
.collect-flash {
  position: absolute; z-index: 9; left: 50%; top: 22%; transform: translateX(-50%);
  display: grid; justify-items: center; gap: 4px; padding: 12px 20px; border-radius: 18px;
  background: #fff; border: 3px solid var(--yellow); box-shadow: 0 6px 0 var(--yellow-edge), 0 16px 30px -12px rgba(23,21,59,.5);
  pointer-events: none; animation: collect-pop 1.9s ease forwards;
}
.collect-flash strong { font: 800 clamp(16px, 2.6vw, 22px)/1.2 var(--display); color: var(--ink); white-space: nowrap; }
.collect-flash span { font: 700 14px/1.3 var(--font); color: var(--mint-edge); }
@keyframes collect-pop {
  0% { opacity: 0; transform: translateX(-50%) scale(.6); }
  12% { opacity: 1; transform: translateX(-50%) scale(1.08); }
  20% { transform: translateX(-50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-16px); }
}
#quest-tracker.pulse { animation: qt-pulse .7s ease; }
@keyframes qt-pulse { 0% { transform: scale(1); } 35% { transform: scale(1.08); box-shadow: 0 0 0 4px var(--yellow); } 100% { transform: scale(1); } }

/* Dica de controlos no PC (primeira vez) */
.controls-hint {
  position: absolute; z-index: 9; left: 50%; bottom: 120px; transform: translateX(-50%);
  width: min(560px, calc(100vw - 32px)); display: grid; gap: 8px; justify-items: start;
  padding: 16px 18px; border-radius: 18px; background: #fff; color: var(--ink);
  border: 2px solid var(--line); box-shadow: 0 6px 0 var(--blue), 0 18px 34px -14px rgba(23,21,59,.5);
  animation: talk-in .3s ease-out;
}
.controls-hint strong { font: 800 17px/1.2 var(--display); }
.controls-hint p { margin: 0; font: 500 14.5px/1.7 var(--font); color: var(--ink-2); }
.controls-hint kbd, .menu-help kbd {
  display: inline-block; min-width: 22px; padding: 0 6px; margin: 0 1px; border-radius: 6px; text-align: center;
  font: 700 12px/1.6 var(--font); color: var(--ink); background: #fff; border: 2px solid var(--line-strong); box-shadow: 0 2px 0 var(--line-strong);
}

/* Menu: secção de som e disposição compacta em ecrãs baixos (sem scroll) */
.menu-sound { display: grid; gap: 6px; padding: 8px 10px; border-radius: 14px; background: var(--surface-2); }
.menu-sound > b { font: 800 13px/1.2 var(--display); color: var(--ink-2); }
.sound-settings { display: grid; gap: 6px; }
.ss-row { display: grid; grid-template-columns: 62px minmax(0, 1fr) 70px auto; gap: 8px; align-items: center; font: 700 13px/1.2 var(--font); color: var(--ink); }
.ss-row input[type=range] { width: 100%; accent-color: var(--blue); padding: 0; border: 0; min-width: 0; }
.ss-val { font-size: 12px; color: var(--muted); text-align: right; }
.ss-mute { padding: 5px 9px !important; font-size: 12px !important; }
@media (pointer: coarse) { .menu-help { display: none; } }
html.touch .menu-help { display: none; }
@media (max-height: 460px) {
  .menu { top: calc(10px + var(--sa-t)); width: min(640px, 94vw); grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px; }
  .menu .menu-sound, .menu .menu-help { grid-column: 1 / -1; }
  .menu .btn.block { padding-block: 9px; }
}

/* ───────── Mundo grande ───────── */
.mount-btn { align-self: flex-end; font-size: 22px; }
.mount-btn.on { background: var(--yellow); box-shadow: 0 4px 0 var(--yellow-edge); }
.cabin-btn { background: var(--mint) !important; border-color: var(--mint-edge) !important; color: #fff !important; box-shadow: 0 5px 0 var(--mint-edge) !important; }
.lbl.is-cabin .nm { color: #fff; background: rgba(23,21,59,.55); padding: 2px 8px; border-radius: 8px; font-size: 11px; }
.lbl.is-cabin.known .nm { background: var(--mint-edge); }
.lbl.rival .nm { text-decoration: underline dotted; text-underline-offset: 3px; }

/* secções extra no diálogo do NPC */
.dlg-sec { display: grid; gap: 6px; }
.dlg-sec h4 { margin: 4px 0 0; font: 800 14px/1.2 var(--display); color: var(--ink-2); }
.shop-item .req { color: var(--pink-edge) !important; font-weight: 700; }
.wui-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 10px; align-items: center; width: 100%; text-align: left;
  padding: 9px 12px; border-radius: 14px; border: 2px solid var(--line); background: #fff; font: inherit; color: var(--ink); cursor: pointer; }
.wui-row:hover:not(:disabled) { border-color: var(--blue); }
.wui-row:disabled { opacity: .5; cursor: not-allowed; }
.wui-row .ic { font-size: 22px; text-align: center; }
.wui-row b { display: block; font-size: 15px; }
.wui-row small { display: block; font-size: 12.5px; color: var(--muted); }
.wui-row .price { font-weight: 800; white-space: nowrap; }

/* camada de painéis (cabines, facção, viagem, mapa) */
.wui-layer { position: absolute; inset: 0; z-index: 12; display: grid; place-items: center; padding: max(10px, var(--sa-t)) max(10px, var(--sa-r)) max(10px, var(--sa-b)) max(10px, var(--sa-l));
  background: rgba(23,21,59,.35); }
.wui-panel { width: min(460px, 100%); max-height: 100%; overflow: auto; overscroll-behavior: contain; display: grid; gap: 10px; align-content: start;
  background: #fff; border-radius: 22px; padding: 16px 18px; box-shadow: 0 8px 0 rgba(23,21,59,.25); }
.wui-panel.wide { width: min(760px, 100%); }
.wui-panel.map { width: min(1100px, 100%); height: 100%; max-height: 100%; grid-template-rows: auto minmax(0, 1fr) auto auto; }
.wui-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wui-head h3 { margin: 0; font-size: clamp(17px, 2.2vw, 22px); }
.wui-close { width: 36px; height: 36px; border-radius: 12px; border: 2px solid var(--line); background: #fff; font-size: 16px; cursor: pointer; flex: none; }
.wui-list { display: grid; gap: 8px; }
.wui-panel .muted { margin: 0; font-size: 14px; }

/* escolha de facção */
.fac-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fac-card { --fc: var(--blue); display: grid; gap: 6px; justify-items: center; text-align: center; padding: 16px 12px; border-radius: 20px;
  border: 3px solid var(--fc); background: color-mix(in srgb, var(--fc) 10%, #fff); box-shadow: 0 6px 0 var(--fc); cursor: pointer; font: inherit; color: var(--ink); }
.fac-card:hover, .fac-card.hl { background: color-mix(in srgb, var(--fc) 20%, #fff); }
.fac-card:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--fc); }
.fac-emblem { font-size: clamp(34px, 6vh, 52px); }
.fac-card b { font: 800 clamp(15px, 2vw, 19px)/1.2 var(--display); }
.fac-card .motto { font-size: 14px; color: var(--ink-2); font-style: italic; }
.fac-card small { color: var(--muted); font-weight: 700; }
@media (max-width: 520px) { .fac-cards { grid-template-columns: 1fr; } }

/* viagem */
.travel-box { width: min(420px, 100%); display: grid; gap: 10px; justify-items: center; text-align: center; background: #fff; border-radius: 24px; padding: 22px; box-shadow: 0 8px 0 rgba(23,21,59,.25); }
.travel-art { font-size: 64px; animation: travel-bob 1.2s ease-in-out infinite; }
.travel-box.ferry .travel-art { animation-name: travel-sway; }
@keyframes travel-bob { 50% { transform: translateY(-10px); } }
@keyframes travel-sway { 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }
.travel-title { font: 800 20px/1.2 var(--display); }
.travel-sub { margin: 0; color: var(--ink-2); min-height: 1.4em; }
.travel-bar { width: 100%; height: 12px; border-radius: 8px; background: var(--surface-2); overflow: hidden; }
.travel-bar i { display: block; height: 100%; width: 0; background: var(--blue); transition: width .15s linear; }

/* mapa do mundo */
.map-conts { display: grid; grid-template-columns: 1.7fr 1fr; gap: 12px; min-height: 0; }
.map-cont { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 6px; min-height: 0; padding: 10px; border-radius: 18px; background: #e8f4ff; }
.map-cont:nth-child(2) { background: #fff4e0; }
.map-cont h4 { margin: 0; font: 800 13px/1.2 var(--display); color: var(--ink-2); }
.map-grid { display: grid; gap: 6px; min-height: 0; align-content: center; }
.map-zone { --zc: #cfd6ff; --zb: transparent; display: grid; gap: 1px; align-content: center; padding: 6px 7px; min-width: 0; min-height: 44px; border-radius: 12px;
  border: 2px solid rgba(23,21,59,.12); border-left: 5px solid var(--zb); background: var(--zc); color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.map-zone b { font: 800 12px/1.15 var(--font); overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; hyphens: auto; }
.map-zone span, .map-zone small { font-size: var(--fs-3xs); line-height: 1.2; color: var(--ink-2); overflow: hidden;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.map-zone em { font-style: normal; font-size: var(--fs-3xs); font-weight: 800; color: var(--blue); }
.map-zone em.tg { color: var(--pink-edge); }
.map-zone.here { outline: 3px solid var(--blue); outline-offset: 1px; }
.map-zone.target { box-shadow: 0 0 0 3px var(--yellow); }
.map-zone.locked { opacity: .6; }
.map-info { display: grid; gap: 2px; padding: 8px 12px; border-radius: 14px; background: var(--surface-2); font-size: 13.5px; min-height: 44px; }
.map-legend { font-size: 12px !important; }
@media (max-width: 760px), (max-height: 460px) {
  .map-conts { grid-template-columns: 1.5fr 1fr; gap: 8px; }
  .map-zone { min-height: 34px; padding: 3px 4px; }
  .map-grid { gap: 4px; }
  .map-zone small { display: none; }
  .map-zone span { font-size: 10px; }
  .map-zone b { font-size: 10px; letter-spacing: -.2px; -webkit-line-clamp: 2; line-clamp: 2; }
  .map-zone.here span, .map-zone.target span { display: none; }
  .map-legend { display: none; }
  .wui-panel { padding: 12px; gap: 8px; }
}
@media (max-width: 520px) and (orientation: portrait) { .map-conts { grid-template-columns: 1fr; } }

/* ───────────── PvP (fase 3) ───────────── */
/* títulos de rank por cima do nome; inimigos atacáveis bem marcados */
.lbl .nm[data-rt]:not([data-rt=""])::before { content: attr(data-rt); display: block; font: 700 10px/1.2 var(--font); color: var(--yellow); opacity: .95; }
.lbl.hostile .nm { color: #ff4d6d; font-weight: 800; }
.lbl.hostile .nm::after { content: " ⚔️"; }
.lbl.is-flag .hpb, .lbl.is-flag.dropped .hpb { display: none; }
.lbl.is-flag .nm { background: var(--ink); padding: 3px 8px; border-radius: 9px; text-shadow: none; }
.lbl.is-flag.dropped .nm { background: var(--pink); }
.lbl.is-tower .nm { background: rgba(23,21,59,.82); padding: 3px 8px; border-radius: 9px; text-shadow: none; }
.lbl.is-tower .hpb { width: 110px; height: 8px; }
.pop.honor { color: #ffd24a; }

/* indicador da zona (disputada / tréguas / PvP total) */
.pvp-chip { position: absolute; z-index: 5; top: calc(max(10px, var(--sa-t, 0px)) + 58px); left: 50%; transform: translateX(-50%);
  padding: 5px 12px; border-radius: 999px; font: 800 13px/1.2 var(--font); background: #fff; color: var(--ink); box-shadow: 0 3px 0 rgba(23,21,59,.2); pointer-events: none; white-space: nowrap; }
.pvp-chip.contested { background: #ffe1e6; color: #b3123a; }
.pvp-chip.truce { background: #dff7ec; color: #0b7a55; }
.pvp-chip.pvp { background: #ff4d6d; color: #fff; }
.pvp-buff { position: absolute; z-index: 5; top: calc(max(10px, var(--sa-t, 0px)) + 88px); left: 50%; transform: translateX(-50%);
  padding: 4px 10px; border-radius: 10px; background: rgba(23,21,59,.82); color: #fff; font: 700 12px/1.2 var(--font); pointer-events: none; white-space: nowrap; }

/* fila do battleground (pílula) */
.pvp-queue { position: absolute; z-index: 6; left: 50%; bottom: calc(max(10px, var(--sa-b, 0px)) + 150px); transform: translateX(-50%);
  border: 0; border-radius: 999px; padding: 8px 14px; background: var(--ink); color: #fff; font: 800 13px/1 var(--font); cursor: pointer; box-shadow: 0 4px 0 rgba(0,0,0,.25); }
.pvp-queue.starting { background: var(--pink); animation: pvp-pulse .9s ease-in-out infinite; }
@keyframes pvp-pulse { 50% { transform: translateX(-50%) scale(1.06); } }

/* placar do battleground */
.pvp-board { position: absolute; z-index: 6; top: calc(max(8px, var(--sa-t, 0px)) + 56px); left: 50%; transform: translateX(-50%);
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: stretch; pointer-events: none; }
.pb-side { display: grid; justify-items: center; gap: 1px; min-width: 110px; padding: 6px 12px; border-radius: 14px; background: #fff; box-shadow: 0 4px 0 var(--ca); }
.pb-side:last-child { box-shadow: 0 4px 0 var(--cb); }
.pb-side.mine { outline: 3px solid var(--yellow); }
.pb-fac { font: 700 12px/1.2 var(--font); color: var(--muted); white-space: nowrap; }
.pb-caps { font: 800 26px/1 var(--display); }
.pb-side small, .pb-time small { font: 700 11px/1.2 var(--font); color: var(--muted); white-space: nowrap; }
.pb-time { display: grid; justify-items: center; align-content: center; padding: 6px 10px; border-radius: 14px; background: var(--ink); color: #fff; }
.pb-time b { font: 800 18px/1 var(--display); }
.pb-time small { color: #c9c6ee; }

/* seta para o objetivo */
.pvp-arrow { position: absolute; z-index: 5; left: 0; top: 0; display: grid; justify-items: center; gap: 2px; pointer-events: none; }
.pvp-arrow .pa-ic { font-size: 30px; color: var(--pink); text-shadow: 0 2px 0 #fff, 0 0 8px rgba(255,79,154,.8); line-height: 1; }
.pvp-arrow .pa-txt { font: 800 12px/1.2 var(--font); color: #fff; background: rgba(23,21,59,.85); padding: 3px 8px; border-radius: 8px; white-space: nowrap; }

/* feed de abates */
.pvp-feed { position: absolute; z-index: 5; left: max(10px, var(--sa-l, 0px)); top: calc(max(10px, var(--sa-t, 0px)) + 150px); display: grid; gap: 4px; pointer-events: none; max-width: min(360px, 45vw); }
.pf-item { padding: 5px 10px; border-radius: 10px; background: rgba(23,21,59,.82); color: #fff; font: 700 12.5px/1.25 var(--font); transition: opacity .8s; }
.pf-item.good { border-left: 4px solid var(--mint); }
.pf-item.bad { border-left: 4px solid var(--pink); }
.pf-item.mine { border-left: 4px solid var(--yellow); }
.pf-item.fade { opacity: 0; }

/* celebração (promoção / reputação) */
.pvp-celebrate { position: absolute; z-index: 9; left: 50%; top: 24%; transform: translateX(-50%); display: grid; justify-items: center; gap: 4px;
  padding: 14px 22px; border-radius: 20px; background: #fff; border: 3px solid var(--yellow); box-shadow: 0 6px 0 var(--yellow-edge); pointer-events: none; animation: collect-pop 3.4s ease forwards; text-align: center; }
.pvp-celebrate strong { font: 800 clamp(18px, 3vw, 26px)/1.2 var(--display); }
.pvp-celebrate span { font: 700 15px/1.3 var(--font); color: var(--ink-2); }
.pvp-celebrate small { font: 700 12px/1 var(--font); color: var(--muted); }

/* painéis: battleground, fim de partida, perfil de guerra */
.pvp-panel .pvp-status { display: grid; gap: 4px; padding: 12px; border-radius: 14px; background: var(--surface-2); }
.pvp-panel .row { display: flex; gap: 8px; flex-wrap: wrap; }
.pvp-rewards { display: grid; gap: 4px; font: 600 13px/1.35 var(--font); color: var(--ink-2); }
.pvp-end.win { box-shadow: 0 8px 0 var(--mint); }
.pvp-end.lose { box-shadow: 0 8px 0 var(--pink); }
.pvp-rew-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pvp-rew-row .rw { display: grid; justify-items: center; padding: 10px; border-radius: 14px; background: var(--surface-2); }
.pvp-rew-row b { font: 800 20px/1.1 var(--display); }
.pvp-rew-row small { font: 700 12px/1.2 var(--font); color: var(--muted); }
.pvp-table-wrap { overflow: auto; max-height: 38vh; overscroll-behavior: contain; }
.pvp-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.pvp-table th { text-align: left; font-size: 12px; color: var(--muted); padding: 4px 6px; border-bottom: 1px solid var(--line); }
.pvp-table td { padding: 5px 6px; border-bottom: 1px solid var(--line); }
.pvp-table tr.mine td { background: #fff4d1; }
.wp-fac { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 16px; background: var(--surface-2); box-shadow: inset 5px 0 0 var(--fc); }
.wp-emoji { font-size: 34px; }
.wp-fac b { display: block; font: 800 clamp(17px, 2.2vw, 21px)/1.2 var(--display); }
.wp-fac small { display: block; font: 700 12.5px/1.3 var(--font); color: var(--muted); }
.wp-sec { display: grid; gap: 5px; }
.wp-line { display: flex; justify-content: space-between; font-weight: 700; font-size: 14.5px; }
.wp-bar { height: 12px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.wp-bar i { display: block; height: 100%; background: var(--yellow); border-radius: 99px; }
.wp-bar.rep i { background: var(--fc, var(--blue)); }
.wp-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.wp-stats span { display: grid; justify-items: center; padding: 8px; border-radius: 12px; background: var(--surface-2); }
.wp-stats b { font: 800 20px/1.1 var(--display); }
.wp-stats small { font: 700 12px/1.2 var(--font); color: var(--muted); }

@media (max-height: 460px) {
  .pvp-chip { top: calc(max(6px, var(--sa-t, 0px)) + 46px); font-size: 11.5px; padding: 3px 9px; }
  /* no telemóvel o bónus fica compacto, na mesma linha do aviso de PvP, para não tapar as etiquetas das torres */
  .pvp-buff { top: calc(max(6px, var(--sa-t, 0px)) + 46px); left: calc(50% + 58px); transform: none; font-size: 11px; padding: 3px 8px; }
  .pvp-buff .pb-long { display: none; }
  .pvp-board { top: calc(max(6px, var(--sa-t, 0px)) + 46px); gap: 5px; }
  .pb-side { min-width: 84px; padding: 3px 8px; }
  .pb-caps { font-size: 19px; }
  .pb-time b { font-size: 15px; }
  .pvp-feed { top: calc(max(6px, var(--sa-t, 0px)) + 110px); max-width: 38vw; }
  .pf-item { font-size: 11px; padding: 3px 8px; }
  .pvp-queue { bottom: calc(max(6px, var(--sa-b, 0px)) + 112px); }
  .pvp-panel .pvp-rewards { display: none; }
  .pvp-table-wrap { max-height: 30vh; }
  .wp-fac { padding: 8px; }
  .wp-emoji { font-size: 26px; }
}

/* ── Grupo (party.js) ── */
.party-frames { top: calc(104px + var(--sa-t)); left: calc(10px + var(--sa-l)); display: grid; gap: 4px; width: 210px; }
.pf { --pc: var(--blue); display: grid; grid-template-columns: 26px 1fr auto; grid-template-rows: auto 6px; column-gap: 6px; align-items: center;
  padding: 4px 8px 5px 5px; border-radius: 12px; background: rgba(255,255,255,.92); box-shadow: 0 3px 0 rgba(23,21,59,.16); border-left: 4px solid var(--pc); }
.pf-ic { grid-row: span 2; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-size: 16px; background: #eef0fb; }
.pf-name { font: 700 12.5px/1.2 var(--font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf-lvl { font: 700 11px/1 var(--font); color: var(--muted); }
.pf-bar { grid-column: 2 / span 2; height: 6px; border-radius: 3px; background: #e6e8f6; overflow: hidden; position: relative; }
.pf-bar i { position: absolute; inset: 0; background: var(--mint); transform-origin: left; transition: transform .2s; }
.pf.off { opacity: .55; } .pf.dead .pf-bar i { background: var(--pink); } .pf.far { opacity: .8; }
.party-panel { position: absolute; z-index: 20; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(420px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  overflow: auto; background: #fff; border-radius: 20px; padding: 14px 16px; box-shadow: 0 18px 50px -12px rgba(23,21,59,.5); display: grid; gap: 10px; }
.pp-list { display: grid; gap: 6px; }
.pp-row { display: grid; grid-template-columns: 26px 1fr auto auto; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 12px; background: #f3f4fb; }
.pp-row.off { opacity: .6; }
.pp-name { display: grid; } .pp-name small { color: var(--muted); font-size: 12px; }
.pp-invite { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.pp-invite input { padding: 8px 10px; border-radius: 10px; border: 2px solid #e2e4f3; font: inherit; }
.pp-tip { font-size: 12.5px; margin: 0; }
.party-invite { position: absolute; z-index: 22; left: 50%; top: calc(70px + var(--sa-t)); transform: translateX(-50%); background: #fff; border-radius: 16px;
  padding: 10px 14px; box-shadow: 0 6px 0 var(--blue), 0 16px 30px -12px rgba(23,21,59,.5); display: grid; gap: 8px; max-width: calc(100vw - 24px); }
.party-invite p { margin: 0; font-size: 14px; }
.party-ctx { position: absolute; z-index: 21; background: #fff; border-radius: 14px; padding: 8px 10px; display: grid; gap: 6px; box-shadow: 0 10px 26px -8px rgba(23,21,59,.5); }
.party-ctx b { font: 700 13px/1.2 var(--display); }
.menu-inst { display: grid; gap: 4px; padding: 6px 0; border-top: 1px solid #eceef8; }
.menu-inst p { margin: 0; font-size: 13px; }
.mi-row { display: flex; justify-content: space-between; gap: 8px; }
.mi-why { font-size: 12px; }
.touch .party-frames { top: calc(170px + var(--sa-t)); width: 170px; }
/* com o botão 👥 a fila do topo fica mais comprida: no telemóvel deitado encolhe e centra-se no espaço livre
   entre o quadro do jogador e a missão/minimapa */
@media (max-height: 500px) {
  .hud-buttons { left: calc(50% - 38px); gap: 3px; }
  .hud-buttons .round-btn { width: 33px; height: 33px; font-size: 15px; border-radius: 11px; }
}
@media (max-height: 460px) {
  .party-frames { top: calc(84px + var(--sa-t)); gap: 3px; width: 170px; }
  .touch .party-frames { top: calc(150px + var(--sa-t)); }
  .pf { padding: 3px 6px 4px 4px; } .pf-ic { width: 22px; height: 22px; font-size: 14px; }
}

/* ───────── Fase 4: impacto dos golpes (números) ───────── */
.num { animation: num-pop .95s cubic-bezier(.2,.9,.3,1) forwards; will-change: transform, opacity; }
.num.dealt { color: #fff; }
.num.other { font-size: 14px; color: #e8ecff; -webkit-text-stroke: 1.2px var(--ink); opacity: .85; }
.num.dot { font-size: 13px; color: #c9a6ff; }
.num.me-hurt { color: #ff4f5a; }
.num.crit { font-size: 30px; color: #ffb020; -webkit-text-stroke: 2px var(--ink); z-index: 2; animation: num-crit 1.15s cubic-bezier(.2,.9,.3,1) forwards; }
.num.crit.me-hurt { color: #ff2a3a; }
.num.heal { animation: float-up 1s ease-out forwards; }
@keyframes num-pop {
  0% { opacity: 0; transform: translate(-50%, 0) scale(.4); }
  12% { opacity: 1; transform: translate(calc(-50% + var(--dx, 0px) * .3), -22px) scale(1.28); }
  30% { transform: translate(calc(-50% + var(--dx, 0px) * .55), -34px) scale(1); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx, 0px)), -58px) scale(.9); }
}
@keyframes num-crit {
  0% { opacity: 0; transform: translate(-50%, 0) scale(.3) rotate(-8deg); }
  10% { opacity: 1; transform: translate(-50%, -26px) scale(1.65) rotate(6deg); }
  18% { transform: translate(calc(-50% + 4px), -30px) scale(1.25) rotate(-4deg); }
  26% { transform: translate(calc(-50% - 4px), -32px) scale(1.32) rotate(2deg); }
  42% { transform: translate(calc(-50% + var(--dx, 0px) * .4), -42px) scale(1.2) rotate(0); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx, 0px)), -72px) scale(1); }
}
/* aviso de perigo (mecânicas dos chefes) */
#game-screen.danger::after { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 8; box-shadow: inset 0 0 140px 30px rgba(255, 40, 60, .5); animation: danger 1.4s ease-out forwards; }
@keyframes danger { 0% { opacity: 0; } 15% { opacity: 1; } 100% { opacity: 0; } }
.raid-alert { position: absolute; z-index: 13; left: 50%; top: calc(64px + var(--sa-t)); transform: translateX(-50%); max-width: min(640px, calc(100vw - 24px));
  padding: 10px 18px; border-radius: 16px; text-align: center; font: 800 clamp(15px, 2.2vw, 20px)/1.25 var(--display); color: #fff; pointer-events: none;
  background: rgba(229, 36, 94, .92); box-shadow: 0 6px 0 rgba(120, 10, 40, .6), 0 16px 30px -12px rgba(23,21,59,.6); }
.raid-alert.info { background: rgba(51, 85, 255, .92); box-shadow: 0 6px 0 rgba(20, 30, 120, .6); }
.raid-alert.good { background: rgba(25, 195, 156, .95); box-shadow: 0 6px 0 rgba(10, 90, 70, .6); }
.raid-alert.show { animation: alert-in .35s cubic-bezier(.2,1.6,.4,1); }
@keyframes alert-in { from { opacity: 0; transform: translateX(-50%) scale(.7); } }

/* ───────── Fase 4: botões e barras ───────── */
.life-btn { background: var(--mint) !important; border-color: var(--mint-edge) !important; color: #fff !important; box-shadow: 0 5px 0 var(--mint-edge) !important; }
.life-btn.stacked { bottom: calc(max(14px, var(--sa-b, 0px)) + 150px); }
@media (max-height: 460px) { .life-btn.stacked { bottom: calc(max(10px, var(--sa-b, 0px)) + 122px); } }
.cast-bar { position: absolute; z-index: 7; left: 50%; bottom: calc(max(14px, var(--sa-b, 0px)) + 206px); transform: translateX(-50%); width: min(260px, 70vw);
  display: grid; gap: 4px; justify-items: center; pointer-events: none; }
.cast-bar span { font: 800 13px/1.2 var(--font); color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.7); }
.cast-bar::before { content: ""; grid-area: 2 / 1; width: 100%; height: 12px; border-radius: 6px; background: rgba(23,21,59,.55); }
.cast-bar i { grid-area: 2 / 1; width: 100%; height: 12px; border-radius: 6px; background: linear-gradient(90deg, #3bd26a, #9cff7a); transform-origin: left; transform: scaleX(0); }
.event-btn { background: #eafff3; }
.life-buffs { grid-column: 1 / -1; display: flex; gap: 4px; flex-wrap: wrap; min-height: 0; }
.life-buffs:empty { display: none; }
.life-buffs .lb { display: inline-flex; align-items: center; gap: 2px; padding: 1px 6px; border-radius: 10px; background: rgba(255,255,255,.85); font-size: 14px; }
.life-buffs .lb small { font: 700 11px/1 var(--font); color: var(--ink-2); }

/* etiquetas no mundo */
.lbl.is-node .nm { font-size: 11px; color: #fff; background: rgba(40, 110, 60, .75); padding: 2px 7px; border-radius: 8px; }
.lbl.is-node.empty .nm { background: rgba(80, 80, 90, .6); }
.lbl.is-node.far { display: none !important; }
.lbl.is-node .hpb, .lbl.is-node .st { display: none; }
.lbl.is-station .nm { font-size: 11px; color: #fff; background: rgba(255, 120, 30, .85); padding: 2px 8px; border-radius: 8px; }
.lbl.is-station.natal .nm { background: rgba(30, 140, 80, .85); }
.lbl.is-slot .nm { font-size: 11px; color: var(--ink); background: rgba(255, 255, 255, .8); border: 1px dashed var(--ink-2); padding: 1px 6px; border-radius: 8px; }

/* ───────── Fase 4: painel da mochila (sem scroll: páginas) ───────── */
.life-panel { height: min(640px, 100%); overflow: hidden; grid-template-rows: auto minmax(0, 1fr); }
.life-tabs { display: flex; gap: 4px; flex-wrap: wrap; min-width: 0; }
.life-tab { display: inline-flex; align-items: center; gap: 5px; padding: 7px 10px; border-radius: 12px; border: 2px solid var(--line); background: #fff; font: 700 13px/1 var(--font); color: var(--ink); cursor: pointer; }
.life-tab span { font-size: 17px; }
.life-tab.on { background: var(--yellow); border-color: var(--yellow-edge); }
.life-body { display: flex; flex-direction: column; gap: 8px; min-height: 0; overflow: hidden; }
.life-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.life-row p { margin: 2px 0 0; }
.chip { display: inline-flex; align-items: center; gap: 2px; padding: 4px 9px; border-radius: 12px; background: var(--surface-2); font: 600 13px/1.2 var(--font); }
.chip.food { background: #eafff3; }
.life-grid { display: grid; gap: 6px; align-content: start; }
.life-tile { position: relative; display: grid; place-items: center; aspect-ratio: 1; min-height: 52px; max-height: 70px; border-radius: 14px; border: 2px solid var(--line);
  background: #fff; cursor: pointer; padding: 2px; font: inherit; color: var(--ink); }
.life-tile .ic { font-size: 26px; line-height: 1; }
.life-tile .qty { position: absolute; right: 4px; bottom: 2px; font: 800 12px/1 var(--font); color: var(--ink); }
.life-tile.on { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(51,85,255,.2); }
.life-tile.dish { background: #fff8ea; }
.life-tile.pet.locked { background: #f1f2f8; opacity: .7; }
.life-tile.pet.active { border-color: var(--yellow-edge); background: #fff6d6; }
.life-tile.slot { aspect-ratio: auto; min-height: 58px; grid-template-rows: auto auto; gap: 2px; }
.life-tile.slot small { font: 600 10.5px/1.1 var(--font); color: var(--ink-2); text-align: center; }
.life-tile.slot.empty .ic { color: var(--muted); }
.life-tile:disabled { cursor: default; }
.life-detail { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 14px; background: var(--surface-2); }
.life-detail > .ic { font-size: 30px; text-align: center; }
.life-detail p { margin: 2px 0 0; font-size: 13px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.life-detail .acts { display: flex; gap: 6px; }
.life-pager { display: flex; gap: 8px; align-items: center; justify-content: center; font: 700 13px/1 var(--font); }
.prof-bars { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.prof-bar { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 6px 10px; border-radius: 14px; background: var(--surface-2); }
.prof-bar .ic { font-size: 22px; }
.prof-bar b { font-size: 13px; }
.prof-bar .bar { height: 8px; margin-top: 3px; }
.prof-bar .bar i { background: var(--mint); }
.prof-bar small { font: 700 11px/1 var(--font); color: var(--muted); }
.life-hint { margin: 0; font-size: 13px; }
.life-hint.ok { color: var(--mint-edge); font-weight: 700; }
.recipe-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.recipe { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 12px; border: 2px solid var(--line); background: #fff; }
.recipe.ready { border-color: #9be6c4; }
.recipe .ic { font-size: 24px; text-align: center; }
.recipe b { font-size: 13px; line-height: 1.2; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.recipe small { font-size: var(--fs-3xs); color: var(--muted); line-height: 1.2;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.recipe .ings { display: flex; gap: 6px; font: 700 12px/1.3 var(--font); }
.recipe .ings .ok { color: var(--mint-edge); }
.recipe .ings .no { color: var(--pink-edge); }
.recipe .acts { display: grid; gap: 4px; }
.recipe .acts .btn { padding: 5px 9px; font-size: var(--fs-2xs); }
.life-empty { display: grid; justify-items: center; gap: 6px; text-align: center; padding: 10px; }
.big-ic { font-size: 40px; line-height: 1; }
.ev-quests { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ev-q { display: flex; justify-content: space-between; gap: 6px; padding: 6px 10px; border-radius: 12px; background: var(--surface-2); font-size: 13px; }
.ev-q span { color: var(--muted); font-weight: 700; }
.ev-q.ready span, .ev-q.available span { color: var(--mint-edge); }
@media (max-width: 620px) {
  .life-tab b { display: none; }
  .recipe-list, .ev-quests { grid-template-columns: 1fr; }
  .prof-bars { grid-template-columns: 1fr; }
}
@media (max-height: 460px) {
  .life-panel { padding: 10px 12px; gap: 6px; }
  .life-tab { padding: 5px 8px; }
  .life-tab b { display: none; }
  .life-body { gap: 5px; }
  .life-tile { min-height: 44px; max-height: 52px; }
  .life-tile .ic { font-size: 22px; }
  .recipe-list { grid-template-columns: 1fr 1fr; }
  .prof-bars { grid-template-columns: 1fr 1fr; }
  .life-detail { padding: 5px 8px; }
  .raid-alert { top: calc(48px + var(--sa-t)); padding: 6px 12px; }
  .cast-bar { bottom: calc(max(10px, var(--sa-b, 0px)) + 170px); }
}

/* ───────── Mapa do mundo calculado pelos portais ───────── */
.map-grid { position: relative; gap: 0 !important; }
.map-grid > .map-zone { position: relative; z-index: 1; margin: 3px; }
.map-links { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; overflow: visible; }
.map-links line { stroke: rgba(23, 21, 59, .35); stroke-width: 5; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.map-links line.door { stroke: rgba(123, 92, 255, .55); stroke-dasharray: 6 6; }
.map-zone.dungeon { border-style: dashed; }
.map-cont h4 { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.map-ferry { font: 700 11px/1.2 var(--font); color: var(--blue); }
.map-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.map-insts { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.map-inst { padding: 4px 9px; border-radius: 10px; border: 2px solid var(--line); background: #fff; font: 700 12px/1.1 var(--font); cursor: pointer; color: var(--ink); }
@media (max-width: 760px), (max-height: 460px) {
  .map-grid > .map-zone { margin: 2px; }
  .map-ferry { display: none; }
  .map-foot .map-legend { display: none; }
}
@media (max-height: 460px) { .map-grid > .map-zone { min-height: 0; overflow: hidden; padding: 2px 4px; } }

/* Telemóvel ao alto (auditoria de layout): botões do topo numa grelha de 2 colunas por baixo do minimapa
   e a missão seguida ao lado deles — nada sai do ecrã nem fica por cima dos poderes. */
@media (max-width: 760px) and (orientation: portrait) {
  .hud-buttons { display: grid; grid-template-columns: repeat(2, 38px); gap: 5px; right: calc(10px + var(--sa-r)); top: calc(160px + var(--sa-t)); }
  .hud-buttons .round-btn { width: 38px; height: 38px; font-size: 17px; border-radius: 12px; }
  .quest-tracker { position: fixed; right: calc(100px + var(--sa-r)); top: calc(160px + var(--sa-t)); width: min(190px, calc(100vw - 118px)); }
  .quest-tracker .qt-item:not(:first-child) { display: none; }
  .menu { top: calc(90px + var(--sa-t)); max-height: calc(100dvh - 110px - var(--sa-t)); overflow-y: auto; }
}
