/* === LFTM combat styles v19 — full viewport + juice === */




/* ── FULL VIEWPORT OVERLAY ── */
#combat-overlay {
  position: fixed;
  inset: 0;
  width: 95vw; height: 90vh;
  max-width: 900px; max-height: 900px;
  margin: auto;
  background: #0a0a0f;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  font-family: 'Share Tech Mono', monospace;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  border: 3px solid var(--cyan, #5af0ff);
  border-radius: 4px;
  box-shadow:
    0 0 14px var(--cyan, #5af0ff),
    0 0 36px rgba(90, 240, 255, 0.65),
    0 0 80px rgba(90, 240, 255, 0.35),
    0 0 0 100vmax rgba(0, 0, 0, 0.88),
    inset 0 0 24px rgba(90, 240, 255, 0.04);
}

/* ── INTRO TRANSITION ── */
#combat-overlay.entering {
  clip-path: inset(0 50% 0 50%);
  animation: battle-slice .8s cubic-bezier(.22,1,.36,1) forwards;
}
#combat-overlay.entering > * { opacity: 0; }
#combat-overlay.entered > * {
  animation: content-arrive .4s ease-out forwards;
}
@keyframes battle-slice {
  0%   { clip-path: inset(0 50% 0 50%); }
  100% { clip-path: inset(0 0 0 0); }
}
@keyframes content-arrive {
  0%   { opacity: 0; }
  100% { opacity: 1; }
}
#combat-overlay.entering::before {
  content: '';
  position: fixed;
  top: 0; bottom: 0; left: 50%;
  width: 2px; margin-left: -1px;
  background: #fff;
  box-shadow: 0 0 30px #fff, 0 0 80px rgba(255,255,255,.5);
  z-index: 10000;
  animation: flash-line .7s ease-out forwards;
}
@keyframes flash-line {
  0%   { opacity: 1; transform: scaleY(0); }
  25%  { opacity: 1; transform: scaleY(1); }
  100% { opacity: 0; transform: scaleY(1); }
}

/* ── FLASHES ── */
#combat-overlay.flash-gold {
  animation: ov-gold .5s ease-out;
}
#combat-overlay.flash-red {
  animation: ov-red .5s ease-out;
}
@keyframes ov-gold {
  0%, 100% { box-shadow: none; }
  40% { box-shadow: inset 0 0 120px rgba(255,200,80,.3); }
}
@keyframes ov-red {
  0%, 100% { box-shadow: none; }
  40% { box-shadow: inset 0 0 120px rgba(255,50,50,.2); }
}

/* ── SCENE (top portion) ── */
#combat-scene {
  position: relative;
  width: 100%;
  flex: 1 1 50%;
  min-height: 0;
  background: #000;
  background-image: var(--bg, none);
  background-size: cover;
  background-position: bottom center;
  overflow: hidden;
}
#combat-scene::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 80px;
  background: linear-gradient(to bottom, transparent, #0a0a0f);
  z-index: 3;
  pointer-events: none;
}

/* ── SPRITE ── */
.enemy-sprite {
  position: absolute;
  bottom: 24px;
  left: 50%;
  width: 40%;
  height: 55%;
  max-width: 360px;
  max-height: 320px;
  object-fit: contain;
  object-position: bottom center;
  transform: translateX(-50%);
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  z-index: 2;
  filter: drop-shadow(0 6px 20px rgba(0,0,0,.9));
}
.enemy-sprite.idle { animation: idle-bob 2.2s ease-in-out infinite, idle-glow 5.3s ease-in-out infinite; }
@keyframes idle-bob {
  0%, 100% { transform: translateX(-50%) translateY(0) scale(1); }
  50%      { transform: translateX(-50%) translateY(-4px) scale(1.012); }
}
.enemy-sprite.attacking { animation: none; }
.enemy-sprite.flash-hit { animation: hitflash .3s steps(2, end), idle-bob 2.2s ease-in-out infinite .3s; }
@keyframes hitflash {
  0%, 100% { filter: drop-shadow(0 6px 20px rgba(0,0,0,.9)); }
  50% { filter: brightness(4) saturate(0) drop-shadow(0 6px 20px rgba(255,255,255,.8)); }
}
.enemy-sprite.flash-perfect { animation: lunge-back .5s ease-out; }
@keyframes lunge-back {
  0%   { transform: translateX(-50%) translateY(0) scale(1); }
  25%  { transform: translateX(calc(-50% + 18px)) translateY(-12px) scale(1.06); }
  100% { transform: translateX(-50%) translateY(0) scale(1); }
}
.enemy-sprite.dodge { animation: dodge-lean .4s ease-out; }
@keyframes dodge-lean {
  0%   { transform: translateX(-50%) rotate(0); }
  35%  { transform: translateX(calc(-50% - 16px)) rotate(-10deg); }
  100% { transform: translateX(-50%) rotate(0); }
}

.slash-mark {
  position: absolute;
  top: 35%; left: 50%;
  transform: translateX(-50%) rotate(-25deg);
  width: 100px; height: 3px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.9), transparent);
  z-index: 4;
  animation: slash-fade .5s ease-out forwards;
  pointer-events: none;
}
@keyframes slash-fade {
  0%   { opacity: 1; transform: translateX(-50%) rotate(-25deg) scaleX(0); }
  25%  { opacity: 1; transform: translateX(-50%) rotate(-25deg) scaleX(1); }
  100% { opacity: 0; transform: translateX(-50%) rotate(-25deg) scaleX(1.3); }
}

#damage-numbers { position: absolute; inset: 0; pointer-events: none; z-index: 5; }

/* ── NAMEPLATE ── */
#combat-nameplate {
  position: relative;
  z-index: 4;
  margin-top: -55px;
  padding: 10px 20px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.np-left {
  display: flex;
  gap: 12px;
  align-items: baseline;
}
.np-name {
  font-family: 'Josefin Sans', sans-serif;
  font-size: 18px;
  color: #fff;
  letter-spacing: 3px;
  text-shadow: 0 0 12px rgba(255,90,90,.6), 0 2px 4px #000;
}
.np-flavor {
  font-size: 11px;
  color: rgba(255,255,255,.4);
  font-style: italic;
}

/* ── ENEMY HP ── */
#enemy-hp-wrap {
  width: 35%;
  max-width: 200px;
  flex-shrink: 0;
}

/* ── HP BARS ── */
.hp-bar {
  position: relative;
  width: 100%;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}
.enemy-hp {
  aspect-ratio: 715 / 147;
  background-image: url('sprites/enemy-life-frame.webp');
}
#player-hp {
  flex: 0 0 auto;
  width: 180px;
  height: 28px;
  aspect-ratio: auto;
  background-image: url('sprites/player-life-frame.webp');
  background-size: 100% 100%;
  background-repeat: no-repeat;
}
.hp-bar .hp-fill {
  position: absolute;
  transition: width .5s cubic-bezier(.4,0,.2,1);
}
.enemy-hp .hp-fill {
  position: absolute;
  top: 17%; bottom: 14.3%; left: 4.2%;
  width: calc(92.7% * var(--hp-pct, 1));
  max-width: 92.7%;
  background: linear-gradient(180deg,
    rgba(255,90,90,.5) 0%,
    rgba(255,50,50,.95) 50%,
    rgba(255,90,90,.5) 100%);
  box-shadow: 0 0 8px rgba(255,50,50,.5), inset 0 0 4px rgba(255,200,200,.25);
}
#player-hp .hp-fill {
  position: absolute;
  top: 20%; bottom: 17%;
  left: 3.8%; right: 4%;
  max-width: 92.2%;
  background: linear-gradient(180deg,
    rgba(140,250,255,.55) 0%,
    rgba(90,240,255,.95) 50%,
    rgba(140,250,255,.55) 100%);
  box-shadow: 0 0 8px rgba(90,240,255,.5), inset 0 0 4px rgba(200,250,255,.3);
  transform-origin: left center;
  transition: width .5s cubic-bezier(.4,0,.2,1);
}
.hp-bar .hp-text {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-family: 'Josefin Sans', sans-serif;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 4px #000, 0 0 8px rgba(0,0,0,.8);
  letter-spacing: 2px;
  z-index: 2;
  pointer-events: none;
}

/* ── BOTTOM PANEL ── */
#combat-panel {
  flex: 0 0 auto;
  position: relative;
  min-height: 220px;
  max-height: 320px;
  background:
    linear-gradient(to bottom, rgba(10,10,15,0.88) 0%, rgba(10,10,15,0.72) 100%),
    url('sprites/panel-texture.webp') center/cover;
  border-top: 1px solid rgba(90, 240, 255, 0.15);
}

#combat-panel-inner {
  display: flex;
  align-items: stretch;
  padding: 12px 20px 16px;
  gap: 16px;
  height: 100%;
}

/* ── PLAYER CARD (left) ── */
#player-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  position: relative;
  padding: 8px 16px;
  background: transparent;
  border: none;
  border-radius: 0;
}
#player-card.shake { animation: shake .4s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}
.pc-name {
  font-family: 'Josefin Sans', sans-serif;
  font-size: 14px;
  color: var(--cyan, #5af0ff);
  letter-spacing: 2px;
}
.pc-level {
  font-size: 10px;
  color: rgba(255,255,255,.3);
  letter-spacing: 2px;
  margin-top: -4px;
}
.pc-hp-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pc-hp-label {
  font-size: 9px;
  color: rgba(255,255,255,.35);
  letter-spacing: 2px;
  flex-shrink: 0;
}
.pc-hp-row .hp-bar { flex: 1; }
.pc-sp-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pc-sp-label {
  font-size: 9px;
  color: rgba(255,255,255,.35);
  letter-spacing: 2px;
  flex-shrink: 0;
}
#player-sp {
  position: relative;
  flex: 0 0 auto;
  width: 180px;
  height: 16px;
  border: 1px solid rgba(180,130,255,.45);
  border-radius: 8px;
  background: rgba(38,28,58,.55);
  overflow: hidden;
}
.sp-bar .sp-fill {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 100%;
  background: linear-gradient(180deg,
    rgba(205,165,255,.85) 0%,
    rgba(150,90,255,.95) 50%,
    rgba(205,165,255,.85) 100%);
  box-shadow: 0 0 8px rgba(150,90,255,.5), inset 0 0 4px rgba(220,200,255,.3);
  transition: width .4s cubic-bezier(.4,0,.2,1);
}
.sp-bar .sp-text {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px;
  font-family: 'Josefin Sans', sans-serif;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 4px #000, 0 0 8px rgba(0,0,0,.8);
  letter-spacing: 1.5px;
  z-index: 2;
  pointer-events: none;
}
#player-damage-numbers {
  position: absolute; inset: 0;
  pointer-events: none; z-index: 5;
}

/* ── STREAK PIPS ── */
#streak-pips { display: flex; gap: 5px; margin-top: 2px; }
.streak-pip {
  width: 7px; height: 7px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 50%;
  background: transparent;
  transition: all .15s;
}
.streak-pip.lit {
  background: #ffc850;
  border-color: #ffc850;
  box-shadow: 0 0 6px #ffc850;
}

/* ── COMMAND GRID (right) ── */
#combat-commands {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: 1fr 1fr;
  gap: 8px;
  width: 320px;
  flex-shrink: 0;
  align-self: center;
}
#combat-commands button {
  background: url('sprites/button.webp') center/100% 100% no-repeat, transparent;
  border: none;
  color: rgba(255,255,255,.9);
  font-family: 'Josefin Sans', sans-serif;
  font-size: 13px;
  letter-spacing: 3px;
  padding: 22px 4px 26px;
  cursor: pointer;
  transition: filter .15s, transform .1s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  text-shadow: 0 0 8px rgba(0,0,0,.95), 0 2px 4px rgba(0,0,0,.8);
  position: relative;
}
#combat-commands button:hover:not(:disabled) {
  filter: brightness(1.25);
  transform: translateY(-1px);
}
#combat-commands button:disabled {
  filter: grayscale(.8) brightness(.5);
  cursor: not-allowed;
}
#combat-commands button[data-cmd="attack"] { /* keep native pink underglow */ }
#combat-commands button[data-cmd="attack"]:hover:not(:disabled) { filter: brightness(1.35) saturate(1.2); }
#combat-commands button[data-cmd="talk"] { filter: hue-rotate(160deg); }
#combat-commands button[data-cmd="talk"]:hover:not(:disabled) { filter: hue-rotate(160deg) brightness(1.35); }
#combat-commands button[data-cmd="flee"] { filter: grayscale(.7) brightness(.75); color: rgba(255,255,255,.5); }

/* ── ACTION AREA (overlays panel when active) ── */
#combat-action-area {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 20px;
  background: rgba(10,10,15,.85);
}

/* ── TALK BUBBLE ── */
#talk-bubble {
  text-align: center;
  animation: talk-appear .3s ease-out;
}
.talk-text {
  font-family: 'Josefin Sans', sans-serif;
  font-size: 15px;
  color: rgba(255,255,255,.7);
  letter-spacing: 1px;
  font-style: italic;
  line-height: 1.6;
  padding: 12px 24px;
  border-left: 2px solid rgba(255,255,255,.15);
}
@keyframes talk-appear {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── ATTACK BAR ── */
#attack-bar-container {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
#attack-bar-label {
  font-family: 'Josefin Sans', sans-serif;
  font-size: 13px;
  letter-spacing: 5px;
  font-weight: 700;
  color: rgba(255,255,255,.85);
  animation: pulselabel 1.2s infinite ease-in-out;
}
@keyframes pulselabel { 0%, 100% { opacity: 1; } 50% { opacity: .7; } }
#attack-bar {
  width: 100%;
  height: 32px;
  background: #060608;
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 2px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  touch-action: manipulation;
}
.attack-zone { position: absolute; top: 0; bottom: 0; }
.attack-zone.green {
  background: rgba(80,220,120,.18);
  border-left: 1px solid rgba(80,220,120,.25);
  border-right: 1px solid rgba(80,220,120,.25);
}
.attack-zone.perfect {
  background: rgba(212,169,72,.55);
  box-shadow: 0 0 12px rgba(255,200,80,.7), inset 0 0 12px rgba(255,240,180,.4);
  z-index: 2;
  animation: perfect-pulse 1.4s infinite ease-in-out;
}
@keyframes perfect-pulse {
  0%, 100% { box-shadow: 0 0 12px rgba(255,200,80,.7), inset 0 0 12px rgba(255,240,180,.4); }
  50% { box-shadow: 0 0 24px rgba(255,200,80,1), inset 0 0 20px rgba(255,240,180,.7); }
}
#attack-marker {
  position: absolute; top: -2px; bottom: -2px;
  width: 3px; background: #fff;
  box-shadow: 0 0 8px #fff, 0 0 16px rgba(255,255,255,.5);
  margin-left: -1.5px; z-index: 3; pointer-events: none;
}
#attack-bar.result-perfect { animation: barflash-gold .35s; }
#attack-bar.result-hit     { animation: barflash-green .35s; }
#attack-bar.result-miss    { animation: barflash-red .35s; }
@keyframes barflash-gold  { 0%, 100% { box-shadow: none; } 50% { box-shadow: 0 0 40px rgba(255,200,80,1); } }
@keyframes barflash-green { 0%, 100% { box-shadow: none; } 50% { box-shadow: 0 0 20px rgba(80,220,120,.8); } }
@keyframes barflash-red   { 0%, 100% { box-shadow: none; } 50% { box-shadow: 0 0 15px rgba(255,60,60,.5); } }

/* ── DEFENSE CIRCLE ── */
#defense-container { display: flex; flex-direction: column; align-items: center; gap: 12px; }
#defense-label {
  font-family: 'Josefin Sans', sans-serif;
  font-size: 13px; letter-spacing: 5px;
  font-weight: 700;
  color: rgba(255,90,90,1);
  text-shadow: 0 0 10px rgba(255,90,90,.6), 0 0 20px rgba(255,90,90,.3);
  animation: pulselabel 1.2s infinite ease-in-out;
}
#defense-circle {
  position: relative; width: 180px; height: 180px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; touch-action: manipulation;
}

#defense-inner {
  position: absolute; width: 100%; height: 100%;
  border: 2px solid rgba(255,90,90,.6); border-radius: 50%;
  box-shadow: 0 0 10px rgba(255,90,90,.3);
}


#defense-circle.warming #defense-inner { animation: defense-warmup .45s ease-in-out; }
@keyframes defense-warmup { 0%, 100% { border-color: rgba(255,90,90,.6); } 50% { border-color: #fff; box-shadow: 0 0 25px rgba(255,90,90,.8); } }





/* ── DAMAGE NUMBERS ── */
.dmg-num {
  position: absolute; left: 50%; top: 45%;
  transform: translate(-50%, -50%);
  font-family: 'Josefin Sans', sans-serif; font-weight: 700;
  pointer-events: none; opacity: 1;
  transition: transform var(--float-dur, 1000ms) ease-out, opacity var(--float-dur, 1000ms) ease-out;
}
.dmg-num.hit     { color: #fff; font-size: 32px; text-shadow: 0 0 10px rgba(255,255,255,.5), 0 2px 4px #000; }
.dmg-num.perfect { color: #ffc850; font-size: 40px; text-shadow: 0 0 16px rgba(255,200,80,.8), 0 2px 4px #000; }
.dmg-num.miss    { color: rgba(255,255,255,.3); font-size: 22px; }
.dmg-num.full    { color: #ff4444; font-size: 26px; text-shadow: 0 0 8px rgba(255,68,68,.5); }
.dmg-num.blocked { color: var(--cyan); font-size: 24px; text-shadow: 0 0 8px rgba(90,240,255,.5); }
.dmg-num.float { transform: translate(-50%, -220%); opacity: 0; }

/* ── INITIATIVE ── */
#combat-init {
  font-family: 'Josefin Sans', sans-serif;
  font-size: 22px; letter-spacing: 4px;
  text-align: center;
  animation: init-appear .35s ease-out;
}
#combat-init.init-player { color: var(--cyan, #5af0ff); text-shadow: 0 0 14px var(--cyan); }
#combat-init.init-enemy  { color: #ff5a5a; text-shadow: 0 0 14px #ff5a5a; }
@keyframes init-appear { from { opacity: 0; transform: scale(0.85); } to { opacity: 1; transform: scale(1); } }

/* ── POST-FIGHT RESULTS ── */
.res-heading { font-family: 'Josefin Sans', sans-serif; font-size: clamp(15px, 4.5vw, 20px); letter-spacing: 3px; line-height: 1.3; max-width: 92%; }
.res-victory .res-heading { color: #ffc850; text-shadow: 0 0 12px rgba(255,200,80,.6); }
.res-defeat .res-heading  { color: #ff5a5a; text-shadow: 0 0 12px rgba(255,90,90,.5); }
.res-subtitle { font-size: 12px; color: rgba(255,255,255,.35); font-style: italic; letter-spacing: 1px; }
.res-xp-row { display: flex; align-items: baseline; gap: 6px; font-family: 'Josefin Sans', sans-serif; }
.res-xp-label { font-size: 11px; color: rgba(255,255,255,.35); letter-spacing: 2px; }
.res-xp-value { font-size: 24px; letter-spacing: 1px; }
.res-victory .res-xp-value { color: #ffc850; text-shadow: 0 0 8px rgba(255,200,80,.5); }
.res-defeat  .res-xp-value { color: #ff5a5a; }
.res-xp-bar { width: 160px; height: 5px; background: rgba(255,255,255,.06); border-radius: 3px; overflow: hidden; }
.res-xp-fill { height: 100%; background: linear-gradient(90deg, #a07520, #ffc850); box-shadow: 0 0 6px rgba(255,200,80,.4); transition: width .6s cubic-bezier(.4,0,.2,1); border-radius: 3px; }
.res-level { font-family: 'Josefin Sans', sans-serif; font-size: 10px; color: rgba(255,255,255,.25); letter-spacing: 3px; }
#combat-continue {
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.12);
  color: rgba(255,255,255,.6); font-family: 'Josefin Sans', sans-serif;
  font-size: 12px; letter-spacing: 3px; padding: 10px 28px;
  cursor: pointer; border-radius: 2px; transition: all .15s;
  touch-action: manipulation; margin-top: 4px;
}
#combat-continue:hover { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.3); color: #fff; }

#combat-end { text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }
#combat-end .end-msg { font-family: 'Josefin Sans', sans-serif; font-size: 14px; letter-spacing: 2px; color: rgba(255,255,255,.4); }

/* ── MOBILE ── */
@media (max-width: 600px) {
  #combat-panel-inner {
    flex-direction: column;
    padding: 8px 14px 12px;
    gap: 8px;
  }
  #player-card {
    padding: 4px 8px;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
  }
  .pc-name { font-size: 13px; }
  .pc-level { margin-top: 0; }
  #player-hp { width: 140px; height: 24px; }
  #player-sp { width: 140px; height: 14px; }
  #combat-commands {
    width: 100%;
    grid-template-columns: repeat(3, 1fr);
  }
  #combat-commands button { padding: 14px 4px 18px; font-size: 11px; }
  .np-name { font-size: 15px; }
  .dmg-num.hit { font-size: 26px; }
  .dmg-num.perfect { font-size: 32px; }
  #combat-scene {
    flex: 1 1 45%;
    /* match desktop: fill the frame, preserve aspect, anchor to the ground —
       instead of the old 180% zoom that over-cropped portrait backgrounds. */
    background-size: cover;
    background-position: center bottom;
    background-repeat: no-repeat;
    background-color: #0a0a0f;
  }
  .enemy-sprite {
    width: 60%;
    max-width: none;
    max-height: none;
  }
  #combat-nameplate {
    margin-top: 0;
    background:
      linear-gradient(to bottom, rgba(10,10,15,0.92) 0%, rgba(10,10,15,0.85) 100%),
      url('sprites/panel-texture.webp') center/cover;
    border-top: 1px solid rgba(90, 240, 255, 0.15);
    border-bottom: 1px solid rgba(90, 240, 255, 0.08);
    padding: 8px 14px;
  }
  .np-left { flex-direction: column; gap: 2px; }
  #enemy-hp-wrap { width: 45%; max-width: 160px; }
  .np-flavor { font-size: 10px; }
}


/* ── ITEM button (amber tint) ── */
#combat-commands button[data-cmd="item"] { filter: hue-rotate(80deg) saturate(.9); }
#combat-commands button[data-cmd="item"]:hover:not(:disabled) { filter: hue-rotate(80deg) saturate(.9) brightness(1.35); }


/* ── DEFENSE TARGET (three-zone redesign) ── */
#combat-action-area {
  background: url('sprites/panel-texture.webp') center/cover, rgba(10,10,15,0.92);
  border-top: 1px solid rgba(90, 240, 255, 0.18);
}

#defense-circle {
  position: relative;
  width: 180px;
  height: 180px;
}
#defense-target {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  user-select: none; pointer-events: none;
}
#defense-inner {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  border: 2px solid #fff;
  border-radius: 50%;
  background: transparent !important;
  box-shadow: 0 0 14px rgba(255,255,255,.9), inset 0 0 6px rgba(255,255,255,.45);
  pointer-events: none;
}
#defense-circle.warming #defense-inner {
  border-color: rgba(255,255,255,.4);
  box-shadow: 0 0 6px rgba(255,255,255,.3);
}
#defense-circle.block-perfect { animation: defzone-cyan .5s ease-out; }
#defense-circle.block-good    { animation: defzone-amber .5s ease-out; }
#defense-circle.block-fail    { animation: defzone-red .5s ease-out; }
#defense-circle.block-no-block { animation: defzone-red .5s ease-out; }
@keyframes defzone-cyan  { 0% { filter: brightness(1.8) drop-shadow(0 0 30px #5af0ff); } 100% { filter: none; } }
@keyframes defzone-amber { 0% { filter: brightness(1.6) drop-shadow(0 0 22px #ffaa22); } 100% { filter: none; } }
@keyframes defzone-red   { 0% { filter: brightness(1.5) drop-shadow(0 0 22px #ff3333); } 100% { filter: none; } }
.dmg-num.block-perfect { color:#5af0ff; text-shadow:0 0 10px rgba(90,240,255,.95), 0 0 22px rgba(90,240,255,.5); font-size:30px; font-weight:700; }
.dmg-num.block-good    { color:#ffaa22; text-shadow:0 0 8px rgba(255,170,34,.85); font-size:24px; font-weight:700; }
.dmg-num.block-fail    { color:#ff5555; text-shadow:0 0 10px rgba(255,68,68,.95); font-size:26px; font-weight:700; }


/* === ATTACK BAR (MJ asset + dynamic zones + neon marker) === */
#attack-bar {
  position: relative !important;
  width: 90%;
  max-width: 640px;
  aspect-ratio: 1452 / 380;
  height: auto !important;
  background: url('sprites/attack-bar.webp') center/100% 100% no-repeat !important;
  margin: 0 auto;
  border: none !important;
}


#attack-marker {
  position: absolute !important;
  top: 8% !important; bottom: 8% !important;
  width: 5px !important;
  margin-left: -2.5px;
  background: #fff !important;
  border-radius: 1px;
  box-shadow:
    0 0 10px #fff,
    0 0 22px rgba(255,90,220,.95),
    0 0 38px rgba(255,60,180,.7),
    inset 0 0 4px rgba(255,200,240,.8) !important;
  pointer-events: none; border: none !important;
}
#attack-bar-label {
  font-family: 'Josefin Sans', sans-serif !important;
  letter-spacing: 6px;
  color: #fff;
  text-shadow: 0 0 8px rgba(255,255,255,.8), 0 0 16px rgba(90,240,255,.5);
  margin-bottom: 14px;
}


/* === Hide attack zone overlays — MJ asset alone provides the visual === */

#attack-marker {
  z-index: 10 !important;
}


/* === ATTACK BAR — kill ALL inner divs except marker (catches whatever zones JS creates) === */
#attack-bar > div:not(#attack-marker) { display: none !important; }
#attack-bar > div#attack-marker { display: block !important; }

/* === DEFENSE TARGET — fit inside action area === */
#defense-container {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  height: 100% !important;
  padding: 4px 12px !important;
  gap: 6px;
}
/* Circle takes ALL the panel's height minus a fixed reserve for the label +
   HP-row + gaps (~68px), so it grows to fill whatever room the panel has and
   still can't shear off BLOCK. Cap is generous; floor keeps it tappable. */
#defense-circle {
  position: relative !important;
  width: auto !important;
  height: calc(100% - 10px) !important;
  aspect-ratio: 1 !important;
  max-height: 280px !important;
  min-height: 110px !important;
  max-width: 92% !important;
}

/* === FEEDBACK — big result text above the target === */







/* === FEEDBACK — loud ring flash on the SVG itself === */
#defense-circle.block-perfect img,
#defense-circle.block-good img,
#defense-circle.block-fail img,
#defense-circle.block-no-block img {
  animation: zone-flash 0.55s ease-out;
}
#defense-circle.block-perfect img { filter: drop-shadow(0 0 28px #5af0ff) drop-shadow(0 0 48px rgba(90,240,255,.8)) brightness(1.6); }
#defense-circle.block-good img    { filter: drop-shadow(0 0 24px #ffaa22) drop-shadow(0 0 44px rgba(255,170,34,.7)) brightness(1.5); }
#defense-circle.block-fail img    { filter: drop-shadow(0 0 24px #ff3333) drop-shadow(0 0 44px rgba(255,68,68,.7)) brightness(1.5); }
#defense-circle.block-no-block img { filter: drop-shadow(0 0 16px rgba(255,255,255,.5)) brightness(0.8); }
@keyframes zone-flash {
  0% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

/* === FEEDBACK — reticle changes color based on which zone its currently in === */
#defense-inner.in-cyan {
  border-color: #5af0ff !important;
  box-shadow: 0 0 18px rgba(90,240,255,.95), inset 0 0 10px rgba(90,240,255,.6) !important;
}
#defense-inner.in-amber {
  border-color: #ffaa22 !important;
  box-shadow: 0 0 14px rgba(255,170,34,.85), inset 0 0 8px rgba(255,170,34,.4) !important;
}
#defense-inner.in-red {
  border-color: #ff5555 !important;
  box-shadow: 0 0 14px rgba(255,68,68,.85), inset 0 0 8px rgba(255,68,68,.4) !important;
}


/* === Dynamic result text driven by JS data-result attribute === */


/* === Attack bar result popup (same treatment as defense) === */
#attack-bar { position: relative !important; }






/* === ATTACK BAR HAPTICS — match defense feel === */

/* Unclip the popup so it can render above the bar */
#combat-action-area,
#attack-bar-container { overflow: visible !important; }
#attack-bar {
  overflow: visible !important;
  position: relative !important;
}

/* Popup text — mirror defense ::after styling exactly */





/* Glow burst emanating from the bar — same drop-shadow treatment defense uses on its SVG */
#attack-bar.result-perfect { animation: attack-burst-cyan 0.55s ease-out !important; }
#attack-bar.result-hit    { animation: attack-burst-amber 0.55s ease-out !important; }
#attack-bar.result-miss   { animation: attack-burst-dim 0.55s ease-out !important; }

@keyframes attack-burst-cyan {
  0%   { filter: drop-shadow(0 0 28px #5af0ff) drop-shadow(0 0 56px rgba(90,240,255,.85)) brightness(1.7); }
  100% { filter: none; }
}
@keyframes attack-burst-amber {
  0%   { filter: drop-shadow(0 0 24px #ffaa22) drop-shadow(0 0 50px rgba(255,170,34,.75)) brightness(1.55); }
  100% { filter: none; }
}
@keyframes attack-burst-dim {
  0%   { filter: drop-shadow(0 0 14px rgba(255,255,255,.4)) brightness(0.65); }
  100% { filter: none; }
}


/* === Post-fight drops row (floating, top-right of action area) === */
/* res-loot-band: in-flow loot reward (was absolute corner-pinned) */
.res-drops-row {
  width: 100%;
  margin: 4px 0 0 0;
  padding-top: 14px;
  border-top: 1px solid rgba(255,170,34,.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  font-family: 'Share Tech Mono', monospace;
}
.res-drops-label {
  color: rgba(255,255,255,.4);
  font-size: 10px;
  letter-spacing: 4px;
}
.res-drops-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: 100%;
}
.res-drop-item {
  color: #ffaa22;
  font-size: 12px;
  letter-spacing: 1px;
  text-shadow: 0 0 6px rgba(255,170,34,.4);
  padding: 5px 11px;
  border: 1px solid rgba(255,170,34,.3);
  border-radius: 2px;
  background: rgba(255,170,34,.05);
}


/* === Result text moved to float over enemy — suppress bar popup === */


/* === Defense result text moved to float over enemy — suppress circle popup === */


.lftm-battle {
  color: inherit;
  cursor: default;
  pointer-events: none;
  border-bottom: none;
  text-shadow: none;
  transition: color .25s, text-shadow .25s;
}
body.has-character .lftm-battle {
  color: #ff2d78;
  cursor: pointer;
  pointer-events: auto;
  border-bottom: 1px solid rgba(255,45,120,0.5);
  text-shadow: 0 0 8px #ff2d78, 0 0 20px rgba(255,45,120,0.5);
  animation: battle-pulse 2.2s ease-in-out infinite;
}
body.has-character .lftm-battle:hover {
  color: #ff5599;
  text-shadow: 0 0 12px #ff2d78, 0 0 30px rgba(255,45,120,0.8);
}
body.has-character .lftm-battle.defeated {
  color: var(--text-muted);
  border-bottom-color: var(--text-muted);
  text-decoration: line-through;
  cursor: default;
  pointer-events: none;
  opacity: .55;
  text-shadow: none;
  animation: none;
}
@keyframes battle-pulse {
  0%,100% { text-shadow: 0 0 8px #ff2d78, 0 0 20px rgba(255,45,120,0.5); }
  50%      { text-shadow: 0 0 14px #ff2d78, 0 0 36px rgba(255,45,120,0.8), 0 0 60px rgba(255,0,80,0.3); }
}


/* === JUICE v19 === */

/* screen shake */
#combat-overlay.shake-hit   { animation: combat-shake-hit .26s cubic-bezier(.36,.07,.19,.97); }
#combat-overlay.shake-heavy { animation: combat-shake-heavy .44s cubic-bezier(.36,.07,.19,.97); }
@keyframes combat-shake-hit {
  0%,100% { transform: translate(0,0); }
  20% { transform: translate(-4px,2px); }
  40% { transform: translate(4px,-2px); }
  60% { transform: translate(-3px,1px); }
  80% { transform: translate(3px,-1px); }
}
@keyframes combat-shake-heavy {
  0%,100% { transform: translate(0,0) rotate(0); }
  15% { transform: translate(-9px,4px) rotate(-.45deg); }
  30% { transform: translate(9px,-5px) rotate(.45deg); }
  45% { transform: translate(-7px,3px) rotate(-.3deg); }
  60% { transform: translate(6px,-3px) rotate(.3deg); }
  75% { transform: translate(-4px,2px); }
  90% { transform: translate(3px,-1px); }
}

/* white impact pop (freeze-frame sell) */
#combat-overlay.flash-impact::after {
  content:''; position:absolute; inset:0; z-index:9998; pointer-events:none;
  background: radial-gradient(circle at 50% 40%, rgba(255,255,255,.55), rgba(255,255,255,0) 62%);
  animation: impact-pop .15s ease-out forwards;
}
@keyframes impact-pop { 0% { opacity:1; } 100% { opacity:0; } }

/* damage-number pop-in (scale overshoot, separate element from the float) */
.dmg-pop { display:inline-block; animation: dmg-pop-in .18s cubic-bezier(.34,1.56,.64,1); }
@keyframes dmg-pop-in { 0% { transform: scale(0); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }

/* HP ghost / trailing bar — fill snaps, ghost drains after a beat */
.hp-bar .hp-ghost { position:absolute; z-index:0; pointer-events:none; }
.hp-bar .hp-fill  { z-index:1; transition: width .14s cubic-bezier(.4,0,.2,1) !important; }
.enemy-hp .hp-ghost {
  top:17%; bottom:14.3%; left:4.2%; max-width:92.7%;
  background: linear-gradient(180deg, rgba(255,255,255,.9), rgba(255,170,170,.75));
  box-shadow: 0 0 6px rgba(255,255,255,.45);
  transition: width .5s cubic-bezier(.4,0,.2,1) .35s;
}
#player-hp .hp-ghost {
  top:20%; bottom:17%; left:3.8%; max-width:92.2%;
  background: linear-gradient(180deg, rgba(255,255,255,.9), rgba(200,250,255,.75));
  box-shadow: 0 0 6px rgba(255,255,255,.45);
  transition: width .5s cubic-bezier(.4,0,.2,1) .35s;
}

/* enemy squash-and-stretch on hit (transform anim runs alongside the filter flash) */
.enemy-sprite.flash-hit {
  animation: hitflash .3s steps(2,end), enemy-squash .3s ease-out,
             idle-bob 2.2s ease-in-out infinite .3s !important;
}
@keyframes enemy-squash {
  0%   { transform: translateX(-50%) scale(1,1); }
  25%  { transform: translateX(calc(-50% + 6px)) scale(1.12,.86); }
  55%  { transform: translateX(calc(-50% - 2px)) scale(.94,1.08); }
  100% { transform: translateX(-50%) scale(1,1); }
}

/* spark burst on perfect */
.spark {
  position:absolute; top:35%; left:50%;
  width:5px; height:5px; margin:-2.5px 0 0 -2.5px; border-radius:50%;
  background:#fff; box-shadow:0 0 8px #ffd86a, 0 0 16px rgba(255,200,80,.85);
  z-index:6; pointer-events:none;
  animation: spark-fly .5s ease-out forwards;
}
@keyframes spark-fly {
  0%   { transform: translate(0,0) scale(1); opacity:1; }
  100% { transform: translate(var(--dx,0), var(--dy,0)) scale(.3); opacity:0; }
}

/* CRT scanlines + vignette over the scene */
#combat-scene::before {
  content:''; position:absolute; inset:0; z-index:4; pointer-events:none;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,.16) 0, rgba(0,0,0,.16) 1px, transparent 1px, transparent 3px),
    radial-gradient(ellipse at 50% 42%, transparent 55%, rgba(0,0,0,.5) 100%);
  mix-blend-mode: multiply; opacity:.55;
}

/* neon ground pad under the enemy */
#enemy-ground {
  position:absolute; bottom:20px; left:50%; transform:translateX(-50%);
  width:42%; max-width:340px; height:34px;
  background: radial-gradient(ellipse at center, rgba(0,255,224,.2), rgba(0,255,224,0) 70%);
  filter: blur(2px); z-index:1; pointer-events:none;
}

/* per-command accent text (hue-rotate frames stay; this just colours the labels) */
#combat-commands button[data-cmd="attack"] { color:#ff9bc8; }
#combat-commands button[data-cmd="talk"]   { color:#7fe0ff; }
#combat-commands button[data-cmd="item"]   { color:#ffcf6a; }

@media (max-width: 600px) {
  #enemy-ground { width:60%; max-width:none; }
}
@media (prefers-reduced-motion: reduce) {
  #combat-overlay.shake-hit, #combat-overlay.shake-heavy { animation: none !important; }
  .spark { display:none !important; }
}


/* === DEF-HP v20 === */
/* Player HP bar surfaced inside the BLOCK overlay. Self-contained (no v19 dep). */
#defense-hp-row { display:flex; align-items:center; gap:8px; margin-top:2px; }
.defense-hp-tag {
  font-family:'Josefin Sans', sans-serif; font-size:9px; letter-spacing:2px;
  color:rgba(90,240,255,.55);
}
#defense-hp {
  position:relative; width:170px; height:22px; overflow:hidden;
  border:1px solid rgba(90,240,255,.35); border-radius:3px;
  background:rgba(90,240,255,.06);
  box-shadow:0 0 8px rgba(90,240,255,.15), inset 0 0 6px rgba(0,0,0,.5);
}
#defense-hp .hp-fill {
  position:absolute; top:0; bottom:0; left:0; z-index:1;
  background:linear-gradient(180deg, rgba(140,250,255,.6) 0%, rgba(90,240,255,.95) 50%, rgba(140,250,255,.6) 100%);
  box-shadow:0 0 8px rgba(90,240,255,.5);
  transition:width .14s cubic-bezier(.4,0,.2,1);
}
#defense-hp .hp-ghost {
  position:absolute; top:0; bottom:0; left:0; z-index:0;
  background:linear-gradient(180deg, rgba(255,255,255,.9), rgba(200,250,255,.7));
  box-shadow:0 0 6px rgba(255,255,255,.45);
  transition:width .35s cubic-bezier(.4,0,.2,1) .1s; /* ~.45s, finishes inside the post-block window */
}
#defense-hp .hp-text {
  position:absolute; inset:0; z-index:2; pointer-events:none;
  display:flex; align-items:center; justify-content:center;
  font-family:'Josefin Sans', sans-serif; font-weight:700;
  font-size:11px; letter-spacing:2px; color:#fff;
  text-shadow:0 0 4px #000, 0 0 8px rgba(0,0,0,.8);
}


/* ════════════════════════════════════════════════════════════
   MULTI-ENEMY LAYOUT  (rough — eyeball only, perspective pass TBD)
   ════════════════════════════════════════════════════════════ */
#enemy-hp-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
}
.enemy-hp-row { display: flex; flex-direction: column; gap: 2px; }
.enemy-hp-name {
  font-family: 'Josefin Sans', sans-serif;
  font-size: 11px; letter-spacing: 2px; color: #fff;
  text-shadow: 0 0 8px rgba(255,90,90,.5), 0 1px 2px #000;
}
/* target highlight */
.enemy-hp-row.targeted .enemy-hp { outline: 2px solid rgba(255,220,120,.9); outline-offset: 2px; border-radius: 3px; }
.enemy-sprite.targeted {
  filter: drop-shadow(0 0 14px rgba(255,220,120,.95)) drop-shadow(0 6px 20px rgba(0,0,0,.9));
}
/* a downed enemy stays on the field, dimmed */
.enemy-sprite.dead {
  opacity: .25;
  filter: grayscale(1) drop-shadow(0 6px 20px rgba(0,0,0,.9));
  animation: none !important;
}

/* TARGET SELECT */
#target-select { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
#target-select-label {
  font-family: 'Josefin Sans', sans-serif; font-size: 14px; letter-spacing: 4px;
  color: #ffcf6a; text-shadow: 0 0 10px rgba(255,207,106,.5);
}
#target-chips { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.target-chip {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-width: 96px; padding: 10px 14px; cursor: pointer;
  background: rgba(10,10,15,.85); border: 1px solid rgba(255,207,106,.5);
  border-radius: 8px; color: #fff; font-family: 'Josefin Sans', sans-serif;
  letter-spacing: 2px; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: border-color .15s, box-shadow .15s, transform .05s;
}
.target-chip:hover { border-color: rgba(255,220,120,.95); box-shadow: 0 0 14px rgba(255,207,106,.35); }
.target-chip:active { transform: translateY(1px); }
.target-chip .tc-name { font-size: 13px; }
.target-chip .tc-hp { font-size: 11px; color: rgba(255,255,255,.6); letter-spacing: 1px; }

/* ── PRELOAD / ANTI-POP-IN (Part B) ──────────────────────────────────────
   A standalone loading gate ("STABILIZING REALITY") shown BEFORE the combat
   overlay is built (combat.js stabilizeThenStart). Solid backdrop so no
   half-painted scene shows through; big Share Tech Mono label; cyan progress
   bar + percentage. The combat intro slice/box animation is UNCHANGED — this
   screen simply precedes it. */

#combat-stabilize {
  position: fixed;
  inset: 0;
  z-index: 10050;                 /* above everything, including the overlay */
  background: #07080c;            /* solid near-black: nothing shows through */
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity .3s ease-out;
}
#combat-stabilize.done {
  opacity: 0;
}
#stabilize-inner {
  width: min(420px, 78vw);
  text-align: center;
  font-family: 'Share Tech Mono', monospace;
  color: #cfe9ef;
}
#stabilize-label {
  font-size: clamp(18px, 4vw, 26px);
  letter-spacing: .42em;
  text-indent: .42em;             /* balance the trailing letter-spacing */
  color: var(--cyan, #5af0ff);
  text-shadow: 0 0 14px rgba(90,240,255,.55), 0 0 32px rgba(90,240,255,.25);
  margin-bottom: 22px;
  animation: stabilize-pulse 1.8s ease-in-out infinite;
}
@keyframes stabilize-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .55; }
}
#stabilize-bar {
  position: relative;
  width: 100%;
  height: 6px;
  border-radius: 4px;
  background: var(--blue-glow, rgba(0,136,255,0.16));
  box-shadow: inset 0 0 0 1px rgba(90,240,255,.18);
  overflow: hidden;
}
#stabilize-fill {
  height: 100%;
  width: 0%;
  border-radius: 4px;
  background: var(--cyan, #5af0ff);
  box-shadow: 0 0 8px rgba(90,240,255,.85), 0 0 18px rgba(90,240,255,.45);
  transition: width .2s linear;
}
#stabilize-pct {
  margin-top: 12px;
  font-size: 13px;
  letter-spacing: .25em;
  color: rgba(207,233,239,.7);
}
#stabilize-note {
  margin-top: 20px;
  min-height: 1em;
  font-size: 12px;
  letter-spacing: .08em;
  line-height: 1.5;
  color: rgba(255,170,90,.9);     /* amber: caution, distinct from the cyan */
  opacity: 0;
  transition: opacity .4s ease-out;
}
#stabilize-note.shown {
  opacity: 1;
}
/* ── END-OF-FIGHT RESULT MODAL (popup, replaces in-flow result band) ── */
.res-modal-scrim {
  position: absolute; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(6,6,12,.72);
  animation: res-scrim-in .25s ease-out;
}
@keyframes res-scrim-in { from { opacity: 0; } to { opacity: 1; } }
.res-modal-card {
  width: 340px; max-width: 100%;
  max-height: calc(100% - 40px); overflow-y: auto;
  background: rgba(12,12,20,.96);
  border: 1px solid rgba(255,200,80,.35);
  border-radius: 6px;
  box-shadow: 0 0 28px rgba(255,200,80,.12), 0 12px 40px rgba(0,0,0,.6);
  padding: 26px 26px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  text-align: center;
  animation: res-card-in .35s cubic-bezier(.2,.8,.25,1);
}
.res-defeat   .res-modal-card { border-color: rgba(255,90,90,.35);  box-shadow: 0 0 28px rgba(255,90,90,.12), 0 12px 40px rgba(0,0,0,.6); }
.res-resolved .res-modal-card { border-color: rgba(94,255,160,.35); box-shadow: 0 0 28px rgba(94,255,160,.12), 0 12px 40px rgba(0,0,0,.6); }
@keyframes res-card-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.res-eyebrow { font-size: 9px; letter-spacing: 5px; font-family: 'Share Tech Mono', monospace; }
.res-modal-card .res-heading { font-size: clamp(16px, 4vw, 21px); letter-spacing: 2px; line-height: 1.25; max-width: 100%; }
.res-modal-card .res-xp-bar { width: 200px; max-width: 100%; }
.res-modal-card .res-drops-row { margin-top: 4px; }
.res-modal-continue {
  margin-top: 8px; width: 100%;
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.14);
  color: rgba(255,255,255,.65); font-family: 'Josefin Sans', sans-serif;
  font-size: 12px; letter-spacing: 3px; padding: 12px 0;
  cursor: pointer; border-radius: 2px; transition: all .15s;
  touch-action: manipulation;
}
.res-modal-continue:hover { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.32); color: #fff; }


/* ============================================================================
   P0/P1 POLISH PASS — game-feel, readability, haptic-visual fallback.
   Additive: new keyframes + classes the engine toggles at real events.
   ============================================================================ */

/* ---- easing tokens (mirrors :root in index.html; safe fallback here) ---- */
:root {
  --ease-snap: cubic-bezier(.2,.8,.25,1);
  --ease-pop: cubic-bezier(.34,1.56,.64,1);
  --ease-soft: cubic-bezier(.22,1,.36,1);
  --ease-anticipate: cubic-bezier(.36,0,.66,-.4);
}

/* ---- P0: tactile press-states on combat commands ---- */
#combat-commands button:active:not(:disabled) {
  transform: translateY(1px) scale(.965);
  filter: brightness(1.15);
  transition: transform .06s var(--ease-snap), filter .06s var(--ease-snap);
}

/* ---- P1: enemy "aliveness" — slow filter breath (composes w/ idle-bob) ---- */
@keyframes idle-glow {
  0%, 100% { filter: drop-shadow(0 6px 20px rgba(0,0,0,.9)) brightness(1); }
  50%      { filter: drop-shadow(0 6px 24px rgba(0,0,0,.92)) brightness(1.07) saturate(1.06); }
}

/* ---- P1: enemy SPAWN drama (scene flash-in + ground slam; conflict-free) ---- */
#combat-scene { animation: scene-spawn .5s var(--ease-soft) 1; }
@keyframes scene-spawn {
  0%   { filter: brightness(2.2) contrast(1.2); opacity: 0; }
  35%  { opacity: 1; }
  100% { filter: none; opacity: 1; }
}
#enemy-ground { animation: ground-slam .55s var(--ease-pop) 1; }
@keyframes ground-slam {
  0%   { transform: translateX(-50%) scaleX(2.4); opacity: 0; }
  45%  { transform: translateX(-50%) scaleX(.7);  opacity: 1; }
  100% { transform: translateX(-50%) scaleX(1);   opacity: 1; }
}

/* ---- P1: HP bar as a character ---- */
/* recoil: a quick brightness punch + shudder when the fill drops */
.hp-bar .hp-fill.recoil { animation: hp-recoil .26s var(--ease-snap); }
@keyframes hp-recoil {
  0%   { filter: brightness(2.6) saturate(.6); transform: translateX(0); }
  25%  { transform: translateX(-2px); }
  55%  { transform: translateX(2px); }
  100% { filter: none; transform: translateX(0); }
}
/* heal: a rising shimmer sweep */
.hp-bar .hp-fill.healed { animation: hp-heal .6s var(--ease-soft); }
@keyframes hp-heal {
  0%   { filter: brightness(1.9) saturate(1.4); box-shadow: 0 0 18px rgba(120,255,180,.9); }
  100% { filter: none; }
}
/* low-health: anxious breathing on the player bar under ~25% */
#player-hp.low { animation: hp-low 1.1s ease-in-out infinite; }
@keyframes hp-low {
  0%, 100% { filter: none; }
  50%      { filter: brightness(1.25) drop-shadow(0 0 10px rgba(255,60,60,.7)); }
}
#player-hp.low .hp-fill {
  background: linear-gradient(180deg, rgba(255,120,120,.6) 0%, rgba(255,60,60,.97) 50%, rgba(255,120,120,.6) 100%);
}

/* ---- P1: the timing bar — make the perfect window irresistible ---- */
.attack-zone.perfect { animation: zone-breathe 1.15s ease-in-out infinite; }
@keyframes zone-breathe {
  0%, 100% { box-shadow: 0 0 8px rgba(255,200,80,.5); filter: brightness(1); }
  50%      { box-shadow: 0 0 18px rgba(255,210,90,.95); filter: brightness(1.25); }
}
/* perfect-hit full-screen bloom (engine appends .perfect-bloom into the scene) */
.perfect-bloom {
  position: absolute; inset: 0; z-index: 9; pointer-events: none;
  background: radial-gradient(circle at center, rgba(255,225,140,.55), rgba(255,210,90,0) 60%);
  animation: perfect-bloom-fx .5s var(--ease-soft) forwards;
}
@keyframes perfect-bloom-fx {
  0%   { opacity: 0; transform: scale(.6); }
  20%  { opacity: 1; }
  100% { opacity: 0; transform: scale(1.4); }
}

/* ---- P1: crit damage numbers — bigger, hotter, arc + hold ---- */
.dmg-num.perfect {
  text-shadow: 0 0 18px rgba(255,210,90,.95), 0 0 40px rgba(255,180,40,.6), 0 2px 4px #000;
  letter-spacing: .02em;
}
.dmg-num.perfect.float { animation: crit-arc 1s var(--ease-soft) forwards; }
@keyframes crit-arc {
  0%   { transform: translate(-50%, -120%) scale(.4); opacity: 0; }
  18%  { transform: translate(-50%, -150%) scale(1.35); opacity: 1; }
  40%  { transform: translate(-50%, -175%) scale(1); opacity: 1; }
  100% { transform: translate(-48%, -300%) scale(.95); opacity: 0; }
}

/* ---- P1: enemy death — dissolve, not blink-out ---- */
.enemy-sprite.dead {
  animation: enemy-dissolve .9s var(--ease-soft) forwards !important;
  pointer-events: none;
}
@keyframes enemy-dissolve {
  0%   { opacity: 1; filter: drop-shadow(0 6px 20px rgba(0,0,0,.9)) brightness(1); }
  20%  { filter: brightness(3) saturate(0); }
  100% { opacity: 0; filter: brightness(2) saturate(0) blur(6px); transform: translateX(-50%) translateY(8px) scale(.92); }
}
/* victory hold-beat: brief slow-mo while the death plays, before the card */
#combat-overlay.victory-beat #combat-scene { animation: victory-slowmo 1.4s ease-out; }
@keyframes victory-slowmo {
  0% { filter: saturate(1.4) brightness(1.1); }
  100% { filter: none; }
}

/* ---- haptic visual fallback (iOS / no Vibration API): a 1-frame kick ---- */
body.haptic-kick       { animation: haptic-kick .12s ease-out; }
body.haptic-kick-heavy { animation: haptic-kick-heavy .16s ease-out; }
@keyframes haptic-kick       { 0%,100% { transform: none; } 50% { transform: translateY(1px); } }
@keyframes haptic-kick-heavy { 0% { transform: none; } 30% { transform: translate(-2px,2px); } 60% { transform: translate(2px,-1px); } 100% { transform: none; } }

/* ---- P1: legibility nudge on critical readouts (no palette change) ---- */
.hp-bar .hp-text { text-shadow: 0 1px 3px rgba(0,0,0,.85), 0 0 2px rgba(0,0,0,.6); }

/* ============================================================
   CANTOS FIGHT MODAL — word-combat layout (combat.css v37)
   v2: board is HEIGHT-DRIVEN so Shuffle/Flee always fit; one auto-sized name
   word per side; layered STRIKE impact (cell flash + recoil + projectile bolt).
   #combat-overlay is reused (shared result modal + closeOverlay still apply).
   Pure SVG/CSS visual language — no sprites.
   ============================================================ */
#combat-overlay.cantos-fight-mode {
  position: fixed; inset: 0; z-index: 4000;
  background:
    radial-gradient(120% 90% at 50% -10%, rgba(120,100,200,0.16), transparent 60%),
    linear-gradient(180deg, #0b0b14 0%, #06060e 100%);
  display: flex; align-items: center; justify-content: center;
  padding: max(10px, env(safe-area-inset-top)) 12px max(10px, env(safe-area-inset-bottom));
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent; overflow: hidden;
}
#cantos-fight {
  width: 100%; max-width: 480px; height: 100%;
  display: flex; flex-direction: column; gap: 8px;
  align-items: stretch; justify-content: flex-start;
}
.cantos-fight-mode .cf-side {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  flex: 0 0 auto;
}
.cantos-fight-mode .cf-side-label {
  font-family: "Archivo Black", "Arial Black", sans-serif;
  font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: #a090b8;
}
.cantos-fight-mode .cf-enemy-side .cf-side-label { color: #ff7aa8; }
.cantos-fight-mode .cf-player-tag { color: #6ff7ec; }
.cantos-fight-mode .cf-name {
  width: 100%; min-height: 40px;
  display: flex; align-items: center; justify-content: center;
  flex-wrap: nowrap; gap: 2px; line-height: 0;
}
.cantos-fight-mode .cf-name .cantos-cell { flex: 0 0 auto; }

/* beat-clock */
.cantos-fight-mode .cf-clock-wrap { flex: 0 0 auto; display: flex; flex-direction: column; gap: 3px; }
.cantos-fight-mode .cf-clock-tag {
  font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: #7a6a92; text-align: center;
}
.cantos-fight-mode .cf-clock {
  position: relative; height: 8px; border-radius: 999px; overflow: hidden;
  background: #141420; box-shadow: inset 0 1px 3px rgba(0,0,0,0.7); border: 1px solid #221c33;
}
.cantos-fight-mode .cf-clock-fill {
  position: absolute; inset: 0 auto 0 0; width: 0%;
  background: linear-gradient(90deg, #5a3df0, #8b6cff);
  box-shadow: 0 0 10px rgba(139,108,255,0.6); transition: width 0.08s linear;
}
.cantos-fight-mode .cf-clock.charged .cf-clock-fill {
  background: linear-gradient(90deg, #ff5a3c, #ff2d78);
  box-shadow: 0 0 14px rgba(255,45,120,0.75);
  animation: cf-clock-pulse 0.5s ease-in-out infinite alternate;
}
@keyframes cf-clock-pulse { from { opacity: 0.75; } to { opacity: 1; } }
.cantos-fight-mode .cf-clock.frozen { border-color: #4aa6d8; }
.cantos-fight-mode .cf-clock.frozen .cf-clock-fill {
  background: linear-gradient(90deg, #7fd8ff, #cdeeff);
  box-shadow: 0 0 12px rgba(127,216,255,0.7); animation: none;
}

/* readout — compact so it never crowds the board */
.cantos-fight-mode .cf-readout {
  flex: 0 0 auto; text-align: center;
  background: #06060e; border: 1px solid #1c1c2b; border-radius: 10px;
  padding: 5px 12px; display: flex; flex-direction: column; gap: 2px;
}
.cantos-fight-mode .cf-current {
  font-family: "Archivo Black", "Arial Black", sans-serif;
  font-size: 18px; line-height: 1; min-height: 20px; letter-spacing: 0.04em;
  text-transform: uppercase; color: #f1f1f8;
}
.cantos-fight-mode .cf-current.empty { color: #2c2c40; }
.cantos-fight-mode .cf-status { font-size: 12px; font-weight: 700; min-height: 15px; }
.cantos-fight-mode .cf-status.ok { color: #36e0a8; }
.cantos-fight-mode .cf-status.no { color: #ff5d73; }
.cantos-fight-mode .cf-status.idle { color: #8a8a9a; }

/* board — HEIGHT-DRIVEN: fills the leftover column space and stays square, so the
   controls below are never pushed off-screen. Overrides the board module's
   width:100% with higher specificity. */
.cantos-fight-mode .cf-board-wrap {
  flex: 1 1 auto; min-height: 0;
  display: flex; align-items: center; justify-content: center;
}
.cantos-fight-mode #cf-board.cantos-board {
  width: auto; height: 100%; max-width: 100%; max-height: 100%;
  aspect-ratio: 1 / 1; margin: 0 auto;
}

/* controls — always-visible reserved row */
.cantos-fight-mode .cf-controls {
  flex: 0 0 auto; display: flex; gap: 10px; justify-content: center; padding-top: 2px;
}
.cantos-fight-mode .cf-controls button {
  background: rgba(22,22,34,0.6); color: #e9e9f2;
  border: 1px solid #2a2a3d; border-radius: 10px;
  padding: 9px 18px; font-size: 13px; font-weight: 700; cursor: pointer;
  touch-action: manipulation;
}
.cantos-fight-mode .cf-controls button:disabled { opacity: 0.45; cursor: not-allowed; }
.cantos-fight-mode .cf-controls button:active:not(:disabled) { transform: translateY(1px); }

/* ---------- STRIKE IMPACT ---------- */
/* each struck letter flashes + recoils; the crack (render) appears on the same beat */
.cantos-fight-mode .cantos-cell.cf-struck { animation: cf-recoil 0.30s cubic-bezier(.2,1.4,.3,1); z-index: 3; }
@keyframes cf-recoil {
  0% { transform: scale(1); }
  22% { transform: scale(1.26) translateY(-4px); }
  55% { transform: scale(0.95); }
  100% { transform: scale(1); }
}
.cantos-fight-mode .cantos-cell.cf-struck-big { animation: cf-recoil-big 0.42s cubic-bezier(.2,1.4,.3,1); }
@keyframes cf-recoil-big {
  0% { transform: scale(1) rotate(0); }
  18% { transform: scale(1.42) translateY(-7px) rotate(-3deg); }
  50% { transform: scale(0.9) rotate(1.5deg); }
  100% { transform: scale(1) rotate(0); }
}
/* white-hot flash on the letter cell — pseudo-element survives render's innerHTML swap */
.cantos-fight-mode .cantos-cell.cf-struck::after {
  content: ''; position: absolute; inset: -4px; border-radius: 10px; pointer-events: none;
  background: radial-gradient(circle at 50% 45%, #ffffff 0%, var(--cf-strike, #fff) 55%, transparent 76%);
  mix-blend-mode: screen; opacity: 0; animation: cf-flash 0.30s ease-out;
}
.cantos-fight-mode .cantos-cell.cf-struck-big::after { animation-duration: 0.42s; }
@keyframes cf-flash {
  0% { opacity: 0; transform: scale(0.55); }
  18% { opacity: 0.95; transform: scale(1.1); }
  100% { opacity: 0; transform: scale(1.35); }
}

/* the flying projectile (big words / enemy attacks) */
.cf-bolt {
  position: fixed; left: 0; top: 0; width: 22px; height: 22px; margin: -11px 0 0 -11px;
  border-radius: 50%; pointer-events: none; z-index: 2147483640;
  background: radial-gradient(circle, #ffffff 0%, var(--cf-bolt-color, #8b6cff) 52%, transparent 72%);
  box-shadow: 0 0 16px var(--cf-bolt-color, #8b6cff), 0 0 34px var(--cf-bolt-color, #8b6cff);
}

/* whole-name jolt on a big hit */
.cantos-fight-mode .cf-name.cf-shake { animation: cf-name-shake 0.30s ease-out; }
@keyframes cf-name-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

@media (prefers-reduced-motion: reduce) {
  .cantos-fight-mode .cantos-cell.cf-struck,
  .cantos-fight-mode .cantos-cell.cf-struck-big,
  .cantos-fight-mode .cf-name.cf-shake { animation: none !important; }
  .cf-bolt { display: none !important; }
}
/* ---------- INTRO REVEAL (name scrolls in left->right) ---------- */
.cantos-fight-mode .cf-name.cf-revealing .cantos-cell {
  opacity: 0;
  animation: cf-reveal 0.42s cubic-bezier(.2,1,.3,1) forwards;
  animation-delay: calc(var(--cf-reveal-i, 0) * 0.075s);
}
@keyframes cf-reveal {
  0% { opacity: 0; transform: translateX(-18px) scale(0.7); }
  60% { opacity: 1; transform: translateX(2px) scale(1.06); }
  100% { opacity: 1; transform: translateX(0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .cantos-fight-mode .cf-name.cf-revealing .cantos-cell { opacity: 1; animation: none; }
}


/* ============================================================
   COMBAT_MODE_V1 — web combat parked.
   combat-mode.js puts .combat-off on <body>; battle spans then read as
   ordinary story text (no glow, no pulse, no pointer, no strike-through)
   whether or not a character exists. Removing the body class restores
   every rule above untouched.
   ============================================================ */
body.combat-off .lftm-battle,
body.combat-off.has-character .lftm-battle,
body.combat-off.has-character .lftm-battle:hover,
body.combat-off.has-character .lftm-battle.defeated {
  color: inherit;
  cursor: default;
  pointer-events: none;
  border-bottom: none;
  text-shadow: none;
  text-decoration: none;
  animation: none;
  opacity: 1;
}
