/* v2.8 player combat presentation + battle log */

.player-motion-ghost {
  position: absolute !important;
  z-index: 40 !important;
  margin: 0 !important;
  pointer-events: none !important;
  transform-origin: center center !important;
  will-change: transform, opacity;
}

.player-arrival-flash {
  animation: playerArrivalFlash .48s ease-out;
}

.player-attacker-focus {
  z-index: 8;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 5px rgba(200, 255, 72, .26), 0 0 30px rgba(139, 223, 61, .3) !important;
  transform: translateY(-8px) scale(1.07) !important;
  filter: brightness(1.14);
}

.player-target-focus {
  z-index: 8;
  border-color: #ff776d !important;
  box-shadow: 0 0 0 5px rgba(255, 84, 76, .25), 0 0 30px rgba(255, 70, 61, .3) !important;
  filter: brightness(1.09);
}

.player-hit-flash {
  animation: playerHitFlash .42s ease-out;
}

.player-destroying {
  pointer-events: none !important;
  animation: playerDestroy .52s ease-in forwards !important;
}

.player-attack-arrow {
  position: absolute;
  z-index: 35;
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(200, 255, 72, .28), #a8ef55 65%, #70d83c);
  transform-origin: 0 50%;
  pointer-events: none;
  box-shadow: 0 0 14px rgba(151, 235, 72, .52);
  animation: playerArrowIn .24s ease-out both;
}

.player-attack-arrow::after {
  content: "";
  position: absolute;
  right: -11px;
  top: 50%;
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 13px solid #74dc40;
  transform: translateY(-50%);
  filter: drop-shadow(0 0 5px rgba(151, 235, 72, .55));
}

.player-arrow-label {
  position: absolute;
  left: 50%;
  top: -26px;
  transform: translateX(-50%) rotate(var(--counter-rotation, 0deg));
  padding: 3px 8px;
  border: 1px solid rgba(209, 255, 141, .42);
  border-radius: 999px;
  background: rgba(22, 35, 15, .95);
  color: #e7ffc4;
  font-size: .62rem;
  font-weight: 950;
  letter-spacing: .08em;
  white-space: nowrap;
}

.player-damage-float {
  position: absolute;
  z-index: 46;
  transform: translate(-50%, -50%);
  color: #fff3e7;
  font-size: clamp(1.45rem, 4vw, 2.25rem);
  font-weight: 1000;
  line-height: 1;
  text-shadow: 0 2px 0 #6e160f, 0 0 14px rgba(255, 58, 44, .8);
  pointer-events: none;
  animation: playerDamageFloat .7s ease-out forwards;
}

.player-action-menu .battle-log-menu-button {
  border-top-color: rgba(255, 255, 255, .12);
}

.battle-log-modal[hidden] {
  display: none !important;
}

.battle-log-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(4, 5, 6, .76);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}

.battle-log-dialog {
  width: min(92vw, 620px);
  max-height: min(78vh, 720px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 18px;
  background: #141416;
  color: var(--text);
  box-shadow: 0 28px 80px rgba(0, 0, 0, .5);
}

.battle-log-header {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
}

.battle-log-title-wrap {
  display: grid;
  gap: 3px;
}

.battle-log-title-wrap strong {
  font-size: .94rem;
  letter-spacing: .08em;
}

.battle-log-title-wrap small {
  color: var(--muted);
  font-size: .68rem;
}

.battle-log-close {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 10px;
  background: #1d1d20;
  color: #eee;
  font: inherit;
  font-size: 1.2rem;
  cursor: pointer;
}

.battle-log-close:hover,
.battle-log-close:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.battle-log-list {
  min-height: 160px;
  margin: 0;
  padding: 14px 16px 22px;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
  scrollbar-width: thin;
}

.battle-log-empty {
  padding: 34px 8px;
  color: var(--muted);
  text-align: center;
  font-size: .78rem;
}

.battle-log-entry {
  position: relative;
  display: grid;
  gap: 6px;
  margin: 0 0 8px;
  padding: 10px 11px 10px 14px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 11px;
  background: rgba(255, 255, 255, .025);
}

.battle-log-entry::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 999px;
  background: #6a6a72;
}

.battle-log-entry.player::before { background: var(--accent); }
.battle-log-entry.cpu::before { background: #ff8a75; }
.battle-log-entry.result::before { background: #f4d46e; }

.battle-log-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  color: #8d8d96;
  font-size: .58rem;
  font-weight: 900;
  letter-spacing: .1em;
}

.battle-log-actor {
  padding: 2px 6px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 999px;
  color: #c9c9cf;
}

.battle-log-entry.player .battle-log-actor { color: #dcff9f; }
.battle-log-entry.cpu .battle-log-actor { color: #ffb1a5; }
.battle-log-entry.result .battle-log-actor { color: #ffe594; }

.battle-log-text {
  margin: 0;
  color: #e4e4e8;
  font-size: .76rem;
  line-height: 1.55;
}

@keyframes playerArrivalFlash {
  0% { filter: brightness(1.8); transform: scale(1.15); }
  100% { filter: brightness(1); transform: scale(1); }
}

@keyframes playerArrowIn {
  from { opacity: 0; transform: rotate(var(--arrow-angle)) scaleX(.1); }
  to { opacity: 1; transform: rotate(var(--arrow-angle)) scaleX(1); }
}

@keyframes playerHitFlash {
  0%, 100% { filter: brightness(1); }
  30% { filter: brightness(2.2) saturate(1.5); transform: translateX(-5px); }
  55% { transform: translateX(5px); }
}

@keyframes playerDamageFloat {
  0% { opacity: 0; transform: translate(-50%, -15%) scale(.72); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -135%) scale(.95); }
}

@keyframes playerDestroy {
  0% { opacity: 1; filter: brightness(1); transform: scale(1); }
  35% { filter: brightness(1.8) saturate(.35); transform: scale(1.08) rotate(2deg); }
  100% { opacity: 0; filter: grayscale(1) brightness(.45); transform: scale(.28) rotate(-10deg); }
}

@media (max-width: 760px) {
  .player-arrow-label {
    top: -23px;
    font-size: .54rem;
    padding: 3px 6px;
  }

  .player-attack-arrow {
    height: 4px;
  }

  .battle-log-modal {
    padding: 10px;
  }

  .battle-log-dialog {
    width: min(96vw, 620px);
    max-height: 82vh;
    border-radius: 15px;
  }

  .battle-log-list {
    padding: 11px 11px 18px;
  }

  .battle-log-text {
    font-size: .72rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .player-arrival-flash,
  .player-hit-flash,
  .player-destroying,
  .player-attack-arrow,
  .player-damage-float {
    animation-duration: .01ms !important;
  }
}
