/* Base: tokens, reset e tipografia. Mobile-first: tudo é pensado para toque. */
:root {
  --bg: #14110f;
  --bg-2: #1a1612;
  --surface: #221d17;
  --surface-2: #2b241c;
  --line: #3a3125;
  --text: #ece3d1;
  --muted: #a09481;
  --gold: #cfa95a;
  --gold-2: #e6c47e;
  --gold-ink: #241a08;
  --danger: #d0624c;
  --ok: #86b573;

  --radius: 14px;
  --radius-sm: 10px;
  --tap: 48px;

  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Noto Serif", Georgia, serif;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);

  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(120% 60% at 50% -10%, #2a2118 0%, rgba(42, 33, 24, 0) 60%),
    var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font-body);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior: none; /* evita puxar-para-recarregar sem querer */
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.2;
  margin: 0;
  letter-spacing: 0.01em;
}
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0; }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--gold-2);
  outline-offset: 2px;
}

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

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


/* Layout: a tela ocupa 100% da altura visível; só o miolo rola. */
#app {
  height: 100vh;
  height: 100dvh;
  max-width: 920px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding-left: var(--safe-l);
  padding-right: var(--safe-r);
}

.screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  animation: screen-in 0.18s ease-out;
}
@keyframes screen-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.screen__header {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(var(--safe-t) + 8px) 12px 8px;
  min-height: 56px;
}
.screen__header .grow { flex: 1; min-width: 0; }
.screen__title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.screen__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 8px 16px 20px;
}

.screen__footer {
  flex: none;
  display: flex;
  gap: 10px;
  padding: 10px 16px calc(var(--safe-b) + 10px);
  background: var(--bg-2);
  border-top: 1px solid var(--line);
}
.screen__footer > .btn { flex: 1 1 0; min-width: 0; padding: 0 12px; white-space: nowrap; }
.screen__footer > .btn--primary { flex-grow: 1.6; }

.stack { display: flex; flex-direction: column; gap: 12px; }
.stack--tight { gap: 8px; }
.stack--loose { gap: 20px; }
.row { display: flex; align-items: center; gap: 10px; }
.row--wrap { flex-wrap: wrap; }
.row--between { justify-content: space-between; }

/* ---------- Assistente de criação ---------- */
.wizard__main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.wizard__preview {
  flex: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 16px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
}
.wizard__preview .portrait { width: 64px; flex: none; }
.wizard__who { display: flex; flex-direction: column; min-width: 0; }
.wizard__who strong {
  font-family: var(--font-display);
  font-size: 1.1rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.progress { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; margin: 0 16px; }
.progress > span { display: block; height: 100%; background: var(--gold); transition: width 0.25s ease; }

/* ---------- Painel do herói (abas) ---------- */
.hub { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.hub__content { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tabbar {
  flex: none;
  display: flex;
  background: var(--bg-2);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}

/* ---------- Paisagem em celular (pouca altura) ---------- */
@media (orientation: landscape) and (max-height: 540px) {
  .screen__header { min-height: 48px; padding-top: calc(var(--safe-t) + 4px); padding-bottom: 4px; }
  .screen__body { padding-top: 4px; }
  .screen__footer { padding-top: 8px; padding-bottom: calc(var(--safe-b) + 8px); }

  /* Criação: retrato à esquerda, formulário à direita */
  .wizard__main { flex-direction: row; }
  .wizard__preview {
    flex-direction: column;
    justify-content: center;
    width: 190px;
    border-bottom: 0;
    border-right: 1px solid var(--line);
    padding: 8px 12px;
    text-align: center;
  }
  .wizard__preview .portrait { width: 110px; }
  .wizard__who { align-items: center; }
  .wizard__form { flex: 1; min-width: 0; }

  /* Painel do herói: abas viram uma coluna lateral */
  .hub { flex-direction: row-reverse; }
  .tabbar {
    flex-direction: column;
    width: 84px;
    border-top: 0;
    border-right: 1px solid var(--line);
    padding-bottom: 0;
  }
  .tabbar .tab { flex: 1; }

  /* (o layout do Início em paisagem fica em components.css, depois de .home__split) */
}

/* Telas largas (tablet/desktop): só centraliza, sem inventar layout novo */
@media (min-width: 700px) and (orientation: portrait) {
  .screen__body { padding-left: 24px; padding-right: 24px; }
}


/* Componentes. Alvos de toque >= 48px, sem depender de hover. */

/* ---------- Botões ---------- */
.btn {
  min-height: var(--tap);
  padding: 0 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  user-select: none;
  -webkit-user-select: none;
}
.btn:active { transform: scale(0.98); filter: brightness(1.1); }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.btn--primary {
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  border-color: #a98639;
  color: var(--gold-ink);
}
.btn--danger { color: var(--danger); border-color: rgba(208, 98, 76, 0.5); background: transparent; }
.btn--ghost { background: transparent; }
.btn--block { width: 100%; }
.btn--tall { min-height: 54px; font-size: 1.05rem; }

.icon-btn {
  width: var(--tap);
  height: var(--tap);
  flex: none;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: var(--text);
}
.icon-btn:active { background: var(--surface-2); }
.icon { display: block; flex: none; }

/* ---------- Cartões ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.card__title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
  margin-bottom: 10px;
  font-family: var(--font-body);
  font-weight: 700;
}
.empty {
  text-align: center;
  color: var(--muted);
  padding: 28px 12px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.notice {
  border: 1px solid rgba(208, 98, 76, 0.5);
  background: rgba(208, 98, 76, 0.08);
  color: #f0b8ab;
  border-radius: var(--radius);
  padding: 12px 14px;
}

/* ---------- Início ---------- */
.home__brand { text-align: center; padding: 18px 0 10px; }
.home__emblem { width: 88px; height: 88px; margin: 0 auto 10px; color: var(--gold); }
.home__brand h1 {
  font-size: 2.1rem;
  color: var(--gold-2);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.home__split { display: flex; flex-direction: column; gap: 8px; }

.campaign {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 4px 6px 6px;
}
.campaign__main {
  flex: 1;
  min-width: 0;
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  border: 0;
  text-align: left;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
}
.campaign__main:active { background: var(--surface-2); }
.campaign .portrait { width: 52px; flex: none; }
.campaign__text { display: flex; flex-direction: column; min-width: 0; }
.campaign__name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- Seleção (raças, classes, origens, opções) ---------- */
.choice { display: flex; flex-direction: column; gap: 8px; }
.choice--chips { flex-direction: row; flex-wrap: wrap; }
.choice__item {
  text-align: left;
  min-height: var(--tap);
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.choice__item[aria-checked="true"] {
  border-color: var(--gold);
  background: linear-gradient(180deg, rgba(207, 169, 90, 0.16), rgba(207, 169, 90, 0.06));
  box-shadow: inset 0 0 0 1px var(--gold);
}
.choice__label { font-weight: 600; }
.choice__desc { color: var(--muted); font-size: 0.9rem; }
.choice--chips .choice__item { flex-direction: row; align-items: center; padding: 8px 16px; border-radius: 999px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(207, 169, 90, 0.15);
  color: var(--gold-2);
}

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid var(--line);
  padding: 0;
  position: relative;
}
.swatch[aria-checked="true"] { border-color: var(--gold-2); box-shadow: 0 0 0 3px rgba(230, 196, 126, 0.35); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.field__label .muted { font-weight: 400; }
.input {
  min-height: var(--tap);
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  font-size: 1rem; /* >=16px: evita zoom automático no celular */
  color: var(--text);
}
.input:focus { outline: 2px solid var(--gold); border-color: var(--gold); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.field__error { color: var(--danger); font-size: 0.9rem; min-height: 1.3em; }

/* ---------- Atributos ---------- */
.attrs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.attr {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 4px;
  text-align: center;
}
.attr__v { font-family: var(--font-display); font-size: 1.5rem; line-height: 1.1; }
.attr__k { font-size: 0.75rem; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--muted); }
.bar { height: 8px; border-radius: 8px; background: var(--line); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--gold); }

/* ---------- Retratos e imagens provisórias ---------- */
.portrait { display: block; aspect-ratio: 120 / 140; line-height: 0; }
.portrait svg { width: 100%; height: 100%; display: block; border-radius: 12px; }
.portrait--hero { width: min(46vw, 180px); margin: 0 auto; }
.tag {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px dashed var(--muted);
  color: var(--muted);
  width: fit-content;
}
.art-placeholder {
  position: relative;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 16px;
  color: var(--muted);
  border: 1px dashed var(--muted);
  border-radius: var(--radius);
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.035) 0 12px, rgba(255, 255, 255, 0) 12px 24px),
    var(--surface);
}
.art-placeholder b { display: block; letter-spacing: 0.12em; font-size: 0.75rem; color: var(--gold); }
.art-placeholder code { font-size: 0.8rem; word-break: break-all; }

/* ---------- Abas do painel ---------- */
.tab {
  flex: 1;
  min-height: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}
.tab[aria-selected="true"] { color: var(--gold-2); }
.tab[aria-selected="true"] .icon { filter: drop-shadow(0 0 6px rgba(230, 196, 126, 0.5)); }

/* ---------- Segmentado (idioma) ---------- */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--surface); }
.seg button {
  min-height: var(--tap);
  min-width: 52px;
  padding: 0 14px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}
.seg button[aria-checked="true"] { background: var(--gold); color: var(--gold-ink); }
.seg--large button { min-height: var(--tap); padding: 0 20px; flex: 1; }
.seg--large { display: flex; }

/* ---------- Folha inferior (confirmações) ---------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.62);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade-in 0.15s ease-out;
}
.sheet {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 20px 20px 0 0;
  padding: 20px 18px calc(var(--safe-b) + 18px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: sheet-up 0.2s ease-out;
  max-height: 90dvh;
  overflow-y: auto;
}
.sheet__title { font-family: var(--font-display); font-size: 1.2rem; }
.sheet__actions { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.sheet__actions .btn { min-height: 52px; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0.6; } to { transform: none; opacity: 1; } }
@media (orientation: landscape) and (max-height: 540px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 20px; border-bottom: 1px solid var(--line); }
}

/* ---------- Avisos rápidos ---------- */
#toasts {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--safe-b) + 84px);
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  padding: 0 16px;
}
.toast {
  background: #efe6d3;
  color: #1c1710;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
  max-width: 100%;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  animation: sheet-up 0.2s ease-out;
}
.toast--error { background: #f3c3b8; }

/* Com uma folha aberta, os avisos sobem para o topo e não cobrem os botões dela. */
body:has(.sheet-backdrop) #toasts {
  bottom: auto;
  top: calc(var(--safe-t) + 12px);
}

/* Início em paisagem (celular deitado): marca à esquerda, campanhas à direita.
   Fica aqui, depois de .home__split, para não ser sobrescrito. */
@media (orientation: landscape) and (max-height: 540px) {
  .home__split { flex-direction: row; gap: 20px; align-items: flex-start; }
  .home__split > .home__brand { flex: 0 0 36%; padding-top: 6px; }
  .home__split > .home__list { flex: 1; min-width: 0; }
  .home__emblem { width: 64px; height: 64px; margin-bottom: 6px; }
  #toasts { bottom: calc(var(--safe-b) + 72px); }
}

/* ---------- Fase 2: mapa, locais, diálogo, combate ---------- */
.map { position: relative; border-radius: var(--radius); overflow: hidden; }
.pin {
  position: absolute; transform: translate(-50%, -50%);
  min-width: 44px; min-height: 44px; padding: 0;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: transparent; border: 0; color: var(--text);
}
.pin__dot { width: 22px; height: 22px; border-radius: 50%; background: var(--gold); border: 3px solid var(--bg); box-shadow: 0 0 0 2px var(--gold); }
.pin__label { font-size: 0.78rem; font-weight: 700; background: rgba(20, 17, 15, 0.82); padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.poi-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  min-height: 64px; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface); color: var(--text);
}
.poi-card strong { font-family: var(--font-display); font-size: 1.05rem; }
.btn--left { justify-content: flex-start; flex-direction: column; align-items: flex-start; text-align: left; gap: 2px; padding-top: 10px; padding-bottom: 10px; }
.bubble { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.bubble__react { color: var(--muted); font-style: italic; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: rgba(208, 169, 79, 0.16); color: var(--gold); border: 1px solid rgba(208, 169, 79, 0.4); border-radius: 999px; padding: 2px 10px; font-size: 0.85rem; font-weight: 600; }
.log { min-height: 5.2em; display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 0.95rem; }
.log p:last-child { color: var(--text); }
.combat-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.combat-actions .btn { padding: 0 8px; }
.notice--warn { border-color: var(--danger); color: #f3c3b8; background: rgba(208, 98, 76, 0.1); }
.bar--hp > span { background: #c0594a; }
.bar--mp > span { background: #4f7fc0; }
.bar--enemy > span { background: #8c8c8c; }
.tag--ok { color: var(--ok, #8fbf7a); border-color: currentColor; }
.entry { display: flex; flex-direction: column; padding: 8px 0; border-bottom: 1px solid var(--line); }
.gold { color: var(--gold); font-weight: 700; }


