/* Karten-Rendering & Effects */
.card-wrapper { --cw: var(--field-w, 150px); position: relative; flex: none; width: var(--cw); aspect-ratio: 5 / 7; container-type: inline-size; cursor: pointer; transition: transform 0.2s; }
.card-wrapper.hand-card { --cw: var(--hand-w, 140px); }
.card-wrapper.is-exhausted { margin-inline: calc(var(--cw) * 0.2); }
.deck-view-card { position: relative; }
.cfx-rot  { position: absolute; inset: 0; }
.card-wrapper.is-exhausted > .cfx-rot { transform: rotate(90deg); }
.cfx-tilt { position: absolute; inset: 0; pointer-events: none; transition: transform 0.1s; }
/* Kipp-Werte nur für .cfx-tilt selbst: nicht vererbt, damit eine Änderung nicht den Stil aller Kind-Elemente neu berechnet */
@property --rx { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
@property --ry { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
@property --lift { syntax: '<length>'; inherits: false; initial-value: 0px; }
.cfx-tilt.cfx-live { transform: perspective(900px) translateY(var(--lift, 0px)) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); }
.card-visual { --bd: #4a3f35; position: absolute; inset: 0; overflow: hidden; isolation: isolate; border-radius: 4.6cqw; background: linear-gradient(180deg, #1f1a16 0%, #0f0c0a 100%); box-shadow: 0 0.8cqw 2.4cqw rgba(0,0,0,.65); backface-visibility: hidden; }
.card-visual::after { content: ''; position: absolute; inset: 0; z-index: 9; pointer-events: none; border-radius: inherit; box-shadow: inset 0 0 0 0.7cqw var(--bd); }
.card-visual.has-img::after { box-shadow: none; }
.card-visual.can-play { --bd: var(--gold, #c9a84c); box-shadow: 0 0 3cqw rgba(201,168,76,.85); }
.card-visual.can-play.has-img::after { box-shadow: inset 0 0 0 0.7cqw var(--gold, #c9a84c); }
.card-wrapper.is-dragging .card-visual { opacity: .4; }
.card-wrapper.target-pulsing .card-visual { --bd: #ef4444; box-shadow: 0 0 5cqw 1.5cqw #ef4444 !important; }
.card-wrapper.target-pulsing .card-visual.has-img::after { box-shadow: inset 0 0 0 0.7cqw #ef4444; }
/* Wählbares Ziel einer Entscheidung: blauer Rahmen + Zielsymbol */
.card-wrapper.choice-target .card-visual { --bd: #3b82f6; box-shadow: 0 0 0 0.9cqw #3b82f6, 0 0 5cqw 1.2cqw rgba(59,130,246,.8); animation: choicePulse 1.1s ease-in-out infinite; }
.card-wrapper.choice-target .card-visual.has-img::after { box-shadow: inset 0 0 0 0.9cqw #3b82f6; }
.card-wrapper.choice-target::before { content: '🎯'; position: absolute; top: -8%; right: -6%; z-index: 40; font-size: clamp(14px, 16cqw, 26px); filter: drop-shadow(0 0 4px #000); pointer-events: none; }
@keyframes choicePulse { 50% { box-shadow: 0 0 0 0.9cqw #60a5fa, 0 0 7cqw 2cqw rgba(96,165,250,.95); } }
.card-wrapper.target-drop-valid .card-visual { box-shadow: 0 0 4cqw 1cqw #22c55e; }
.dropzone-active { outline: 2px dashed var(--gold, #c9a84c); outline-offset: -4px; }
.card-image-layer { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 3; object-fit: fill; opacity: 0; transition: opacity .15s; image-rendering: auto; -webkit-user-drag: none; user-select: none; }
.card-visual.has-img .card-image-layer { opacity: 1; }
.card-visual.has-img .cfx-text { visibility: hidden; }
.cfx-text { position: absolute; inset: 0; z-index: 1; padding: 5cqw; display: flex; flex-direction: column; gap: 2cqw; overflow: hidden; }
.cfx-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 2cqw; font-size: 7.5cqw; font-weight: 700; line-height: 1.15; }
.cfx-cost { background: #1e3a5f; color: #b0d4ff; border: 0.5cqw solid #4a7aab; border-radius: 6cqw; padding: 0.5cqw 3.5cqw; font-size: 8cqw; flex: none; }
.cfx-sub  { font-size: 6cqw; color: var(--gold, #c9a84c); font-style: italic; }
.cfx-body { font-size: 6.2cqw; line-height: 1.3; flex: 1; overflow: hidden; }
.cfx-stats-bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: flex-end; z-index: 10; pointer-events: none; }
.cfx-stat-badge { position: relative; width: 38cqw; display: flex; justify-content: center; align-items: center; filter: drop-shadow(0 1cqw 2cqw rgba(0,0,0,0.85)); }
.cfx-stat-badge img { display: block; width: 100%; height: auto; }
.cfx-stat-badge span { position: absolute; left: 50%; top: 51%; transform: translate(-50%, -50%); font-size: 20cqw; line-height: 1; font-weight: 900; font-family: Impact, 'Arial Black', 'Georgia', sans-serif; color: #fff;
    -webkit-text-stroke: 3.4cqw #000; paint-order: stroke fill; text-shadow: 0 0 1.5cqw #000, 0 0 3cqw #000; }
.cfx-stat-badge.lean span { left: 42%; top: 58%; }
.cfx-stat-badge.hp-badge span { left: 57%; }
.cfx-stat-badge.hp-badge.overkill span { color: #ff5a5a; }
/* Aktuelle Kosten auf der Hand (renderer.js opts.costNow): über dem gedruckten Kostensymbol */
.cfx-cost-now { position: absolute; z-index: 5; left: 12.6%; top: 8.6%; width: 13cqw; height: 13cqw; transform: translate(-50%, -50%); border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font: 900 9.5cqw/1 Impact, 'Arial Black', Georgia, sans-serif; color: #fff; text-shadow: 0 0.4cqw 0.8cqw #000; border: 0.9cqw solid #d6c08a; box-shadow: 0 0 3cqw 0.8cqw rgba(0,0,0,.6); }
.cfx-cost-now.down { background: radial-gradient(circle at 40% 35%, #34d36b, #0f6b2e); box-shadow: 0 0 3.5cqw 1.2cqw rgba(74,222,128,.75); }
.cfx-cost-now.up { background: radial-gradient(circle at 40% 35%, #f05252, #7f1d1d); }
.card-visual.img-ea .cfx-cost-now { left: 10.6%; top: 74%; }
.card-wrapper.cost-down.cost-down .card-visual { --bd: #4ade80; box-shadow: 0 0 0 0.9cqw #4ade80, 0 0 5cqw 1.4cqw rgba(74,222,128,.7); }
.card-wrapper.cost-down.cost-down .card-visual.has-img::after { box-shadow: inset 0 0 0 0.9cqw #4ade80; }
.cfx-stat-badge.def-badge { margin-left: auto; }
.card-action-bar { position: absolute; left: 0; right: 0; bottom: -32px; z-index: 20; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; pointer-events: auto; }
.card-wrapper:hover .card-action-bar { opacity: 1; }
.card-action-bar button { flex: 1; padding: 5px 0; font-size: 10px; border-radius: 3px; border: 1px solid var(--gold-dark, #8a6d2b); font-weight: bold; color: #fff; cursor: pointer; background: linear-gradient(180deg, #3d3530, #1a1512); }
.card-action-bar button:hover { border-color: var(--gold, #c9a84c); }
.cfx-glare { position: absolute; inset: 0; z-index: 7; pointer-events: none; border-radius: inherit; background: radial-gradient(farthest-corner circle at var(--mx, 50%) var(--my, 50%), rgba(255,255,255,.34), transparent 55%); mix-blend-mode: soft-light; opacity: calc(var(--h, 0) * 1); }
.cfx-foil { position: absolute; inset: 0; z-index: 6; pointer-events: none; border-radius: inherit; opacity: 0; mix-blend-mode: color-dodge; transition: opacity 0.3s; }
.card-wrapper:hover .cfx-foil { opacity: 1; }
#cfx-preview .cfx-foil { opacity: 1 !important; }
/* ---- Foil-Effekte (--mx/--my = Mausposition auf der Karte); Muster: das Foil-Element setzt Mischmodus, die Pseudo-Elemente liefern den Inhalt */
.cfx-foil { --rb: #ff8fa3, #ffd479, #b9ff9c, #8ff6ff, #9fb2ff, #e7a3ff, #ff8fa3; }
.cfx-foil.n1::before, .cfx-foil.n1::after, .cfx-foil.n5::before, .cfx-foil.n5::after { content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; }
/* Prisma-Holo (sanft): Regenbogenbänder, die mit der Maus wandern, stärker nahe der Maus */
.cfx-foil.n1 { background: repeating-linear-gradient(115deg, #ff2a6d 0%, #ffcf3a 6%, #3dff7a 12%, #2ae8ff 18%, #4d6bff 24%, #c43dff 30%, #ff2a6d 36%);
    background-size: 320% 320%; background-position: var(--mx, 50%) var(--my, 50%); mix-blend-mode: color-dodge; filter: brightness(.32) contrast(1.3) saturate(1.1);
    -webkit-mask: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(0,0,0,.9), rgba(0,0,0,.25) 75%); mask: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(0,0,0,.9), rgba(0,0,0,.25) 75%); }
/* Magic-Foil 1999: die ganze Karte bekommt einen weichen Regenbogen-Schleier und einen Glanzstreifen */
.cfx-foil.n5 { mix-blend-mode: soft-light; }
.cfx-foil.n5::before { background: linear-gradient(125deg, var(--rb), #ffd479, #8ff6ff); background-size: 280% 280%; background-position: var(--mx, 50%) var(--my, 50%); opacity: .95; }
.cfx-foil.n5::after { background: linear-gradient(125deg, transparent 35%, rgba(255,255,255,.85) 48%, transparent 60%); background-size: 260% 260%; background-position: var(--mx, 50%) var(--my, 50%); }
#cfx-preview { position: fixed; z-index: 999999; margin: 0; pointer-events: none; opacity: 0; transition: opacity .12s; display: none; cursor: default; }
#cfx-preview.show { opacity: 1; }
/* Keyword-Kästen neben der Zoom-Karte */
#kw-boxes { position: fixed; z-index: 999999; width: 240px; display: none; flex-direction: column; gap: 8px; pointer-events: none; opacity: 0; transition: opacity .12s; }
#kw-boxes.show { opacity: 1; }
.kw-box { background: linear-gradient(180deg, #2a2118, #120d09); border: 2px solid var(--gold-dark, #8a6d2b); border-radius: 6px; padding: 8px 10px; box-shadow: 0 6px 18px rgba(0,0,0,.75); }
.kw-name { font: 900 14px/1.2 Georgia, serif; color: var(--gold-light, #f5d77a); margin-bottom: 4px; }
/* Bekannte Abweichung vom Kartentext (CARD_ISSUES) */
.kw-box.kw-issue { border-color: #dc2626; background: linear-gradient(180deg, #3a1414, #1a0808); }
.kw-issue .kw-name { color: #fca5a5; }
.cfx-issue { position: absolute; top: 4%; left: 50%; transform: translateX(-50%); z-index: 6; font-size: calc(var(--cw, 120px) * 0.16); line-height: 1; padding: 2% 5%; border-radius: 999px; background: rgba(127,29,29,.92); color: #fde047; border: 2px solid #fca5a5; box-shadow: 0 0 8px rgba(220,38,38,.8); pointer-events: auto; }
.db-issue { color: #f87171; }
.kw-text { font-size: 12.5px; line-height: 1.4; color: var(--text-main, #e8dcc8); font-style: italic; }
#cfx-preview .cfx-stats-bar { display: none !important; }
/* Friedhof: Karte spielen (Dramla Lifebender, Readiness, Greed Before Need) */
.gy-play-btn { display: block; width: 100%; margin-top: 6px; padding: 5px 0; font-weight: 900; color: #fff; cursor: pointer; border-radius: 4px; border: 1px solid var(--gold, #c9a84c); background: linear-gradient(180deg, #3d3530, #1a1512); }
.gy-play-btn:hover { border-color: var(--gold-light, #f5d77a); }
#cfx-preview .card-visual { box-shadow: 0 2.5cqw 9cqw rgba(0,0,0,.85); }
#cfx-preview.card-wrapper.is-exhausted, #cfx-preview .cfx-rot { margin: 0; transform: none; }

/* FIX: Damage-Maske */
.damage-mask { 
    position: absolute; 
    inset: 0; 
    width: 100%; 
    height: 100%; 
    z-index: 8 !important; 
    pointer-events: none; 
    mix-blend-mode: normal; 
    -webkit-mix-blend-mode: normal;
    display: block !important;
    transition: opacity 0.1s ease-out; /* NEU: Sanfter Übergang beim Scrollen */
}
/* Erhöhter ATK-Wert (z. B. Heartseeker im Kampf, "+1 ATK this turn"): grün */
.cfx-stat-badge.buffed span { color: #4ade80; }

/* Touch: langes Drücken auf eine Karte zeigt den Zoom – kein Systemmenü / keine Textauswahl */
.card-wrapper, .card-wrapper img { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }

/* Ziehen mit dem Finger: kein Scrollen/Zoomen auf ziehbaren Karten; mitlaufende Kopie der Karte */
[draggable="true"] { touch-action: none; }
.touch-drag-ghost { position: fixed !important; left: 0; top: 0; z-index: 100000; pointer-events: none; margin: 0 !important;
    filter: drop-shadow(0 14px 22px rgba(0,0,0,.7)); opacity: .95; transition: none !important; }
.touch-drag-ghost .card-action-bar { display: none; }
/* Spielfeld: der Browser darf Berührungen auf Karten nicht übernehmen (sonst bricht Gedrückthalten-Zoom ab) */
#arena .card-wrapper { touch-action: none; }

/* Geräte ohne Hover (Handy): Kartenknöpfe nur bei angetippter Karte sichtbar und antippbar */
@media (hover: none) {
    .card-action-bar { pointer-events: none; }
    .card-wrapper.touch-active .card-action-bar { opacity: 1; pointer-events: auto; }
    .card-wrapper.touch-active .card-visual { box-shadow: 0 0 0 3px #fde68a, 0 0 18px rgba(250,204,21,.8); }
}
/* Touch-Geräte: eingebautes Ziehen des Browsers aus (startet sonst beim langen Drücken und bricht den Zoom ab).
   Das Ziehen mit dem Finger übernimmt ui.js (TOUCH_DRAG). */
@media (hover: none) { [draggable="true"], .card-wrapper, .card-wrapper img { -webkit-user-drag: none; } }

/* Roguelike-Aufwertung: violetter Rahmen mit Schimmer und der Effekt als eingedrucktes Pergamentfeld im Textkasten */
.card-visual.rl-up { --bd: #a77bff; box-shadow: 0 0 0 0.5cqw rgba(167, 123, 255, .55), 0 0 4cqw rgba(167, 123, 255, .55), 0 0.8cqw 2.4cqw rgba(0,0,0,.65); }
.card-visual.rl-up.has-img::after { box-shadow: inset 0 0 0 0.9cqw #a77bff; }
.card-up-text { position: absolute; left: 8cqw; right: 8cqw; bottom: 15cqw; z-index: 11; pointer-events: none;
    padding: 1.4cqw 2.6cqw; border-radius: 1.6cqw; font: 600 3.4cqw/1.18 Georgia, 'Times New Roman', serif; color: #2b1640;
    background: linear-gradient(180deg, rgba(246, 236, 255, .96), rgba(225, 208, 250, .96)); border: 0.5cqw solid #8a5cf0;
    box-shadow: 0 0.6cqw 2cqw rgba(0, 0, 0, .55); max-height: 30cqw; overflow: hidden; }
/* Karte mit Regeltext: Feld endet knapp über der Typzeile und wächst nach oben ins Bild */
.card-up-text.over-art { bottom: 67cqw; }
.card-up-text.in-box { top: 100cqw; bottom: auto; }
/* Unten zwischen Angriff und Leben – Flavor-Text, Set-Zeile und Artist dürfen verdeckt werden */
.card-up-text.at-bottom { left: 17cqw; right: 17cqw; bottom: 3cqw; }
/* Effekttext nur in der Hover-Vergrößerung – auf kleinen Karten (Hand, Spielfeld) unlesbar; dort zeigt nur der Rahmen die Aufwertung.
   Ohne Kartenbild steht die Aufwertung schon in [Klammern] im Ersatztext */
.card-up-text { display: none; }
#cfx-preview .card-visual.has-img > .card-up-text { display: block; }

/* Zähler auf Karten (Locations: capture/honor/arena u. a.) – rechts oben, gut lesbar */
.cfx-counters { position: absolute; top: 14cqw; right: 3cqw; z-index: 30; display: flex; flex-direction: column; gap: 2cqw; pointer-events: none; }
.cfx-counter { display: flex; align-items: center; gap: 1.5cqw; padding: 1cqw 3cqw 1cqw 1cqw; border-radius: 99px;
    background: rgba(10,7,5,.85); border: 0.6cqw solid #c9a84c; box-shadow: 0 1cqw 3cqw rgba(0,0,0,.7); }
.cfx-counter img { width: 13cqw; height: 13cqw; border-radius: 50%; object-fit: cover; display: block; }
.cfx-counter span { color: #fde68a; font: 800 12cqw/1 Georgia, serif; text-shadow: 0 0.5cqw 1cqw #000; min-width: 6cqw; text-align: center; }
/* ATK beim Angreifen (Vorschau, ui.js showAttackAtk): glühendes Schwert-Abzeichen oben rechts am ATK-Symbol */
.cfx-stat-badge .atk-att { position: absolute; left: 58%; top: -2cqw; z-index: 2; display: flex; align-items: center; gap: 1cqw; padding: 1.6cqw 4.5cqw 1.6cqw 3cqw;
    border-radius: 99px; pointer-events: none; white-space: nowrap; color: #fff8e6;
    background: linear-gradient(180deg, #ffcf6b 0%, #f07a1a 45%, #9c2a06 100%); border: 0.7cqw solid #ffe2a0;
    box-shadow: 0 0 3.5cqw rgba(255, 140, 40, .85), inset 0 0.6cqw 0.8cqw rgba(255, 255, 255, .45), 0 1cqw 2cqw rgba(0, 0, 0, .8); }
.cfx-stat-badge .atk-att svg { width: 10cqw; height: 10cqw; filter: drop-shadow(0 0.4cqw 0 #5a1500); }
.cfx-stat-badge .atk-att i { font: normal 900 12cqw/1 Impact, 'Arial Black', sans-serif; text-shadow: 0 0.5cqw 0 #5a1500, 0 0 1.5cqw #5a1500; }
/* Aktive Formen am Helden (ui.js showHeroForms): runde Icons am linken Rand, leuchten in der Farbe der Form */
.hero-forms { position: absolute; left: -7cqw; top: 26cqw; z-index: 40; display: flex; flex-direction: column; gap: 3cqw; pointer-events: auto; }
.hero-forms.opp { left: auto; right: -7cqw; }
.hero-form { --fc: #f5c542; width: 21cqw; height: 21cqw; border-radius: 50%; overflow: hidden; background: #120d08; border: 1.1cqw solid var(--fc);
    box-shadow: 0 0 0 0.6cqw #000, 0 0 4cqw var(--fc), 0 1cqw 2cqw rgba(0,0,0,.9); animation: formGlow 2.4s ease-in-out infinite; display: grid; place-items: center; }
.hero-form img { width: 100%; height: 100%; object-fit: cover; display: block; transform: scale(1.12); }
.hero-form b { color: var(--fc); font: 900 12cqw/1 Georgia, serif; }
.hero-form.form-cat { --fc: #ffb13b; } .hero-form.form-bear { --fc: #e0603a; } .hero-form.form-moonkin { --fc: #8fb4ff; }
.hero-form.form-tree { --fc: #7ee06a; } .hero-form.form-travel, .hero-form.form-flight, .hero-form.form-aquatic { --fc: #6ad8e0; }
.hero-form.form-shadow { --fc: #b57cff; } .hero-form.form-serpent { --fc: #5fe0a0; }
@keyframes formGlow { 0%, 100% { box-shadow: 0 0 0 0.6cqw #000, 0 0 2.5cqw var(--fc), 0 1cqw 2cqw rgba(0,0,0,.9); } 50% { box-shadow: 0 0 0 0.6cqw #000, 0 0 6cqw var(--fc), 0 1cqw 2cqw rgba(0,0,0,.9); } }
/* Offene Location (ui.js locCapBadge): Turm mit Zählern / Kapazität über dem gedruckten Turm; voll = goldene Zahl */
.loc-cap { position: absolute; right: 2cqw; bottom: 2cqw; z-index: 31; width: 26cqw; pointer-events: none; filter: drop-shadow(0 1cqw 2cqw rgba(0,0,0,.9)); }
.loc-cap img { display: block; width: 100%; height: auto; }
.loc-cap span { position: absolute; left: 50%; top: 56%; transform: translate(-50%, -50%); white-space: nowrap; color: #fff; font: 900 13cqw/1 Impact, 'Arial Black', sans-serif;
    -webkit-text-stroke: 0.5cqw #2a1d0e; text-shadow: 0 0.6cqw 1cqw #000; }
.loc-cap small { font: 800 7.5cqw/1 Impact, 'Arial Black', sans-serif; color: #f3e3c0; -webkit-text-stroke: 0.3cqw #2a1d0e; margin-left: 0.5cqw; }
.loc-cap.full span { color: #ffd34d; }
.card-visual:has(.loc-cap) .cfx-counters { display: none; }
/* Protector: Schild oben mittig auf der Karte (sitzt in .cfx-tilt, dreht beim Erschöpfen mit) */
.protector-badge { position: absolute; left: 50%; top: -5cqw; width: 22cqw; transform: translateX(-50%); z-index: 6; pointer-events: none;
    filter: drop-shadow(0 0.8cqw 1.6cqw rgba(0,0,0,.85)) drop-shadow(0 0 2.5cqw rgba(150,190,230,.55)); }
.protector-badge svg { display: block; width: 100%; height: auto; }
