/*
   PTCG MuZero Battle Arena & Visualizer
   Design inspired by PTCG_ABCS_Visualizer (hiro094)
   =================================================
*/

:root {
  --bg: #0f1419;
  --panel: #1b232c;
  --panel2: #222d38;
  --line: #33414f;
  --txt: #e6edf3;
  --dim: #8b98a5;
  --accent: #4aa3ff;
  --p0: #3a6df0;
  --p1: #e0533d;
  --hpgood: #3fb950;
  --hpmid: #d29922;
  --hpbad: #f85149;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Meiryo, system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--txt);
  font-size: 14px;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── HEADER ─────────────────────────────────────────────────────────────────── */
header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

header h1 {
  font-size: 18px;
  margin: 0;
  color: var(--accent);
  white-space: nowrap;
  font-weight: 800;
}

.engine-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(74, 163, 255, 0.12);
  border: 1px solid rgba(74, 163, 255, 0.3);
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  animation: pulse 2s infinite ease-in-out;
}

@keyframes pulse {
  0%, 100% { transform: scale(0.8); opacity: 0.6; }
  50% { transform: scale(1.3); opacity: 1; }
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 14px;
}

.meta {
  color: var(--dim);
}

.meta b {
  color: var(--txt);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

button {
  background: var(--panel2);
  color: var(--txt);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s ease;
}

button:hover {
  background: #2c3a48;
  border-color: var(--accent);
}

button:disabled {
  opacity: .4;
  cursor: default;
}

.btn-primary {
  background: var(--accent);
  color: #0b0f14;
  border-color: var(--accent);
}
.btn-primary:hover {
  background: #388fe5;
}

.btn-danger {
  background: rgba(224, 83, 61, 0.2);
  border-color: rgba(224, 83, 61, 0.4);
  color: #ff7b72;
}
.btn-danger:hover {
  background: rgba(224, 83, 61, 0.4);
}

.btn-secondary {
  background: var(--panel2);
  color: var(--txt);
}

.btn-sm {
  font-size: 12px;
  padding: 4px 10px;
}

/* ── LAYOUT ─────────────────────────────────────────────────────────────────── */
#wrap {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 14px;
  padding: 14px;
  align-items: start;
  flex: 1;
  overflow: hidden;
  height: calc(100vh - 55px);
}

@media(max-width: 1000px) {
  #wrap { grid-template-columns: 1fr; }
}

.board {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
  overflow-y: auto;
  padding-right: 6px;
}

/* ── PLAYERS & PANELS ───────────────────────────────────────────────────────── */
.player {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  transition: box-shadow 0.3s ease;
}

.player.p0 { border-top: 4px solid var(--p0); }
.player.p1 { border-top: 4px solid var(--p1); }

.player.p0.turn {
  box-shadow: 0 0 0 2px var(--p0), 0 0 20px #3a6df0aa;
}

.player.p1.turn {
  box-shadow: 0 0 0 2px var(--p1), 0 0 20px #e0533daa;
}

.turnflag {
  font-weight: 700;
  font-size: 12px;
  color: #fff;
  border-radius: 5px;
  padding: 2px 9px;
  background: var(--accent);
}

.player.p0 .turnflag { background: var(--p0); }
.player.p1 .turnflag { background: var(--p1); }

.prow {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.tag {
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 6px;
  font-size: 12px;
}

.tag.p0 { background: var(--p0); }
.tag.p1 { background: var(--p1); }

.counts {
  color: var(--dim);
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 13px;
}

.counts b { color: var(--txt); }

.zone-label {
  color: var(--dim);
  font-size: 12px;
  font-weight: 600;
  margin: 4px 0 3px;
}

.cards {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 4px;
}

/* ── CARDS & ANIMATIONS ─────────────────────────────────────────────────── */
.card {
  position: relative;
  width: 95px;
  height: 132px;
  border-radius: 8px;
  background: var(--panel2);
  border: 1.5px solid var(--line);
  overflow: hidden;
  flex: none;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.2s ease, box-shadow 0.2s ease;
  animation: cardEntrance 0.35s cubic-bezier(0.2, 0.9, 0.3, 1) backwards;
}

@keyframes cardEntrance {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.card:hover {
  transform: translateY(-5px) scale(1.03);
  border-color: var(--accent);
  box-shadow: 0 8px 20px rgba(74, 163, 255, 0.45);
  z-index: 10;
}

.card.active {
  width: 120px;
  height: 168px;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent), 0 0 24px rgba(74, 163, 255, 0.55);
  animation: activeBreathe 3s infinite ease-in-out;
}

@keyframes activeBreathe {
  0%, 100% {
    box-shadow: 0 0 0 2px var(--accent), 0 0 16px rgba(74, 163, 255, 0.4);
  }
  50% {
    box-shadow: 0 0 0 3px #818cf8, 0 0 28px rgba(129, 140, 248, 0.7);
  }
}

/* Holographic shimmer effect for active cards */
.card.active::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    60deg,
    transparent 35%,
    rgba(255, 255, 255, 0.15) 50%,
    rgba(74, 163, 255, 0.2) 55%,
    transparent 65%
  );
  transform: rotate(25deg);
  pointer-events: none;
  animation: holoSheen 4.5s infinite linear;
}

@keyframes holoSheen {
  0% { transform: translateY(-100%) rotate(25deg); }
  100% { transform: translateY(100%) rotate(25deg); }
}

.card.damage-fx {
  animation: damageShake 0.4s ease-in-out;
}

@keyframes damageShake {
  0%, 100% { transform: translateX(0); filter: brightness(1); }
  20% { transform: translateX(-6px); filter: brightness(1.5) drop-shadow(0 0 10px #f85149); }
  40% { transform: translateX(6px); filter: brightness(1.7) drop-shadow(0 0 14px #f85149); }
  60% { transform: translateX(-4px); filter: brightness(1.4); }
  80% { transform: translateX(4px); filter: brightness(1.2); }
}

.card.small {
  width: 68px;
  height: 95px;
}


.card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.card .txt {
  position: absolute;
  inset: 0;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.card .nm {
  font-size: 11px;
  line-height: 1.2;
  font-weight: 700;
  max-height: 42px;
  overflow: hidden;
}

.card .stat {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.card .hp {
  font-size: 11px;
  color: var(--dim);
}

.card.faceup .txt {
  background: linear-gradient(180deg, #263340, #1a232c);
}

.card.hasimg img {
  display: block;
}

.card.hasimg .txt {
  background: none;
}

.card.mon.hasimg .txt {
  background: linear-gradient(180deg, transparent 32%, rgba(0, 0, 0, 0.85) 100%);
}

.card.hasimg .nm {
  display: none;
}

.card.hasimg .hp {
  color: var(--txt);
  text-shadow: 0 1px 3px #000, 0 0 4px #000;
  font-weight: 700;
}

.hpbar {
  height: 5px;
  border-radius: 3px;
  background: #30363d;
  overflow: hidden;
  margin-top: 2px;
}

.hpbar > i {
  display: block;
  height: 100%;
}

.energies {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.en {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 10px;
  line-height: 16px;
  text-align: center;
  color: #0b0b0b;
  font-weight: 800;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.badges {
  position: absolute;
  top: 3px;
  right: 3px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-end;
  z-index: 2;
}

.badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid var(--line);
}

.badge.sc { background: #7b1fa2; }
.badge.tool { background: #00695c; }
.badge.ex { background: #b8860b; }

/* ── CENTER ZONE (STADIUM & AI HUD) ─────────────────────────────────────────── */
.center-zone {
  display: flex;
  flex-direction: column;
  gap: 6px;
}


.stadium {
  text-align: center;
  color: var(--dim);
  padding: 4px 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.stadium b {
  color: var(--txt);
}

.stadium[data-id] {
  cursor: help;
}

.ai-hud {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ai-hud-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ai-hud-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
}

.ai-winrate {
  font-size: 11px;
  color: var(--dim);
}

.ai-winrate strong {
  color: var(--accent);
}

.ai-bar-track {
  width: 100%;
  height: 4px;
  background: #30363d;
  border-radius: 2px;
  overflow: hidden;
}

.ai-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #818cf8);
  transition: width 0.4s ease;
}

.ai-intent-row {
  font-size: 11px;
  color: var(--dim);
  display: flex;
  gap: 8px;
}

.context-banner {
  background: rgba(74, 163, 255, 0.1);
  border: 1px solid rgba(74, 163, 255, 0.3);
  padding: 5px 12px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.context-icon {
  font-size: 14px;
}

.context-text {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}

/* ── SIDEBAR (ACTIONS & LOGS) ───────────────────────────────────────────────── */
.side {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
}

.logbox, .selbox {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
}

.selbox {
  position: relative;
  flex: 1;
  overflow-y: auto;
}

/* ── STYLIZED THINKING OVERLAY ────────────────────────────────────────────── */
.thinking-overlay {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  background: rgba(15, 20, 25, 0.84);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  border: 1.5px solid rgba(74, 163, 255, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 25;
  overflow: hidden;
  box-shadow: inset 0 0 30px rgba(74, 163, 255, 0.15), 0 0 25px rgba(0, 0, 0, 0.5);
  animation: overlayFadeIn 0.3s ease-out;
}

@keyframes overlayFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Glowing scan beam sliding slowly downwards */
.thinking-scan-beam {
  position: absolute;
  left: 0;
  right: 0;
  height: 80px;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(74, 163, 255, 0.05) 20%,
    rgba(74, 163, 255, 0.35) 70%,
    rgba(129, 140, 248, 0.75) 96%,
    #4aa3ff 100%
  );
  box-shadow: 0 4px 20px rgba(74, 163, 255, 0.6);
  filter: blur(1px);
  pointer-events: none;
  animation: scanlineDown 2.6s ease-in-out infinite;
}

@keyframes scanlineDown {
  0% {
    top: -80px;
    opacity: 0;
  }
  15% {
    opacity: 1;
  }
  85% {
    opacity: 1;
  }
  100% {
    top: calc(100% + 20px);
    opacity: 0;
  }
}

.thinking-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  z-index: 2;
  text-align: center;
  padding: 16px;
}

.thinking-brain-ring {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(74, 163, 255, 0.15);
  border: 2px solid rgba(74, 163, 255, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(74, 163, 255, 0.4), inset 0 0 12px rgba(74, 163, 255, 0.3);
  animation: ringPulse 2s infinite ease-in-out;
}

@keyframes ringPulse {
  0%, 100% {
    transform: scale(0.95);
    box-shadow: 0 0 15px rgba(74, 163, 255, 0.3);
  }
  50% {
    transform: scale(1.1);
    box-shadow: 0 0 28px rgba(129, 140, 248, 0.7);
    border-color: #818cf8;
  }
}

.thinking-brain-icon {
  font-size: 26px;
  animation: brainWiggle 2s infinite ease-in-out;
}

@keyframes brainWiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-5deg) scale(1.05); }
  75% { transform: rotate(5deg) scale(1.05); }
}

.thinking-text-main {
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.6px;
  text-shadow: 0 0 12px rgba(74, 163, 255, 0.8), 0 0 24px rgba(74, 163, 255, 0.4);
  animation: textShimmer 2.2s infinite ease-in-out;
}

@keyframes textShimmer {
  0%, 100% { opacity: 0.85; text-shadow: 0 0 10px rgba(74, 163, 255, 0.6); }
  50% { opacity: 1; text-shadow: 0 0 20px rgba(74, 163, 255, 1), 0 0 30px rgba(129, 140, 248, 0.8); }
}

.thinking-sub-text {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(74, 163, 255, 0.12);
  border: 1px solid rgba(74, 163, 255, 0.3);
  padding: 3px 12px;
  border-radius: 999px;
}


.logbox {
  height: 46%;
  overflow-y: auto;
}

.selbox-header, .logbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.logbox h3, .selbox h3 {
  margin: 0;
  font-size: 12px;
  color: var(--accent);
}

.action-count {
  background: rgba(74, 163, 255, 0.18);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
}

.actions-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

.action-item {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.action-item:hover {
  background: #2c3a48;
  border-color: var(--accent);
  transform: translateX(3px);
}

.action-item.selected {
  border-color: var(--accent);
  background: rgba(74, 163, 255, 0.18);
}

.action-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.action-title {
  font-weight: 700;
  font-size: 13.5px;
  color: #fff;
}

.action-tag {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  color: #0b0b0b;
}

.action-sub {
  font-size: 12px;
  color: var(--dim);
}

/* Combat Log */
.log {
  white-space: pre-wrap;
  font-family: Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  overflow-y: auto;
  flex: 1;
}

.log .res { color: var(--hpgood); font-weight: 700; }
.log .atk { color: #ffb454; }
.log .hp { color: #ff7b72; }
.log .ai { color: #c4b5fd; }
.log .player { color: #7dd3fc; }

.hint {
  color: var(--dim);
  font-size: 12px;
}

/* ── HOVER PREVIEW ──────────────────────────────────────────────────────────── */
#preview {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  display: none;
  width: auto;
  pointer-events: none;
  background: var(--panel);
  border: 1.5px solid var(--accent);
  border-radius: 12px;
  padding: 8px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.85);
}

#preview .pvrow {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

#preview .pvmain {
  width: 280px;
  flex: none;
}

#preview img {
  display: block;
  width: 100%;
  border-radius: 8px;
  background: var(--panel2);
}

#preview .cap {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--txt);
}

#preview .cap .sub {
  color: var(--dim);
  margin-top: 3px;
}

#preview .pvenergy {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

#preview .egroup {
  display: flex;
  align-items: center;
  gap: 8px;
}

#preview .estack {
  display: inline-flex;
}

#preview .estack img {
  width: 80px;
  border-radius: 6px;
  background: var(--panel2);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.7);
}

#preview .estack img:not(:first-child) {
  margin-left: -58px;
}

#preview .ecount {
  font-size: 13px;
  font-weight: 800;
  color: var(--dim);
}

#preview .pvtools {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 280px;
  flex: none;
}

#preview .pvtools .tname {
  font-size: 13px;
  color: var(--dim);
  margin-top: 4px;
  line-height: 1.35;
}


/* ── DISCARD / ZOOM MODAL ───────────────────────────────────────────────────── */
.zone-open {
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 6px;
}

.zone-open:hover {
  background: #2c3a48;
  border-color: var(--accent);
}

.zoom {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
}

.zoom.hide { display: none; }

.zoom-box {
  display: flex;
  flex-direction: column;
  width: min(92vw, 850px);
  min-height: 65vh;
  max-height: 86vh;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
}

.zoom-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

#zoom-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
}

.zoom-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
  gap: 8px;
  justify-items: center;
  align-content: flex-start;
  flex: 1;
  min-height: 0;
  overflow: auto;
}

/* ── DECK MODAL ─────────────────────────────────────────────────────────────── */
.deck-modal-box {
  width: min(92vw, 800px);
}

.deck-modal-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  flex: 1;
}

.deck-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.deck-option-card {
  background: var(--panel2);
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.deck-option-card:hover {
  border-color: var(--accent);
}

.deck-option-card.selected {
  border-color: var(--accent);
  background: rgba(74, 163, 255, 0.12);
}

.deck-opt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.deck-opt-header h4 {
  margin: 0;
  font-size: 12px;
  color: #fff;
}

.deck-option-card p {
  font-size: 11px;
  color: var(--dim);
  margin: 0;
  line-height: 1.35;
}

.badge-tag {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
}

.meta-badge { background: var(--accent); color: #0b0b0b; }
.ai-badge { background: #818cf8; color: #0b0b0b; }
.tier1-badge { background: #f59e0b; color: #0b0b0b; }

.deck-preview-area {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.deck-prev-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 12px;
}

.deck-stats-pill {
  display: flex;
  gap: 8px;
  font-size: 11px;
  color: var(--dim);
}

.deck-stats-pill b {
  color: var(--txt);
}

.deck-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 6px;
  max-height: 160px;
  overflow-y: auto;
}

.prev-pill {
  background: var(--panel2);
  border: 1px solid var(--line);
  padding: 4px 8px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
}

.styled-select {
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--txt);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
}

.deck-modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.zoom-box {
  animation: modalPop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalPop {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ── GAME OVER BOX ─────────────────────────────────────────────────────────── */
.game-over-box {
  width: 440px;
  text-align: center;
  align-items: center;
  padding: 28px;
  background: var(--panel);
  border: 2px solid var(--accent);
  box-shadow: 0 0 40px rgba(74, 163, 255, 0.4);
}

.game-over-icon {
  font-size: 56px;
  animation: bounceTrophy 1.2s infinite ease-in-out;
}

@keyframes bounceTrophy {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-8px) scale(1.1); }
}

/* ── MODEL COMPILE MODAL ─────────────────────────────────────────────────── */
.compile-modal-box {
  width: min(92vw, 620px);
  min-height: auto;
  max-height: 90vh;
}

.compile-modal-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 4px 0;
}

.compile-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: rgba(210, 153, 34, 0.12);
  border: 1px solid rgba(210, 153, 34, 0.35);
  border-radius: 8px;
  padding: 12px 14px;
}

.compile-banner-icon {
  font-size: 24px;
  line-height: 1;
}

.target-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.target-option-card {
  background: var(--panel2);
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.target-option-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.target-option-card.selected {
  border-color: var(--accent);
  background: rgba(74, 163, 255, 0.12);
  box-shadow: 0 0 16px rgba(74, 163, 255, 0.2);
}

.target-opt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.target-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--txt);
}

.target-option-card p {
  margin: 0;
  font-size: 11px;
  color: var(--dim);
  line-height: 1.4;
}

.compile-progress-area {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-top: 4px;
}

.compile-spinner-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.compile-spinner {
  width: 18px;
  height: 18px;
  border: 3px solid rgba(74, 163, 255, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.compile-status-text {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

.compile-bar-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.compile-bar-fill {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 40%;
  background: linear-gradient(90deg, var(--accent), #818cf8, var(--accent));
  background-size: 200% 100%;
  border-radius: 999px;
  animation: compileShimmer 1.8s infinite linear, compileSlide 2.5s infinite ease-in-out;
}

@keyframes compileSlide {
  0% { left: 0%; width: 25%; }
  50% { left: 60%; width: 40%; }
  100% { left: 100%; width: 10%; }
}

@keyframes compileShimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.compile-error-area {
  background: rgba(248, 81, 73, 0.12);
  border: 1px solid var(--hpbad);
  border-radius: 6px;
  padding: 10px 12px;
  color: #ff9994;
  font-size: 12px;
  line-height: 1.4;
}

