/* ============================================================
   STR Combat Countdown Overlay
   Full-screen 3-2-1 countdown before combat begins
   ============================================================ */

.str-combat-countdown-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.82);
  z-index: 3000;
  pointer-events: none;
}

.str-combat-countdown-overlay.str-countdown-fade-out {
  animation: str-countdown-fade 0.4s ease-out forwards;
}

@keyframes str-countdown-fade {
  from { opacity: 1; }
  to   { opacity: 0; }
}

.str-countdown-number {
  font-family: 'Courier New', monospace;
  font-size: clamp(6rem, 20vw, 14rem);
  font-weight: bold;
  color: #ffaa00;
  text-shadow:
    0 0 40px rgba(255, 170, 0, 0.9),
    0 0 80px rgba(255, 170, 0, 0.5);
  animation: str-countdown-pulse 0.9s ease-in-out;
  line-height: 1;
}

@keyframes str-countdown-pulse {
  0%   { transform: scale(1.4); opacity: 0; }
  30%  { transform: scale(1);   opacity: 1; }
  85%  { transform: scale(1);   opacity: 1; }
  100% { transform: scale(0.8); opacity: 0; }
}

/* Contextual annotation beneath each countdown number */
.str-countdown-context {
  font-family: 'Courier New', monospace;
  font-size: clamp(0.75rem, 2.2vw, 1.1rem);
  color: #cccccc;
  text-align: center;
  max-width: min(80vw, 520px);
  line-height: 1.4;
  letter-spacing: 0.04em;
  opacity: 0.88;
  margin-top: 0.6em;
  animation: str-context-slide-in 0.35s ease-out;
  text-shadow: 0 0 8px rgba(255, 170, 0, 0.25);
}

@keyframes str-context-slide-in {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 0.88; }
}

.str-countdown-fight {
  font-family: 'Courier New', monospace;
  font-size: clamp(3rem, 10vw, 7rem);
  font-weight: bold;
  color: #ff1c4a;
  text-shadow:
    0 0 40px rgba(255, 28, 74, 0.9),
    0 0 80px rgba(255, 28, 74, 0.5);
  letter-spacing: 0.15em;
  animation: str-fight-appear 0.5s ease-out;
}

@keyframes str-fight-appear {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* ============================================================
   Background tint when combat is minimized
   ============================================================ */

body.str-combat-minimized-state {
  background: rgba(255, 28, 74, 0.08);
}

body.str-combat-minimized-state::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 28, 74, 0.08);
  pointer-events: none;
  z-index: 999;
}

/* Main STR Combat Window */
.str-combat-window {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(85vw, 500px);
  background: rgba(10, 10, 10, 0.95);
  backdrop-filter: blur(10px);
  border: 3px solid #ffaa00;
  border-radius: 12px;
  box-shadow:
    0 0 30px rgba(255, 170, 0, 0.6),
    inset 0 0 20px rgba(255, 170, 0, 0.08);
  z-index: 2000;
  font-family: 'Courier New', monospace;
  overflow: hidden;
}

/* Window appear animation */
.str-combat-window.str-window-appear {
  animation: str-window-appear 0.3s ease-out;
}

@keyframes str-window-appear {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.8);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

/* Window minimizing animation */
.str-combat-window.str-window-minimizing {
  animation: str-window-minimize 0.3s ease-out forwards;
}

@keyframes str-window-minimize {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    opacity: 0.8;
    transform: translate(-50%, -50%) scale(0.6);
  }
  100% {
    opacity: 0;
    transform: translate(calc(50vw - 100%), calc(-50vh + 50px)) scale(0.4);
  }
}

/* Window maximizing animation */
.str-combat-window.str-window-maximizing {
  animation: str-window-maximize 0.3s ease-in;
}

@keyframes str-window-maximize {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.4);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

/* Window Header */
.str-window-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: linear-gradient(135deg, #1a1506 0%, #2a1a0a 100%);
  border-bottom: 2px solid #ffaa00;
}

.str-window-title {
  color: #ffaa00;
  font-size: 16px;
  font-weight: bold;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.str-minimize-btn {
  background: rgba(255, 170, 0, 0.1);
  border: 2px solid #ffaa00;
  border-radius: 4px;
  color: #ffaa00;
  font-size: 20px;
  font-weight: bold;
  width: 32px;
  height: 32px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.str-minimize-btn:hover {
  background: rgba(255, 170, 0, 0.2);
  transform: scale(1.1);
  box-shadow: 0 0 10px rgba(255, 170, 0, 0.5);
}

.str-minimize-btn:active {
  transform: scale(0.95);
}

/* Window Body */
.str-window-body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

/* Combatant Display */
.str-combatant {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.str-combatant-emoji {
  font-size: 48px;
  line-height: 1;
  filter: drop-shadow(0 0 10px rgba(255, 170, 0, 0.5));
}

.str-enemy .str-combatant-emoji {
  animation: enemy-pulse 2s ease-in-out infinite;
}

/* Highlight when a card is being targeted at the enemy */
.str-enemy.str-enemy-targetable {
  box-shadow: 0 0 0 2px rgba(255, 235, 59, 0.35) inset, 0 0 18px rgba(255, 235, 59, 0.18);
  border-radius: 10px;
}

.str-enemy.str-enemy-targeted {
  box-shadow: 0 0 0 2px rgba(255, 82, 82, 0.45) inset, 0 0 22px rgba(255, 82, 82, 0.22);
  border-radius: 10px;
}

@keyframes enemy-pulse {
  0%, 100% {
    filter: drop-shadow(0 0 10px rgba(255, 28, 74, 0.5));
  }
  50% {
    filter: drop-shadow(0 0 20px rgba(255, 28, 74, 0.8));
  }
}

.str-player .str-combatant-emoji {
  animation: player-pulse 1s ease-in-out infinite;
}

@keyframes player-pulse {
  0%, 100% {
    filter: drop-shadow(0 0 10px rgba(28, 255, 155, 0.5));
  }
  50% {
    filter: drop-shadow(0 0 15px rgba(28, 255, 155, 0.7));
  }
}

/* Intent Display */
.str-intent-display {
  font-size: 24px;
  line-height: 1;
  color: #ffaa00;
  text-shadow: 0 0 10px rgba(255, 170, 0, 0.8);
  margin-top: -5px;
  margin-bottom: 5px;
  letter-spacing: 4px;
  animation: intent-shimmer 3s ease-in-out infinite;
}

@keyframes intent-shimmer {
  0%, 100% {
    text-shadow: 0 0 10px rgba(255, 170, 0, 0.8);
  }
  50% {
    text-shadow: 0 0 20px rgba(255, 170, 0, 1);
  }
}

/* HP Bar */
.str-hp-bar-container {
  width: 100%;
  max-width: 300px;
  background: rgba(0, 0, 0, 0.5);
  border: 2px solid #333;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  height: 28px;
}

.str-hp-bar {
  height: 100%;
  transition: width 0.3s ease;
  background: linear-gradient(90deg, #1cff9b 0%, #00d580 100%);
}

.str-hp-bar.enemy-hp {
  background: linear-gradient(90deg, #ff1c4a 0%, #d00030 100%);
}

.str-hp-bar.player-hp {
  background: linear-gradient(90deg, #1cff9b 0%, #00d580 100%);
}

.str-hp-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 14px;
  font-weight: bold;
  text-shadow:
    1px 1px 2px rgba(0, 0, 0, 0.8),
    -1px -1px 2px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

/* Advantage Indicator */
.str-advantage-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 15px;
  background: rgba(255, 170, 0, 0.1);
  border: 2px solid #ffaa00;
  border-radius: 8px;
}

.str-advantage-emoji {
  font-size: 40px;
  line-height: 1;
}

.str-advantage-text {
  color: #ffaa00;
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 1px;
}

/* Window Footer */
.str-window-footer {
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.3);
  border-top: 2px solid #ffaa00;
  display: flex;
  justify-content: center;
}

.str-timer-display {
  color: #1cff9b;
  font-size: 14px;
  font-weight: bold;
}

.str-timer-label {
  color: #999;
  margin-right: 8px;
}

.str-timer-value {
  color: #1cff9b;
  font-size: 18px;
  transition: color 0.3s ease;
}

/* Timer warning state */
.str-timer-value[style*="color: #ff1c4a"] {
  animation: timer-warning 0.5s ease-in-out infinite;
}

@keyframes timer-warning {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

/* ============================================================
   Minimized Indicator
   ============================================================ */

.str-combat-minimized {
  position: fixed;
  top: 70px;
  right: 20px;
  width: 48px;
  height: 48px;
  background: rgba(10, 10, 10, 0.95);
  backdrop-filter: blur(5px);
  border: 2px solid #ffaa00;
  border-radius: 8px;
  box-shadow:
    0 0 15px rgba(255, 170, 0, 0.5),
    inset 0 0 10px rgba(255, 170, 0, 0.1);
  z-index: 1900;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.str-combat-minimized:hover {
  transform: scale(1.1);
  box-shadow:
    0 0 20px rgba(255, 170, 0, 0.7),
    inset 0 0 15px rgba(255, 170, 0, 0.15);
}

.str-combat-minimized:active {
  transform: scale(0.95);
}

/* Minimized indicator appear animation */
.str-combat-minimized.str-indicator-appear {
  animation: indicator-appear 0.3s ease-out;
}

@keyframes indicator-appear {
  from {
    opacity: 0;
    transform: scale(0);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Minimized indicator maximizing animation */
.str-combat-minimized.str-indicator-maximizing {
  animation: indicator-maximize 0.3s ease-out forwards;
}

@keyframes indicator-maximize {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(3);
  }
}

/* Minimized content */
.str-mini-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 2px;
}

.str-mini-emoji {
  font-size: 18px;
  line-height: 1;
}

.str-mini-intent {
  font-size: 10px;
  line-height: 1;
  color: #ffaa00;
  text-shadow: 0 0 5px rgba(255, 170, 0, 0.8);
}

.str-mini-timer {
  font-size: 8px;
  color: #1cff9b;
  font-weight: bold;
}

/* Timer text micro-pulse to reinforce deceleration */
.str-mini-timer.str-mini-timer-pulse {
  animation: str-mini-timer-pulse 120ms ease-out;
}

@keyframes str-mini-timer-pulse {
  0%   { transform: scale(1.0); }
  40%  { transform: scale(1.12); }
  100% { transform: scale(1.0); }
}

.str-mini-expand {
  font-size: 10px;
  color: #ffaa00;
  line-height: 1;
}

/* Bounce attention animation */
.str-combat-minimized.bounce-attention {
  animation: bounce-indicator 0.8s ease-out;
}

@keyframes bounce-indicator {
  0%, 100% {
    transform: translateY(0);
  }
  25% {
    transform: translateY(-8px);
  }
  50% {
    transform: translateY(0);
  }
  75% {
    transform: translateY(-4px);
  }
}

/* Pulsing indicator when at low time */
.str-combat-minimized[data-time-critical="true"] {
  animation: indicator-pulse 0.5s ease-in-out infinite;
}

@keyframes indicator-pulse {
  0%, 100% {
    border-color: #ffaa00;
    box-shadow: 0 0 15px rgba(255, 170, 0, 0.5);
  }
  50% {
    border-color: #ff1c4a;
    box-shadow: 0 0 25px rgba(255, 28, 74, 0.7);
  }
}

/* ============================================================
   Responsive Design
   ============================================================ */

@media (max-width: 768px) {
  .str-combat-window {
    width: 90vw;
    max-width: none;
  }

  .str-window-title {
    font-size: 14px;
  }

  .str-combatant-emoji {
    font-size: 40px;
  }

  .str-hp-bar-container {
    max-width: 250px;
    height: 24px;
  }

  .str-hp-text {
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  .str-combat-window {
    width: 95vw;
  }

  .str-window-header {
    padding: 6px 10px;
  }

  .str-window-title {
    font-size: 12px;
  }

  .str-minimize-btn {
    width: 28px;
    height: 28px;
    font-size: 18px;
  }

  .str-window-body {
    padding: 10px;
    gap: 10px;
  }

  .str-combatant-emoji {
    font-size: 36px;
  }

  .str-hp-bar-container {
    max-width: 200px;
    height: 22px;
  }

  .str-advantage-emoji {
    font-size: 32px;
  }

  .str-advantage-text {
    font-size: 10px;
  }
}

/* ============================================================
   Accessibility
   ============================================================ */

.str-minimize-btn:focus,
.str-combat-minimized:focus {
  outline: 2px solid #1cff9b;
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .str-combat-window,
  .str-combat-minimized,
  .str-hp-bar,
  .str-timer-value,
  .str-combat-window.str-frame-overload {
    animation: none !important;
    transition: none !important;
  }
}

/* ============================================================
   Phase 5: Information Duel — Frame Tint States
   Shifts the combat window border color to reflect duel tension.
   Applied by InformationDuelHUD._updateFrameTint().
   ============================================================ */

/* Escalation urgent: border shifts toward red */
.str-combat-window.str-frame-escalation {
  border-color: #ff6644;
  box-shadow:
    0 0 30px rgba(255, 102, 68, 0.5),
    inset 0 0 20px rgba(255, 102, 68, 0.06);
  transition: border-color 0.4s ease, box-shadow 0.4s ease;
}

/* Overload eligible (rising): border shifts toward bright yellow */
.str-combat-window.str-frame-overload-rising {
  border-color: #ffdd00;
  box-shadow:
    0 0 30px rgba(255, 221, 0, 0.5),
    inset 0 0 20px rgba(255, 221, 0, 0.06);
  transition: border-color 0.4s ease, box-shadow 0.4s ease;
}

/* Overload active: pulsing white-yellow */
.str-combat-window.str-frame-overload {
  animation: str-frame-overload-pulse 0.8s ease-in-out infinite;
}

@keyframes str-frame-overload-pulse {
  0%, 100% {
    border-color: #ffdd00;
    box-shadow:
      0 0 30px rgba(255, 221, 0, 0.5),
      inset 0 0 20px rgba(255, 221, 0, 0.06);
  }
  50% {
    border-color: #ffffaa;
    box-shadow:
      0 0 50px rgba(255, 255, 170, 0.7),
      inset 0 0 30px rgba(255, 255, 170, 0.1);
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .str-combat-window {
    border-width: 4px;
  }

  .str-hp-bar {
    border: 2px solid #fff;
  }

  .str-minimize-btn {
    border-width: 3px;
  }
}

/* ============================================================
   YOU DIED Full-Screen Death Overlay
   ============================================================ */

.str-death-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.92);
  z-index: 4000;
  pointer-events: none;
  animation: str-death-appear 0.4s ease-out;
}

@keyframes str-death-appear {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.str-death-overlay.str-death-fade-out {
  animation: str-death-fade 0.6s ease-in forwards;
}

@keyframes str-death-fade {
  from { opacity: 1; }
  to   { opacity: 0; }
}

.str-death-message {
  font-family: 'Courier New', monospace;
  font-size: clamp(4rem, 16vw, 10rem);
  font-weight: bold;
  color: #ff1c4a;
  text-shadow:
    0 0 40px rgba(255, 28, 74, 0.9),
    0 0 100px rgba(255, 28, 74, 0.5);
  letter-spacing: 0.1em;
  animation: str-death-pulse 1.2s ease-in-out infinite;
  line-height: 1;
}

@keyframes str-death-pulse {
  0%, 100% { text-shadow: 0 0 40px rgba(255, 28, 74, 0.9), 0 0 100px rgba(255, 28, 74, 0.5); }
  50%       { text-shadow: 0 0 60px rgba(255, 28, 74, 1.0), 0 0 150px rgba(255, 28, 74, 0.8); }
}

.str-death-sub {
  font-family: 'Courier New', monospace;
  font-size: clamp(0.8rem, 2.5vw, 1.2rem);
  color: #888;
  margin-top: 1.2em;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  animation: str-death-sub-in 0.5s ease-out 0.3s both;
}

@keyframes str-death-sub-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Camera shake applied to game container on death */
.death-shake {
  animation: death-shake 0.5s ease-out;
}

@keyframes death-shake {
  0%   { transform: translate(0, 0); }
  10%  { transform: translate(-6px, 4px); }
  20%  { transform: translate(5px, -3px); }
  30%  { transform: translate(-4px, 5px); }
  40%  { transform: translate(4px, -2px); }
  50%  { transform: translate(-3px, 3px); }
  60%  { transform: translate(3px, -2px); }
  70%  { transform: translate(-2px, 2px); }
  80%  { transform: translate(2px, -1px); }
  90%  { transform: translate(-1px, 1px); }
  100% { transform: translate(0, 0); }
}

/* Red vignette that fades in before the death overlay */
.death-red-vignette {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none;
  z-index: 3999;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(51, 0, 0, 0.85) 100%);
  animation: death-vignette-in 0.5s ease-out forwards;
}

@keyframes death-vignette-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Run stats section inside the death overlay */
.str-death-stats {
  font-family: 'Courier New', monospace;
  font-size: clamp(0.7rem, 2vw, 0.95rem);
  color: #aaa;
  margin-top: 1.8em;
  text-align: left;
  line-height: 1.8;
  letter-spacing: 0.05em;
  animation: str-death-sub-in 0.5s ease-out 0.6s both;
}

.str-death-stats .stat-row {
  display: flex;
  justify-content: space-between;
  gap: 2em;
  border-bottom: 1px solid rgba(255, 28, 74, 0.15);
  padding: 0.15em 0;
}

.str-death-stats .stat-label {
  color: #777;
}

.str-death-stats .stat-value {
  color: #ff1c4a;
  font-weight: bold;
}

.str-death-stats .stat-penalty {
  color: #ff4444;
  font-size: 0.85em;
}

/* ============================================================
   Attack Lunge Animations (Pokemon-style)
   ============================================================ */

/* Hit flash on the target combatant */
.str-lunge-hit {
  animation: str-hit-flash 0.25s ease-out;
}

@keyframes str-hit-flash {
  0%   { filter: brightness(1); transform: translateX(0); }
  20%  { filter: brightness(2.5) saturate(0); transform: translateX(-4px); }
  40%  { filter: brightness(2.5) saturate(0); transform: translateX(4px); }
  60%  { filter: brightness(1.5); transform: translateX(-2px); }
  100% { filter: brightness(1); transform: translateX(0); }
}

/* Impact flash on the advantage indicator area */
.str-impact-flash {
  animation: str-impact-pulse 0.3s ease-out;
}

@keyframes str-impact-pulse {
  0%   { transform: scale(1); filter: brightness(1); }
  50%  { transform: scale(1.15); filter: brightness(2); }
  100% { transform: scale(1); filter: brightness(1); }
}
