/* Fiefs — tuiles de bois peintes sur une table d'ardoise ; couleurs héraldiques pour les seigneurs */
body[data-theme="fiefs"] {
  --bg: #1d2830;
  --bg-glow: #2b3b45;
  --surface: #24313a;
  --fg: #ebe1cb;
  --muted: #a39d8f;
  --line: rgba(235, 225, 203, .14);
  --glass: rgba(235, 225, 203, .06);
  --accent: #c7951b;
  --accent-ink: #20170a;
  --hot: #b3322b;
  --hot-ink: #ffffff;
  --paper: #ebe1cb;
  --ink: #241c14;
  --f-display: "Grenze Gotisch", "UnifrakturMaguntia", Georgia, serif;
  --f-body: "Alegreya Sans", "Segoe UI", system-ui, sans-serif;
  --gold: #c7951b;
  --bad: #f0a093;
  --good: #a9d89b;
}

/* Tuile d'accueil */
.tile-fiefs { background: linear-gradient(155deg, #26343d 0%, #172128 100%); color: #ebe1cb; border-color: rgba(199, 149, 27, .35); }
.tile-fiefs h2 { font: 700 42px/0.9 "Grenze Gotisch", Georgia, serif; color: #ead9ad; letter-spacing: .01em; }
.tile-fiefs .btn.primary { background: #b3322b; color: #fff; }

/* ---------- Disposition ---------- */
.ff-table { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 390px; position: relative; font-family: var(--f-body); }
.ff-board { position: relative; display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0;
  background: radial-gradient(110% 80% at 45% 45%, #2a3943 0%, #1b252c 60%, #151d22 100%); }
.ff-map { position: relative; min-height: 0; padding: 10px 14px 44px; }
.ff-svg { width: 100%; height: 100%; display: block; overflow: visible; -webkit-user-select: none; user-select: none; }
.ff-side { overflow-y: auto; background: #212d35; border-left: 1px solid rgba(235, 225, 203, .1); scrollbar-width: thin; }
@media (max-width: 980px) {
  .ff-table { grid-template-columns: 1fr; grid-template-rows: minmax(420px, 62vh) auto; overflow-y: auto; }
  .ff-side { border-left: 0; border-top: 1px solid rgba(235, 225, 203, .1); overflow: visible; }
}

/* ---------- Bandeau : tour, chrono, trésor ---------- */
.ff-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding: 8px 16px; background: rgba(14, 20, 24, .78);
  border-bottom: 1px solid rgba(235, 225, 203, .1); }
.ff-turn { display: flex; align-items: baseline; gap: 12px; border-radius: 8px; padding: 0 6px; }
.ff-title { font: 700 28px/1 var(--f-display); color: #ead9ad; }
.ff-turn b { font-size: 18px; font-variant-numeric: tabular-nums; }
.ff-clock { flex: 1 1 180px; display: flex; align-items: center; gap: 10px; min-width: 150px; }
.ff-clock .bar { flex: 1; height: 7px; border-radius: 99px; background: rgba(235, 225, 203, .12); overflow: hidden; }
.ff-clock i { display: block; height: 100%; background: linear-gradient(90deg, #a87b14, #e2b43c); transition: width .25s linear; }
.ff-clock.low i { background: #c2402f; }
.ff-clock.off { visibility: hidden; }
.ff-secs { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 3.4ch; text-align: right; }
.ff-clock.low .ff-secs { color: #f08b74; }
.ff-treasury { display: flex; flex-wrap: wrap; gap: 6px; }
.ff-res { display: flex; align-items: center; gap: 6px; padding: 4px 10px 4px 6px; border-radius: 10px; background: rgba(235, 225, 203, .06); cursor: default; }
.ff-res b { font-size: 18px; font-variant-numeric: tabular-nums; }
.ff-res small { color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.ff-res small.neg { color: var(--bad); }
.ff-res.pop.full b { color: var(--bad); }

/* ---------- Icônes ---------- */
.ff-i { width: 22px; height: 22px; flex: none; fill: currentColor; stroke: rgba(20, 14, 8, .7); stroke-width: 1.2; stroke-linejoin: round; stroke-linecap: round; }
.ff-i .ln { fill: none; stroke: rgba(20, 14, 8, .78); stroke-width: 1.5; }
.ff-i .lt { fill: rgba(255, 255, 255, .32); }
.ff-i .gold { fill: #e7b933; }
.ff-i.r-f { color: #dfbf5f; }
.ff-i.r-w { color: #b67e48; }
.ff-i.r-s { color: #aaa69d; }
.ff-i.r-o { color: #e8bb36; }
.ff-i.r-pop { color: #c9c1ad; }
.ff-i.u { color: #e6dbc2; stroke: none; }
.ff-i.u .ln { stroke: currentColor; stroke-width: 1.9; }
.ff-i.u .lt { fill: #212d35; stroke: currentColor; stroke-width: 1.4; }
.ff-i.b { width: 30px; height: 30px; color: #ebe1cb; }

/* ---------- Tuiles ---------- */
.t-plaine { --tf: #d6bd63; --te: #8e7a33; }
.t-foret { --tf: #5d7c42; --te: #33482a; }
.t-colline { --tf: #b08955; --te: #6f5333; }
.t-montagne { --tf: #8b8985; --te: #4f4d4a; }
.t-marais { --tf: #6f8b76; --te: #3f5546; }
.t-lac { --tf: #4f7e98; --te: #2d4d60; }
.ff-hx .edge { fill: var(--te); }
.ff-hx .top { fill: var(--tf); stroke: rgba(28, 21, 14, .55); stroke-width: 1.2; }
.ff-hx .deco { fill: none; stroke: rgba(36, 28, 18, .5); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.ff-hx.t-foret .deco .fill { fill: #3c5a2e; stroke: rgba(24, 34, 18, .7); stroke-width: 1; }
.ff-hx.t-montagne .deco .fill { fill: #6e6c69; stroke: rgba(30, 28, 26, .7); stroke-width: 1.1; }
.ff-hx.t-montagne .deco .snow { fill: #efe9dc; stroke: none; }
.ff-hx.t-lac .deco { stroke: rgba(225, 240, 246, .55); }
.ff-hx .rim { fill: none; stroke: var(--pc); stroke-width: 5.5; stroke-linejoin: round; }
.ff-hx .rim.faint { stroke-width: 3; opacity: .55; }
.ff-hx .fogv { fill: url(#ff-fog); }
.ff-hx .hit { fill: transparent; cursor: pointer; }
.ff-hx:hover .top { filter: brightness(1.09); }
.ff-hx.sel .top { stroke: #ffe8a0; stroke-width: 4; }
.ff-hx.sel .edge { fill: #2a1f0c; }
.ff-hx.target .top { stroke: #ffffff; stroke-width: 2.6; stroke-dasharray: 6 4; }
.ff-hx.target .hit { cursor: context-menu; }

/* bâtiments, posés sur la tuile */
.ff-hx .bld > * { fill: #f1e7cf; stroke: #2a2118; stroke-width: 1.3; stroke-linejoin: round; }
.ff-hx .bld .ln { fill: none; }
.ff-hx .bld .lt { fill: #2a2118; }
.ff-hx .bld .gold { fill: #e7b933; }
.ff-hx .bld.castle > :not(.ln):not(.lt) { fill: var(--pc); }
.ff-hx .bld.castle .ln { stroke: #f1e7cf; stroke-width: 1.6; }
.ff-hx .bld.castle .lt { fill: #1b140d; }
.ff-hx .bld.pending { opacity: .7; }
.ff-hx .bld.pending > * { stroke-dasharray: 2.5 2; }
.ff-hx .pips circle { fill: #f6dc8c; stroke: #2a2118; stroke-width: 1; }
.ff-hx .badge path { fill: var(--pc); stroke: #f1e7cf; stroke-width: 1.3; }
.ff-hx .badge text, .ff-hx .rec text, .ff-arrow text, .ff-fx text { font: 800 11px var(--f-body); text-anchor: middle; fill: #fff; }
.ff-hx .rec circle { fill: #f1e7cf; stroke: #2a2118; stroke-width: 1; }
.ff-hx .rec text { fill: #2a2118; font-size: 9px; }
.ff-hx .flag path { stroke: #2a2118; stroke-width: 1.4; fill: none; }
.ff-hx .flag .cloth { fill: #8d8a80; }

/* ordres : flèches de la couleur du joueur */
.ff-arrow path { fill: none; stroke: var(--pc); stroke-width: 3.4; stroke-dasharray: 7 5; stroke-linecap: round; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .6)); }
.ff-arrow circle { fill: var(--pc); stroke: #f1e7cf; stroke-width: 1.5; }

/* résolution du tour */
.ff-fx .tok { filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .65)); }
.ff-fx .tok path { fill: var(--pc); stroke: #fff; stroke-width: 1.8; }
.ff-fx .trail { fill: none; stroke: var(--pc); stroke-width: 4; stroke-linecap: round; opacity: .9; }
.ff-svg.ff-playing .ff-tiles .badge, .ff-svg.ff-playing .ff-tiles .rec { opacity: .18; transition: opacity .3s; }
.ff-svg .ff-tiles .badge { transition: opacity .5s; }
.ff-fx .burst .sw { stroke: #ffe8a0; stroke-width: 3.5; stroke-linecap: round; }
.ff-fx .burst .ring { fill: rgba(20, 14, 8, .35); stroke: #ffe8a0; stroke-width: 2; }
.ff-fx .burst text { font-size: 13px; paint-order: stroke; stroke: #1a130b; stroke-width: 4px; stroke-linejoin: round; }
.ff-fx .burst.cap text { fill: #ffd86a; }
.ff-fx .burst.held text { fill: #d2e9ff; }
.ff-fx .pop > g > * { fill: #f1e7cf; stroke: #2a2118; stroke-width: 1.3; }
.ff-fx .pop .ln { fill: none; }
.ff-fx text.plus { font-size: 15px; fill: #b9f0a8; paint-order: stroke; stroke: #1a130b; stroke-width: 4px; }

.ff-hint { position: absolute; left: 16px; bottom: 12px; margin: 0; max-width: min(560px, calc(100% - 32px)); padding: 7px 12px; border-radius: 10px;
  background: rgba(14, 20, 24, .82); color: var(--muted); font-size: 14px; pointer-events: none; }

/* ---------- Panneau ---------- */
.ff-sec { padding: 14px 18px; border-bottom: 1px solid rgba(235, 225, 203, .09); }
.ff-sec h3 { font: 700 16px/1.2 var(--f-body); color: #ead9ad; margin: 0 0 10px; }
.ff-sec h3 small, .ff-block h4 small { color: var(--muted); font-weight: 500; font-size: 13px; margin-left: 6px; }
.ff-note { color: var(--muted); font-size: 13.5px; margin: 6px 0 0; }
.ff-out { padding: 14px 18px; margin: 0; color: #ead9ad; border-bottom: 1px solid rgba(235, 225, 203, .09); }

.ff-ready { padding: 16px 18px; border-bottom: 1px solid rgba(235, 225, 203, .09); background: rgba(179, 50, 43, .1); }
.ff-ready .btn { width: 100%; font-size: 16px; padding: 12px; }
.ff-ready .btn.primary, .ff-ready .btn.primary:hover:not(:disabled) { background: #b3322b; color: #fff; }
.ff-ready .btn.primary:hover:not(:disabled) { filter: brightness(1.12); }
.ff-ready.done { background: rgba(199, 149, 27, .08); }
.ff-ready p { margin: 8px 0 0; color: var(--muted); font-size: 13.5px; }

.ff-cell.empty p { color: var(--muted); margin: 0; }
.ff-cell-head { display: flex; gap: 12px; align-items: center; }
.ff-cell-head .sw { width: 30px; height: 34px; flex: none; background: var(--tf); clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); box-shadow: inset 0 -4px 0 var(--te); }
.ff-cell-head h3 { margin: 0; font-size: 19px; }
.ff-cell-head p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.ff-facts { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 10px 0 0; font-size: 14px; }
.ff-facts span { display: inline-flex; align-items: center; gap: 4px; }
.ff-facts .ff-i { width: 16px; height: 16px; }
.ff-troops { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-weight: 700; }
.ff-troops span { display: inline-flex; align-items: center; gap: 5px; }

.ff-block { margin-top: 14px; padding-top: 12px; border-top: 1px dashed rgba(235, 225, 203, .14); }
.ff-block h4 { margin: 0 0 8px; font: 700 14.5px var(--f-body); color: var(--fg); }
.ff-row { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 3px 0; }
.ff-row .lbl { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--fg); font-size: 14.5px; }
.ff-row .lbl small { color: var(--muted); font-weight: 500; }
.ff-row.rec .c { margin-left: auto; }
.ff-step { display: inline-flex; align-items: center; gap: 4px; }
.ff-step b { min-width: 2.2ch; text-align: center; font-variant-numeric: tabular-nums; }
.ff-step .btn.small { padding: 2px 10px; min-width: 32px; }

.ff-blds { display: grid; gap: 6px; }
.ff-bld { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; text-align: left; width: 100%; padding: 7px 10px; border-radius: 10px;
  border: 1px solid rgba(235, 225, 203, .14); background: rgba(235, 225, 203, .04); color: var(--fg); font: inherit; cursor: pointer; }
.ff-bld:hover:not(:disabled) { border-color: var(--gold); background: rgba(199, 149, 27, .08); }
.ff-bld:disabled { opacity: .42; cursor: not-allowed; }
.ff-bld.on { border-color: var(--gold); background: rgba(199, 149, 27, .16); }
.ff-bld .t { display: flex; flex-direction: column; min-width: 0; }
.ff-bld .t b { font-size: 14.5px; }
.ff-bld .t small { color: var(--muted); font-size: 12.5px; line-height: 1.3; }
.ff-bld .c { display: flex; gap: 6px; font-weight: 700; font-size: 13px; white-space: nowrap; }
.ff-cost { display: inline-flex; align-items: center; gap: 2px; font-variant-numeric: tabular-nums; }
.ff-cost .ff-i { width: 15px; height: 15px; }
.ff-cost.short { color: var(--bad); }

.ff-orders ul, .ff-chron ul, .ff-lords ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ff-orders li { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.ff-orders .x { margin-left: auto; background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 13px; padding: 2px 6px; border-radius: 6px; }
.ff-orders .x:hover { color: var(--fg); background: rgba(235, 225, 203, .08); }
.ff-orders .ar { width: 16px; height: 0; border-top: 3px dashed var(--pc); flex: none; }

.ff-trade-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-weight: 700; }
.ff-trade-row select { font: 600 14px var(--f-body); color: var(--fg); background: #2a3741; border: 1px solid rgba(235, 225, 203, .18); border-radius: 8px; padding: 4px 6px; }
.ff-trade-row .btn { margin-left: auto; }

.ff-lords li { display: grid; grid-template-columns: 16px 1fr auto; grid-template-areas: "s n rd" "s st st"; gap: 0 10px; align-items: center; }
.ff-lords .shield, .ff-end .shield { grid-area: s; width: 14px; height: 17px; background: var(--pc); clip-path: polygon(0 0, 100% 0, 100% 55%, 50% 100%, 0 55%); display: inline-block; }
.ff-lords .nm { grid-area: n; font-weight: 700; }
.ff-lords .nm small { color: var(--muted); font-weight: 500; }
.ff-lords .st { grid-area: st; color: var(--muted); font-size: 13px; }
.ff-lords .rd { grid-area: rd; font-size: 13px; color: var(--muted); }
.ff-lords li.ready .rd { color: var(--good); font-weight: 700; }
.ff-lords li.out { opacity: .5; }

.ff-chron li { font-size: 14px; line-height: 1.4; padding-left: 12px; position: relative; }
.ff-chron li::before { content: ""; position: absolute; left: 0; top: .55em; width: 5px; height: 5px; border-radius: 50%; background: var(--muted); }
.ff-chron li.good { color: var(--good); }
.ff-chron li.good::before { background: var(--good); }
.ff-chron li.bad { color: var(--bad); }
.ff-chron li.bad::before { background: var(--bad); }
.ff-chron li.big { color: #f1d07a; font-weight: 700; }

/* ---------- Fin de partie ---------- */
.ff-end { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(10, 14, 17, .66); z-index: 5; padding: 20px; }
.ff-end-box { width: min(560px, 100%); background: #212d35; border: 1px solid rgba(199, 149, 27, .5); border-radius: 16px; padding: 26px 28px; box-shadow: 0 30px 80px rgba(0, 0, 0, .5); }
.ff-end h2 { font: 700 40px/1 var(--f-display); color: #ead9ad; margin: 0 0 8px; }
.ff-end p { color: var(--muted); margin: 0 0 16px; }
.ff-end th { text-transform: none; letter-spacing: 0; font-size: 13px; }
.ff-end td:first-child { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.ff-end tr.win td { color: #f1d07a; }
.ff-end .actions { margin-top: 18px; }

@media (prefers-reduced-motion: reduce) { .ff-clock i { transition: none; } }
