/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  background: #09090d;
  overflow: hidden;
  font-family: 'Lora', serif;
}

/* ── Main game container ── */
#game {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  background: #0f0f14;
}

/* ── ZONES ── */
#enemy-zone {
  flex: 0 0 auto;
  background: #160c0a;
  border-bottom: 1px solid #2a1808;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 12px 6px;
}

#player-zone {
  flex: 1 1 auto;
  background: #0a0e18;
  border-top: 1px solid #102030;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 12px 8px;
}

/* ── CENTRE BAND ── */
#centre-band {
  flex: 0 0 58px;
  background: #0d0d14;
  border-top: 1px solid #1e1808;
  border-bottom: 1px solid #101828;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}
#centre-left { width: 160px; }
#centre-info { text-align: center; }
#centre-right { width: 160px; display: flex; justify-content: flex-end; }

#round-txt {
  font-family: 'Cinzel', serif;
  font-size: 11px;
  color: #2a2010;
  letter-spacing: 4px;
  text-transform: uppercase;
}
#turn-txt {
  font-family: 'Cinzel', serif;
  font-size: 15px;
  font-weight: 700;
  margin-top: 2px;
}
#turn-txt.your-turn  { color: #30a060; }
#turn-txt.enemy-turn { color: #a03030; }

/* ── END TURN BUTTON ── */
#btn-end {
  padding: 10px 20px;
  background: #0c2016;
  border: 2px solid #2d7048;
  border-radius: 10px;
  color: #4ec870;
  font-family: 'Cinzel', serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  transition: .15s;
  white-space: nowrap;
}
#btn-end:hover { background: #163a24; border-color: #50c878; color: #80e898; }
#btn-end:disabled { opacity: .35; cursor: default; pointer-events: none; }

/* ── HUD ── */
#enemy-hud {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #180a08;
  border: 1px solid #3a1210;
  border-radius: 8px;
  padding: 8px 14px;
}
#player-hud {
  display: flex;
  align-items: center;
  gap: 16px;
  background: #08101e;
  border: 1px solid #182848;
  border-radius: 8px;
  padding: 8px 14px;
  margin-top: auto;
}
.hud-name {
  font-family: 'Cinzel', serif;
  font-size: 15px;
  font-weight: 700;
  min-width: 72px;
}
.hud-name.enemy  { color: #c05040; }
.hud-name.player { color: #3888c0; }

.hud-bars { flex: 1; display: flex; flex-direction: column; gap: 5px; }
.player-bars { flex-direction: column; gap: 5px; }

.bar-wrap { display: flex; align-items: center; gap: 8px; }
.bar-wrap.small { margin-top: 2px; }
.bar-tag { font-family: 'Lora', serif; font-size: 11px; color: #4a2010; min-width: 38px; }

.bar-track {
  flex: 1;
  height: 14px;
  background: #060202;
  border-radius: 7px;
  overflow: hidden;
  max-width: 280px;
}
.bar-track.thin { height: 8px; border-radius: 4px; }
.bar-track.w80  { max-width: 80px; }

.bar-fill {
  height: 100%;
  border-radius: inherit;
  transition: width .4s ease;
}
.bar-fill.red    { background: #b83030; width: 100%; }
.bar-fill.blue   { background: #2878b0; width: 100%; }
.bar-fill.orange { background: #b87020; }
.bar-fill.indigo { background: #4878e8; }
.bar-fill.purple { background: #6838a8; }
.bar-fill.danger { background: #e83020; }

.bar-label { font-family: 'Lora', serif; font-size: 14px; min-width: 60px; }
.bar-label.red  { color: #a04040; }
.bar-label.blue { color: #3888c0; }

/* ── STAT ROW (Energy / Stress / Empathy) ── */
.stat-row { display: flex; gap: 20px; align-items: center; }
.stat-item { display: flex; align-items: center; gap: 6px; }
.stat-lbl { font-family: 'Lora', serif; font-size: 11px; color: #404050; min-width: 52px; }
.stat-val { font-family: 'Cinzel', serif; font-size: 15px; font-weight: 700; min-width: 24px; }
.stat-val.indigo { color: #6888f0; }
.stat-val.orange { color: #b87020; }
.stat-val.purple { color: #8858c8; }
.stat-val.danger { color: #e83020; }

/* ── PILE AREA ── */
#enemy-pile-area, #player-pile-area {
  display: flex; flex-direction: column; gap: 6px;
  min-width: 70px;
}
.pile {
  position: relative;
  width: 58px; height: 80px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.pile-stack {
  position: absolute; inset: 0;
  background: #102030;
  border: 1px solid #204860;
  border-radius: 5px;
  box-shadow: 2px -2px 0 0 #0d1a28, 4px -4px 0 0 #091218;
}
.pile.empty .pile-stack { background: transparent; border: 1px dashed #1e1c12; box-shadow: none; }
.pile-num {
  position: relative;
  font-family: 'Cinzel', serif;
  font-size: 18px; font-weight: 700;
  color: #1e4060;
  text-shadow: 0 1px 3px #000;
  z-index: 1;
}
.pile.empty .pile-num { color: #1a1810; }
.pile-lbl {
  position: relative;
  font-family: 'Cinzel', serif;
  font-size: 8px;
  letter-spacing: 2px;
  color: #0e2030;
  z-index: 1;
}
.pile.empty .pile-lbl { color: #141210; }

/* ── FIELD ROWS ── */
#enemy-field-row, #player-field-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  padding: 4px 0;
  flex: 1;
}
.field-slot {
  width: 112px;
  min-height: 144px;
  border: 1px dashed rgba(255,255,255,0.06);
  border-radius: 7px;
  position: relative;
  display: flex; align-items: center; justify-content: center;
}
#enemy-field-row .field-slot { border-color: rgba(180,80,40,0.12); }
#player-field-row .field-slot { border-color: rgba(40,100,180,0.12); }

/* ── ENEMY HAND ROW ── */
#enemy-hand-row {
  display: flex;
  gap: 6px;
  justify-content: center;
  padding: 2px 0;
}
.face-down {
  width: 34px; height: 50px;
  background: #0c1826;
  border: 1px solid #1e3050;
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}
.face-down::after {
  content: '';
  position: absolute; inset: 4px;
  border: 1px solid #1a2840;
  border-radius: 2px;
  background: repeating-linear-gradient(
    45deg, transparent, transparent 3px,
    rgba(26,40,64,0.3) 3px, rgba(26,40,64,0.3) 4px
  );
}

/* ── PLAYER HAND ── */
#player-hand-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  padding: 4px 0;
  flex: 1;
  align-items: flex-end;
}

/* ── CARDS ── */
.card {
  width: 130px;
  height: 182px;
  border-radius: 10px;
  border: 1.5px solid #2a2418;
  position: relative;
  cursor: pointer;
  transition: transform .13s ease, box-shadow .13s ease, border-color .13s;
  flex-shrink: 0;
  overflow: hidden;
  user-select: none;
}
.card:hover {
  transform: translateY(-24px) scale(1.04);
  box-shadow: 0 16px 40px rgba(0,0,0,.8);
  border-color: #504030;
  z-index: 10;
}
.card.selected {
  border: 2.5px solid #e2c040;
  transform: translateY(-32px) scale(1.05);
  box-shadow: 0 20px 50px rgba(0,0,0,.9), 0 0 20px rgba(226,192,64,.25);
  z-index: 20;
}

/* Card art zone */
.card-art {
  height: 64px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.3);
  border-radius: 8px 8px 0 0;
  overflow: hidden;
}
.card-art-icon {
  font-size: 26px;
  opacity: .7;
}

/* Card name */
.card-name {
  font-family: 'Cinzel', serif;
  font-size: 13px;
  font-weight: 700;
  color: #f0e4c8;
  text-align: center;
  padding: 6px 6px 2px;
  line-height: 1.3;
  text-shadow: 0 1px 3px rgba(0,0,0,.9);
}

/* Gold divider */
.card-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(220,185,60,.3), transparent);
  margin: 0 8px;
}

/* Card description */
.card-desc {
  font-family: 'Lora', serif;
  font-size: 12px;
  font-style: italic;
  color: #d0c0a0;
  text-align: center;
  padding: 4px 7px;
  line-height: 1.45;
  text-shadow: 0 1px 2px rgba(0,0,0,.8);
}

/* Effect pills */
.card-pills {
  position: absolute;
  bottom: 24px;
  left: 0; right: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  justify-content: center;
  padding: 0 4px;
}
.pill {
  font-family: 'Lora', serif;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 3px;
  background: rgba(0,0,0,.5);
  white-space: nowrap;
}

/* Cost badge */
.card-cost {
  position: absolute;
  top: 7px; left: 7px;
  width: 30px; height: 30px;
  background: rgba(0,0,0,.9);
  border: 2px solid #4068e0;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Cinzel', serif;
  font-size: 14px; font-weight: 700;
  color: #6888f0;
  text-shadow: 0 1px 3px rgba(0,0,0,.9);
  z-index: 2;
}

/* Rarity gem */
.card-rarity {
  position: absolute;
  top: 8px; right: 8px;
  width: 10px; height: 10px;
  border-radius: 50%;
  z-index: 2;
}
.rarity-common   { background: #4a5668; }
.rarity-uncommon { background: #286848; }
.rarity-rare     { background: #906020; }
.rarity-epic     { background: #602898; }

/* Minion ATK/HP */
.card-atk, .card-hp {
  position: absolute;
  bottom: 4px;
  width: 28px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 5px;
  font-family: 'Cinzel', serif;
  font-size: 13px; font-weight: 700;
  text-shadow: 0 1px 3px rgba(0,0,0,.9);
  z-index: 2;
}
.card-atk { left: 4px;  background: rgba(136,24,24,.95); color: #f8a060; }
.card-hp  { right: 4px; background: rgba(24,96,48,.95);  color: #70e890; }

/* ── FIELD MINION CARDS ── */
.field-card {
  width: 108px;
  height: 140px;
  border-radius: 8px;
  border: 1.5px solid #2a2418;
  position: absolute;
  inset: 0;
  margin: auto;
  overflow: hidden;
  user-select: none;
  cursor: pointer;
  transition: transform .1s, box-shadow .1s;
}
.field-card:hover { transform: scale(1.05); box-shadow: 0 8px 24px rgba(0,0,0,.7); }
.field-card.exhausted { opacity: .5; cursor: default; }
.field-card.ready { border-color: #4080d0; box-shadow: 0 0 8px rgba(64,128,208,.3); }
.field-card.enemy-card { border-color: #380c0c; }
.field-card.atk-target:hover { border-color: #e04040 !important; box-shadow: 0 0 12px rgba(224,64,64,.5) !important; }

.field-art {
  height: 48px;
  background: rgba(0,0,0,.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; opacity: .7;
}
.field-name {
  font-family: 'Cinzel', serif;
  font-size: 12px; font-weight: 700;
  color: #d8ecff;
  text-align: center;
  padding: 4px 4px 2px;
  line-height: 1.25;
  text-shadow: 0 1px 3px rgba(0,0,0,.9);
}
.field-desc {
  font-family: 'Lora', serif;
  font-size: 10px; font-style: italic;
  color: #8090a0;
  text-align: center;
  padding: 0 4px;
  line-height: 1.3;
}
.field-atk, .field-hp {
  position: absolute; bottom: 4px;
  width: 24px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px;
  font-family: 'Cinzel', serif; font-size: 12px; font-weight: 700;
  text-shadow: 0 1px 2px rgba(0,0,0,.9); z-index: 2;
}
.field-atk { left: 3px;  background: rgba(136,24,24,.95); color: #f8a060; }
.field-hp  { right: 3px; background: rgba(24,96,48,.95);  color: #70e890; }

/* ── TOOLTIP ── */
#tooltip {
  position: fixed;
  background: #0e0c08;
  border: 1px solid rgba(220,185,60,.5);
  border-radius: 10px;
  padding: 13px 15px;
  width: 215px;
  pointer-events: none;
  z-index: 999;
  box-shadow: 0 8px 32px rgba(0,0,0,.95);
  transition: opacity .12s;
}
#tooltip.hidden { display: none; }
#tt-name { font-family: 'Cinzel', serif; font-size: 14px; font-weight: 700; color: #e2c460; margin-bottom: 5px; }
#tt-cost { font-family: 'Lora', serif; font-size: 11px; color: #607090; margin-bottom: 5px; }
#tt-desc { font-family: 'Lora', serif; font-size: 12px; font-style: italic; color: #9a8c70; line-height: 1.5; }
#tt-fx   { font-family: 'Lora', serif; font-size: 11px; color: #5a7060; margin-top: 8px; padding-top: 7px; border-top: 1px solid rgba(255,255,255,.07); white-space: pre-line; line-height: 1.6; }

/* ── ATTACK BANNER ── */
#atk-banner {
  position: fixed;
  bottom: 28%;
  left: 50%; transform: translateX(-50%);
  background: rgba(10,8,4,.9);
  border: 1px solid rgba(200,160,30,.4);
  border-radius: 8px;
  padding: 7px 22px;
  font-family: 'Cinzel', serif;
  font-size: 12px; color: #c8a828;
  letter-spacing: 1px;
  pointer-events: none;
  white-space: nowrap;
  z-index: 998;
}
#atk-banner.hidden { display: none; }

/* ── FLOATING TEXT ── */
#floats { position: fixed; inset: 0; pointer-events: none; z-index: 900; overflow: hidden; }
.float-txt {
  position: absolute;
  font-family: 'Cinzel', serif;
  font-size: 22px; font-weight: 700;
  text-shadow: 0 2px 6px rgba(0,0,0,.9);
  animation: floatUp 1.1s ease-out forwards;
  white-space: nowrap;
}
@keyframes floatUp {
  0%   { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-72px); }
}

/* ── BURNOUT OVERLAY ── */
#burnout-msg {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; z-index: 950;
}
.burnout-inner {
  font-family: 'Cinzel', serif;
  font-size: 40px; font-weight: 700;
  color: #e03818;
  text-shadow: 0 0 40px rgba(224,56,24,.6), 0 2px 8px rgba(0,0,0,.9);
  letter-spacing: 4px;
  animation: burnoutFlash 2.8s ease-out forwards;
}
@keyframes burnoutFlash {
  0%   { opacity: 1; transform: scale(1.1); }
  40%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.9); }
}

/* ── SCREEN FLASH ── */
.screen-flash {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 940;
  animation: fadeFlash .4s ease-out forwards;
}
@keyframes fadeFlash {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

/* ── END SCREEN ── */
#end-screen {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.85);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 1000;
  gap: 16px;
}
#end-screen.hidden { display: none; }
#end-title { font-family: 'Cinzel', serif; font-size: 58px; font-weight: 700; text-shadow: 0 2px 20px rgba(0,0,0,.9); }
#end-title.win  { color: #50d888; }
#end-title.loss { color: #d84040; }
#end-sub { font-family: 'Lora', serif; font-size: 17px; font-style: italic; color: #907858; }
#btn-restart {
  padding: 12px 32px;
  background: #0c2016; border: 2px solid #286840; border-radius: 10px;
  color: #40b868; font-family: 'Cinzel', serif; font-size: 15px; font-weight: 700;
  cursor: pointer; transition: .15s; margin-top: 8px;
}
#btn-restart:hover { background: #163a24; border-color: #50c878; color: #80e898; }

/* ── PHASER FX CANVAS ── */
#fx-canvas {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 800;
}

/* ── SELECTION HINT ── */
#play-hint {
  text-align: center;
  font-family: 'Lora', serif;
  font-size: 12px; font-style: italic;
  color: #c8a030;
  height: 18px;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════
   CARD PLAY ANIMATIONS
═══════════════════════════════════════════ */

/* Card flies up to field when played */
@keyframes cardPlay {
  0%   { transform: translateY(0) scale(1); opacity: 1; }
  40%  { transform: translateY(-60px) scale(1.15); opacity: 1; }
  100% { transform: translateY(-200px) scale(0.7); opacity: 0; }
}
.card-playing { animation: cardPlay 0.45s ease-out forwards; pointer-events:none; z-index:50; }

/* ── DAMAGE SHAKE on hero portrait ── */
@keyframes shakeRed {
  0%,100% { transform: translateX(0); filter: brightness(1); }
  15%  { transform: translateX(-8px); filter: brightness(1.8) saturate(3); }
  30%  { transform: translateX(8px);  filter: brightness(1.6) saturate(2) hue-rotate(-20deg); }
  45%  { transform: translateX(-5px); filter: brightness(1.4); }
  60%  { transform: translateX(5px);  filter: brightness(1.2); }
  75%  { transform: translateX(-2px); }
}
.hero-portrait.taking-damage { animation: shakeRed 0.45s ease-out; }

/* ── HP ORB PULSE when damaged ── */
@keyframes orbPulse {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.4); box-shadow: 0 0 20px currentColor; }
  100% { transform: scale(1); }
}
.hero-hp.damaged { animation: orbPulse 0.4s ease-out; }

/* ── HP BAR FLASH ── */
@keyframes barFlash {
  0%,100% { filter: brightness(1); }
  40%     { filter: brightness(2.5) saturate(2); }
}
.hp-fill.flashing { animation: barFlash 0.4s ease-out; }

/* ── LIGHTNING BOLT (Defibrillator) ── */
.fx-lightning {
  position: fixed;
  pointer-events: none;
  z-index: 950;
}
.lightning-bolt {
  position: absolute;
  width: 4px;
  background: linear-gradient(180deg, #ffffff, #a0c8ff, #4060ff);
  border-radius: 2px;
  box-shadow: 0 0 8px #80b0ff, 0 0 20px #4060ff, 0 0 40px #2040e0;
  transform-origin: top center;
  animation: lightningStrike 0.5s ease-out forwards;
}
.lightning-branch {
  position: absolute;
  width: 2px;
  background: linear-gradient(180deg, #a0c8ff, transparent);
  border-radius: 1px;
  box-shadow: 0 0 6px #80b0ff;
  transform-origin: top center;
  animation: lightningStrike 0.4s ease-out forwards;
}
@keyframes lightningStrike {
  0%   { opacity: 1; transform: scaleY(0) rotate(var(--rot,0deg)); }
  20%  { opacity: 1; transform: scaleY(1) rotate(var(--rot,0deg)); }
  60%  { opacity: 1; }
  100% { opacity: 0; transform: scaleY(1) rotate(var(--rot,0deg)); }
}

/* ── IMPACT FLASH (big hit) ── */
.fx-impact {
  position: fixed;
  width: 80px; height: 80px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 949;
  transform: translate(-50%, -50%);
  animation: impactBurst 0.5s ease-out forwards;
}
@keyframes impactBurst {
  0%   { transform: translate(-50%,-50%) scale(0); opacity: 1; }
  40%  { transform: translate(-50%,-50%) scale(1.5); opacity: 0.8; }
  100% { transform: translate(-50%,-50%) scale(3); opacity: 0; }
}

/* ── HEAL GREEN PULSE ── */
.fx-heal {
  position: fixed;
  pointer-events: none;
  z-index: 949;
  transform: translate(-50%, -50%);
  animation: healPulse 0.8s ease-out forwards;
}
.heal-ring {
  position: absolute;
  border-radius: 50%;
  border: 3px solid #40e070;
  box-shadow: 0 0 16px #40e070, inset 0 0 16px rgba(64,224,112,.2);
  transform: translate(-50%, -50%);
  animation: healExpand 0.8s ease-out forwards;
}
@keyframes healExpand {
  0%   { width: 20px; height: 20px; opacity: 1; }
  100% { width: 120px; height: 120px; opacity: 0; }
}

/* ── STRESS SMOKE ── */
.fx-stress-particle {
  position: fixed;
  font-size: 20px;
  pointer-events: none;
  z-index: 949;
  animation: stressDrift 1.2s ease-out forwards;
  filter: blur(0px);
}
@keyframes stressDrift {
  0%   { opacity: 1; transform: translate(0, 0) rotate(0deg) scale(1); }
  100% { opacity: 0; transform: translate(var(--dx,20px), -80px) rotate(var(--rot,30deg)) scale(0.5); filter: blur(4px); }
}

/* ── SHIELD BLOCK ── */
.fx-shield {
  position: fixed;
  pointer-events: none;
  z-index: 949;
  transform: translate(-50%, -50%);
  font-size: 48px;
  animation: shieldBlock 0.6s ease-out forwards;
  text-shadow: 0 0 20px rgba(80,160,255,.8);
}
@keyframes shieldBlock {
  0%   { opacity: 0; transform: translate(-50%,-50%) scale(0.5); }
  30%  { opacity: 1; transform: translate(-50%,-50%) scale(1.3); }
  70%  { opacity: 1; transform: translate(-50%,-50%) scale(1.0); }
  100% { opacity: 0; transform: translate(-50%,-50%) scale(0.8); }
}

/* ── FIELD CARD ATTACK LUNGE ── */
@keyframes minionLunge {
  0%   { transform: translateY(0) scale(1); }
  35%  { transform: translateY(-28px) scale(1.12); }
  65%  { transform: translateY(-8px) scale(1.05); }
  100% { transform: translateY(0) scale(1); }
}
.field-card.lunging { animation: minionLunge 0.5s ease-out; }

/* ── CARD GLOW on hover by type ── */
.card[data-id="defibrillator"]:hover { box-shadow: 0 18px 44px rgba(0,0,0,.85), 0 0 24px rgba(80,120,255,.5) !important; }
.card[data-id="zusammenbruch"]:hover { box-shadow: 0 18px 44px rgba(0,0,0,.85), 0 0 24px rgba(220,80,20,.5) !important; }
.card[data-id="adrenalin"]:hover     { box-shadow: 0 18px 44px rgba(0,0,0,.85), 0 0 24px rgba(255,200,40,.4) !important; }
.card[data-id="pause"]:hover         { box-shadow: 0 18px 44px rgba(0,0,0,.85), 0 0 24px rgba(60,180,80,.4) !important; }
.card[data-id="espresso"]:hover      { box-shadow: 0 18px 44px rgba(0,0,0,.85), 0 0 24px rgba(180,120,40,.4) !important; }
