/* =====================================================================
   Manager Roguelike — identidade visual da página (opção A do usuário).
   Tokens primeiro: a mesma lista de cores/espaços/tipos vai para o USS
   do Unity depois. Tema claro é o padrão; escuro segue o sistema ou o
   botão do jogador (data-theme).
   ===================================================================== */
:root {
  --font-display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --font-body: "Nunito Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  --bg: #f3f1ea;
  --bg-2: #e9e6dc;
  --surface: #ffffff;
  --surface-2: #f7f6f1;
  --ink: #15201a;
  --ink-2: #3a4740;
  --muted: #6b776f;
  --line: #d9d5c8;
  --line-2: #c8c3b3;

  --green: #1b7a3e;
  --green-2: #0f5a2c;
  --green-soft: #e3f1e6;
  --gold: #d99a16;
  --gold-soft: #fbf1d6;
  --red: #c62828;
  --red-soft: #fbe5e3;
  --amber: #e0a106;
  --amber-soft: #fdf3d8;
  --blue: #2d5fcf;
  --slate: #5b6672;
  --slate-soft: #e8ebee;

  --us: var(--green);
  --us-soft: var(--green-soft);
  --them: var(--slate);
  --them-soft: var(--slate-soft);

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 30, 24, 0.06), 0 6px 18px rgba(20, 30, 24, 0.06);
  --gap: 12px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1512;
    --bg-2: #0a0f0c;
    --surface: #182019;
    --surface-2: #1f2a21;
    --ink: #edf2ea;
    --ink-2: #c7d1c6;
    --muted: #93a096;
    --line: #2a362d;
    --line-2: #3a4a3e;
    --green: #3cbf68;
    --green-2: #2c9b52;
    --green-soft: #173823;
    --gold: #f0b429;
    --gold-soft: #3a2e10;
    --red: #ef5350;
    --red-soft: #3b1b1a;
    --amber: #f2b705;
    --amber-soft: #3a2f0c;
    --slate: #9aa6b2;
    --slate-soft: #232c33;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

:root[data-theme="dark"] {
  --bg: #0f1512;
  --bg-2: #0a0f0c;
  --surface: #182019;
  --surface-2: #1f2a21;
  --ink: #edf2ea;
  --ink-2: #c7d1c6;
  --muted: #93a096;
  --line: #2a362d;
  --line-2: #3a4a3e;
  --green: #3cbf68;
  --green-2: #2c9b52;
  --green-soft: #173823;
  --gold: #f0b429;
  --gold-soft: #3a2e10;
  --red: #ef5350;
  --red-soft: #3b1b1a;
  --amber: #f2b705;
  --amber-soft: #3a2f0c;
  --slate: #9aa6b2;
  --slate-soft: #232c33;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font-body);
  -webkit-text-size-adjust: 100%;
}

body { background-image: radial-gradient(1200px 400px at 50% -200px, var(--green-soft), transparent 70%); }

h1, h2, h3, h4, .display { font-family: var(--font-display); letter-spacing: 0.01em; line-height: 1.1; }
h1 { font-size: 2.2rem; margin: 6px 0 2px; font-weight: 800; }
h2 { font-size: 1.6rem; margin: 18px 0 8px; font-weight: 700; text-transform: uppercase; }
h3 { font-size: 1.15rem; margin: 10px 0 6px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-2); }
p { margin: 6px 0; }
small, .muted { color: var(--muted); }
a { color: var(--green); }

.page { max-width: 820px; margin: 0 auto; padding: 0 16px 56px; }

.loading { text-align: center; padding-top: 18vh; color: var(--muted); }

/* ---- Barra do aplicativo ---- */
.app-bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  margin: 0 -16px 12px; padding: 8px 16px;
  background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: var(--shadow);
}
.app-bar .brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.app-bar .brand b { font-family: var(--font-display); font-size: 1.35rem; font-weight: 800; letter-spacing: 0.02em; white-space: nowrap; }
.app-bar .brand small { display: block; margin-top: -4px; }
.app-bar select, .app-bar .icon-btn { min-height: 36px; }

.crest { width: 34px; height: 34px; flex: none; }
.crest.big { width: 72px; height: 72px; margin: 0 auto 8px; }

/* ---- HUD da run ---- */
.hud { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin: 10px 0; }
.hud .stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; min-width: 0; }
.hud .stat .label { display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.hud .stat .value { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; line-height: 1.1; white-space: nowrap; }
.hud .stat .value small { font-family: var(--font-body); font-size: 0.8rem; }
.hud .stat.wide { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.meter { height: 8px; border-radius: 6px; background: var(--bg-2); overflow: hidden; margin-top: 4px; }
.meter > span { display: block; height: 100%; background: var(--green); border-radius: 6px; transition: width 0.3s; }
.meter.warn > span { background: var(--amber); }
.meter.danger > span { background: var(--red); }

/* ---- Cartões ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 12px 0; box-shadow: var(--shadow); overflow-x: auto; }
.card.soft { background: var(--surface-2); box-shadow: none; }
.card.alert { border-color: var(--red); background: var(--red-soft); }
.card.ok { border-color: var(--green); background: var(--green-soft); }
.card.gold { border-color: var(--gold); background: var(--gold-soft); }
.card h3:first-child, .card h2:first-child { margin-top: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

.help { border-left: 4px solid var(--green); }
.help summary { cursor: pointer; font-weight: 700; color: var(--green); list-style: none; display: flex; gap: 8px; align-items: center; }
.help summary::before { content: "?"; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--green); color: #fff; font-size: 0.85rem; }
.help[open] summary { margin-bottom: 6px; }
.help ul, .help ol { margin: 4px 0 4px 20px; padding: 0; }
.help li { margin: 4px 0; }

/* ---- Botões ---- */
button {
  font: 600 1rem var(--font-body);
  border: 1px solid var(--green);
  background: var(--green);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  cursor: pointer;
  min-height: 40px;
  transition: filter 0.15s, transform 0.05s;
}
button:hover { filter: brightness(1.05); }
button:active { transform: translateY(1px); }
button.secondary { background: var(--surface); color: var(--green); }
button.danger { background: var(--surface); color: var(--red); border-color: var(--red); }
button.ghost { background: transparent; color: var(--ink-2); border-color: var(--line-2); }
button.big { width: 100%; font-family: var(--font-display); font-size: 1.35rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 14px; margin-top: 10px; }
button:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }
.icon-btn { background: var(--surface); color: var(--ink-2); border-color: var(--line-2); padding: 6px 10px; display: inline-flex; align-items: center; gap: 6px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 6px 0; }
.spread { justify-content: space-between; }

.option { display: block; width: 100%; text-align: left; margin: 8px 0; padding: 12px 14px; border-radius: var(--radius); }
.option b { font-family: var(--font-display); font-size: 1.2rem; font-weight: 700; }
.option small { display: block; color: inherit; opacity: 0.85; font-weight: 400; margin-top: 2px; }
.option.secondary small { color: var(--muted); }

/* ---- Tabelas ---- */
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 700; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tr.me { background: var(--green-soft); }
tr.me td:first-child { border-left: 3px solid var(--green); }
.cell-actions { white-space: nowrap; }
.cell-actions button { padding: 4px 10px; min-height: 32px; font-size: 0.85rem; }
td.traits { white-space: nowrap; }

/* ---- Jogadores ---- */
.pos { display: inline-grid; place-items: center; min-width: 34px; height: 24px; padding: 0 6px; border-radius: 6px; font: 700 0.75rem var(--font-display); letter-spacing: 0.06em; background: var(--slate-soft); color: var(--slate); }
.pos.gk { background: var(--gold-soft); color: var(--gold); }
.pos.cb, .pos.fb { background: var(--slate-soft); color: var(--slate); }
.pos.dm, .pos.am { background: var(--green-soft); color: var(--green-2); }
.pos.lw, .pos.rw, .pos.st { background: var(--red-soft); color: var(--red); }
.stars { color: var(--gold); letter-spacing: -1px; }
.pill { display: inline-block; font-size: 0.78rem; padding: 1px 7px; border: 1px solid var(--line-2); border-radius: 999px; margin-right: 4px; color: var(--muted); white-space: nowrap; }
.pill.on { border-color: var(--green); color: var(--green); font-weight: 700; background: var(--green-soft); }
.pill.warn { border-color: var(--red); color: var(--red); font-weight: 700; background: var(--red-soft); }
.pill.gold { border-color: var(--gold); color: var(--gold); font-weight: 700; background: var(--gold-soft); }
.price { color: var(--gold); font-weight: 700; font-family: var(--font-display); font-size: 1.05rem; }
.statbox { display: inline-grid; place-items: center; min-width: 26px; padding: 0 4px; height: 24px; border-radius: 5px; background: var(--bg-2); font: 700 0.9rem var(--font-display); }
.statbox.hi { background: var(--green-soft); color: var(--green-2); }
.statbox.lo { background: var(--red-soft); color: var(--red); }

/* ---- Loja em cartões ---- */
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.offer { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; background: var(--surface-2); display: flex; flex-direction: column; gap: 6px; }
.offer .name { font-family: var(--font-display); font-size: 1.15rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.offer .stats { display: flex; gap: 8px; align-items: center; }
.offer .stats .k { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; }
.offer .foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: auto; }
.offer.empty { color: var(--muted); align-items: center; justify-content: center; min-height: 90px; border-style: dashed; }
.rarity { color: var(--gold); font-size: 0.8rem; letter-spacing: 1px; }

/* ---- Ações do clube ---- */
.action { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.action:first-of-type { border-top: 0; }
.action button { min-width: 7em; }
.action.on { background: var(--green-soft); margin: 0 -16px; padding: 10px 16px; }

/* ---- Mapa ---- */
.map { display: flex; gap: 6px; overflow-x: auto; padding: 6px 0; }
.map .col { min-width: 104px; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px; background: var(--surface-2); }
.map .col.now { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); }
.map .col h4 { margin: 0 0 4px; font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.map .node { font-size: 0.85rem; padding: 3px 6px; border-radius: 6px; margin: 3px 0; border: 1px solid transparent; }
.map .node.visited { color: var(--muted); text-decoration: line-through; }
.map .node.current { background: var(--green); color: #fff; font-weight: 700; }
.map .node.reachable { border-color: var(--green); color: var(--green); font-weight: 700; }
.map .node.off { color: var(--line-2); }
.map .node.special { font-weight: 700; }

/* ---- Partida ---- */
.scoreboard { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--radius); background: linear-gradient(135deg, var(--green-2), var(--green)); color: #fff; }
.scoreboard .team { font-family: var(--font-display); font-size: 1.1rem; font-weight: 700; line-height: 1.1; }
.scoreboard .team.right { text-align: right; }
.scoreboard .team small { display: block; opacity: 0.8; font-family: var(--font-body); font-size: 0.75rem; font-weight: 400; }
.scoreboard .score { font-family: var(--font-display); font-size: 2.6rem; font-weight: 800; letter-spacing: 0.04em; }
.scoreboard .minute { grid-column: 1 / -1; font-size: 0.8rem; opacity: 0.9; text-align: center; }
.narration { list-style: none; padding: 0; margin: 10px 0 0; }
.narration li { padding: 6px 8px; border-bottom: 1px dotted var(--line); display: grid; grid-template-columns: 36px 1fr; gap: 6px; align-items: baseline; }
.narration li .min { color: var(--muted); font-variant-numeric: tabular-nums; font-family: var(--font-display); font-weight: 700; }
.narration li.e2 { font-weight: 700; background: var(--surface-2); border-radius: 6px; }
.narration li.e1 { font-weight: 600; }
.narration li.ours { border-left: 3px solid var(--us); }
.narration li.theirs { border-left: 3px solid var(--them); }
.narration li.neutral { color: var(--muted); }
.team-tag { display: inline-block; font-size: 0.68rem; font-weight: 800; letter-spacing: 0.06em; padding: 1px 6px; border-radius: 4px; margin-right: 6px; vertical-align: middle; font-family: var(--font-display); }
.team-tag.us { background: var(--us); color: #fff; }
.team-tag.them { background: var(--them-soft); color: var(--them); }
.banner { border-radius: var(--radius); padding: 12px 16px; font-family: var(--font-display); font-size: 1.4rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; }
.banner.win { background: var(--green-soft); color: var(--green-2); border: 1px solid var(--green); }
.banner.draw { background: var(--amber-soft); color: var(--amber); border: 1px solid var(--amber); }
.banner.loss { background: var(--red-soft); color: var(--red); border: 1px solid var(--red); }
.banner small { display: block; font-family: var(--font-body); font-size: 0.9rem; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--ink-2); margin-top: 2px; }

/* ---- Sinergias ---- */
.synergy { display: inline-flex; align-items: center; gap: 6px; margin: 3px 6px 3px 0; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line-2); font-size: 0.9rem; background: var(--surface-2); }
.synergy.active { border-color: var(--green); background: var(--green-soft); font-weight: 700; color: var(--green-2); }
.synergy .pips { display: inline-flex; gap: 2px; }
.synergy .pips i { width: 7px; height: 7px; border-radius: 50%; background: var(--line-2); display: inline-block; }
.synergy .pips i.on { background: var(--green); }

/* ---- Eventos recentes ---- */
.events { list-style: none; padding: 0; margin: 0; }
.events li { padding: 2px 0; }

/* ---- Formulários ---- */
label.inline { display: inline-flex; gap: 6px; align-items: center; margin-right: 12px; }
input[type="number"], input[type="text"], select { font: inherit; padding: 7px 10px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); }
textarea { font: inherit; width: 100%; box-sizing: border-box; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); resize: vertical; margin-bottom: 8px; }
.choice { display: block; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin: 8px 0; cursor: pointer; background: var(--surface-2); }
.choice.on { border-color: var(--green); background: var(--green-soft); }
.choice b { font-family: var(--font-display); font-size: 1.15rem; }
.choice input { margin-right: 8px; }

pre.share { white-space: pre-wrap; background: var(--surface-2); padding: 10px; border-radius: var(--radius-sm); font-size: 0.9rem; border: 1px solid var(--line); }

.narrow-only { display: none; }
@media (max-width: 480px) {
  .narrow-only { display: block; margin: 4px 0; }
  table { font-size: 0.85rem; }
  th, td { padding: 5px 3px; }
  .cell-actions button { padding: 3px 6px; font-size: 0.8rem; }
  h1 { font-size: 1.8rem; }
  .scoreboard .score { font-size: 2.1rem; }
}

#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: var(--red-soft); color: var(--ink); padding: 10px 16px; border-top: 1px solid var(--red); }
#blazor-error-ui .dismiss { float: right; cursor: pointer; }

/* Barra do app em telas estreitas: o nome não pode ser cortado pelo seletor de idioma. */
.app-bar select { max-width: 40vw; }
.app-bar .brand b { overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 520px) {
  .app-bar .brand small { display: none; }
  .app-bar .brand b { font-size: 1.1rem; white-space: normal; line-height: 1.05; }
  .app-bar select { max-width: 34vw; font-size: 0.9rem; }
}

/* ---- Questionário de percepção (D76) ---- */
.survey-q { margin: 10px 0; }
.survey-q label { display: block; font-weight: 700; margin-bottom: 4px; }
.scale { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.scale button { min-width: 40px; min-height: 36px; padding: 4px 10px; background: var(--surface-2); color: var(--ink); border: 1px solid var(--line-2); border-radius: var(--radius-sm); font-weight: 600; }
.scale button.on { border-color: var(--green); background: var(--green-soft); color: var(--green-2); font-weight: 700; }
.scale small { color: var(--muted); }
