/* Bumpkin Legends - Guerra dei Clan (js/clanwar.js, 10 novembre 2026). Finestra sopra il kit di Sunflower (sfl.css + game.css).
   La Fortezza e' una scena di DOM: prato a scacchi, muro dal foglio walls_sheet.png del Villaggio, Porta e Mastio in SVG a pixel
   (colori qui sotto, Goblin con la palizzata e la pietra muschiosa). Proprieta' logiche (inline-start/end) per le lingue RTL. */
.cw-body {
  --cw-ink: #3e2731; --cw-dark: #1d1216; --cw-my: #3e8948; --cw-foe: #c0392b; --cw-gold: #e3a216; --cw-paper: #f3d6a8; --cw-paper2: #fbe8c6;
  --s1: #c4cfe3; --s2: #8b9bb4; --s3: #a7b3cc; --dk: #2a1d26; --wd: #8f563b; --wd2: #6b3d2a; --pc: #4a3b44; --ac: #ffcf4a;
}
.sfl-font .cw-body { font-size: 18px; line-height: 18px; }
.cw-body .num { font-family: "SflSecondary", monospace; }
.cw-body small { font-size: 15px; line-height: 15px; }

/* ---------- fase e conto alla rovescia ---------- */
.cw-phase { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px 10px; margin-bottom: 8px; padding: 7px 10px;
  background: var(--cw-paper2); border: 2px solid var(--cw-ink); border-inline-start-width: 8px; border-radius: 6px; }
.cw-phase b { font-weight: normal; }
.cw-phase .cw-cd { font-family: "SflSecondary", monospace; font-size: 17px; color: #7a3b22; }
.cw-phase.ph-prep { border-inline-start-color: var(--cw-gold); }
.cw-phase.ph-war { border-inline-start-color: var(--cw-foe); }
.cw-phase.ph-wait, .cw-phase.ph-skip { border-inline-start-color: #2f7fd6; }
.cw-phase.ph-ending, .cw-phase.ph-done, .cw-phase.ph-off { border-inline-start-color: #7d6f6a; }
.cw-why { margin: 6px 0; padding: 6px 8px; background: rgba(192, 57, 43, .12); border-radius: 6px; color: #7a2b20; font-size: 16px; }

/* ---------- sfida: noi contro loro ---------- */
.cw-match { margin-bottom: 8px; padding: 8px 8px 10px; color: #fff; background: var(--cw-ink); border: 3px solid var(--cw-dark); border-radius: 8px;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.12); }
.cw-mrow { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 6px; }
.cw-side { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; text-align: center; }
.cw-bn { width: 24px; height: 50px; flex: none; image-rendering: pixelated; }
.cw-side.foe .cw-bn { filter: hue-rotate(320deg) saturate(2.2) brightness(.95); }
.cw-sn { display: flex; flex-direction: column; align-items: center; gap: 3px; max-width: 100%; min-width: 0; }
.cw-sn b { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; max-width: 100%; overflow: hidden; overflow-wrap: anywhere; font-weight: normal; font-size: 16px; line-height: 17px; }
.cw-sn small { color: #d9c3b0; font-size: 13px; line-height: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw-side.mine .cw-sn b { color: #9fe08a; }
.cw-side.foe .cw-sn b { color: #ff9a86; }
.cw-side.gob .cw-sn b { color: #c9e07a; }
.cw-score { display: flex; align-items: baseline; gap: 4px; padding: 0 4px; }
.cw-score b { font-size: 30px; line-height: 30px; font-weight: normal; color: #ffd84a; text-shadow: 2px 2px 0 var(--cw-dark); }
.cw-score i { font-style: normal; font-size: 22px; color: #d9c3b0; }
.cw-tug { position: relative; height: 10px; margin-top: 8px; background: #5a4a50; border: 2px solid var(--cw-dark); border-radius: 3px; overflow: hidden; }
.cw-tug i { position: absolute; top: 0; bottom: 0; }
.cw-tug .a { inset-inline-start: 0; background: linear-gradient(#6fc35a, #3e8948); }
.cw-tug .b { inset-inline-end: 0; background: linear-gradient(#e0614c, #a3302a); }
.cw-tug.gob .a { background: linear-gradient(#e8d05a, #b8962a); }
.cw-tug em { position: absolute; top: -2px; bottom: -2px; width: 2px; margin-left: -1px; background: #fff; }
.cw-tugn { display: block; margin-top: 5px; color: #d9c3b0; }

/* ---------- i miei attacchi ---------- */
.cw-me { margin-bottom: 8px; padding: 6px 8px; background: var(--cw-paper2); border: 2px solid rgba(62,39,49,.35); border-radius: 6px; }
.cw-mel { display: flex; align-items: center; gap: 8px; }
.cw-pips { display: inline-flex; gap: 5px; flex: none; }
.cw-pips i { width: 12px; height: 12px; margin: 2px; transform: rotate(45deg); background: #b9a593; border: 2px solid var(--cw-ink); }
.cw-pips i.on { background: var(--cw-gold); box-shadow: inset 2px 2px 0 #ffe9a0; }
.cw-pips.sm i { width: 8px; height: 8px; border-width: 2px; }
.cw-cdnote { display: block; color: #a3302a; }
.cw-cdnote:empty { display: none; }
.cw-lockn { display: block; margin-top: 4px; }
.cw-last { margin-bottom: 8px; padding: 5px 8px; font-size: 15px; background: rgba(62,39,49,.08); border-radius: 6px; }
.cw-last b { font-weight: normal; }
.cw-last .num { white-space: nowrap; }
.cw-last.r-win b { color: #2e7a35; } .cw-last.r-loss b { color: #a3302a; }
.cw-result { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; padding: 10px 12px; background: var(--cw-paper2); border: 3px solid var(--cw-ink); border-radius: 8px; }
.cw-result img { width: 44px; height: 64px; flex: none; image-rendering: pixelated; }
.cw-result > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cw-result b { font-weight: normal; font-size: 30px; line-height: 28px; }
.cw-result.r-win { background: #fff1c2; } .cw-result.r-win b { color: #9a6b00; text-shadow: 2px 2px 0 #fff; }
.cw-result.r-loss b { color: #8a2b20; }
.cw-result .num { font-size: 20px; }
.cw-rule { display: block; margin: 10px 0 2px; }
.cw-h { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; margin: 12px 0 6px; }
.cw-h b { font-weight: normal; font-size: 20px; }
.cw-h small { color: #7a5545; }
.cw-hint { display: block; margin: 6px 0; text-align: center; }
.win-body .cw-prep { margin: 0 0 4px; }

/* ---------- la Fortezza (scena) ---------- */
.cw-scene { position: relative; height: 336px; overflow: hidden; border: 3px solid var(--cw-dark); border-radius: 8px;
  background: repeating-conic-gradient(#6aaf53 0 25%, #63a74d 0 50%) 0 0 / 16px 16px; box-shadow: inset 0 0 0 2px rgba(255,255,255,.15), inset 0 -40px 60px rgba(0,0,0,.18); }
.cw-scene.side-goblin { background: repeating-conic-gradient(#7d8f4a 0 25%, #768845 0 50%) 0 0 / 16px 16px;
  --s1: #a9b48a; --s2: #77845c; --s3: #8e9a72; --wd: #6b4a2b; --wd2: #4f3420; --ac: #9dff6a; }
.cw-path { position: absolute; left: 50%; bottom: -4px; width: 44px; height: 60px; margin-left: -22px; background: #c79b62;
  box-shadow: inset 4px 0 0 #b0844f, inset -4px 0 0 #b0844f; }
.cw-post { position: absolute; display: flex; flex-direction: column; align-items: center; padding: 0; border: 0; background: none; color: inherit; font: inherit;
  transform: translate(-50%, -50%); -webkit-tap-highlight-color: transparent; }
button.cw-post { cursor: pointer; }
.cw-post:focus-visible { outline: 3px dashed #ffd84a; outline-offset: 2px; }
.cw-post.p-wall { left: 20% !important; width: 60%; transform: translate(0, -50%); }
/* chi sta davanti copre chi sta dietro (targhette comprese): Mastio e Mura in fondo, poi le Torri, la Porta davanti */
/* la Porta si appoggia piu' in basso (la targhetta sta sotto): cosi' non copre la targhetta delle Mura */
.cw-post.p-gate { transform: translate(-50%, -34%); }
.cw-post.p-keep, .cw-post.p-wall { z-index: 1; } .cw-post.p-west, .cw-post.p-east { z-index: 2; } .cw-post.p-gate { z-index: 3; }
.p-wall .cw-art { width: 100%; }
.cw-art { position: relative; display: block; line-height: 0; }
.cw-svg { display: block; }
.cw-svg svg { display: block; width: 100%; height: 100%; }
.p-gate .cw-art > .cw-svg:first-child { width: 90px; height: 70px; }
.p-keep .cw-art { width: 100px; height: 95px; }
.cw-keep { position: relative; display: block; width: 100%; height: 100%; }
.cw-keep .cw-svg { width: 100%; height: 100%; }
.cw-flag { position: absolute; left: 50%; top: -18px; width: 24px; height: 50px; margin-left: -12px; image-rendering: pixelated; }
.side-opp .cw-flag { filter: hue-rotate(320deg) saturate(2.2) brightness(.95); }
.cw-tower { display: block; width: 48px; height: 90px; background: url("/sfl/village/walls/walls_sheet.png") 0 -180px / 816px 270px no-repeat; image-rendering: pixelated; }
img.cw-tower.wood { width: 44px; height: 91px; background: none; }
.cw-wallrow { display: flex; justify-content: center; width: 100%; height: 60px; overflow: hidden; }
.cw-wseg { flex: none; width: 32px; height: 60px; background-image: url("/sfl/village/walls/walls_sheet.png"); background-size: 544px 180px; image-rendering: pixelated; }
.cw-svg .ol { fill: var(--cw-ink); } .cw-svg .s1 { fill: var(--s1); } .cw-svg .s2 { fill: var(--s2); } .cw-svg .s3 { fill: var(--s3); }
.cw-svg .dk { fill: var(--dk); } .cw-svg .wd { fill: var(--wd); } .cw-svg .wd2 { fill: var(--wd2); } .cw-svg .pc { fill: var(--pc); } .cw-svg .ac { fill: var(--ac); }
/* targhetta: nome, vita, guardiano */
.cw-plate { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 70px; max-width: 96px; margin-top: -6px; padding: 2px 6px 3px;
  color: #fff; background: rgba(42, 26, 33, .9); border: 2px solid var(--cw-dark); border-radius: 4px; line-height: 13px; }
.cw-plate b { font-weight: normal; font-size: 14px; white-space: nowrap; }
.p-wall .cw-plate { position: absolute; left: 50%; top: 50%; margin: 0; transform: translate(-50%, -50%); }
.cw-hp { display: block; width: 100%; height: 5px; background: #4a2f37; border-radius: 2px; overflow: hidden; }
.cw-hp i { display: block; height: 100%; background: #e0614c; }
.side-my .cw-hp i { background: #6fc35a; } .side-goblin .cw-hp i { background: #e8d05a; }
.cw-hp.big { height: 12px; margin: 6px 0; border: 2px solid var(--cw-dark); }
.cw-gd { max-width: 88px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: #ffe8a8; }
.cw-gd.npc { color: #c9b3a6; }
.cw-lock { position: absolute; top: 2px; inset-inline-end: 2px; z-index: 3; font-style: normal; font-size: 16px; line-height: 16px; }
/* stati: aperto all'assalto, scelto, danneggiato (fuoco), distrutto (macerie), bloccato */
.cw-post.is-open .cw-plate { border-color: #ff6a4a; }
.cw-post.is-sel .cw-art { filter: drop-shadow(2px 0 0 #ffd84a) drop-shadow(-2px 0 0 #ffd84a) drop-shadow(0 2px 0 #ffd84a) drop-shadow(0 -2px 0 #ffd84a); }
.cw-post.is-sel .cw-plate { border-color: #ffd84a; }
.cw-post.is-locked .cw-art > :first-child { filter: saturate(.6) brightness(.9); }
.cw-post.is-down .cw-art > :first-child { filter: grayscale(1) brightness(.6); clip-path: inset(48% 0 0 0); }
.cw-post.is-down .cw-plate { opacity: .75; }
.cw-art > .cw-svg:last-child:not(:first-child) { position: absolute; left: 6%; right: 6%; bottom: 0; height: 30%; }
.cw-fire { position: absolute; left: 50%; top: 30%; width: 16px; height: 24px; margin-left: -8px; background: url("/sfl/goblins/fire_sheet.png") 0 0 / 64px 24px; image-rendering: pixelated;
  animation: cwfire .5s steps(4) infinite; }
@keyframes cwfire { to { background-position: -64px 0; } }
@media (prefers-reduced-motion: reduce) { .cw-fire { animation: none; } }
/* Fortezza nemica nascosta prima dell'inizio */
.cw-scene.is-hidden .cw-art { filter: brightness(0) opacity(.35); }
.cw-scene.is-hidden .cw-plate { opacity: .5; }
.cw-fog { position: absolute; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(ellipse at center, rgba(38, 30, 56, .55), rgba(38, 30, 56, .88)); }
.cw-fog span { max-width: 240px; padding: 8px 12px; text-align: center; color: #fff; background: rgba(29, 18, 22, .85); border: 2px solid #6b5a8a; border-radius: 6px; font-size: 16px; }

/* pannello del posto scelto */
.cw-pp { margin-top: 8px; padding: 8px 10px; color: #fff; background: var(--cw-ink); border: 3px solid var(--cw-dark); border-radius: 8px; }
.cw-pph { display: flex; align-items: baseline; gap: 8px; }
.cw-pph b { font-weight: normal; font-size: 20px; }
.cw-pph .num { color: #d9c3b0; font-size: 15px; }
.cw-pph em { margin-inline-start: auto; font-style: normal; color: #ffd84a; font-size: 15px; }
.cw-pp .cw-hp i { background: #e0614c; }
.cw-ppg { margin-bottom: 4px; font-size: 16px; }
.cw-ppg [data-notr] { color: #ffe8a8; }
.cw-pp .muted { display: block; color: #d9c3b0; margin-bottom: 6px; }
.cw-ppx { margin-top: 4px; padding: 6px; text-align: center; color: #d9c3b0; background: rgba(255,255,255,.08); border-radius: 4px; }
.win-body .cw-pp .btn.big { margin-top: 4px; }

/* ---------- mappa dei siti ---------- */
.cw-map { position: relative; height: 200px; margin-bottom: 6px; overflow: hidden; border: 3px solid var(--cw-dark); border-radius: 8px;
  background: repeating-conic-gradient(#86c065 0 25%, #7fb95f 0 50%) 0 0 / 16px 16px; }
.cw-river { position: absolute; left: calc(70% - 14px); top: -35%; width: 28px; height: 130%; transform: rotate(28deg); background: #4f9bd9;
  box-shadow: inset 4px 0 0 #6fb6ec, inset -4px 0 0 #3a7ab8; }
.cw-marsh { position: absolute; left: calc(52% - 46px); top: calc(48% - 20px); width: 92px; height: 40px; border-radius: 50%;
  background: radial-gradient(circle at 30% 40%, #5f8a7a 0 10px, transparent 11px), radial-gradient(circle at 70% 60%, #5f8a7a 0 8px, transparent 9px), #7aa07e; opacity: .9; }
.cw-site { position: absolute; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 0; border: 0; background: none; font: inherit; color: inherit;
  transform: translate(-50%, -50%); cursor: pointer; }
.cw-site:focus-visible { outline: 3px dashed #ffd84a; outline-offset: 2px; }
.cw-deco { display: flex; align-items: flex-end; gap: 0; min-height: 4px; }
.cw-deco img { image-rendering: pixelated; }
.s-woods .cw-deco img { width: 27px; height: 52px; margin: 0 -6px; }
.s-hill .cw-deco { padding: 0 14px 2px; border-radius: 40px 40px 6px 6px; background: #9fd27a; box-shadow: inset 0 -4px 0 #7fb95f; }
.s-hill .cw-deco img { width: 26px; height: 25px; }
.s-ruins .cw-deco img { width: 22px; height: 26px; }
.cw-dot { width: 12px; height: 12px; background: #fff; border: 3px solid var(--cw-ink); border-radius: 50%; }
.cw-pin { width: 20px; height: 41px; margin-top: -12px; image-rendering: pixelated; }
.cw-site b { font-weight: normal; padding: 1px 6px; font-size: 13px; line-height: 14px; white-space: nowrap; color: #fff; background: rgba(42, 26, 33, .88); border: 2px solid var(--cw-dark); border-radius: 4px; }
.cw-site.on b { color: var(--cw-ink); background: #ffd84a; }
.cw-siteinfo { margin-bottom: 8px; padding: 6px 8px; font-size: 15px; background: var(--cw-paper2); border-radius: 6px; }
.cw-siteinfo b { font-weight: normal; color: #2e6a35; }
.cw-save { position: sticky; bottom: -6px; z-index: 6; display: flex; flex-direction: column; gap: 4px; margin: 8px -6px 0; padding: 6px; background: var(--cw-paper); }
.cw-dirty { color: #a3302a; text-align: center; }

/* ---------- elenchi (rosa, classifica, registro, storico) ---------- */
.cw-list { display: flex; flex-direction: column; gap: 4px; }
.cw-row { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 5px 8px; background: var(--cw-paper2); border: 2px solid rgba(62,39,49,.2); border-radius: 6px; }
.cw-row.off { opacity: .55; }
.cw-rn { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.cw-rn > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw-rn small { color: #7a5545; }
.cw-rn b { font-weight: normal; }
.cw-best { color: #2e7a35 !important; }
.cw-rk { width: 22px; flex: none; text-align: center; font-style: normal; color: #7a5545; }
.cw-li { flex: none; width: 22px; text-align: center; font-style: normal; }
.cw-log.opp { background: #f6dcd2; }
.cw-log.w .cw-rn small { color: #2e7a35; }
.win-body .cw-row .btn { flex: none; padding: 5px 10px; font-size: 17px; }
.win-body .cw-rp { min-width: 40px; }
.cw-gdn { flex: none; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #2e6a35; }
.cw-scs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.cw-sc { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 6px; min-width: 0; color: #fff; background: var(--cw-ink); border: 3px solid var(--cw-dark); border-radius: 8px; text-align: center; }
.cw-sc b { max-width: 100%; font-weight: normal; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw-sc.mine b { color: #9fe08a; } .cw-sc.foe b { color: #ff9a86; }
.cw-sc .num { font-size: 28px; line-height: 28px; color: #ffd84a; }
.cw-sc small { color: #d9c3b0; font-size: 13px; }
.cw-hr img { width: 22px; height: 32px; flex: none; image-rendering: pixelated; }
.cw-hs { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: none; }
.cw-hs b { font-weight: normal; font-size: 18px; }
.cw-hr.r-win .cw-rn small:last-child { color: #2e7a35; } .cw-hr.r-loss .cw-rn small:last-child { color: #a3302a; }

/* scelta del guardiano (finestrella) */
.cw-picks { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.cw-picks .cw-pick { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; width: 100%; min-height: 40px; padding: 6px 10px; text-align: start; font: inherit; font-size: 17px;
  color: var(--cw-ink, #3e2731); background: #fbe8c6; border: 2px solid #3e2731; border-radius: 6px; }
.cw-picks .cw-pick.on { background: #cde8b8; }
.cw-pick b { font-weight: normal; }
.cw-pick small { color: #7a5545; font-size: 14px; }
.cw-pick em { margin-inline-start: auto; font-style: normal; font-size: 13px; color: #a3302a; }

/* ---------- ingresso dalla finestra del clan ---------- */
.cw-entry { display: flex; align-items: center; gap: 10px; width: 100%; margin: 8px 0; padding: 6px 10px; text-align: start; font: inherit; color: #fff; cursor: pointer;
  background: var(--cw-ink, #3e2731); border: 3px solid #1d1216; border-radius: 8px; box-shadow: inset 0 -4px 0 rgba(0,0,0,.3), inset 0 2px 0 rgba(255,255,255,.12); }
.cw-entry img { width: 20px; height: 41px; flex: none; image-rendering: pixelated; }
.cw-entry span { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.cw-entry b { font-weight: normal; font-size: 19px; color: #ffd84a; }
.cw-entry small { color: #d9c3b0; font-size: 14px; line-height: 14px; }
.cw-entry em { flex: none; font-style: normal; font-size: 15px; color: #ffb3a8; }
.cw-entry.ph-war { border-color: #6b1a12; }

@media (max-width: 380px) {
  .p-keep .cw-art { width: 88px; height: 84px; }
  .p-gate .cw-art > .cw-svg:first-child { width: 80px; height: 62px; }
  .cw-score b { font-size: 26px; }
}
