/* =============================================================
   BASE: cores, letras, botões, janelas, ícones
   Jogo com um só visual (noite na arena, dourado e azul).
   ============================================================= */
:root {
  /* layout: cena 3D a ecrã inteiro, interface em vidro por cima */
  --ink: #0d1124;
  --panel: rgba(16, 20, 44, 0.84);
  --panel-2: rgba(30, 36, 76, 0.92);
  --line: rgba(255, 255, 255, 0.13);
  --text: #f8f4ea;
  --muted: #aab1d8;
  --gold: #ffd04d;
  --gold-2: #ff9a1f;
  --blue: #3d8bff;
  --green: #36cf6c;
  --red: #ff4d6a;
  --display: 'Lilita One', 'Arial Rounded MT Bold', 'Trebuchet MS', system-ui, sans-serif;
  --body: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  --r: 16px;
  color-scheme: dark;
}

html, body { height: 100%; }
body {
  margin: 0; background: var(--ink); color: var(--text);
  font-family: var(--body); font-weight: 700; font-size: 15px;
  overflow: hidden; overscroll-behavior: none; touch-action: none;
  -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
}
[hidden] { display: none !important; }
#app { position: fixed; inset: 0; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { cursor: default; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
h1, h2, h3, h4, h5 { font-family: var(--display); font-weight: 400; margin: 0; letter-spacing: 0.01em; text-wrap: balance; }
p { margin: 0; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.4; }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.mi { display: inline-flex; }

/* ---------- cena 3D ---------- */
#stage3d { position: fixed; inset: 0; }
#board { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
#flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; mix-blend-mode: screen; }
body:not([data-screen="game"]) #labels { display: none; }
#mini { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 70; }

/* Interface: o tamanho de um telemóvel, ampliado por igual (js/ui/ui.js → MB.UI.fit).
   É o "contentor" das regras @container app (…) e das unidades cqw/cqh. */
#ui {
  position: fixed; left: 0; top: 0; z-index: 10;
  width: var(--uiw, 100vw); height: var(--uih, 100vh);
  transform: scale(var(--uis, 1)); transform-origin: 0 0;
  container: app / size;
  pointer-events: none;
}
#ui > :not(.hud) { pointer-events: auto; }
#ui > .toast { pointer-events: none; }
.screen { position: fixed; inset: 0; z-index: 10; }

/* ---------- botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 14px; font-weight: 900; font-size: 15px; letter-spacing: 0.01em;
  background: rgba(255, 255, 255, 0.08); border: 1px solid var(--line); color: var(--text);
  transition: transform 0.08s, filter 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.btn:active:not(:disabled) { transform: translateY(2px); }
.btn:disabled { opacity: 0.4; filter: saturate(0.4); }
.btn.primary { background: linear-gradient(180deg, #ffe07a, var(--gold) 45%, var(--gold-2)); color: #3a2200; border: 0; box-shadow: 0 4px 0 #b86a00, 0 8px 22px rgba(255, 160, 30, 0.28); }
.btn.primary:active:not(:disabled) { box-shadow: 0 1px 0 #b86a00; }
.btn.sec { background: linear-gradient(180deg, #6aa8ff, var(--blue)); border: 0; box-shadow: 0 4px 0 #1f4fb0; color: #fff; }
.btn.danger { background: linear-gradient(180deg, #ff7a8e, var(--red)); border: 0; box-shadow: 0 4px 0 #a8203a; color: #fff; }
.btn.ok { background: linear-gradient(180deg, #6fe597, var(--green)); border: 0; box-shadow: 0 4px 0 #1d8a45; color: #08301a; }
.btn.ghost { background: rgba(255, 255, 255, 0.07); }
.btn.big { padding: 15px 26px; font-size: 18px; border-radius: 18px; font-family: var(--display); font-weight: 400; letter-spacing: 0.02em; }
.btn.sm { padding: 7px 11px; font-size: 13px; border-radius: 11px; }
.btn.wide { width: 100%; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 14px; display: inline-grid; place-items: center; flex: none;
  background: rgba(14, 18, 40, 0.72); border: 1px solid var(--line);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.icon-btn .ic { width: 21px; height: 21px; }
.icon-btn:active { transform: scale(0.94); }

.type-chip {
  display: inline-flex; align-items: center; gap: 5px; vertical-align: middle;
  font-size: 11.5px; font-weight: 900; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 2px 9px 1px; border-radius: 99px;
  background: color-mix(in srgb, var(--tc) 22%, transparent); color: var(--tc);
  border: 1px solid color-mix(in srgb, var(--tc) 50%, transparent);
}
.type-chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--tc); box-shadow: 0 0 6px var(--tc); }
.chip { display: inline-block; padding: 4px 12px; border-radius: 99px; background: rgba(255, 255, 255, 0.1); font-family: var(--body); font-weight: 800; font-size: 13px; }

.field {
  width: 100%; box-sizing: border-box; padding: 14px 16px; border-radius: 14px;
  background: rgba(0, 0, 0, 0.35); border: 2px solid var(--line); color: var(--text);
  font: 800 18px var(--body); user-select: text; -webkit-user-select: text;
}
.field:focus { border-color: var(--gold); outline: none; }
.field.code { font-family: var(--display); font-size: 30px; letter-spacing: 0.25em; text-align: center; text-transform: uppercase; }
.shake { animation: shake 0.35s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { padding: 8px 12px; border-radius: 11px; background: rgba(255, 255, 255, 0.07); border: 1px solid var(--line); font-weight: 800; font-size: 13px; }
.seg button[aria-pressed="true"] { background: var(--gold); color: #3a2200; border-color: transparent; }
.seg button:disabled:not([aria-pressed="true"]) { opacity: 0.45; }

.row-end { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }

/* ---------- janelas ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: rgba(6, 8, 20, 0.6); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  padding: max(12px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) max(12px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
}
.overlay.solid { background: radial-gradient(80% 70% at 50% 35%, rgba(52, 40, 120, 0.92), rgba(8, 10, 24, 0.97)); }
.modal {
  width: min(440px, 100%); max-height: 100%; overflow: auto; box-sizing: border-box;
  background: linear-gradient(180deg, rgba(34, 40, 84, 0.97), rgba(18, 22, 48, 0.97));
  border: 1px solid var(--line); border-radius: 22px; padding: 18px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  animation: pop 0.22s ease-out;
}
.modal.wide { width: min(760px, 100%); }
.modal h3 { font-size: 24px; }
.modal p { color: #dcd8f0; line-height: 1.45; margin-top: 8px; font-weight: 700; }
.mh { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.mh h3 { flex: 1; }
.mh .count { font-weight: 900; color: var(--gold); }
@keyframes pop { from { transform: translateY(16px) scale(0.97); opacity: 0; } }
.menu-list { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.rules { margin: 14px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; color: #dcd8f0; font-size: 14px; line-height: 1.4; }

.toast {
  position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom, 0px)); z-index: 80; transform: translate(-50%, 30px);
  background: rgba(14, 18, 40, 0.94); border: 1px solid var(--line); padding: 10px 18px; border-radius: 14px; font-weight: 800;
  opacity: 0; pointer-events: none; transition: 0.25s; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

#loading { z-index: 90; }
.loader { display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; max-width: 420px; padding: 20px; }
.spin { width: 54px; height: 54px; border-radius: 50%; border: 5px solid rgba(255, 255, 255, 0.15); border-top-color: var(--gold); animation: rot 0.9s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }

/* dicas no loading (js/ui/dicas.js): as dicas ficam umas por cima das outras e rodam pela opacidade */
.dica {
  margin-top: 8px; box-sizing: border-box; width: 400px; max-width: calc(var(--uiw, 100vw) - 32px); padding: 10px 6px 12px; border-radius: 16px; cursor: pointer;
  background: rgba(14, 18, 40, 0.72); border: 1px solid var(--line); text-align: left; -webkit-tap-highlight-color: transparent; user-select: none;
}
.dica-cab { padding: 0 44px 4px; }
.dica-tit { font-size: 12px; font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold); }
.dica-corpo { display: flex; align-items: center; gap: 2px; }
.dica-seta { flex: none; width: 40px; height: 48px; display: grid; place-items: center; border: 0; border-radius: 12px; background: none; color: var(--muted); cursor: pointer; padding: 0; }
.dica-seta:active { background: rgba(255, 255, 255, 0.08); color: #fff; }
.dica-seta svg { width: 22px; height: 22px; }
.dica-slides { flex: 1; display: grid; min-width: 0; }
.dica-slide { grid-area: 1 / 1; display: flex; align-items: center; gap: 10px; opacity: 0; will-change: opacity; }
.dica-ic { flex: none; display: inline-flex; width: 26px; height: 26px; align-items: center; justify-content: center; color: var(--gold); }
.dica-ic svg { width: 22px; height: 22px; }
.dica-ic .type-ic { width: 26px; height: 26px; }
.dica-txt { margin: 0; font-size: 15px; font-weight: 700; line-height: 1.35; }
.dica-tp { font-weight: 900; }

/* ---------- linhas de stats e ataques (partilhadas) ---------- */
.ip-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 12px; }
.st { display: grid; grid-template-columns: 38px 1fr 22px; align-items: center; gap: 6px; font-size: 12px; font-weight: 900; }
.st span { color: var(--muted); letter-spacing: 0.04em; }
.st .sb { height: 6px; border-radius: 4px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.st .sb i { display: block; height: 100%; border-radius: 4px; background: var(--tc, var(--gold)); }
.st b { text-align: right; font-variant-numeric: tabular-nums; }
.st b.up { color: #8fd0ff; } .st b.down { color: #d6a2ff; }

.atk-row {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 8px 10px; border-radius: 14px; box-sizing: border-box;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); position: relative;
}
.atk-row:not(.static):active:not(:disabled) { transform: scale(0.98); }
.atk-row[aria-pressed="true"] { background: color-mix(in srgb, var(--gold) 18%, transparent); border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.atk-row:disabled { opacity: 0.45; }
.atk-ic {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; color: #fff;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--tc) 85%, #fff), var(--tc) 55%, color-mix(in srgb, var(--tc) 60%, #000));
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25), 0 0 0 2px var(--cc);
}
.atk-ic .ic { width: 23px; height: 23px; stroke-width: 2.1; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.4)); }
.atk-txt { flex: 1; min-width: 0; }
.atk-txt b { display: block; font-size: 14.5px; font-weight: 900; line-height: 1.15; }
.atk-txt small { display: block; font-size: 11.5px; color: var(--muted); font-weight: 800; line-height: 1.25; margin-top: 1px; }
.atk-txt p { font-size: 12.5px; color: #dcd8f0; margin-top: 4px; line-height: 1.35; font-weight: 700; }
.atk-row .cd { position: absolute; right: 8px; top: 8px; min-width: 22px; height: 22px; border-radius: 99px; background: #ff9a1f; color: #2a1200; display: grid; place-items: center; font-weight: 900; font-size: 12px; }
.atk-row .cdmax { font-size: 10.5px; color: var(--muted); font-weight: 800; align-self: flex-start; white-space: nowrap; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01s !important; transition-duration: 0.01s !important; } }

/* nível ("Nv 5") antes do nome de um domador ou monstro (MB.nvTag) */
.nv-tag { display: inline-block; flex: none; margin-right: 0.35em; padding: 0.12em 0.45em 0.08em; border-radius: 0.5em; font-family: inherit; font-size: 0.62em; font-weight: 900; line-height: 1.25; letter-spacing: 0.02em; vertical-align: 0.18em; white-space: nowrap;
  color: #2a1a00; background: linear-gradient(180deg, #ffe895, #f0b43a); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.6); text-shadow: none; }

/* ---------- reports dos jogadores (js/ui/report.js, docs/REPORTS.md) ----------
   O botão fica sempre na fila de cima, à direita; o "right" é acertado pelo
   código para se encostar à esquerda do que já lá estiver. --rps = escala da interface. */
.rp-btn {
  position: fixed; z-index: 85; box-sizing: border-box;
  top: calc(max(10px, env(safe-area-inset-top, 0px)) * var(--rps, 1));
  right: calc(max(10px, env(safe-area-inset-right, 0px)) * var(--rps, 1));
  width: calc(42px * var(--rps, 1)); height: calc(42px * var(--rps, 1)); border-radius: calc(14px * var(--rps, 1));
  display: grid; place-items: center; padding: 0; color: var(--text); cursor: pointer;
  background: rgba(14, 18, 40, 0.62); border: 1px solid var(--line);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  opacity: 0.82; transition: opacity 0.15s;   /* muda de sítio de uma vez: a deslizar passava por cima da cruz */
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.rp-btn[hidden] { display: none; }
.rp-btn .ic { width: calc(21px * var(--rps, 1)); height: calc(21px * var(--rps, 1)); fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.rp-btn:active { transform: scale(0.94); opacity: 1; }
/* a introdução do Mundo é um filme: sem botões por cima */
body.em-intro:not(.intro-andar) .rp-btn { display: none; }
.rp-ov { z-index: 86; }
.rp-win { width: min(520px, 100%); }
.rp-corpo { display: flex; gap: 12px; align-items: stretch; }
.rp-img { position: relative; flex: none; width: 38%; max-width: 190px; align-self: flex-start; padding: 0; border-radius: 14px; overflow: hidden; border: 2px solid var(--gold); background: #0b0e20; cursor: pointer; }
.rp-img[hidden] { display: none; }
.rp-img img { display: block; width: 100%; height: auto; }
.rp-visto { position: absolute; right: 6px; top: 6px; width: 24px; height: 24px; border-radius: 8px; display: grid; place-items: center; background: var(--gold); color: #3a2200; }
.rp-visto .ic { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.rp-img[aria-pressed="false"] { border-color: var(--line); }
.rp-img[aria-pressed="false"] img { opacity: 0.25; filter: grayscale(1); }
.rp-img[aria-pressed="false"] .rp-visto { background: rgba(255, 255, 255, 0.12); color: transparent; }
.rp-lado { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.rp-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.rp-tag { padding: 7px 12px; border-radius: 999px; font: 800 13px var(--body); color: var(--muted); background: rgba(255, 255, 255, 0.07); border: 1px solid var(--line); cursor: pointer; }
.rp-tag[aria-pressed="true"] { color: #3a2200; background: var(--gold); border-color: transparent; }
.rp-win textarea {
  flex: 1; width: 100%; min-height: 76px; box-sizing: border-box; resize: none; padding: 10px 12px; border-radius: 14px;
  font: 700 15px var(--body); color: var(--text); background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); outline: none;
  user-select: text; -webkit-user-select: text;
}
.rp-win textarea:focus { border-color: var(--gold); }
.rp-win textarea::placeholder { color: var(--muted); opacity: 0.8; }
.rp-fim { align-items: center; margin-top: 12px; }
.rp-n { margin-right: auto; color: var(--muted); font: 800 12px var(--body); }
.rp-priv { margin: 8px 0 0; color: var(--muted); font: 700 11.5px/1.35 var(--body); }
.rp-priv a { color: #9fb4ff; }
@media (max-width: 480px) { .rp-corpo { flex-direction: column; } .rp-img { width: 60%; align-self: center; } }
