:root{
  --bg:#0f1a1e; --panel:#173029e8; --panel2:#203c34f0; --line:#52725d; --gold:#e7c67e;
  --tile:min(9vw,72px); --radius:16px; --shadow:0 10px 26px rgba(0,0,0,.25);
  font-family:system-ui,-apple-system,Segoe UI,Roboto,sans-serif;
}
*{box-sizing:border-box}
body{margin:0;min-height:100vh;color:#f4f6f1;background:#17352d}
.topbar{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:12px max(16px,calc((100vw - 1320px)/2));background:#0d1714c9;border-bottom:1px solid #315145;position:sticky;top:0;z-index:10;backdrop-filter:blur(10px)}
.brand{display:flex;align-items:center;gap:12px}.logo{font-size:30px}.brand strong{font-size:22px;letter-spacing:1px}.brand small{display:block;color:#bfd0c7}
#roomBadge{color:var(--gold);font-weight:800}
main{max-width:1320px;margin:0 auto;padding:18px 14px 28px}
.panel{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow);padding:18px}.centered{max-width:560px;margin:44px auto;text-align:center}
.hidden{display:none!important}
h1,h2,h3{margin-top:0}p{line-height:1.5;color:#d7e3db}.muted{color:#a8bbb0;font-size:13px}label{display:block;text-align:left;margin:14px 0;font-weight:700}input{display:block;width:100%;padding:12px 13px;margin-top:8px;border-radius:10px;border:1px solid #557362;background:#081311;color:white;font-size:16px}
button{appearance:none;border:1px solid #607f6c;background:#27463c;color:#fff;border-radius:10px;padding:11px 14px;font-weight:750;cursor:pointer}button:hover:not(:disabled){filter:brightness(1.1)}button:disabled{opacity:.45;cursor:not-allowed}.primary{background:linear-gradient(#f0c766,#b57d30);color:#1c231d;border-color:#f6d284}
.divider{margin:14px 0;color:#adc1b7}.buttonrow{display:flex;gap:10px;flex-wrap:wrap}.buttonrow>*{flex:1}
.playerlist,.factions,.controls,.cards{display:grid;gap:10px}.playerlist{margin:10px 0 18px}.playerrow{display:flex;justify-content:space-between;align-items:center;background:#10211c;padding:11px;border-radius:10px}.factions{grid-template-columns:repeat(2,minmax(0,1fr))}.faction{background:#11241e;padding:10px;border-radius:12px;border:1px solid transparent;text-align:left}.faction.active{border-color:var(--gold);box-shadow:0 0 0 2px rgba(231,198,126,.25) inset}.faction img{width:56px;height:56px;object-fit:contain;display:block;margin-bottom:6px}
.gametop{display:flex;justify-content:space-between;align-items:center;gap:12px;flex-wrap:wrap;margin-bottom:12px}.statsbar{display:flex;gap:12px;flex-wrap:wrap}.statsbar span{background:#0d1a15;padding:8px 10px;border-radius:999px;border:1px solid #335346}
.gamegrid{display:grid;grid-template-columns:minmax(0,1fr) 340px;gap:14px;align-items:start}
.boardpanel{padding:12px;overflow:hidden}
#battlefield{background:#294a3a;border-radius:18px;min-height:980px;position:relative;padding:14px;display:grid;grid-template-rows:auto auto auto;gap:6px}
.player-area{background:rgba(8,20,18,.42);backdrop-filter:blur(2px);border:1px solid rgba(255,255,255,.15);border-radius:18px;padding:10px}
.area-head{display:flex;justify-content:space-between;gap:10px;align-items:flex-end;flex-wrap:wrap;margin-bottom:10px}.area-head small{display:block;color:#d4dfd6}.mini-stats{display:flex;gap:10px;flex-wrap:wrap}.mini-stats span{background:#0e1a17cc;padding:5px 9px;border-radius:999px;font-size:14px}
.colheads{display:grid;grid-template-columns:repeat(6,var(--tile));justify-content:center;gap:4px;margin-bottom:4px}.colheads div{text-align:center;font-weight:800;color:#fff;text-shadow:0 2px 3px rgba(0,0,0,.5)}
.boardwrap{overflow:auto}.board{display:grid;grid-template-columns:repeat(6,var(--tile));grid-template-rows:repeat(5,var(--tile));gap:4px;justify-content:center}
.tile{width:var(--tile);height:var(--tile);border-radius:14px;border:1px solid rgba(255,255,255,.18);display:flex;align-items:center;justify-content:center;position:relative;background:rgba(244,246,241,.12);cursor:pointer;transition:transform .08s ease, box-shadow .12s ease, filter .12s ease}
.enemy .tile{background:rgba(226,235,244,.18)}.self .tile{background:rgba(237,245,222,.2)}
.tile.defense-row{outline:2px solid rgba(255,214,140,.34);clip-path:polygon(50% 3%, 96% 18%, 96% 61%, 50% 97%, 4% 61%, 4% 18%);border-radius:0}
.tile:hover{filter:brightness(1.1)}.tile.selected{box-shadow:0 0 0 3px var(--gold) inset}.tile.target{box-shadow:0 0 0 3px #8eeaa1 inset}
.tile img.chip{width:90%;height:90%;object-fit:contain;filter:drop-shadow(0 2px 3px rgba(0,0,0,.45))}
.tile .wall{font-size:28px;filter:drop-shadow(0 2px 2px rgba(0,0,0,.45))}
.badge{position:absolute;right:2px;bottom:2px;min-width:23px;height:23px;padding:0 6px;border-radius:999px;background:#f0d597;color:#1c211a;border:2px solid #5e5037;font-weight:900;font-size:13px;display:flex;align-items:center;justify-content:center}.badge.top{top:2px;bottom:auto;background:#d6e6ff}
.midlabel{text-align:center;font-weight:700;background:#10201bb5;padding:4px 10px;border-radius:999px;margin:0 auto;color:#f0e3b2;font-size:12px;letter-spacing:.2px}
.sidebar{position:sticky;top:78px}.controls button,.sidebar>button{width:100%}.controls{grid-template-columns:1fr 1fr}.pending{background:#10281d;border:1px solid #3d624f;border-radius:12px;padding:10px;color:#e5f5de;margin:10px 0}.cards{margin-bottom:10px}.carditem{background:#0e1b17;border:1px solid #3d5f50;border-radius:12px;padding:10px}.carditem strong{display:block;margin-bottom:4px}.carditem button{margin-top:8px;width:100%}.rules p{font-size:13px}.log{max-height:260px;overflow:auto;font-size:13px;line-height:1.45}.log div{padding:6px 0;border-bottom:1px solid rgba(255,255,255,.08)}
#toast{position:fixed;left:50%;bottom:18px;transform:translateX(-50%);max-width:min(92vw,580px);background:#8b3838;color:white;padding:12px 16px;border-radius:12px;display:none;z-index:50;box-shadow:var(--shadow)}
@media (max-width:1000px){.gamegrid{grid-template-columns:1fr}.sidebar{position:static}#battlefield{min-height:auto;padding:10px}}
@media (max-width:720px){:root{--tile:min(12.9vw,58px)}.factions{grid-template-columns:1fr 1fr}.controls{grid-template-columns:1fr}.gametop{padding:14px}.boardpanel{padding:8px}.player-area{padding:8px}.topbar{padding:10px 12px}.brand strong{font-size:18px}.brand small{font-size:12px}}

.tile.selected{outline:3px solid #ffd36b;outline-offset:-3px}.controls button.active{border-color:var(--gold)}

.tile.active-formation{box-shadow:0 0 0 3px rgba(255,214,80,.88) inset, 0 0 18px rgba(255,216,100,.35); background:rgba(255,228,120,.18)}
.tile.active-formation .badge{background:#ffd768;border-color:#88631f}
.tile.active-formation .badge.top{background:#fff2b8}
.board{row-gap:6px}

/* Identical SVG shield outlines on all browsers and devices. */
.tile.defense-row{clip-path:none;border:none;outline:none!important;background:transparent!important;border-radius:0;background-image:url('/assets/shield-slot.svg')!important;background-repeat:no-repeat!important;background-position:center!important;background-size:94% 97%!important}
.tile.defense-row:hover{filter:brightness(1.22)}
.tile .wall-art{width:90%;height:90%;object-fit:contain;filter:drop-shadow(0 2px 3px rgba(0,0,0,.55))}

#battlefield.active-turn{background:#494928;box-shadow:inset 0 0 0 3px #e3c55c80}
#battlefield.active-turn .bottom-area{background:rgba(111,93,31,.29);border-color:#f1d376}
.combat-flash{position:absolute;inset:0;display:flex;justify-content:center;align-items:center;z-index:30;pointer-events:none;font-size:35px;color:#ffe98b;text-shadow:0 0 18px #ffc341,0 0 4px black;animation:combatPulse .62s ease-out forwards}
.area-head{position:relative}.combat-flash.heart-hit{font-size:36px;color:#ff6666;background:#d8424240;border-radius:14px}
@keyframes combatPulse{0%{opacity:0;transform:scale(.4)}30%{opacity:1;transform:scale(1.45)}100%{opacity:0;transform:scale(1.8)}}

/* Defense tiles: dedicated grid cells with identical SVG shields on all devices. */
.tile.defense-row {
  background-color:rgba(227,202,138,.19)!important;
  background-image:url('/assets/shield-slot.svg')!important;
  border:2px solid rgba(236,205,132,.72)!important;
  border-radius:13px!important;
  outline:1px solid rgba(62,43,19,.5)!important;
  clip-path:none!important;
  box-shadow:inset 0 0 12px rgba(0,0,0,.26),0 1px 5px rgba(0,0,0,.28);
  background-size:79% 85%!important;
}
.tile.defense-row:has(.wall-art) { background-color:rgba(244,211,136,.28)!important; }
.mini-stats { align-items:center; }
.mini-stats span { white-space:nowrap; }

.combat-flash.skull-hit{font-size:34px;color:#f6f1e5;background:rgba(35,24,24,.28);border-radius:14px;text-shadow:0 0 12px #000,0 0 3px #000;}
.combat-flash.chip-hit{font-size:30px;color:#ffd777;}

.board-end-turn{display:block;margin:12px auto 0;width:min(100%,480px);padding:15px;font-size:16px;box-shadow:0 3px 13px #0005;}

.combat-flash.wall-break-hit{font-size:34px;color:#ffe4bf;background:rgba(89,56,23,.28);border-radius:14px;text-shadow:0 0 12px #000,0 0 3px #000;}
.combat-flash.shield-hit{font-size:34px;color:#9fd4ff;background:rgba(25,56,94,.30);border-radius:14px;text-shadow:0 0 12px #001b35,0 0 3px #001b35;}

/* Keine Aktionspunkte: eigenes Schlachtfeld rot statt gelb. */
#battlefield.no-actions{background:#63302f;box-shadow:inset 0 0 0 3px #ff746caa}
#battlefield.no-actions .bottom-area{background:rgba(138,34,35,.38);border-color:#ff8078}

/* Bannerbruch cinematic 2D presentation */
.sound-controls{display:flex;justify-content:flex-end;gap:9px;margin-bottom:9px}
.sound-controls button{font-size:13px;padding:9px 13px;border:1px solid #cda961;background:linear-gradient(160deg,#4b4735,#182c27);box-shadow:0 3px 12px #0006}
.player-area{transition:box-shadow .4s,background-color .4s;}
.tile.active-formation{animation:formationAura 2.5s ease-in-out infinite alternate}
.tile.active-formation img.chip{filter:drop-shadow(0 0 9px #f1d36bbb) drop-shadow(0 2px 3px #000)}
/* Stationary chip and wall artwork stays at its natural size. Entrances use board-event ghosts. */
.battle-particle{position:absolute;z-index:34;left:50%;top:50%;width:6px;height:6px;border-radius:2px;background:var(--particle-color);box-shadow:0 0 10px var(--particle-color);pointer-events:none;animation:particleFly .78s ease-out forwards}
.combat-flash.wall-break-hit{animation:wallSmash .61s ease-out forwards;font-size:39px}
.combat-flash.skull-hit{animation:skullRise .63s ease-out forwards}
.combat-flash.heart-hit{animation:heartImpact .63s ease-out forwards}
.combat-flash.shield-hit{animation:shieldImpact .63s ease-out forwards}
.carditem{position:relative;overflow:hidden;border:1px solid #937950;box-shadow:inset 0 1px 0 #ffffff18,0 6px 12px #0004;transition:transform .2s,box-shadow .2s;background:linear-gradient(145deg,#304538,#142820)}
.carditem:hover{transform:translateY(-2px);box-shadow:0 8px 19px #0009,0 0 15px #bb9b4b44}
.carditem::before{content:'✧';position:absolute;right:8px;top:3px;color:#d1ba79;opacity:.45;font-size:24px;pointer-events:none}

@keyframes formationAura{from{box-shadow:inset 0 0 0 2px #dfb74c,0 0 9px #e4c75555}to{box-shadow:inset 0 0 0 3px #ffe59c,0 0 19px #e4c75599}}
@keyframes particleFly{from{opacity:1;transform:translate(-50%,-50%) scale(1.5)}to{opacity:0;transform:translate(calc(-50% + var(--px)),calc(-50% + var(--py))) scale(.2)}}
@keyframes wallSmash{0%{opacity:0;transform:scale(.4) rotate(-24deg)}28%{opacity:1;transform:scale(1.5) rotate(14deg)}100%{opacity:0;transform:scale(1.9) rotate(-9deg)}}
@keyframes skullRise{0%{opacity:0;transform:translateY(18px) scale(.5)}28%{opacity:1;transform:translateY(0) scale(1.3)}100%{opacity:0;transform:translateY(-26px) scale(1.2)}}
@keyframes heartImpact{0%{opacity:0;transform:scale(.45)}26%{opacity:1;transform:scale(1.6)}45%{transform:scale(1)}100%{opacity:0;transform:scale(1.7)}}
@keyframes shieldImpact{0%{opacity:0;transform:scale(.5)}28%{opacity:1;transform:scale(1.45)}100%{opacity:0;transform:scale(2)}}
@media(prefers-reduced-motion:reduce){.tile.active-formation,.tile img.chip,.tile img.wall-art,.combat-flash,.battle-particle{animation:none!important}}

/* Bannerbruch 3.5: synchronisierte Zauber-Effekte (Server-Ereignisse). */
.spell-announcement {
  --spell-glow:#efd17b;position:fixed;top:clamp(66px,15vh,160px);left:50%;
  z-index:100;display:flex;align-items:center;gap:13px;max-width:min(88vw,420px);
  padding:11px 19px;border-radius:18px;border:2px solid var(--spell-glow);
  background:linear-gradient(120deg,#071a23f5,#1b2f34f4);
  box-shadow:0 0 30px color-mix(in srgb,var(--spell-glow),transparent 40%),0 12px 33px #000c,inset 0 0 24px #ffffff13;
  pointer-events:none;transform:translateX(-50%);color:#fff5df;
  animation:spellAnnouncement 1.2s ease-out forwards;
}
.spell-announcement-icon{font-size:38px;line-height:1;color:var(--spell-glow);text-shadow:0 0 17px var(--spell-glow)}
.spell-announcement-copy{display:grid;gap:3px}.spell-announcement-copy small{font-size:10px;letter-spacing:.16em;color:#f6df9b}.spell-announcement-copy strong{font:700 clamp(15px,3.4vw,22px) Georgia,serif;white-space:nowrap}
.spell-vfx{--spell-glow:#f6d26c;position:absolute;inset:-14%;z-index:38;display:flex;align-items:center;justify-content:center;pointer-events:none;
  color:#fff;font-size:clamp(28px,6vw,49px);text-shadow:0 0 5px white,0 0 20px var(--spell-glow),0 0 28px var(--spell-glow);
  background:radial-gradient(ellipse at center,color-mix(in srgb,var(--spell-glow),transparent 65%) 0%,transparent 70%);
  animation:spellSurge 1.25s ease-out forwards;
}
.spell-vfx::before,.spell-vfx::after{content:'';position:absolute;inset:5%;border:3px solid var(--spell-glow);border-radius:50%;opacity:.9;box-shadow:0 0 14px var(--spell-glow),inset 0 0 12px var(--spell-glow);animation:spellRing 1.1s ease-out forwards}
.spell-vfx::after{inset:22%;animation-delay:.18s;border-width:2px}
.spell-theme-heilendes_licht,.spell-vfx-heilendes_licht{--spell-glow:#fbe78e}
.spell-theme-zeitwind,.spell-vfx-zeitwind{--spell-glow:#78eaff}
.spell-theme-frostbann,.spell-vfx-frostbann{--spell-glow:#a5dfff}
.spell-theme-kraftfunke,.spell-vfx-kraftfunke{--spell-glow:#ffcb59}
.spell-theme-dornenmauer,.spell-vfx-dornenmauer{--spell-glow:#8bf16c}
.spell-theme-flammenstoss,.spell-vfx-flammenstoss{--spell-glow:#ff6b32}
.spell-theme-magischer_pfeil,.spell-vfx-magischer_pfeil{--spell-glow:#cf7eff}
.spell-theme-schutzzauber,.spell-vfx-schutzzauber{--spell-glow:#66f4ba}
.spell-vfx-heilendes_licht{animation:spellHeal 1.25s ease-out forwards}
.spell-vfx-zeitwind{animation:spellWind 1.25s ease-in-out forwards}
.spell-vfx-frostbann{animation:spellFreeze 1.25s ease-out forwards}
.spell-vfx-kraftfunke{animation:spellPower 1.25s ease-out forwards}
.spell-vfx-dornenmauer{animation:spellNature 1.25s ease-out forwards}
.spell-vfx-flammenstoss{animation:spellFlame 1.25s ease-out forwards}
.spell-vfx-magischer_pfeil{animation:spellArrow 1.25s ease-out forwards}
.spell-vfx-schutzzauber{animation:spellProtection 1.25s ease-out forwards}
@keyframes spellAnnouncement{0%{opacity:0;transform:translate(-50%,-18px) scale(.85)}22%{opacity:1;transform:translate(-50%,0) scale(1.04)}72%{opacity:1;transform:translate(-50%,0) scale(1)}100%{opacity:0;transform:translate(-50%,-12px) scale(.96)}}
@keyframes spellRing{0%{opacity:.9;transform:scale(.25) rotate(0deg)}100%{opacity:0;transform:scale(2) rotate(70deg)}}
@keyframes spellSurge{0%{opacity:0;transform:scale(.4)}25%{opacity:1;transform:scale(1.15)}75%{opacity:.9}100%{opacity:0;transform:scale(1.65)}}
@keyframes spellHeal{0%{opacity:0;transform:translateY(25px) scale(.55)}25%{opacity:1}100%{opacity:0;transform:translateY(-55px) scale(1.45)}}
@keyframes spellWind{0%{opacity:0;transform:rotate(-100deg) scale(.4)}23%{opacity:1}90%{opacity:.8}100%{opacity:0;transform:rotate(440deg) scale(1.55)}}
@keyframes spellFreeze{0%{opacity:0;filter:blur(8px);transform:scale(1.7)}30%{opacity:1;filter:blur(0) saturate(1.8);transform:scale(1)}100%{opacity:0;filter:blur(3px);transform:scale(1.35)}}
@keyframes spellPower{0%{opacity:0;transform:scale(.2) rotate(20deg)}24%{opacity:1;transform:scale(1.7) rotate(-12deg)}100%{opacity:0;transform:scale(.8) rotate(15deg)}}
@keyframes spellNature{0%{opacity:0;transform:translateY(50%) scale(.5)}35%{opacity:1;transform:translateY(0) scale(1.3)}100%{opacity:0;transform:translateY(-10px) scale(1.6)}}
@keyframes spellFlame{0%{opacity:0;transform:translateY(-100%) scale(.4)}36%{opacity:1;transform:translateY(0) scale(1.85)}64%{opacity:.95}100%{opacity:0;transform:scale(2.25)}}
@keyframes spellArrow{0%{opacity:0;transform:translate(-140px,120px) rotate(-30deg) scale(.4)}43%{opacity:1;transform:translate(0,0) rotate(-30deg) scale(1.7)}100%{opacity:0;transform:translate(18px,-15px) rotate(-30deg) scale(.9)}}
@keyframes spellProtection{0%{opacity:0;transform:scale(.1)}35%{opacity:1;transform:scale(1.5)}75%{opacity:1;transform:scale(1.45)}100%{opacity:0;transform:scale(1.7)}}
@media(prefers-reduced-motion:reduce){.spell-announcement,.spell-vfx,.spell-vfx::before,.spell-vfx::after{animation:none!important}.spell-announcement{opacity:1}.spell-vfx{opacity:1}}
