:root {
  --bg: #f4efe6;
  --surface: #fffdf8;
  --ink: #241c15;
  --muted: #6f6257;
  --line: #e0d6c6;
  --accent: #8c1c13;
  --accent-deep: #6d140d;
  --accent-ink: #fff;
  --gold: #a87a1f;
  --gold-soft: rgba(168, 122, 31, 0.16);
  --bad: #b3261e;
  --ok: #2e7d4f;
  --radius: 12px;
  color-scheme: light;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
/* Tema fosc: segons el sistema, o forçat amb data-theme. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17130f;
    --surface: #231d17;
    --ink: #efe6d8;
    --muted: #a59886;
    --line: #3a3027;
    --accent: #b93a26;
    --accent-deep: #8f2a1a;
    --gold: #d6a94a;
    --gold-soft: rgba(214, 169, 74, 0.14);
    --bad: #ff8a7a;
    --ok: #7fcf9f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17130f;
  --surface: #231d17;
  --ink: #efe6d8;
  --muted: #a59886;
  --line: #3a3027;
  --accent: #b93a26;
  --accent-deep: #8f2a1a;
  --gold: #d6a94a;
  --gold-soft: rgba(214, 169, 74, 0.14);
  --bad: #ff8a7a;
  --ok: #7fcf9f;
  color-scheme: dark;
}
body::before {
  content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--accent);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 500px at 50% -120px, var(--gold-soft), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
#app { max-width: 720px; margin: 0 auto; min-height: 100vh; }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; margin: 0; }
a { color: inherit; text-decoration: none; }
a.a { color: var(--accent); text-decoration: underline; }
small { font-weight: 400; }
.muted { color: var(--muted); font-size: 0.875rem; }
.bad { color: var(--bad); }
.ok { color: var(--ok); }
.grow { flex: 1; min-width: 0; }
.block { display: block; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.ic { width: 18px; height: 18px; fill: currentColor; flex: none; }
.ic.big { width: 56px; height: 56px; color: var(--gold); margin-bottom: 8px; }
.loading { text-align: center; padding: 96px 16px; color: var(--muted); }

/* Menú superior (fix) */
.topnav {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 6;
  display: flex; align-items: stretch; gap: 8px;
  padding: 0 max(4px, env(safe-area-inset-right, 0px)) 0 max(4px, env(safe-area-inset-left, 0px));
  background: linear-gradient(var(--accent), var(--accent-deep));
  color: var(--accent-ink);
  border-bottom: 2px solid var(--gold);
  box-shadow: 0 3px 0 -1px var(--accent-deep), 0 4px 0 -1px var(--gold), 0 6px 12px rgba(0, 0, 0, 0.18);
}
.tabs { flex: 1; display: flex; max-width: 760px; margin: 0 auto; }
.tab {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  padding: 8px 2px 7px; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em; opacity: 0.78;
  border-bottom: 3px solid transparent; margin-bottom: -2px;
}
.tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab .ic { width: 21px; height: 21px; }
.tab.on { opacity: 1; color: #f7e3a6; border-bottom-color: #f0d48a; }
.tab-logo { width: 24px; height: 24px; border-radius: 6px; box-shadow: 0 0 0 1px rgba(240, 212, 138, 0.6); }
.tab-home { opacity: 0.95; }
@media (max-width: 380px) { .tab { font-size: 0.66rem; letter-spacing: 0; } }
@media (min-width: 700px) {
  .tab { flex-direction: row; gap: 7px; font-size: 0.85rem; padding: 14px 6px 12px; }
}

/* Pestanyes internes de secció (control segmentat) */
.seg.subtabs {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; padding: 3px; overflow: visible;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 16px;
}
.seg.subtabs a { border: 0; background: transparent; border-radius: 9px; text-align: center; padding: 8px 4px; font-size: 0.84rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg.subtabs a.on { background: linear-gradient(var(--accent), var(--accent-deep)); color: var(--accent-ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); }

/* Portada */
.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo { width: 64px; height: 64px; flex: none; border-radius: 16px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28), 0 0 0 1px var(--gold); }
.brand h1 { font: 700 1.6rem/1.1 Georgia, serif; margin: 0 0 4px; }
.btn.round { width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 50%; display: grid; place-items: center; flex: none; }
.tagline { margin: 14px 0 0; color: var(--muted); font-size: 0.95rem; max-width: 52ch; }
.quick { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 18px; padding: 0 16px 4px; scrollbar-width: none; }
.quick::-webkit-scrollbar { display: none; }
.quick .chip { flex: none; display: inline-flex; align-items: center; font-weight: 600; font-size: 0.88rem; border-color: var(--gold); background: var(--gold-soft); }
.live-card { border-left: 3px solid var(--accent); }
.fix { display: flex; flex-direction: column; gap: 6px; margin: 0 0 10px; padding: 10px 12px; border-radius: var(--radius); background: var(--gold-soft); border: 1px dashed var(--gold); }
.fix .chip { min-height: 36px; font-weight: 600; }

/* Capçalera de cada secció */
.bar {
  display: flex; align-items: center; gap: 4px;
  padding: 14px max(12px, env(safe-area-inset-right, 0px)) 10px max(12px, env(safe-area-inset-left, 0px));
  border-bottom: 1px solid var(--line);
}
.bar-title { flex: 1; min-width: 0; padding: 0 4px; }
.bar h1 { font-size: 1.4rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: 0.01em; text-wrap: balance; }
.bar-title p { margin: 2px 0 0; font-size: 0.78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .back { font-size: 2rem; line-height: 1; width: 40px; height: 44px; display: grid; place-items: center; margin-left: -8px; color: var(--accent); }
.bar-actions { display: flex; gap: 6px; }
.bar .btn.ghost { min-height: 36px; padding: 6px 10px; font-size: 0.9rem; }

main {
  padding-block: 14px 96px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
textarea { min-height: 96px; font: 0.8rem/1.4 ui-monospace, Consolas, monospace; }

/* Botons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 16px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer;
  transition: transform 0.08s;
}
.btn:active, .card:active, .chip:active { transform: scale(0.985); }
.btn.primary { background: linear-gradient(var(--accent), var(--accent-deep)); border-color: var(--accent-deep); color: var(--accent-ink); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18); }
.btn.danger { color: var(--bad); }
.btn.add { width: 100%; border-style: dashed; border-color: var(--gold); background: transparent; color: var(--muted); }
.icon { width: 40px; height: 40px; flex: none; border: 0; background: none; color: var(--muted); font-size: 1rem; cursor: pointer; border-radius: 50%; }
.row-actions { display: flex; gap: 8px; margin-top: 16px; }
.row-actions > * { flex: 1; }
.stack { display: grid; gap: 8px; margin-top: 8px; }
.fab {
  position: fixed; right: max(16px, calc(50% - 344px), env(safe-area-inset-right, 0px)); bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(var(--accent), var(--accent-deep)); color: var(--accent-ink); font-weight: 700;
  padding: 14px 20px; border-radius: 999px; border: 1.5px solid var(--gold);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* Targetes */
.card {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px 14px; margin-bottom: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  color: inherit; font: inherit; text-align: left;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: transform 0.08s;
}
.card strong { display: block; overflow-wrap: anywhere; }
.card .muted { display: block; }
.card .det { margin-top: 2px; }
.card .pts { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; font-family: Georgia, serif; font-size: 1.05rem; }
.card .pts small { color: var(--muted); font-family: system-ui, sans-serif; font-size: 0.8rem; }
.card.unit { border-left: 3px solid var(--gold); }
.card.has-error { border-left-color: var(--bad); }
button.card { cursor: pointer; }
.crest {
  width: 42px; height: 46px; flex: none; display: grid; place-items: center;
  background: linear-gradient(var(--accent), var(--accent-deep)); color: #f0d48a;
  font: 700 0.95rem Georgia, serif; letter-spacing: 0.02em;
  clip-path: polygon(0 0, 100% 0, 100% 62%, 50% 100%, 0 62%);
  padding-bottom: 8px;
}
.tag, .badge {
  display: inline-block; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em;
  padding: 2px 8px; border-radius: 99px; background: var(--gold-soft); color: var(--ink); border: 1px solid var(--gold);
}
.tag { margin-top: 4px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }

.empty { text-align: center; padding: 48px 16px; }
.empty p { margin: 0 0 8px; }
.note { background: var(--gold-soft); border-left: 3px solid var(--gold); border-radius: 0 var(--radius) var(--radius) 0; padding: 10px 12px; margin: 0 0 16px; font-size: 0.9rem; }

/* Resum */
.summary {
  position: relative;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 18px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.summary::before {
  content: ""; position: absolute; inset: 4px; border: 1px solid var(--gold); opacity: 0.35; border-radius: 9px; pointer-events: none;
}
.summary.sticky { position: sticky; top: calc(62px + env(safe-area-inset-top, 0px)); z-index: 3; }
.summary p { margin: 8px 0 0; }
.total { font-variant-numeric: tabular-nums; }
.total strong { font-size: 1.9rem; font-family: Georgia, serif; }
.total .muted { margin-left: 6px; }
.meter {
  position: relative; height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 8px;
}
.meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), color-mix(in srgb, var(--gold) 70%, #fff)); border-radius: 99px; }
.meter::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent calc(25% - 1px), var(--surface) 0 25%, transparent 0 calc(50% - 1px), var(--surface) 0 50%, transparent 0 calc(75% - 1px), var(--surface) 0 75%, transparent 0);
  opacity: 0.7;
}
.meter.bad i { background: var(--bad); }
.valid { color: var(--ok); font-weight: 600; }
.invalid { color: var(--bad); font-weight: 600; }
.issues { margin: 6px 0 8px; padding-left: 20px; font-size: 0.875rem; color: var(--bad); }
.issues li { margin: 2px 0; }

/* Categories */
.cat { margin-bottom: 22px; }
.cat-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px; padding-bottom: 5px; color: var(--ink);
  border-bottom: 2px solid var(--gold); position: relative;
}
.cat-head::after {
  content: "◆"; position: absolute; left: 50%; bottom: -9px; transform: translateX(-50%);
  font-size: 0.7rem; color: var(--gold); background: var(--bg); padding: 0 6px; line-height: 1;
}
.cat-head .ic { color: var(--gold); }
.cat-head h2 { font-size: 1.1rem; flex: 1; }
.cat-pts { font-size: 0.85rem; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; line-height: 1.2; }
.cat-pts small { display: block; font-size: 0.72rem; }
.cat-pts.bad { color: var(--bad); font-weight: 600; }

/* Editor d'unitat */
.block { margin-bottom: 20px; }
section.block h2 { font-size: 1rem; margin-bottom: 8px; display: flex; align-items: baseline; gap: 8px; }
section.block h2::before { content: "◆"; color: var(--gold); font-size: 0.6rem; margin-right: -2px; align-self: center; }
section.block h2 small { font-family: system-ui, sans-serif; font-size: 0.85rem; margin-left: auto; }
.opts { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); }
.opt {
  display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 6px 12px;
  border-top: 1px solid var(--line); cursor: pointer;
}
.opts > .opt:first-child, .type-head + .opt { border-top: 0; }
.opt.sub { padding-left: 34px; background: color-mix(in srgb, var(--gold) 6%, transparent); }
.opt.off { opacity: 0.45; }
.opt.link .chev { color: var(--gold); font-size: 1.4rem; line-height: 1; }
.opt input[type="checkbox"], .opt input[type="radio"] { width: 22px; height: 22px; accent-color: var(--accent); flex: none; margin: 0; }
.opt .qty { width: 58px; min-height: 40px; flex: none; text-align: center; padding: 6px 4px; }
.opt-pts { color: var(--muted); font-size: 0.875rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.type-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--gold);
  padding: 10px 12px 4px; background: var(--gold-soft); border-top: 1px solid var(--line);
}
.opts > .type-head:first-child { border-top: 0; }
.type-head small { font-family: system-ui, sans-serif; color: var(--muted); }
.stepper { display: flex; gap: 8px; }
.stepper button { width: 56px; height: 48px; font-size: 1.5rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); cursor: pointer; }
.stepper input { flex: 1; text-align: center; font-size: 1.25rem; font-weight: 700; }
.notes { white-space: pre-wrap; margin: 0; font-size: 0.925rem; }

/* Formularis */
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%; min-width: 0;
}
select:disabled { opacity: 0.6; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.875rem; font-weight: 600; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 40px; padding: 6px 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; }

/* Exportació */
.export { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; white-space: pre-wrap; overflow-wrap: anywhere; font: 0.9rem/1.5 ui-monospace, Consolas, monospace; margin: 0; }

#toast {
  position: fixed; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 99px; font-size: 0.9rem;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; max-width: 90vw; text-align: center; z-index: 20;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.has-action { display: flex; align-items: center; gap: 12px; padding: 6px 6px 6px 16px; width: max-content; }
#toast.has-action span { text-align: left; }
#toast.has-action.show { pointer-events: auto; }
#toast button { border: 0; border-radius: 99px; padding: 8px 14px; font: inherit; font-weight: 700; background: var(--gold); color: #1d1712; cursor: pointer; }
@media (prefers-reduced-motion: reduce) { #toast, .btn, .card { transition: none; } }

/* ---------- Peces comunes noves ---------- */
.eyebrow { margin: 0; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--gold); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 0.875rem; }
.btn.wide { width: 100%; margin-top: 10px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.row-actions.tight { margin-top: 10px; flex-wrap: wrap; }
.row-actions.tight > * { flex: 1 1 auto; }
.ic.lead { width: 26px; height: 26px; color: var(--gold); }
.chev { color: var(--gold); font-size: 1.4rem; line-height: 1; }
.card.off, tr.off { opacity: 0.5; }
.card-form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 18px; }
.card-form h2 { font-size: 1.05rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px 12px; margin: 0; min-width: 0; }
fieldset.grid2 legend { grid-column: 1 / -1; }
legend { font: 700 0.9rem Georgia, serif; padding: 0 6px; color: var(--ink); }
.chip input { accent-color: var(--accent); margin: 0 4px 0 0; }
label.chip { display: inline-flex; align-items: center; }
.inline { display: flex; gap: 8px; margin-top: 10px; }
.inline input { flex: 1; }
.badge.win { background: color-mix(in srgb, var(--ok) 18%, transparent); border-color: var(--ok); }
.badge.loss { background: color-mix(in srgb, var(--bad) 16%, transparent); border-color: var(--bad); }
.badge.live { background: var(--accent); color: var(--accent-ink); border-color: var(--accent-deep); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.tbl { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.tbl th { text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--gold); background: var(--gold-soft); padding: 8px 10px; white-space: nowrap; }
.tbl td { padding: 8px 10px; border-top: 1px solid var(--line); vertical-align: middle; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tr.warn td:first-child { box-shadow: inset 3px 0 0 var(--gold); font-weight: 600; }

/* Inici */
.hero { margin-bottom: 22px; }
.hero h2 { font-size: 1.55rem; margin: 4px 0 14px; text-wrap: balance; }
.tools { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tool {
  position: relative; display: flex; flex-direction: column; gap: 3px; padding: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); transition: transform 0.08s;
}
.tool:active { transform: scale(0.985); }
.tool .ic { width: 28px; height: 28px; color: var(--accent); margin-bottom: 4px; }
.tool strong { font: 700 1.05rem Georgia, serif; }
.tool span { font-size: 0.82rem; color: var(--muted); }
.tool small { margin-top: auto; padding-top: 6px; font-size: 0.75rem; font-weight: 600; color: var(--gold); }
.news { padding: 12px 0; border-bottom: 1px solid var(--line); }
.news:last-child { border-bottom: 0; }
.news time { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--gold); }
.news h3 { font-size: 1.08rem; margin: 2px 0 4px; }
.news p { margin: 0 0 6px; max-width: 65ch; }
.ad {
  position: relative; display: flex; gap: 12px; align-items: center; margin: 0 0 22px; padding: 14px 14px 14px;
  background: var(--surface); border: 1px solid var(--gold); border-radius: var(--radius);
}
.ad img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; flex: none; }
.ad p { margin: 2px 0 0; font-size: 0.9rem; color: var(--muted); }
.ad-label { position: absolute; top: -9px; right: 12px; font-size: 0.65rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; background: var(--bg); color: var(--gold); padding: 0 6px; }
.ad-slot { display: grid; place-items: center; min-height: 90px; margin: 0 0 22px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); font-size: 0.8rem; letter-spacing: 0.06em; text-transform: uppercase; }

/* Comparador */
.tips { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.tips li { padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--gold); border-radius: 0 var(--radius) var(--radius) 0; font-size: 0.92rem; }
.legend { display: flex; gap: 16px; font-size: 0.8rem; color: var(--muted); margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.sw.me, .hbar.me i { background: var(--accent); }
.sw.ref, .hbar.ref i { background: var(--gold); }
.cmp-row { display: grid; grid-template-columns: 96px 1fr; gap: 10px; align-items: center; padding: 6px 0; }
.cmp-label { font-size: 0.875rem; font-weight: 600; }
.cmp-bars { display: grid; grid-template-columns: 1fr 42px; gap: 4px 8px; align-items: center; }
.cmp-bars b { font-size: 0.8rem; text-align: right; font-variant-numeric: tabular-nums; }
.hbar { display: inline-block; width: 100%; height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; vertical-align: middle; }
.hbar i { display: block; height: 100%; border-radius: 99px; }
.tbl .hbar { width: 70px; }
.card .hbar { margin-top: 6px; }

/* Tornejos */
.seg { display: flex; gap: 4px; overflow-x: auto; margin: 0 0 14px; padding-bottom: 2px; }
.seg a { flex: none; padding: 7px 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); font-size: 0.875rem; font-weight: 600; }
.seg a.on { background: var(--accent); border-color: var(--accent-deep); color: var(--accent-ink); }
.seed { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--gold-soft); color: var(--gold); font-weight: 700; font-size: 0.85rem; }
.pairing { align-items: flex-start; }
.pairing.done { border-left: 3px solid var(--ok); }
.table-no { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font: 700 1rem Georgia, serif; }
.vs { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: start; }
.vs .side { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.vs .side:last-child { text-align: right; align-items: flex-end; }
.vs-mark { align-self: center; font: italic 700 0.95rem Georgia, serif; color: var(--gold); }
.scores { display: flex; gap: 6px; margin-top: 6px; }
.score { display: flex; flex-direction: column; gap: 2px; font-size: 0.68rem; font-weight: 700; color: var(--muted); letter-spacing: 0.05em; }
.score input { width: 66px; min-height: 40px; padding: 6px; text-align: center; font-size: 1rem; font-weight: 700; }
.tp { font-size: 0.8rem; font-weight: 700; color: var(--muted); }
.tp.win { color: var(--ok); }
.tp.loss { color: var(--bad); }
.podium { display: flex; gap: 14px; align-items: center; padding: 16px; margin-bottom: 16px; border: 1px solid var(--gold); border-radius: var(--radius); background: var(--gold-soft); }
.podium .ic { width: 40px; height: 40px; color: var(--gold); }
.podium strong { display: block; font: 700 1.3rem Georgia, serif; }

/* Partides */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.stats div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; text-align: center; }
.stats strong { display: block; font: 700 1.6rem Georgia, serif; font-variant-numeric: tabular-nums; }
.stats span { font-size: 0.78rem; color: var(--muted); }
.scoreboard { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; margin-bottom: 14px; }
.scoreboard .side { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-align: center; min-width: 0; }
.scoreboard .side.me { border-top: 3px solid var(--accent); }
.scoreboard .side.opp { border-top: 3px solid var(--gold); }
.scoreboard .who { font-weight: 700; overflow-wrap: anywhere; }
.scoreboard .big { font: 700 2.4rem/1.1 Georgia, serif; font-variant-numeric: tabular-nums; margin: 4px 0; }
.mini { display: flex; flex-direction: column; gap: 2px; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.04em; color: var(--muted); text-align: center; }
.mini input { width: 86px; min-height: 38px; padding: 6px; text-align: center; font-weight: 700; }
.turn { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 20px; }
.turn-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.phases { list-style: none; margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.phases li { text-align: center; padding: 9px 2px; font-size: 0.8rem; font-weight: 600; border-radius: 8px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.phases li.past { color: var(--ink); background: var(--gold-soft); }
.phases li.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent-deep); box-shadow: 0 0 0 2px var(--gold); }
.result { display: flex; align-items: center; gap: 12px; padding: 14px; margin-bottom: 20px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); }
.result strong { font: 700 1.4rem Georgia, serif; }
.result span { flex: 1; font-variant-numeric: tabular-nums; color: var(--muted); }
.result.win { border-color: var(--ok); }
.result.loss { border-color: var(--bad); }
.wizard { margin-bottom: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.wizard > summary { display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; list-style: none; }
.wizard > summary::-webkit-details-marker { display: none; }
.wizard > summary::after { content: "›"; color: var(--gold); font-size: 1.4rem; transition: transform 0.15s; }
.wizard[open] > summary::after { transform: rotate(90deg); }
.wizard .opts { border: 0; border-top: 1px solid var(--line); border-radius: 0; box-shadow: none; }
.spell { display: flex; align-items: center; gap: 8px; padding: 4px 12px; border-top: 1px solid var(--line); min-height: 48px; }
.spell:first-child { border-top: 0; }
.spell-pick { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; cursor: pointer; }
.spell-pick input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; }
.spell-idx { width: 24px; height: 24px; flex: none; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--gold); color: var(--gold); font-size: 0.75rem; font-weight: 700; }
.spell.known .spell-idx { background: var(--gold); color: var(--surface); }
.spell-state { min-height: 36px; padding: 4px 10px; border-radius: 99px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: inherit; font-size: 0.8rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.spell-state.cast { background: var(--accent); color: var(--accent-ink); border-color: var(--accent-deep); }
.spell-state.failed { color: var(--bad); border-color: var(--bad); }
.sec { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-top: 1px solid var(--line); }
.sec:first-child { border-top: 0; }
.sec .mini input { width: 64px; }
.opt.lost .grow { text-decoration: line-through; color: var(--muted); }
.log { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.log li { font-size: 0.92rem; }

/* Més: descàrregues, eines, taberna, pintura */
.search { display: flex; align-items: center; gap: 8px; padding: 0 12px; margin-bottom: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.search .ic { color: var(--muted); }
.search input { border: 0; background: transparent; padding-left: 0; }
.search input:focus { outline: none; }
.search:focus-within { outline: 3px solid var(--gold); outline-offset: 2px; }
.file-badge {
  width: 42px; height: 50px; flex: none; display: grid; place-items: end center; padding-bottom: 7px;
  background: var(--accent); color: var(--accent-ink); font-size: 0.7rem; font-weight: 800; letter-spacing: 0.05em;
  clip-path: polygon(0 0, 72% 0, 100% 22%, 100% 100%, 0 100%); border-radius: 4px;
}
.file-badge.doc { background: var(--gold); color: var(--surface); }
.card.dl .chev { font-size: 1.1rem; }
.construction { text-align: center; padding: 40px 16px; border: 2px dashed var(--gold); border-radius: var(--radius); background: repeating-linear-gradient(-45deg, transparent 0 14px, var(--gold-soft) 14px 28px); }
.construction h2 { font-size: 1.4rem; margin: 6px 0 10px; }
.construction p { max-width: 42ch; margin: 0 auto 8px; }
.funnel { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 10px 0; }
.funnel div { text-align: center; padding: 8px 4px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line); }
.funnel div.hl { background: var(--accent); color: var(--accent-ink); border-color: var(--accent-deep); }
.funnel strong { display: block; font: 700 1.35rem Georgia, serif; font-variant-numeric: tabular-nums; }
.funnel span { font-size: 0.7rem; line-height: 1.2; display: block; }
.cmp-bars.one { grid-template-columns: 1fr 52px; }
.dice { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 8px; }
.die { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 8px; font: 700 1.1rem Georgia, serif; background: var(--bg); border: 1px solid var(--line); }
.die.hit { background: var(--accent); color: var(--accent-ink); border-color: var(--accent-deep); }
.die.miss { opacity: 0.5; }
.paint-row { padding: 10px 12px; border-top: 1px solid var(--line); }
.paint-row:first-child { border-top: 0; }
.paint-steps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; margin-top: 8px; }
.paint-steps button {
  min-height: 36px; padding: 4px 2px; font: inherit; font-size: 0.66rem; font-weight: 600; line-height: 1.1;
  border: 1px solid var(--line); background: var(--bg); color: var(--muted); border-radius: 6px; cursor: pointer;
}
.paint-steps button.on { background: var(--gold-soft); color: var(--ink); border-color: var(--gold); }
.paint-steps button.cur { background: var(--accent); color: var(--accent-ink); border-color: var(--accent-deep); }

/* Col·lecció */
.col-item { align-items: flex-start; }
.col-item.done { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 2px 10px var(--gold-soft); background: linear-gradient(135deg, var(--gold-soft), var(--surface) 60%); }
.col-item.done .col-name strong::after { content: " ★"; color: var(--gold); }
.col-name { display: block; }
.col-thumb {
  width: 64px; height: 64px; flex: none; border-radius: 10px; overflow: hidden; display: grid; place-items: center;
  background: var(--bg); border: 1px solid var(--line); color: var(--gold);
}
.col-thumb img { width: 100%; height: 100%; object-fit: cover; }
.col-thumb .ic { width: 26px; height: 26px; opacity: 0.7; }
.col-steps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; margin-top: 8px; }
.col-steps button {
  min-height: 36px; padding: 4px 2px; font: inherit; font-size: 0.66rem; font-weight: 600; line-height: 1.1;
  border: 1px solid var(--line); background: var(--bg); color: var(--muted); border-radius: 6px; cursor: pointer;
}
.col-steps button.on { background: var(--gold-soft); color: var(--ink); border-color: var(--gold); }
.col-steps button.star.on { background: linear-gradient(var(--gold), color-mix(in srgb, var(--gold) 75%, #000)); color: #fff; border-color: var(--gold); }
.col-steps.big { margin: 0 0 10px; }
.col-steps.big button { min-height: 48px; font-size: 0.78rem; }
.col-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin-top: 12px; }
.col-stats div { text-align: center; padding: 6px 2px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line); }
.col-stats div.hl { background: var(--gold-soft); border-color: var(--gold); }
.col-stats strong { display: block; font: 700 1.15rem Georgia, serif; font-variant-numeric: tabular-nums; }
.col-stats span { font-size: 0.64rem; display: block; color: var(--muted); }
.col-photo {
  margin: 0 0 4px; border-radius: var(--radius); overflow: hidden; background: var(--surface); border: 1px solid var(--line);
  aspect-ratio: 4 / 3; display: grid; place-items: center;
}
.col-photo img { width: 100%; height: 100%; object-fit: cover; }
.col-photo.none { color: var(--muted); text-align: center; border-style: dashed; aspect-ratio: 16 / 7; }
.col-photo figcaption { font-size: 0.875rem; }
.form label.chip { flex-direction: row; color: var(--ink); font-weight: 500; }
.form label.chip.on { color: var(--accent-ink); }
.col-qty { display: flex; gap: 10px; }
.col-qty > label:first-child { width: 92px; flex: none; }
.meter.gold i { background: linear-gradient(90deg, var(--gold), #f0d48a); }
.card .meter { height: 6px; margin-top: 6px; }
.card .meter::after { display: none; }

/* Peu de pàgina i cercador de l'inici */
.foot {
  margin-top: 36px; padding-top: 14px; border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 14px;
  font-size: 0.8rem; color: var(--muted);
}
.foot > span { display: inline-flex; align-items: center; gap: 6px; font: 700 0.85rem Georgia, serif; color: var(--ink); }
.foot > span .ic { width: 16px; height: 16px; color: var(--gold); }
.foot nav { display: flex; gap: 14px; }
.foot nav a { color: var(--accent); font-weight: 600; }
.foot small { flex-basis: 100%; font-size: 0.72rem; }
.hero-search { margin: 14px 0 16px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06); }

/* Cercador de regles */
.rule-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.rule-chip {
  display: inline-flex; align-items: center; gap: 4px; min-height: 32px; padding: 4px 10px;
  border-radius: 99px; border: 1px solid var(--gold); background: var(--gold-soft); color: var(--ink);
  font-size: 0.84rem; font-weight: 600; line-height: 1.2;
}
.rule-chip span { color: var(--gold); font-size: 0.75rem; }
a.rule-chip:hover { background: color-mix(in srgb, var(--gold) 28%, transparent); }
.rule-chip.off { border-color: var(--line); background: transparent; color: var(--muted); font-weight: 500; }
.rules-sub { margin: 12px 0 6px; }
.rule-hit { gap: 10px; }
.rule-kind {
  flex: none; width: 74px; text-align: center; padding: 3px 4px; border-radius: 6px; font-size: 0.62rem; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase; line-height: 1.15; background: var(--bg); border: 1px solid var(--line); color: var(--muted);
}
.rule-kind.k-special-rules { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.rule-kind.k-magic-item { color: var(--gold); border-color: var(--gold); background: var(--gold-soft); }
.rule-kind.k-unit { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 50%, transparent); }
.rule-kind.k-spell, .rule-kind.k-the-lores-of-magic { color: #7a5cc4; border-color: color-mix(in srgb, #7a5cc4 45%, transparent); }
.filter-chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px 14px; padding: 0 16px 4px; scrollbar-width: none; }
.filter-chips::-webkit-scrollbar { display: none; }
.filter-chips .chip { flex: none; min-height: 36px; padding: 4px 12px; font-size: 0.85rem; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent-deep); }

/* Fitxa de la unitat (perfil propi) */
.unit-card {
  margin: 0 0 20px; padding: 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--gold); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}
.unit-card > .eyebrow { margin-bottom: 8px; }
.stat-wrap { overflow-x: auto; margin: 0 -4px 10px; }
.stat-tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: lining-nums tabular-nums; }
.stat-tbl td { font-variant-numeric: lining-nums tabular-nums; }
.stat-tbl th, .stat-tbl td { padding: 7px 4px; text-align: center; border-bottom: 1px solid var(--line); }
.stat-tbl thead th { font-size: 0.7rem; letter-spacing: 0.04em; color: var(--gold); background: var(--gold-soft); border-bottom: 2px solid var(--gold); }
.stat-tbl thead th:first-child { border-radius: 8px 0 0 0; }
.stat-tbl thead th:last-child { border-radius: 0 8px 0 0; }
.stat-tbl abbr { text-decoration: none; cursor: help; }
.stat-tbl tbody th { text-align: left; font-weight: 600; font-size: 0.85rem; padding-left: 6px; min-width: 96px; }
.stat-tbl td { font: 700 1rem system-ui, -apple-system, "Segoe UI", sans-serif; }
.stat-tbl tr.mount th { color: var(--muted); font-style: italic; }
.stat-tbl tr.mount td { color: var(--muted); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 4px 0 6px; font-size: 0.88rem; }
.facts div { display: contents; }
.facts dt { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; padding-top: 2px; }
.facts dd { margin: 0; }
.mini-prof { display: block; margin-top: 4px; font-size: 0.74rem; color: var(--muted); font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }
.mini-prof b { color: var(--gold); font-weight: 700; margin-right: 1px; }
.mini-prof em { font-style: normal; font-weight: 700; }
.mini-saves { display: block; font-size: 0.74rem; font-weight: 600; color: var(--ink); opacity: 0.85; margin-top: 1px; }
.role { display: inline-block; vertical-align: middle; font: 700 0.62rem system-ui, sans-serif; letter-spacing: 0.05em; text-transform: uppercase; padding: 2px 6px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); }
.list-counts { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 8px !important; }
.inline-toggle { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; font-weight: 600; color: var(--ink); cursor: pointer; }
.inline-toggle input { accent-color: var(--accent); width: 16px; height: 16px; }
.tap-hint { margin: 10px 0 0; font-size: 0.78rem; }

/* Fitxa de la unitat incrustada i visor de regles */
.wiki-box { margin: 0 0 18px; border: 1px solid var(--gold); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.wiki-box summary { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; list-style: none; }
.wiki-box summary::-webkit-details-marker { display: none; }
.wiki-box summary .chev { transition: transform 0.2s; }
.wiki-box[open] summary .chev { transform: rotate(90deg); }
.wiki-box[open] summary { border-bottom: 1px solid var(--line); }
.wiki-frame { display: block; width: 100%; height: 520px; border: 0; background: #fff; }
.wiki-wrap { position: relative; background: #fff; }
.wiki-wrap .wiki-frame { position: relative; background: transparent; }
.wiki-wait { position: absolute; top: 40%; left: 0; right: 0; text-align: center; font-size: 0.85rem; color: #6b5d4d; padding: 0 16px; }
.wiki-src { margin: 0; padding: 8px 12px; font-size: 0.75rem; color: var(--muted); }
.wiki-modal {
  position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: flex-end; justify-content: center; animation: fade 0.15s ease-out;
}
.wiki-panel {
  position: relative; width: 100%; max-width: 720px; height: min(86vh, 760px); display: flex; flex-direction: column;
  background: var(--surface); border-radius: 18px 18px 0 0; overflow: hidden; box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.35);
  padding-bottom: env(safe-area-inset-bottom, 0px); animation: rise 0.2s ease-out;
}
.wiki-panel header { display: flex; align-items: center; gap: 8px; padding: 10px 8px 10px 16px; border-bottom: 2px solid var(--gold); }
.wiki-panel header strong { flex: 1; min-width: 0; font: 700 1.05rem Georgia, serif; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wiki-panel .wiki-frame { flex: 1; height: auto; }
.wiki-loading { position: absolute; top: 50%; left: 0; right: 0; z-index: 1; text-align: center; color: #6b5d4d; pointer-events: none; }
.wiki-modal.loaded .wiki-loading { display: none; }
body.modal-open { overflow: hidden; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(30px); } }
@media (prefers-reduced-motion: reduce) { .wiki-modal, .wiki-panel { animation: none; } }
@media (min-width: 760px) { .wiki-modal { align-items: center; } .wiki-panel { border-radius: 18px; } }

/* Valors canviats per l'equip (color propi) */
:root { --mod: #1f7a5a; --mod-soft: rgba(31, 122, 90, 0.12); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --mod: #6fd3a8; --mod-soft: rgba(111, 211, 168, 0.13); } }
:root[data-theme="dark"] { --mod: #6fd3a8; --mod-soft: rgba(111, 211, 168, 0.13); }
.stat-tbl td.mod { color: var(--mod); background: var(--mod-soft); }
.stat-tbl td.mod .was { display: block; font-size: 0.62rem; font-weight: 500; color: var(--muted); text-decoration: line-through; line-height: 1; }
.mod-txt { color: var(--mod); }
.mod-note { display: flex; align-items: center; gap: 6px; margin: -4px 0 10px; font-size: 0.78rem; color: var(--muted); }
.mod-swatch { width: 12px; height: 12px; border-radius: 3px; background: var(--mod-soft); border: 1.5px solid var(--mod); flex: none; }
.saves { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 6px; margin: 0 0 10px; }
.save { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 8px 4px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); min-width: 0; }
.save strong { font: 700 1.3rem system-ui, sans-serif; }
.save span { font-size: 0.68rem; font-weight: 600; color: var(--muted); line-height: 1.2; }
.save small { font-size: 0.66rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.save.mod { border-color: var(--mod); background: var(--mod-soft); }
.save small { white-space: normal; }
.save.mod strong { color: var(--mod); }
.weapon-tbl tbody th { min-width: 130px; }
.weapon-tbl thead th:first-child { text-align: left; padding-left: 6px; }
.weapon-tbl td { font-size: 0.9rem; white-space: nowrap; }
.weapon-tbl tr.magic th { color: var(--gold); }
.magic-mark { color: var(--gold); }
.rule-chips.mini { gap: 4px; margin-top: 4px; }
.rule-chips.mini .rule-chip { min-height: 24px; padding: 1px 7px; font-size: 0.7rem; }
.item-stats { margin-top: 2px; font-size: 0.75rem; color: var(--mod); font-weight: 600; }

/* Explicacions pròpies: fitxa emergent i llista */
.rule-tip {
  position: fixed; z-index: 40; padding: 12px 14px 10px; border-radius: 12px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--gold);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35); animation: fade 0.12s ease-out;
}
.rule-tip.bottom {
  left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); top: auto; width: auto !important;
  max-width: 560px; margin: 0 auto; animation: rise 0.18s ease-out;
}
.rule-tip strong { font: 700 1rem Georgia, serif; }
.rule-tip small { margin-left: 6px; color: var(--muted); font-size: 0.72rem; }
.rule-tip p { margin: 6px 0 8px; font-size: 0.9rem; line-height: 1.45; }
.tip-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tip-actions .icon { width: 32px; height: 32px; }
.explain { margin-top: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.explain summary { padding: 10px 12px; cursor: pointer; font-weight: 700; color: var(--accent); }
.explain dl { margin: 0; padding: 0 12px 10px; }
.explain dl div { padding: 8px 0; border-top: 1px solid var(--line); }
.explain dt { font-weight: 700; }
.explain dd { margin: 2px 0 0; font-size: 0.88rem; line-height: 1.45; }
.explain dd .a { font-size: 0.78rem; margin-left: 4px; white-space: nowrap; }
.spell-name { color: inherit; text-decoration: underline dotted var(--gold); text-underline-offset: 3px; }
.spell-name span { color: var(--gold); font-size: 0.8em; }
.hit-sum { display: block; margin-top: 3px; font-size: 0.82rem; color: var(--ink); opacity: 0.85; line-height: 1.35; }

/* Botó d'informació (què fa l'objecte) */
.info-btn {
  flex: none; width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 50%;
  border: 1.5px solid var(--gold); background: var(--gold-soft); color: var(--gold);
  font: italic 700 1rem Georgia, serif; line-height: 1;
}
.info-btn:hover { background: var(--gold); color: #1d1712; }
.info-btn.static { width: 20px; height: 20px; font-size: 0.75rem; vertical-align: middle; border-width: 1px; }

/* Punts extra al torneig */
.bonus { display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 0.62rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.bonus input { width: 54px; min-height: 36px; padding: 4px; text-align: center; font-weight: 700; }

/* Full de llista i fulls de torneig (paper també en mode fosc) */
.sheet {
  --p-ink: #1d1712; --p-muted: #6b5d4d; --p-line: #d9cdb8; --p-gold: #8a6416;
  background: #fffdf8; color: var(--p-ink); border: 1px solid var(--p-line); border-radius: 6px;
  padding: 18px 16px; margin: 0 0 16px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}
.sheet h2 { font: 700 1.35rem Georgia, serif; margin: 2px 0; }
.sheet p { margin: 0; }
.sheet-head { display: flex; gap: 12px; align-items: flex-end; border-bottom: 3px double var(--p-gold); padding-bottom: 10px; margin-bottom: 10px; }
.sheet-head p { color: var(--p-muted); font-size: 0.85rem; }
.sheet-eyebrow { font-size: 0.68rem !important; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--p-gold) !important; }
.sheet-total { text-align: right; flex: none; }
.sheet-total strong { display: block; font: 700 1.9rem/1 Georgia, serif; }
.sheet-total span { font-size: 0.78rem; color: var(--p-muted); }
.sheet-meta { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 0 0 12px; }
.sheet-meta div { border: 1px solid var(--p-line); border-radius: 4px; padding: 4px 6px; min-width: 0; }
.sheet-meta dt { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--p-muted); }
.sheet-meta dd { margin: 0; font-weight: 600; font-size: 0.85rem; overflow-wrap: anywhere; min-height: 1.2em; }
.sheet-cat { break-inside: avoid; margin-bottom: 10px; }
.sheet-cat h3 { display: flex; justify-content: space-between; gap: 8px; font: 700 0.95rem Georgia, serif; margin: 0 0 2px; padding: 4px 0; border-bottom: 1px solid var(--p-gold); color: var(--p-gold); }
.sheet-cat h3 span:last-child { font: 600 0.8rem system-ui, sans-serif; color: var(--p-muted); }
.sheet table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.sheet td { padding: 5px 4px; border-bottom: 1px solid var(--p-line); vertical-align: top; }
.sheet tr { break-inside: avoid; }
.sheet small { color: var(--p-muted); }
.sheet-n { width: 28px; font-weight: 700; text-align: center; }
.sheet-pts { width: 46px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.sheet-det { font-size: 0.78rem; color: var(--p-muted); margin-top: 1px; }
.sheet .stat-wrap { margin: 4px 0 2px; }
.sheet .stat-tbl { font-size: 0.75rem; }
.sheet .stat-tbl th, .sheet .stat-tbl td { padding: 2px 3px; border-bottom: 1px solid var(--p-line); }
.sheet .stat-tbl thead th { color: var(--p-gold); background: transparent; border-bottom: 1px solid var(--p-gold); }
.sheet .stat-tbl tbody th { font-size: 0.75rem; min-width: 80px; }
.sheet .stat-tbl td { font: 700 0.8rem system-ui, -apple-system, "Segoe UI", sans-serif; }
.sheet .stat-tbl tr.mount th, .sheet .stat-tbl tr.mount td { color: var(--p-muted); }
.sheet-warn { border: 1px solid #b3261e; color: #b3261e; border-radius: 4px; padding: 6px 10px; font-size: 0.82rem; margin-top: 8px; }
.sheet-warn ul { margin: 4px 0 0; padding-left: 18px; }
.sheet-foot { margin-top: 12px; padding-top: 6px; border-top: 1px solid var(--p-line); font-size: 0.68rem; color: var(--p-muted); text-align: center; }
.sheet-table th { text-align: left; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--p-gold); border-bottom: 2px solid var(--p-gold); padding: 4px; }
.sheet-table td.box { width: 54px; border: 1px solid var(--p-line); text-align: center; font-weight: 700; }
.sheet-pre { white-space: pre-wrap; overflow-wrap: anywhere; font: 0.8rem/1.45 ui-monospace, Consolas, monospace; margin: 0; }
.slips { display: grid; grid-template-columns: 1fr; gap: 10px; }
.slip { background: #fffdf8; color: #1d1712; border: 1.5px dashed #9a8a72; border-radius: 6px; padding: 10px 12px; break-inside: avoid; }
.slip-head { display: flex; justify-content: space-between; gap: 8px; margin: 0 0 6px; font-size: 0.82rem; }
.slip-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid #e3d8c6; }
.slip-row small { color: #6b5d4d; }
.slip-box { border: 1px solid #9a8a72; border-radius: 4px; min-width: 64px; height: 38px; font-size: 0.6rem; color: #6b5d4d; padding: 2px 4px; flex: none; }
.slip-box + .slip-box { min-width: 96px; }

/* Estadístiques */
a.stats { color: inherit; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 10px 0 4px; }
.stats-grid div { text-align: center; padding: 8px 2px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line); }
.stats-grid strong { display: block; font: 700 1.3rem Georgia, serif; font-variant-numeric: tabular-nums; }
.stats-grid span { font-size: 0.66rem; color: var(--muted); display: block; line-height: 1.2; }
.form-strip { display: flex; flex-wrap: wrap; gap: 6px; }
.form-dot { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; font-weight: 800; font-size: 0.85rem; border: 1px solid var(--line); background: var(--surface); }
.form-dot.win { background: color-mix(in srgb, var(--ok) 22%, var(--surface)); border-color: var(--ok); }
.form-dot.loss { background: color-mix(in srgb, var(--bad) 18%, var(--surface)); border-color: var(--bad); }
.form-dot.draw { background: var(--gold-soft); border-color: var(--gold); }
.insights { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 18px; }
.insight { display: flex; flex-direction: column; gap: 2px; padding: 12px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); min-width: 0; }
.insight.good { border-left: 3px solid var(--ok); }
.insight.tough { border-left: 3px solid var(--bad); }
.insight strong { font: 700 1rem Georgia, serif; overflow-wrap: anywhere; }
.stats-tbl td:first-child { max-width: 140px; overflow-wrap: anywhere; }
.rate-col { width: 92px; }
.rate { display: grid; grid-template-columns: 1fr 34px; gap: 4px; align-items: center; }
.rate b { font-size: 0.78rem; text-align: right; font-variant-numeric: tabular-nums; }
.tbl .rate .hbar { width: 100%; }

/* Rellotge de ronda */
.timer-box { margin-top: 12px; padding: 12px; border-radius: var(--radius); background: var(--bg); border: 1px solid var(--line); text-align: center; }
.timer { font: 700 2.4rem/1 Georgia, serif; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.timer.low { color: var(--gold); }
.timer.over { color: var(--bad); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) { .timer.over { animation: none; } }
.timer-label { margin: 4px 0 0; font-size: 0.8rem; color: var(--muted); }
.timer-box .row-actions { justify-content: center; }
.list-tag { display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; font-size: 0.78rem; font-weight: 600; color: var(--ok); }
.list-tag .ic { width: 14px; height: 14px; }
.list-tag.bad { color: var(--bad); }
.invite h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; }
.invite h2 .ic { color: var(--gold); }
.cat-head .btn.small { min-height: 30px; padding: 4px 10px; }

/* Pantalla per projectar */
.screen { position: fixed; inset: 0; z-index: 20; overflow-y: auto; background: var(--bg); padding: 16px max(16px, 3vw); display: flex; flex-direction: column; gap: 16px; }
.screen-head { display: flex; align-items: center; gap: 12px; border-bottom: 2px solid var(--gold); padding-bottom: 10px; }
.screen-head h1 { font: 700 clamp(1.3rem, 4vw, 2.6rem) Georgia, serif; margin: 0; }
.screen-head .back { font-size: 2rem; color: var(--accent); width: 32px; }
.screen-body { display: grid; gap: 16px; }
.screen-clock { text-align: center; }
.screen .timer-box.big { background: var(--surface); }
.screen .timer-box.big .timer { font-size: min(16vw, 9rem); }
.screen-list { columns: 2 260px; column-gap: 16px; }
.screen-row { break-inside: avoid; display: grid; grid-template-columns: 1fr auto; gap: 0 10px; padding: 8px 12px; margin-bottom: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; font-size: clamp(0.95rem, 1.6vw, 1.35rem); }
.screen-row .muted { grid-column: 1; font-size: 0.8em; }
.screen-row b { grid-row: 1 / span 2; grid-column: 2; align-self: center; color: var(--gold); font-family: Georgia, serif; white-space: nowrap; }
.screen-wait { text-align: center; font-size: 1.3rem; color: var(--muted); margin-top: 20vh; }
@media (min-width: 900px) {
  .screen-body { grid-template-columns: 1fr 1.3fr; align-items: start; }
  .screen-clock { position: sticky; top: 0; }
  .screen .timer-box.big .timer { font-size: min(7vw, 24vh); }
}

@media (max-width: 340px) {
  .tools { grid-template-columns: 1fr; }
  .score input { width: 56px; }
}

/* =========================================================
   Disseny 2.2: més net i lleuger (inspirat en Old World Builder)
   ========================================================= */

/* Tema clar suau: menys brillant, tons de pergamí apagats */
:root {
  --bg: #e9e5de;
  --surface: #f4f1eb;
  --band: #dfd9cf;
  --ink: #2b2620;
  --muted: #6c635a;
  --line: #d3cbbf;
  --accent: #7e2a21;
  --accent-deep: #66211a;
  --gold: #9a7b3c;
  --gold-soft: rgba(154, 123, 60, 0.13);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --band: #2c251e; }
}
:root[data-theme="dark"] { --band: #2c251e; }
:root:not([data-theme="dark"]) body { background: var(--bg); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) body { background: radial-gradient(1200px 500px at 50% -120px, var(--gold-soft), transparent 70%), var(--bg); } }

/* Menú: cap a mòbils estrets */
.topnav { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16); }
.tabs { min-width: 0; }
@media (max-width: 360px) {
  .tab { font-size: 0.6rem; padding: 7px 0 6px; }
  .tab .ic { width: 19px; height: 19px; }
}

/* Resum de la llista més discret */
.summary::before { display: none; }
.summary { box-shadow: none; padding: 12px 14px; }
.total strong { font-size: 1.6rem; }

/* Categories com a blocs: banda amb el nom i els punts, i les unitats a dins */
.cat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 14px; }
.cat-head { background: var(--band); margin: 0; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.cat-head::after { display: none; }
.cat-head h2 { font-size: 1.02rem; }
.cat > .issues, .cat > .fix { margin: 8px 12px; }
.cat > .card { margin: 0; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; box-shadow: none; background: transparent; padding: 10px 12px; }
.cat > .card.unit { border-left: 3px solid transparent; }
.cat > .card.has-error { border-left-color: var(--bad); }
.cat > .btn.add { width: auto; display: flex; margin: 10px 12px; min-height: 38px; border-style: solid; border-color: var(--line); background: var(--bg); color: var(--ink); }
.card .pts { font-size: 1rem; }
.card > .pts, .card > .nowrap { flex: none; }
.card .det { font-size: 0.8rem; }

/* Selector d'unitats: files compactes (nom + punts) */
.pick-tools { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.pick-tools .search { flex: 1; margin: 0; }
.pick-tools .inline-toggle { margin-left: auto; white-space: nowrap; }
.pick-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.pick-list.flat { border: 0; border-radius: 0; background: transparent; }
.pick { padding: 10px 12px; margin-bottom: 0; border-radius: 0; border-width: 0 0 1px; box-shadow: none; background: transparent; }
.pick-list > :last-child .pick { border-bottom: 0; }
.pick .muted { font-size: 0.8rem; }
.pick .note-line { font-size: 0.76rem; opacity: 0.85; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Targetes generals una mica més planes */
.card { box-shadow: none; }
.opts { box-shadow: none; }

@media print {
  .topnav, .bar, .no-print, #toast, body::before { display: none !important; }
  body { background: #fff; color: #000; }
  .export { border: 0; padding: 0; }
  main { padding: 0 !important; max-width: none !important; }
  .sheet { box-shadow: none; border: 0; padding: 0; margin: 0 0 12mm; background: #fff; }
  .sheet.plist { break-after: page; }
  .slips { grid-template-columns: 1fr 1fr; break-before: page; }
  .slip { background: #fff; }
  .seg, .fab, .timer-box, .podium .ic { display: none !important; }
  .tbl, .table-wrap { background: #fff !important; color: #000 !important; border-color: #bbb !important; }
  .tbl th { background: #eee !important; color: #000 !important; }
  .tbl .muted { color: #444 !important; }
}

/* Fitxa de la muntura dins la fitxa de la unitat */
/* Muntura: files dins la mateixa taula + fitxa clara */
.stat-tbl tr.mount th, .stat-tbl tr.mount td { color: var(--ink); font-style: normal; background: var(--gold-soft); }
.stat-tbl tr.mount-first th, .stat-tbl tr.mount-first td { border-top: 2px solid var(--gold); }
.stat-tbl .row-tag {
  display: block; width: max-content; margin-bottom: 2px; padding: 0 6px; border-radius: 99px;
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  background: var(--gold); color: var(--surface);
}
.mount-card {
  margin-top: 12px; padding: 10px 12px; border: 1px solid var(--gold); border-left-width: 4px;
  border-radius: var(--radius); background: var(--gold-soft);
}
.mount-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 8px; }
.mount-kicker { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold); }
.mount-name { font-size: 1rem; flex: 1 1 auto; }
.mount-facts { margin: 0 0 8px; }
.mount-sub { margin: 4px 0 6px; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.mount-card .rule-chip { background: var(--surface); }
.mount-ref { margin: 8px 0 0; font-size: 0.72rem; color: var(--muted); }

/* Generador de mapes */
.map-opts { margin: 10px 0 14px; }
.map-wrap { margin: 0 0 12px; }
.map-edge { margin: 4px 0; text-align: center; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.map-svg { display: block; width: 100%; height: auto; border-radius: var(--radius); }
.map-board { fill: #84955a; stroke: #4d5a30; stroke-width: .3; }
.map-grid { stroke: rgba(255,255,255,.16); stroke-width: .12; }
.map-mid { stroke: rgba(255,255,255,.5); stroke-width: .18; stroke-dasharray: 1 .8; }
.tr-wood { fill: #3f6b35; stroke: #284522; stroke-width: .25; }
.tr-tree { fill: #2a4a24; }
.tr-hill { fill: #b89c62; stroke: #7a6235; stroke-width: .25; }
.tr-hill-top { fill: #cdb47c; }
.tr-marsh { fill: #5f7d66; stroke: #3d5946; stroke-width: .25; }
.tr-reed { stroke: #2c4234; stroke-width: .3; stroke-linecap: round; }
.tr-pond { fill: #5d93b8; stroke: #376a8e; stroke-width: .25; }
.tr-river { fill: none; stroke: #4f88b0; stroke-width: 2.6; stroke-linecap: round; }
.tr-building { fill: #b4794a; stroke: #5b371c; stroke-width: .25; }
.tr-roof { stroke: #5b371c; stroke-width: .25; }
.tr-ruins-area { fill: rgba(180,168,146,.55); stroke: #6b6152; stroke-width: .2; stroke-dasharray: .6 .4; }
.tr-ruins { fill: none; stroke: #5a5145; stroke-width: .6; stroke-linecap: square; }
.tr-rocks { fill: #7c7c78; stroke: #474744; stroke-width: .25; stroke-linejoin: round; }
.tr-fence { stroke: #6b4a2b; stroke-width: .5; stroke-dasharray: .9 .35; }
.tr-wall { stroke: #9b9b96; stroke-width: 1; }
.map-no circle { fill: #1d1a14; stroke: #e0b84f; stroke-width: .22; }
.map-no text { fill: #fff; font: 700 2px system-ui, sans-serif; text-anchor: middle; }
.map-code { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 14px; }
.map-code code { font: 600 0.9rem ui-monospace, Consolas, monospace; padding: 2px 8px; border-radius: 6px; background: var(--gold-soft); }
.map-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.map-item { display: flex; gap: 10px; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.map-item strong { display: block; }
.map-badge { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #1d1a14; color: #fff; border: 2px solid var(--gold); font-weight: 700; font-size: 0.85rem; }
.map-pos { display: block; font-size: 0.85rem; margin-top: 2px; }
.map-pos span + span { margin-left: 4px; }
.map-fx { display: block; font-size: 0.85rem; margin-top: 4px; }
.map-foot { font-size: 0.8rem; }

.card-form .chip input[type=checkbox] { width: auto; min-height: 0; height: auto; padding: 0; margin: 0 6px 0 0; flex: none; }
.card-form .chip { white-space: nowrap; }

/* ---------- Ordinador: menú lateral, contingut ample i llista dividida ---------- */
.side-brand, .side-foot { display: none; }
@media (min-width: 1100px) {
  body { padding-left: 248px; }
  #app { max-width: 1240px; padding: 0 28px; }
  .topnav {
    position: fixed; inset: 0 auto 0 0; width: 248px; z-index: 6;
    flex-direction: column; align-items: stretch; gap: 0; padding: 18px 12px;
    border-bottom: 0; border-right: 2px solid var(--gold);
    box-shadow: 3px 0 0 -1px var(--accent-deep), 4px 0 0 -1px var(--gold), 6px 0 18px rgba(0, 0, 0, 0.22);
  }
  .side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; margin-bottom: 10px; border-bottom: 1px solid rgba(240, 212, 138, 0.35); }
  .side-brand img { border-radius: 10px; box-shadow: 0 0 0 1px rgba(240, 212, 138, 0.6); }
  .side-brand strong { display: block; font: 700 1.1rem/1.15 Georgia, serif; color: #f7e3a6; }
  .side-brand small { display: block; font-size: 0.72rem; opacity: 0.8; }
  .tabs { flex: none; flex-direction: column; gap: 2px; max-width: none; margin: 0; }
  .tab {
    flex: none; flex-direction: row; justify-content: flex-start; gap: 12px;
    padding: 11px 12px; font-size: 0.95rem; border-radius: 10px; border-bottom: 0; margin: 0;
  }
  .tab:hover { opacity: 1; background: rgba(0, 0, 0, 0.14); }
  .tab.on { background: rgba(0, 0, 0, 0.24); box-shadow: inset 3px 0 0 #f0d48a; }
  .tab-logo { width: 21px; height: 21px; }
  .side-foot { display: block; margin: auto 8px 0; font-size: 0.72rem; line-height: 1.5; opacity: 0.7; }
  .bar { padding: 26px 0 14px; }
  .bar h1 { font-size: 1.75rem; }
  .bar .back { margin-left: -12px; }
  main { padding-inline: 0; padding-bottom: 48px; }

  /* Targetes soltes (llistes, menú Més, col·lecció…) en dues columnes */
  #app > main { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 14px; align-content: start; }
  #app > main > :not(.card) { grid-column: 1 / -1; }

  /* Editor de llistes: llista a l'esquerra, unitat a la dreta */
  .split { display: grid; grid-template-columns: minmax(340px, 420px) minmax(0, 1fr); gap: 28px; align-items: start; }
  .split-side {
    position: sticky; top: 0; max-height: 100vh; overflow-y: auto; overscroll-behavior: contain;
    padding-right: 10px; scrollbar-width: thin;
  }
  .split-side main { padding-bottom: 24px; }
  .split-side .bar h1 { font-size: 1.35rem; }
  .split-side .card.is-open { background: var(--gold-soft); box-shadow: inset 3px 0 0 var(--gold); }
  .split-main { min-width: 0; }
  .split-empty { min-height: 60vh; display: grid; place-items: center; border: 1px dashed var(--line); border-radius: var(--radius); margin-top: 26px; }

  /* Mapa: opcions a l'esquerra, plànol a la dreta */
  .map-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 24px; align-items: start; }
  .map-layout .grid2 { grid-template-columns: 1fr; }
}
@media (min-width: 1100px) and (hover: hover) {
  .card:hover { border-color: var(--gold); }
}