:root {
  /* Uma coluna de telemóvel: cabeçalho atlântico escuro, página de granito claro,
     urze para as missões, giesta para o que pede atenção. O motivo são os anéis do castro. */
  --granite-0: #eceeea;
  --granite-1: #dfe3de;
  --granite-2: #c9d0ca;
  --paper: #f9faf7;
  --ink: #1b2a30;
  --ink-2: #4f6067;
  --ink-3: #7b898e;
  --atlantic: #1d4a5a;
  --atlantic-deep: #12313d;
  --atlantic-soft: #d6e4e7;
  --heather: #7a4a98;
  --heather-soft: #ece2f2;
  --gorse: #d6a419;
  --gorse-soft: #f7edc8;
  --bad: #a93a2a;
  --bad-soft: #f5dfd9;
  --ok: #2f7a4d;
  --ok-soft: #dcefe2;
  --font-display: 'Marcellus', 'Palatino Linotype', 'Book Antiqua', Georgia, serif;
  --font-body: 'Source Sans 3', 'Segoe UI', system-ui, -apple-system, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: #c4cbc6; color: var(--ink); font: 400 16px/1.45 var(--font-body); -webkit-text-size-adjust: 100%; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; padding: 0; }
ul, ol { list-style: none; }
:focus-visible { outline: 3px solid var(--gorse); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.muted { color: var(--ink-2); font-size: 14px; }
.fine { color: var(--ink-3); font-size: 13px; }

/* Moldura */
.app { position: relative; height: 100%; max-width: 520px; margin: 0 auto; overflow: hidden; background: var(--granite-0); display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto 1fr auto; box-shadow: 0 0 0 1px rgba(18, 49, 61, .12), 0 12px 40px rgba(18, 49, 61, .18); }
.app.start-mode { display: block; overflow-y: auto; }

.top { background: var(--atlantic-deep); color: #eef4f5; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--gorse); }
.brand div { min-width: 0; color: #eef4f5; }
.brand b { display: block; font: 400 19px/1.15 var(--font-display); letter-spacing: .03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { display: block; font-size: 12.5px; color: #a9c1c8; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-side { display: flex; align-items: center; gap: 8px; flex: none; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.pill.prestige { background: rgba(255, 255, 255, .1); color: #f3e3a8; font-variant-numeric: tabular-nums; padding: 5px 10px; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.icon-btn { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border: 0; border-radius: 10px; background: rgba(255, 255, 255, .1); color: #eef4f5; cursor: pointer; }
.icon-btn.dark { background: var(--granite-1); color: var(--ink); }

.res { display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; background: var(--atlantic); color: #eef4f5; padding: 6px 8px 7px; }
/* Cada recurso, de cima para baixo: o que há, o limite em número, a barra de enchimento e o que entra por hora. */
.chip { display: grid; grid-template-columns: auto 1fr; column-gap: 4px; row-gap: 1px; align-items: center; padding: 2px 3px; min-width: 0; }
.chip b { font-size: 14.5px; font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chip small { grid-column: 1 / -1; font-size: 11px; line-height: 1.15; color: #a9c1c8; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; }
.chip small.neg { color: #f3b0a4; }
.chip .lim { color: #c5d6db; }
.chip .cap { grid-column: 1 / -1; height: 5px; margin: 2px 0 1px; background: rgba(255, 255, 255, .2); border-radius: 3px; overflow: hidden; }
.chip .cap i { display: block; height: 100%; width: 0; background: #8fc3d0; border-radius: 3px; }
.chip.near .cap i { background: var(--gorse); }
.chip.near .lim { color: #f2cf6b; }
.chip.full .cap i { background: #f08a75; }
.chip.full .lim { color: #f6b8aa; font-weight: 600; }
.chip.low b { color: #f6b8aa; }

#view { overflow-y: auto; padding: 12px 16px 24px; display: flex; flex-direction: column; gap: 12px; }
#alerts, #tabview { display: flex; flex-direction: column; gap: 12px; }
#alerts:empty { display: none; }

.tabs { display: grid; grid-template-columns: repeat(5, 1fr); background: var(--paper); border-top: 1px solid var(--granite-2); }
.tab { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 2px 8px; border: 0; border-top: 3px solid transparent; background: none; color: var(--ink-2); font-size: 11.5px; cursor: pointer; }
.tab.on { color: var(--atlantic-deep); font-weight: 600; border-top-color: var(--gorse); }
.dot { position: absolute; top: 3px; left: 54%; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--bad); color: #fff; font: 700 11px/17px var(--font-body); text-align: center; }

/* Cartões e listas */
.card { background: var(--paper); border: 1px solid var(--granite-2); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.card h2, .sheet h3 { font: 400 18px/1.2 var(--font-display); letter-spacing: .02em; text-wrap: balance; }
.card h2 small { font: 400 13.5px var(--font-body); color: var(--ink-2); letter-spacing: 0; }
.scene { padding: 10px; }
.scene-svg { display: block; width: 100%; height: auto; }
.hint { color: var(--ink-2); font-size: 13.5px; text-align: center; }

.rows { display: flex; flex-direction: column; }
.rows li + li { border-top: 1px solid var(--granite-1); }
.row { width: 100%; min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 4px; border: 0; border-radius: 8px; background: none; text-align: left; cursor: pointer; }
.row:hover { background: var(--granite-0); }
.row-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.row-main b { font-weight: 600; }
.row-main small { color: var(--ink-2); font-size: 13.5px; }
.row-side { display: flex; align-items: center; gap: 5px; flex: none; color: var(--ink-2); font-size: 13.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.cost { display: inline-flex; flex-wrap: wrap; gap: 3px 10px; }
.c { display: inline-flex; align-items: center; gap: 3px; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.c.lack { color: var(--bad); }

.eta { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar { display: block; height: 5px; background: var(--granite-1); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--atlantic); border-radius: 3px; }

/* Missão, avisos e obras */
.mission { background: var(--heather-soft); border: 1px solid #d6c4e3; border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 5px; }
.mission.done { background: var(--gorse-soft); border-color: #e3cf86; }
.m-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
.mission h2 { font: 400 19px/1.2 var(--font-display); text-wrap: balance; }
.mission p { font-size: 14.5px; }
.m-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.reward { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.alert { border-radius: 10px; padding: 10px 12px; font-size: 14.5px; }
.alert.bad { background: var(--bad-soft); color: #6f2318; border: 1px solid #e5b9af; }
.alert.warn { background: var(--gorse-soft); color: #5d4705; border: 1px solid #e3cf86; }
.works { display: flex; flex-direction: column; gap: 6px; }
.work { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 5px 10px; background: var(--paper); border: 1px solid var(--granite-2); border-radius: 10px; padding: 8px 12px; font-size: 14px; }
.work .bar { grid-column: 1 / -1; }
.works-n { font-size: 12.5px; color: var(--ink-2); padding: 0 2px; }
.work-side { display: inline-flex; align-items: center; gap: 10px; }
.work-x { border: 0; background: none; padding: 4px 0; color: var(--ink-2); font: inherit; font-size: 13px; text-decoration: underline; cursor: pointer; }
.work-x.sure { color: var(--bad); font-weight: 600; }
.ing-chip.rare { border-style: dashed; }
.ing-lead { display: block; font-size: 12px; font-style: italic; }
.ing-lead.yes { color: #5d4705; }
.ing-lead.no { color: var(--ink-3); }

/* Botões e campos */
.btn { min-height: 44px; padding: 9px 16px; border: 1px solid transparent; border-radius: 10px; background: var(--atlantic); color: #fff; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--atlantic-deep); }
.btn:disabled { background: var(--granite-1); color: var(--ink-3); cursor: not-allowed; }
.btn.accent { background: var(--heather); }
.btn.accent:hover { background: #643b7e; }
.btn.accent:disabled { background: #dbd1e2; color: #8d7d99; }
.btn.ghost { background: transparent; color: var(--atlantic); border-color: var(--granite-2); }
.btn.ghost:hover { background: var(--granite-0); }
.btn.danger { background: var(--bad); }
.btn.danger:hover { background: #8c2e21; }
.btn.wide { width: 100%; }
.btn.grow { flex: 1; }
.btn-row { display: flex; gap: 8px; }
input, select { min-height: 44px; padding: 8px 10px; border: 1px solid var(--granite-2); border-radius: 10px; background: #fff; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--ink-2); }
.field input, .field select { width: 100%; color: var(--ink); }

/* Cenas desenhadas */
.hex, .slot, .npc { cursor: pointer; outline: none; }
.hex polygon { stroke: #f4f1e6; stroke-width: 2.5; }
.hex:hover polygon, .hex:focus-visible polygon { stroke: var(--gorse); stroke-width: 4; }
.badge rect { fill: var(--atlantic-deep); opacity: .9; }
.badge text { fill: #fff; font: 600 11.5px var(--font-body); }
.slot:hover > circle:first-child, .slot:focus-visible > circle:first-child,
.npc:hover > circle:first-child, .npc:focus-visible > circle:first-child { stroke: var(--gorse); stroke-width: 3; }
.lvl { fill: #fff; font: 700 9.5px var(--font-body); }
.npc-lvl { font: 700 12px var(--font-body); }
.mv { fill: var(--heather); stroke: #fff; stroke-width: 1.5; }
.spin { fill: none; stroke: var(--gorse); stroke-width: 3; stroke-dasharray: 6 8; stroke-linecap: round; transform-box: fill-box; transform-origin: center; pointer-events: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Painel inferior */
#sheet-root { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.backdrop { position: absolute; inset: 0; background: rgba(18, 49, 61, .5); pointer-events: auto; }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 86%; overflow-y: auto; background: var(--paper); border-radius: 16px 16px 0 0; padding: 16px 16px 22px; display: flex; flex-direction: column; gap: 12px; pointer-events: auto; box-shadow: 0 -8px 30px rgba(18, 49, 61, .25); }
@keyframes rise { from { transform: translateY(28px); opacity: .5; } }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.sheet-head h2 { font: 400 23px/1.15 var(--font-display); letter-spacing: .02em; text-wrap: balance; }
.sheet-head h2 small { font: 400 14px var(--font-body); color: var(--ink-2); letter-spacing: 0; }
.kv { display: flex; flex-direction: column; }
.kv > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--granite-1); }
.kv dt { color: var(--ink-2); font-size: 14px; }
.kv dt small { font-size: 12.5px; }
.kv dd { display: inline-flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 4px; font-weight: 600; text-align: right; }
.lock { color: var(--bad); font-size: 14px; }
.note { background: var(--granite-0); border-radius: 10px; padding: 10px 12px; color: var(--ink-2); font-size: 14px; }
.status { background: var(--atlantic-soft); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.options { display: flex; flex-direction: column; gap: 12px; }
.option { border: 1px solid var(--granite-2); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.option p { color: var(--ink-2); font-size: 14.5px; }
.panel { border: 1px solid var(--granite-2); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.trade { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

/* Tropas */
.units { display: flex; flex-wrap: wrap; gap: 6px 8px; }
.u { background: var(--granite-0); border: 1px solid var(--granite-1); border-radius: 8px; padding: 3px 9px; font-size: 14px; }
.units.small .u { font-size: 13px; padding: 2px 7px; }
.list { display: flex; flex-direction: column; gap: 10px; }
.list li { display: flex; flex-direction: column; gap: 5px; }
.li-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.li-loot { display: flex; align-items: center; gap: 8px; }
.unit-list { display: flex; flex-direction: column; }
.unit { padding: 12px 0; display: flex; flex-direction: column; gap: 6px; }
.unit:first-child { padding-top: 0; }
.unit:last-child { padding-bottom: 0; }
.unit + .unit { border-top: 1px solid var(--granite-1); }
.unit-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.unit-head b { font-size: 16.5px; }
.tag { background: var(--atlantic-soft); color: var(--atlantic-deep); border-radius: 6px; padding: 1px 7px; font-size: 12px; font-weight: 600; }
.have { margin-left: auto; color: var(--ink-2); font-size: 13.5px; }
.stats { display: flex; flex-wrap: wrap; gap: 3px 14px; color: var(--ink-2); font-size: 13.5px; }
.stats b { color: var(--ink); font-variant-numeric: tabular-nums; }
.unit-buy { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; }
.unit-form { display: flex; align-items: center; gap: 8px; }
.unit-form input { width: 76px; flex: none; }
.unit-form .btn.ghost { flex: none; padding-inline: 12px; }

/* Ataque e relatórios */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; background: var(--granite-1); border-radius: 11px; padding: 3px; }
.seg button { min-height: 40px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-2); font-weight: 600; cursor: pointer; }
.seg button.on { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .14); }
.send { display: flex; flex-direction: column; gap: 8px; }
.send li { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.send label { display: flex; flex-direction: column; }
.send small { color: var(--ink-2); font-size: 13px; }
.send input { width: 96px; }
.summary { background: var(--granite-0); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 3px; font-size: 14px; }
.good { color: var(--ok); font-weight: 600; }
.warn-text { color: var(--bad); font-weight: 600; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.tbl th { padding: 5px 4px; border-bottom: 1px solid var(--granite-2); color: var(--ink-2); font-weight: 600; text-align: left; }
.tbl td { padding: 5px 4px; border-bottom: 1px solid var(--granite-1); }
.tbl th:not(:first-child), .tbl td:not(:first-child) { text-align: right; }
.phases { display: flex; flex-direction: column; gap: 4px; }
.phases li { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.phases span { color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* Definições e avisos rápidos */
.speeds { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.speed { display: flex; flex-direction: column; padding: 10px 12px; border: 1px solid var(--granite-2); border-radius: 10px; background: var(--paper); text-align: left; cursor: pointer; }
.speed.on { border-color: var(--atlantic); background: var(--atlantic-soft); }
.speed small { color: var(--ink-2); font-size: 13px; }
#toasts { position: absolute; left: 12px; right: 12px; bottom: 74px; z-index: 6; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.toast { background: var(--atlantic-deep); color: #fff; padding: 9px 13px; border-radius: 10px; font-size: 14px; box-shadow: 0 4px 14px rgba(0, 0, 0, .25); }
.toast.ok { background: #245f3d; }
.toast.bad { background: var(--bad); }

/* Abertura */
.start { min-height: 100%; display: flex; flex-direction: column; }
.hero { background: #182b36; color: #eef4f5; display: flex; flex-direction: column; align-items: stretch; text-align: center; }
.hero-scene { display: block; width: 100%; height: 218px; }
.hero-scene .star { transform-box: fill-box; transform-origin: center; }
.hero-text { padding: 14px 20px 24px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.hero-sub { font-size: 12px; font-weight: 600; letter-spacing: .24em; text-transform: uppercase; color: #e3b95a; }
.hero-rings { width: 184px; height: 184px; }
.hero-rings .draw { fill: none; stroke: #b9c6cb; stroke-width: 5; stroke-dasharray: 7 2.5; }
.hero h1 { font: 400 52px/1 var(--font-display); letter-spacing: .14em; text-indent: .14em; }
.lede { max-width: 38ch; color: #c5d6db; text-wrap: balance; }
.start-form { padding: 20px 16px 28px; display: flex; flex-direction: column; gap: 14px; }
.start-form h2 { font: 400 21px var(--font-display); letter-spacing: .02em; }
.factions { display: flex; flex-direction: column; gap: 10px; }
.faction { display: flex; flex-direction: column; gap: 3px; padding: 12px 14px; border: 2px solid var(--granite-2); border-radius: 12px; background: var(--paper); text-align: left; cursor: pointer; }
.faction.on { border-color: var(--heather); background: var(--heather-soft); }
.f-name { font: 400 21px var(--font-display); letter-spacing: .02em; }
.f-motto { color: var(--ink-2); font-size: 14px; font-style: italic; }
.f-trait { margin-top: 4px; font-size: 14.5px; }
.f-sw { color: var(--ink-2); font-size: 13.5px; }

/* A abertura parte de um desenho já completo: os anéis só rodam até assentar. */
@keyframes settle { from { transform: rotate(-40deg) scale(.94); opacity: .6; } }
@media (prefers-reduced-motion: no-preference) {
  .spin { animation: spin 7s linear infinite; }
  .sheet.in { animation: rise .18s ease-out; }
  .hero-rings .draw, .hero-houses { transform-box: view-box; transform-origin: center; animation: settle 1.1s cubic-bezier(.2, .7, .2, 1); }
  .hero-rings .d2 { animation-duration: 1.3s; }
  .hero-rings .d3, .hero-houses { animation-duration: 1.5s; }
}

/* Afinações: pormenores dos cenários, noite e ecrã de computador */
.speed-pill { border: 0; background: rgba(255, 255, 255, .1); color: #eef4f5; padding: 6px 10px; min-height: 30px; cursor: pointer; font-variant-numeric: tabular-nums; }
.speed-pill:hover { background: rgba(255, 255, 255, .2); }
.roof { display: inline-block; width: 12px; height: 12px; flex: none; border-radius: 50%; border: 2px solid #8b9296; }
.row .roof { margin-right: 2px; }
.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; color: var(--ink-2); font-size: 13px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.title-now { font: 400 24px/1.15 var(--font-display); letter-spacing: .02em; color: var(--heather); }
.ladder { display: flex; flex-direction: column; }
.ladder li { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; color: var(--ink-3); font-size: 14px; font-variant-numeric: tabular-nums; }
.ladder li.got { color: var(--ink); font-weight: 600; }
.col-a, .col-b { display: contents; }

.defs { position: absolute; }
.hex-label { cursor: pointer; }
.marks, .glow, .smoke { pointer-events: none; }
.world { filter: brightness(calc(1 - .38 * var(--night, 0))) saturate(calc(1 - .35 * var(--night, 0))) hue-rotate(calc(14deg * var(--night, 0))); }
.glow { opacity: var(--night, 0); }
/* Os edifícios ficam por cima das luzes e escurecem pouco: têm de se reconhecer também de noite. */
.tokens { filter: brightness(calc(1 - .12 * var(--night, 0))); }
.smoke circle { fill: #f4f1e6; opacity: .28; transform-box: fill-box; transform-origin: center; }
.smoke circle:nth-child(2) { opacity: .2; transform: translate(4px, -9px) scale(1.5); }
.smoke circle:nth-child(3) { opacity: .12; transform: translate(9px, -19px) scale(2.1); }
@keyframes smoke { from { transform: translate(0, 0) scale(.7); opacity: .34; } to { transform: translate(12px, -26px) scale(2.4); opacity: 0; } }
@media (prefers-reduced-motion: no-preference) {
  .smoke circle { animation: smoke 5s linear infinite; }
  .smoke circle:nth-child(2) { animation-delay: -1.7s; }
  .smoke circle:nth-child(3) { animation-delay: -3.4s; }
}

@media (min-width: 900px), (min-width: 700px) and (min-height: 600px) {
  body { background: #b9c1bc; }
  .app { max-width: 1140px; grid-template-rows: auto auto auto 1fr; }
  .top { padding: 12px 24px; }
  .res { padding: 9px 20px 10px; gap: 14px; }
}
@media (min-width: 900px) {
  /* No computador cabe tudo numa linha: 657 / 1 070 à esquerda, +10/h à direita, a barra por baixo. */
  .chip { grid-template-columns: auto auto 1fr auto; column-gap: 6px; }
  .chip b { font-size: 16.5px; }
  .chip small { font-size: 12.5px; }
  .chip .lim { grid-column: 3; grid-row: 1; font-size: 14px; }
  .chip .lim::before { content: '/ '; }
  .chip .lim-word { display: none; }
  .chip .rate { grid-column: 4; grid-row: 1; justify-self: end; }
  .chip .cap { grid-row: 2; height: 6px; margin-top: 4px; }
}
@media (min-width: 900px), (min-width: 700px) and (min-height: 600px) {
  .tabs { grid-row: 3; grid-template-columns: repeat(5, auto); justify-content: start; gap: 4px; padding: 0 16px; border-top: 0; border-bottom: 1px solid var(--granite-2); }
  .tab { flex-direction: row; gap: 8px; padding: 12px 14px 10px; border-top: 0; border-bottom: 3px solid transparent; font-size: 15px; }
  .tab.on { border-bottom-color: var(--gorse); }
  .dot { position: static; }
  #view { grid-row: 4; display: grid; grid-template-columns: minmax(0, 11fr) minmax(0, 12fr); grid-template-rows: auto 1fr; align-items: start; align-content: start; gap: 16px 20px; padding: 20px 24px 32px; }
  #alerts { grid-column: 1; }
  #tabview { display: contents; }
  .col-a { grid-column: 1; display: flex; flex-direction: column; gap: 12px; }
  .col-b { grid-column: 2; grid-row: 1 / span 2; display: flex; flex-direction: column; gap: 12px; }
  .backdrop { background: rgba(18, 49, 61, .28); }
  .sheet { left: auto; right: 24px; bottom: 24px; width: 440px; max-height: calc(100% - 48px); border-radius: 16px; }
  #toasts { left: 24px; right: auto; bottom: 24px; width: 380px; }
  .app.start-mode { display: grid; grid-template-rows: 1fr; overflow: hidden; }
  .start { flex-direction: row; min-height: 0; height: 100%; }
  .hero { flex: 1; justify-content: center; background: linear-gradient(#0c222d 35%, #182b36 65%); }
  .hero-scene { height: auto; aspect-ratio: 360 / 210; }
  .hero-text { padding: 26px 40px 0; gap: 12px; }
  .hero-rings { width: 280px; height: 280px; }
  .hero h1 { font-size: 76px; }
  .lede { font-size: 18px; }
  .start-form { flex: 1; max-width: 560px; overflow-y: auto; padding: 32px 28px; justify-content: center; }
}

/* Multijogador: entrada, mapa do mundo, confederação, conversa e classificação */
.loading { padding: 48px 24px; text-align: center; color: var(--ink-2); }
.tabs.six { grid-template-columns: repeat(6, 1fr); }
.tabs.six .tab { font-size: 10.5px; padding-inline: 0; }
.alert.calm { background: var(--atlantic-soft); color: var(--atlantic-deep); border: 1px solid #b4cdd3; }
.tagname { color: var(--heather); font-weight: 600; white-space: nowrap; }
.mapnav { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.mapnav .btn { min-height: 38px; padding: 6px 12px; font-size: 14px; }
.castro-mark:hover > circle:first-child, .castro-mark:focus-visible > circle:first-child { stroke: var(--gorse); stroke-width: 3; }
.chat { display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow-y: auto; padding: 2px; }
.chat li { display: grid; grid-template-columns: 1fr auto; gap: 0 8px; }
.chat .who { font-weight: 600; font-size: 14px; }
.chat .when { color: var(--ink-3); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.chat p { grid-column: 1 / -1; overflow-wrap: anywhere; }
.chat li.mine .who { color: var(--heather); }
.chat-form, .alliance-form { display: flex; align-items: flex-end; gap: 8px; }
.chat-form input { flex: 1; min-width: 0; }
.alliance-form .field { flex: 1; min-width: 0; }
.alliance-form .field:nth-of-type(2) { flex: 0 0 84px; }
.ladder.members li, .ladder.join li { align-items: center; color: var(--ink); gap: 10px; }
.ladder.join li { padding: 6px 0; }
.ladder.join .btn { min-height: 36px; padding: 5px 12px; }
.tbl.rank td:first-child, .tbl.rank th:first-child { width: 2.5em; color: var(--ink-2); text-align: left; }
.tbl.rank td:nth-child(2), .tbl.rank th:nth-child(2) { text-align: left; }
.tbl.rank tr.me td { background: var(--heather-soft); font-weight: 600; }

@media (min-width: 900px), (min-width: 700px) and (min-height: 600px) {
  .tabs.six { grid-template-columns: repeat(6, auto); }
  .tabs.six .tab { font-size: 15px; padding: 12px 14px 10px; }
}

/* Imagens das tropas */
.u-ico { display: block; flex: none; }
.u { display: inline-flex; align-items: center; gap: 4px; padding-left: 5px; }
.u-row { display: inline-flex; align-items: center; gap: 6px; }
.unit-top { display: flex; align-items: flex-start; gap: 10px; }
.unit-about { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.send label { flex: 1; min-width: 0; }
.send li { gap: 10px; }

/* Povos na entrada, chamas e estrelas */
.f-head { display: flex; align-items: center; gap: 10px; }
.f-head > span { display: flex; flex-direction: column; }
.flame { transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes flicker { 0% { transform: scale(1, 1); } 35% { transform: scale(.93, 1.09); } 70% { transform: scale(1.05, .95); } 100% { transform: scale(.97, 1.05); } }
@keyframes twinkle { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: no-preference) {
  .flame { animation: flicker 1.7s ease-in-out infinite alternate; }
  .hero-scene .star { animation: twinkle 4.5s ease-in-out infinite; }
  .hero-scene .star:nth-child(3n) { animation-delay: -1.6s; animation-duration: 6s; }
  .hero-scene .star:nth-child(3n + 1) { animation-delay: -3.1s; animation-duration: 5.2s; }
}
.map-name { font: 600 8.5px var(--font-body); fill: #12313d; paint-order: stroke; stroke: rgba(244, 241, 230, .9); stroke-width: 2.4px; stroke-linejoin: round; pointer-events: none; }

/* Caudilho */
.chief-top { display: flex; align-items: center; gap: 12px; }
.chief-who { min-width: 0; }
.xp { display: flex; flex-direction: column; gap: 4px; }
.xp .bar { height: 8px; }
.xp .bar i { background: var(--heather); }
.xp small { color: var(--ink-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.good-note { background: var(--heather-soft); color: var(--ink); }
.chief-attrs { display: flex; flex-direction: column; }
.chief-attrs li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--granite-1); }
.ca-text { display: flex; flex-direction: column; min-width: 0; }
.ca-text small { color: var(--ink-2); font-size: 13.5px; }
.chief-attrs .btn { min-height: 38px; padding: 5px 14px; flex: none; }
.check { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--granite-2); border-radius: 10px; cursor: pointer; }
.check input { width: 22px; height: 22px; flex: none; margin: 1px 0 0; accent-color: var(--heather); }
.check span { display: flex; flex-direction: column; }
.check small { color: var(--ink-2); font-size: 13px; }

/* Caravanas */
.caravan-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.caravan-grid .field small { color: var(--ink-3); font-size: 12.5px; }

/* Mundos de teste: pausa */
.testbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 6px 5px 14px; border: 1px dashed var(--ink-3); border-radius: 12px; color: var(--ink-2); font-size: 13.5px; }
.testbar .btn { min-height: 36px; padding: 5px 12px; font-size: 14px; flex: none; }
.testbar small { display: block; font-size: 12px; color: var(--ink-3); }
.alert.pause, .alert.stale { display: flex; flex-direction: column; gap: 10px; }
.alert.pause .btn, .alert.stale .btn { align-self: flex-start; }

/* Ecrã inteiro e modo amplo: no telemóvel o cabeçalho recolhe, os recursos ficam numa linha e a missão numa tira. */
.icon-btn[aria-pressed="true"] { background: var(--gorse); color: var(--atlantic-deep); }
.icon-btn.mini { width: 34px; height: 34px; border-radius: 9px; }
.res-side { display: none; }
.mission.slim { flex-direction: row; align-items: center; gap: 8px; padding: 4px 6px 4px 12px; }
.m-slim { flex: 1; min-width: 0; min-height: 40px; display: flex; align-items: center; gap: 8px; padding: 0; border: 0; background: none; text-align: left; cursor: pointer; }
.m-slim .eyebrow { flex: none; }
.m-slim b { flex: 1; min-width: 0; font: 400 16.5px/1.2 var(--font-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-slim svg { flex: none; color: var(--ink-2); }
.mission.slim .btn { min-height: 38px; padding: 5px 12px; flex: none; }
.m-fold { margin-left: auto; min-height: 32px; padding: 0 4px; border: 0; background: none; color: var(--ink-2); font-size: 13px; text-decoration: underline; cursor: pointer; }
@media (max-width: 699px), (max-width: 899px) and (max-height: 599px) {
  .app.wide { grid-template-rows: auto 1fr auto; }
  .app.wide .top { display: none; }
  .app.wide .res { grid-template-columns: repeat(5, minmax(0, 1fr)) auto; align-items: center; padding: 5px 6px; padding-top: max(5px, env(safe-area-inset-top)); }
  .app.wide .res-side { display: flex; gap: 3px; padding-left: 2px; }
  .app.wide .chip { padding: 1px 2px; column-gap: 3px; }
  .app.wide .chip small { display: none; }
  .app.wide .chip b { font-size: 13.5px; }
  .app.wide .chip .ico { width: 16px; height: 16px; }
  .app.wide .chip .cap { height: 3px; margin: 3px 0 0; }
  .app.wide #view { padding: 8px 8px 16px; gap: 8px; }
  .app.wide #alerts, .app.wide #tabview { gap: 8px; }
  .app.wide .testbar { display: none; }
  .app.wide .card.scene { padding: 4px 4px 8px; }
  .app.wide .alert { padding: 7px 10px; font-size: 13.5px; }
  .app.wide .tab { padding: 5px 2px 6px; }
  /* O cabeçalho num telemóvel estreito: três botões e o prestígio à direita; o nome do castro fica com o resto. */
  .top { gap: 8px; padding-inline: 12px; }
  .top-side { gap: 6px; }
  .top .icon-btn { width: 36px; height: 36px; }
  .pill.prestige { padding: 5px 8px; }
  .brand { gap: 8px; }
  .brand > svg { width: 22px; height: 22px; flex: none; }
  /* Com o jogo instalado no ecrã principal (ou em ecrã inteiro), nada fica por baixo do entalhe nem da barra de gestos. */
  .top { padding-top: max(10px, env(safe-area-inset-top)); }
  .tabs { padding-bottom: env(safe-area-inset-bottom); }
  .sheet { padding-bottom: max(22px, env(safe-area-inset-bottom)); }
}
@media (max-width: 479px) {
  /* Num telemóvel estreito, o nome do castro vale mais do que o emblema e do que o nome do povo. */
  .b-fac { display: none; }
  .brand > svg { display: none; }
  .brand b { font-size: 18px; }
}
.scene { overflow: hidden; }

/* O mapa arrasta-se com o dedo ou com o rato. */
.map-svg { touch-action: none; cursor: grab; -webkit-user-select: none; user-select: none; }
.map-svg.dragging { cursor: grabbing; }
.map-svg.dragging .npc { pointer-events: none; }

/* Imagens dos edifícios e guia */
.b-ico { display: block; }
.b-pic { display: grid; place-items: center; width: 46px; height: 46px; flex: none; border-radius: 10px; background: #f4efdf; border: 1px solid var(--granite-2); border-bottom: 3px solid var(--cat, var(--granite-2)); }
.b-pic.big { width: 68px; height: 68px; border-radius: 12px; }
.b-pic.add { border: 1px dashed var(--ink-3); background: none; color: var(--ink-2); font: 400 26px/1 var(--font-body); }
.sheet-titles { flex: 1; min-width: 0; }
.opt-head { display: flex; align-items: flex-start; gap: 10px; }
.opt-head > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.option.pick { border-color: var(--gorse); box-shadow: 0 0 0 3px var(--gorse-soft); }
.guide-btn { display: flex; align-items: center; justify-content: center; gap: 8px; }
.guide-row { align-items: flex-start; }
.guide-row .row-main { gap: 2px; }
.guide-row .g-req { color: var(--ink); }
.guide-row .g-st { font-weight: 600; }
.guide-row .g-st.ok { color: var(--ok); }
.guide-row .g-st.go { color: var(--atlantic); }
.guide-row .g-st.lock { color: var(--bad); }
div.row { cursor: default; }
div.row:hover { background: none; }
.guide-how { display: flex; flex-direction: column; }
.guide-how > div { padding: 7px 0; border-bottom: 1px solid var(--granite-1); }
.guide-how dt { font-weight: 600; }
.guide-how dd { color: var(--ink-2); font-size: 14.5px; }

/* Feitos: três medalhas por feito (bronze, prata, ouro); a tracejado, o grau a que já se chegou e falta recolher. */
.medal-pic { color: var(--gorse); background: var(--gorse-soft); border-bottom-color: var(--gorse); }
.feats-card.ready { border-color: #e3cf86; background: #fdf9ea; }
.feats { display: flex; flex-direction: column; }
.feat { display: flex; flex-direction: column; gap: 5px; padding: 11px 0; border-top: 1px solid var(--granite-1); }
.feat:first-child { border-top: 0; padding-top: 0; }
.feat-top { display: flex; align-items: center; gap: 8px; }
.feat-top b { flex: 1; min-width: 0; }
.feat small b { color: var(--ink); font-variant-numeric: tabular-nums; }
.feat .bar i { background: var(--heather); }
.medals { display: inline-flex; gap: 3px; flex: none; }
.md { width: 15px; height: 15px; border-radius: 50%; border: 2px solid var(--granite-2); }
.md.due { border-color: var(--heather); border-style: dashed; }
.md.got.g0 { background: #b9783f; border-color: #8a5527; }
.md.got.g1 { background: #c8d0d4; border-color: #86949a; }
.md.got.g2 { background: var(--gorse); border-color: #a67c0c; }
.feat-claim { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; margin-top: 2px; }
.feat-claim .btn { min-height: 40px; padding: 7px 14px; }

/* Relatório de batalha: as duas forças frente a frente e as baixas de cada fase. */
.clash { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: stretch; gap: 8px; }
.force { display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 10px; border: 1px solid var(--granite-2); border-radius: 12px; background: var(--granite-0); }
.force.mine { background: var(--atlantic-soft); border-color: #b4cdd3; }
.force-title { font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.force-icons { display: flex; gap: 1px; min-height: 30px; overflow: hidden; }
.force-n { font: 400 21px/1.1 var(--font-display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.force-n span { color: var(--ink-3); font-size: 15px; }
.force .bar { height: 7px; }
.force .bar i { background: var(--ok); }
.force small { color: var(--ink-2); font-size: 12.5px; }
.vs { align-self: center; color: var(--ink-3); font-size: 11.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.phases.viz li { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; }
.ph-bars { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
.ph { display: flex; height: 6px; background: var(--granite-1); border-radius: 3px; overflow: hidden; }
.ph.a { justify-content: flex-end; }
.ph i { display: block; height: 100%; background: var(--bad); }

/* Reforços */
.mini-btn { min-height: 34px; padding: 4px 10px; font-size: 13.5px; flex: none; }
h3.sub { font: 600 14px/1.3 var(--font-body); letter-spacing: 0; margin-top: 4px; }

/* O caldeirão da curandeira */
.pot-pic { background: #e9f1ea; border-bottom-color: #5f8d5a; }
.ing { display: inline-block; width: 13px; height: 13px; flex: none; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .25); }
.ing-list { display: flex; flex-direction: column; }
.ing-chip { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--granite-1); }
.ing-chip > span { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ing-chip small { color: var(--ink-2); font-size: 13px; font-weight: 400; }
.ing-n { font-size: 17px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ing-pick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
.ing-pick button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 56px; padding: 6px 2px; border: 1px solid var(--granite-2); border-radius: 10px; background: var(--paper); font-size: 11.5px; line-height: 1.15; text-align: center; cursor: pointer; }
.ing-pick button.on { border-color: var(--heather); background: var(--heather-soft); font-weight: 600; box-shadow: 0 0 0 2px var(--heather-soft); }
.ing-pick button:disabled { opacity: .45; cursor: not-allowed; }
.mix-plus { text-align: center; color: var(--ink-3); font-size: 13px; font-weight: 600; margin: -4px 0; }
.brews { display: flex; flex-direction: column; }
.brew { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; padding: 11px 0; border-top: 1px solid var(--granite-1); }
.brew:first-child { border-top: 0; padding-top: 0; }
.brew .li-top { width: 100%; }
.book { display: flex; flex-direction: column; gap: 3px; color: var(--ink-2); font-size: 14px; }
.sheet h3 small { font: 400 13.5px var(--font-body); color: var(--ink-2); letter-spacing: 0; }

/* Juras */
.vow-pic { background: var(--gorse-soft); border-bottom-color: var(--gorse); }
.vow-kinds { display: flex; flex-direction: column; gap: 6px; }
.vow-kind { display: flex; flex-direction: column; gap: 1px; min-height: 48px; padding: 8px 12px; border: 1px solid var(--granite-2); border-radius: 10px; background: var(--paper); text-align: left; cursor: pointer; }
.vow-kind span { color: var(--ink-2); font-size: 13.5px; }
.vow-kind.on { border-color: var(--heather); background: var(--heather-soft); box-shadow: 0 0 0 2px var(--heather-soft); }
.seg.three { grid-template-columns: repeat(3, 1fr); }
.seg.three button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-height: 52px; padding: 4px 2px; }
.seg.three small { color: var(--ink-2); font-size: 11.5px; font-weight: 400; line-height: 1.2; text-align: center; }

/* Relevo e vida nos cenários. As animações longas começam em «--t» (a hora em que o desenho entrou na página),
   para continuarem no ponto certo quando o cenário é redesenhado. */
.clouds { pointer-events: none; opacity: calc(1 - var(--night, 0)); }
.orbit { transform-box: view-box; transform-origin: center; transform: rotate(var(--from, 0deg)); pointer-events: none; }
.can { pointer-events: none; transform-box: fill-box; transform-origin: center; }
.can.tap { pointer-events: auto; cursor: pointer; }
.can .can-hit { fill: transparent; stroke: none; }
.can.tap:hover circle:not(.can-hit), .can.tap:focus-visible circle:not(.can-hit) { fill: #3c9a62; }
.can circle { fill: #2f7a4d; stroke: #fff; stroke-width: 1.6; }
.can path { fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.can-hint { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.can-hint i { display: inline-block; width: 11px; height: 11px; border-radius: 50%; background: #2f7a4d; border: 1.5px solid #fff; box-shadow: 0 0 0 1px #2f7a4d; }
@keyframes drift { to { transform: translateX(var(--span, 500px)); } }
@keyframes orbit { from { transform: rotate(var(--from, 0deg)); } to { transform: rotate(calc(var(--from, 0deg) + var(--turn, 360deg))); } }
@keyframes ripple { from { transform: translateX(-2.5px); } to { transform: translateX(2.5px); } }
@keyframes beckon { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.2); } }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: no-preference) {
  .cloud { animation: drift var(--dur, 95s) linear infinite; animation-delay: calc(var(--t, 0) * 1s + var(--lag, 0s)); }
  .orbit { animation: orbit var(--dur, 60s) linear infinite; animation-delay: calc(var(--t, 0) * 1s); }
  .scene-svg:not(.map-svg) .wave { animation: ripple 2.8s ease-in-out infinite alternate; }
  .can { animation: beckon 1.8s ease-in-out infinite; }
  #tabview.enter > * { animation: enter .22s ease-out; }
}
@media (prefers-reduced-motion: reduce) {
  .cloud { display: none; }
}

/* Emboscadas e marchas de outros no mapa */
.spot-ring { fill: rgba(255, 255, 255, .1); stroke: #12313d; stroke-width: 1.1; stroke-dasharray: 2.2 2.6; opacity: .42; }
.spot:hover .spot-ring, .spot:focus-visible .spot-ring { stroke: var(--gorse); stroke-width: 2.4; opacity: 1; }
.amb > circle:first-child { fill: #f4efdf; stroke: #4d4538; stroke-width: 1.4; }
.amb path { fill: #fff; stroke: #4d4538; stroke-width: 1.1; }
.amb .pupil { fill: #4d4538; }
.amb.mine > circle:first-child { fill: var(--heather); stroke: #fff; }
.amb.foe > circle:first-child { fill: var(--bad); stroke: #fff; }
.amb.ally > circle:first-child { fill: #1d7a6a; stroke: #fff; }
.mv.foe { fill: var(--bad); }
.mv.ally { fill: #1d7a6a; }

/* ---------- Gado ---------- */
.herd-top { display: flex; align-items: center; gap: 12px; }
.herd-pic { flex: none; width: 48px; height: 48px; border-radius: 50%; background: var(--gorse-soft); border: 1px solid #e3cf86; display: grid; place-items: center; }
.herd-who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.herd-season { background: var(--granite-0); border-radius: 10px; padding: 9px 12px; font-size: 14px; color: var(--ink-2); }
.herd-season b { color: var(--ink); }
.herd-btns { flex-wrap: wrap; }
.herd-btns .btn.grow { flex: 1 1 100%; }
.herd-btns .btn.ghost { flex: 1 1 0; }
.seasons { list-style: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; padding: 0; margin: 0; }
.seasons li { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 2px; border-radius: 9px; background: var(--granite-0); border: 2px solid transparent; font-size: 12.5px; color: var(--ink-2); text-align: center; }
.seasons li b { font-size: 13.5px; color: var(--ink); }
.seasons li.now { border-color: var(--atlantic); background: var(--paper); }
.seasons li.q3 b { color: var(--ok); }
.seasons li.q1 b { color: #8a6a10; }
.seasons li.q0 b { color: var(--bad); }
.pq { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .18); }
.pq.q3 { background: #2f7a4d; border-color: #e0b12a; box-shadow: 0 0 0 1.5px #e0b12a; }
.pq.q2 { background: #9dbb55; }
.pq.q1 { background: #c79a2a; }
.pq.q0 { background: #a9573f; }
.pasture > circle:first-child { stroke: #f4f1e6; stroke-width: 1.6; }
.pasture.q3 > circle:first-child { fill: #2f7a4d; stroke: #f0c94a; stroke-width: 2.4; }
.pasture.q2 > circle:first-child { fill: #9dbb55; }
.pasture.q1 > circle:first-child { fill: #c79a2a; }
.pasture.q0 > circle:first-child { fill: #a9573f; }
.pasture path { fill: none; stroke: #f4f1e6; stroke-width: 1.5; stroke-linecap: round; }
.herd > circle:first-child { fill: #f4efdf; stroke: var(--bad); stroke-width: 2.2; }
.herd.mine > circle:first-child { stroke: var(--heather); }
.herd.ally > circle:first-child { stroke: #1d7a6a; }
.herd-n { font: 700 9.5px var(--font-body); fill: #12313d; paint-order: stroke; stroke: rgba(244, 241, 230, .92); stroke-width: 2.6px; stroke-linejoin: round; pointer-events: none; }
.mv.cattle { stroke: var(--gorse); stroke-width: 2.6; }
.mapnav .btn .ico { margin-right: 5px; vertical-align: -3px; }
.mapnav .btn.on { background: var(--atlantic); color: #fff; }
.alert.herd-alert { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.alert.herd-alert .btn { flex: none; min-height: 38px; padding: 6px 12px; font-size: 14px; }

/* ---------- Invasão ---------- */
.fallen { fill: rgba(140, 28, 18, .26); pointer-events: none; }
.fallen.next { fill: rgba(140, 28, 18, .1); }
.bands { list-style: none; display: flex; gap: 3px; padding: 0; margin: 0; }
.bands li { flex: 1; height: 14px; border-radius: 4px; background: var(--granite-1); position: relative; }
.bands li.fell { background: #9b2f22; }
.bands li.mine::after { content: ''; position: absolute; left: 50%; top: -5px; width: 8px; height: 8px; margin-left: -4px; border-radius: 50%; background: var(--heather); border: 2px solid var(--paper); }
.stances { display: flex; flex-direction: column; gap: 6px; }
.stance { display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 10px 12px; border-radius: 10px; border: 2px solid var(--granite-2); background: var(--paper); color: var(--ink); cursor: pointer; font: inherit; }
.stance small { color: var(--ink-2); font-size: 13.5px; line-height: 1.35; }
.stance.on { border-color: var(--atlantic); background: var(--atlantic-soft); }
.stance:disabled { cursor: default; }
.stance:disabled:not(.on) { opacity: .6; }

/* ---------- Tablet ao alto ---------- */
@media (min-width: 700px) and (max-width: 899px) and (min-height: 600px) {
  .top { padding: 10px 16px; }
  .res { padding: 7px 12px 8px; gap: 6px; }
  .tabs, .tabs.six { padding: 0 8px; gap: 0; }
  .tab, .tabs.six .tab { font-size: 14px; padding: 11px 9px 9px; gap: 6px; }
  #view { gap: 12px 14px; padding: 14px 14px 28px; }
  .hero h1 { font-size: 60px; }
  .hero-text { padding: 20px 24px 0; }
  .start-form { padding: 24px 18px; }
}

/* ---------- Mundos ---------- */
.code { font: 700 26px/1.1 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .14em; color: var(--atlantic-deep); margin: 2px 0; -webkit-user-select: all; user-select: all; }
.world-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.world-row .btn { flex: none; min-height: 38px; padding: 6px 16px; }
.picks { display: flex; gap: 6px; flex-wrap: wrap; }
.picks .btn { flex: 1; min-height: 40px; padding: 6px 8px; font-size: 14px; white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 14.5px; }
.check input { width: 22px; height: 22px; flex: none; margin: 1px 0 0; }

/* ---------- Fim da época ---------- */
.season-end { border: 2px solid var(--gorse); background: linear-gradient(var(--gorse-soft), var(--paper) 55%); }
.podium { list-style: none; display: grid; grid-template-columns: 1fr 1.15fr 1fr; align-items: end; gap: 6px; padding: 0; margin: 6px 0 2px; }
.podium li { display: flex; flex-direction: column; align-items: center; gap: 1px; text-align: center; padding: 8px 4px 10px; border-radius: 10px 10px 4px 4px; background: var(--granite-1); min-width: 0; }
.podium li b, .podium li small { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.podium li small { color: var(--ink-2); font-size: 12.5px; }
.podium .place { font: 400 20px/1 var(--font-display); color: var(--ink-2); }
.podium .score { margin-top: 4px; font-weight: 700; font-variant-numeric: tabular-nums; }
.podium .p1 { min-height: 132px; background: var(--gorse); color: #2a2205; }
.podium .p1 .place, .podium .p1 small { color: #4a3c08; }
.podium .p2 { min-height: 108px; }
.podium .p3 { min-height: 92px; }
.podium .empty { visibility: hidden; }
.podium .me { outline: 3px solid var(--heather); outline-offset: -3px; }
.verdict { font-size: 15.5px; }

/* O ancião: o botão ao canto e a janela de conversa. */
.adv-fab { position: absolute; right: 10px; bottom: calc(68px + env(safe-area-inset-bottom)); z-index: 4; display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px 0 11px; border: 2px solid var(--gorse); border-radius: 22px; background: var(--atlantic-deep); color: #fff; font-weight: 600; font-size: 14px; cursor: pointer; box-shadow: 0 4px 14px rgba(0, 0, 0, .28); }
.adv-fab:hover { background: var(--atlantic); }
.app.wide .adv-fab { bottom: calc(56px + env(safe-area-inset-bottom)); min-height: 40px; padding: 0 10px; }
.app.wide .adv-fab span { display: none; }
.app.start-mode .adv-fab { display: none; }
.sheet.tall { min-height: 62%; padding-top: 0; padding-bottom: 0; }
.sheet.tall .sheet-head { position: sticky; top: 0; z-index: 2; margin: 0 -16px; padding: 14px 16px 8px; background: var(--paper); border-radius: 16px 16px 0 0; }
.sheet.tall #advisor-form { position: sticky; bottom: 0; z-index: 2; margin: auto -16px 0; padding: 10px 16px calc(14px + env(safe-area-inset-bottom)); background: var(--paper); border-top: 1px solid var(--granite-1); }
.adv-log { display: flex; flex-direction: column; gap: 8px; }
.adv-log > li { max-width: 94%; padding: 10px 12px; border-radius: 14px; display: flex; flex-direction: column; gap: 7px; font-size: 15px; }
.adv-a { align-self: flex-start; background: var(--granite-0); border: 1px solid var(--granite-1); border-bottom-left-radius: 4px; }
.adv-q { align-self: flex-end; background: var(--atlantic); color: #fff; border-bottom-right-radius: 4px; }
.adv-todo { display: flex; flex-direction: column; gap: 6px; padding-left: 20px; list-style: decimal; }
.adv-acts, .adv-more, .adv-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.adv-acts .btn { min-height: 38px; padding: 6px 12px; font-size: 14px; background: var(--paper); }
.adv-chip { min-height: 36px; padding: 6px 12px; border: 1px solid #b4cdd3; border-radius: 18px; background: var(--atlantic-soft); color: var(--atlantic-deep); font-size: 13.5px; font-weight: 600; text-align: left; cursor: pointer; }
.adv-chip:hover { background: #c5d9de; }
@media (max-width: 699px), (max-width: 899px) and (max-height: 599px) {
  #view { padding-bottom: 76px; }
  .app.wide #view { padding-bottom: 64px; }
}
@media (min-width: 900px), (min-width: 700px) and (min-height: 600px) {
  .adv-fab { right: 24px; bottom: 24px; }
  .sheet.tall { min-height: 0; }
}

/* A tira do cimo: etiquetas do que está a valer agora (acontecimento do dia, o de amanhã, proteção, trégua). */
.strip { display: flex; flex-wrap: wrap; gap: 6px; }
.st-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 4px 11px 4px 9px; border: 1px solid var(--granite-2); border-radius: 17px; background: var(--paper); color: var(--ink); font: inherit; font-size: 13.5px; cursor: pointer; text-align: left; }
.st-chip svg { flex: none; }
.st-chip small { color: var(--ink-2); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.st-chip small .eta { font-weight: 600; }
.st-chip.event { background: var(--gorse-soft); border-color: #e3cf86; color: #4a3904; }
.st-chip.event.bad { background: var(--bad-soft); border-color: #e5b9af; color: #6f2318; }
.st-chip.next { border-style: dashed; color: var(--ink-2); }
.st-chip.pause { border-style: dashed; border-color: var(--ink-3); color: var(--ink-2); }
.st-chip.pause b { color: var(--ink); }
.st-chip.warn { background: var(--gorse-soft); border-color: #e3cf86; color: #5d4705; }
.st-chip.calm { background: var(--atlantic-soft); border-color: #b4cdd3; color: var(--atlantic-deep); }
.note.ev-note { background: var(--gorse-soft); color: #5d4705; }
.app.wide .st-chip { min-height: 28px; padding: 2px 9px 2px 7px; font-size: 12.5px; }

/* As crónicas das épocas anteriores. */
.chron { display: flex; flex-direction: column; gap: 3px; padding-left: 20px; list-style: decimal; font-size: 14px; }
.chron li { display: list-item; padding-left: 2px; overflow: hidden; }
.chron li > span { display: inline; }
.chron li > span:last-child { float: right; margin-left: 8px; font-variant-numeric: tabular-nums; font-weight: 600; }

/* Festejar: o salto e o clarão de uma obra pronta, os números que sobem a voar e a chuva de cores. */
#fx { position: absolute; inset: 0; z-index: 7; pointer-events: none; overflow: hidden; }
.burst { display: none; pointer-events: none; }
.burst circle { fill: none; stroke: #f3cf62; stroke-width: 3; }
.burst path { fill: none; stroke: #fff3c4; stroke-width: 2.6; stroke-linecap: round; }
.fly { position: absolute; transform: translate(-50%, 0); padding: 2px 9px; border-radius: 12px; background: #245f3d; color: #fff; font: 700 14px var(--font-body); white-space: nowrap; box-shadow: 0 3px 10px rgba(0, 0, 0, .25); opacity: 0; }
.fly.gold { background: var(--gorse); color: #17262c; }
.confetti { position: absolute; inset: 0; }
.confetti i { position: absolute; top: -14px; width: 9px; height: 14px; border-radius: 2px; opacity: 0; }
@keyframes grew { 0% { transform: scale(.72); } 45% { transform: scale(1.22); } 70% { transform: scale(.96); } 100% { transform: scale(1); } }
@keyframes burst { 0% { transform: scale(.25); opacity: 1; } 70% { opacity: .9; } 100% { transform: scale(1.55); opacity: 0; } }
@keyframes fly { 0% { opacity: 0; transform: translate(-50%, 8px) scale(.8); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.08); } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, 34px) scale(1); } }
@keyframes confetti { 0% { opacity: 1; transform: translate(0, 0) rotate(0deg); } 85% { opacity: 1; } 100% { opacity: 0; transform: translate(var(--sway, 0), 72vh) rotate(var(--turn, 200deg)); } }
@media (prefers-reduced-motion: no-preference) {
  .grew { transform-box: fill-box; transform-origin: center; animation: grew .95s cubic-bezier(.3, 1.3, .5, 1); }
  .burst { display: block; transform-box: fill-box; transform-origin: center; animation: burst 1.1s ease-out forwards; }
  .fly { animation: fly 1.45s ease-out forwards; }
  .confetti i { animation: confetti 1.6s cubic-bezier(.3, .1, .6, 1) forwards; }
}
@media (prefers-reduced-motion: reduce) {
  .fly { opacity: 1; }
  .confetti { display: none; }
}

/* Lugares disputados: a estrela no mapa e o ponto de cor na lista; a etiqueta da dívida de sangue. */
.place > circle { fill: #f6efd8; stroke: #4d4538; stroke-width: 1.5; }
.place polygon:not(.hit) { fill: var(--gorse); stroke: #5d4705; stroke-width: .8; stroke-linejoin: round; }
.place.mine > circle { fill: var(--heather); stroke: #fff; }
.place.ally > circle { fill: #1d7a6a; stroke: #fff; }
.place.foe > circle { fill: var(--bad); stroke: #fff; }
.place.mine polygon:not(.hit), .place.ally polygon:not(.hit), .place.foe polygon:not(.hit) { fill: #fff; stroke: none; }
.place:hover > circle, .place:focus-visible > circle { stroke: var(--gorse); stroke-width: 2.6; }
.map-name.place-name { font-style: italic; fill: #5d4705; }
.place-dot { flex: none; width: 14px; height: 14px; border-radius: 50%; border: 2px solid #4d4538; background: #f6efd8; }
.place-dot.mine { background: var(--heather); border-color: var(--heather); }
.place-dot.ally { background: #1d7a6a; border-color: #1d7a6a; }
.place-dot.foe { background: var(--bad); border-color: var(--bad); }
.st-chip.blood { background: #5c1a12; border-color: #5c1a12; color: #fff; }
.st-chip.blood small { color: #f3cfc8; }

/* A escolha de língua: dois botões lado a lado. */
.lang-row { display: flex; gap: 8px; margin: 10px 0; }
.lang-row .btn { flex: 1; min-height: 40px; }
.start .lang-row { max-width: 420px; margin: 12px auto 0; width: 100%; padding: 0 16px; box-sizing: border-box; }

/* O aviso da morada nova no ecrã de entrada, e um botão que é uma ligação. */
.start-note { max-width: 420px; margin: 12px auto 0; width: 100%; padding: 0 16px; box-sizing: border-box; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
