@import url("https://fonts.googleapis.com/css2?family=Oxanium:wght@400;600;700&family=Righteous&display=swap");

:root {
  --bg: #080b12;
  --bg-2: #141923;
  --ink: #f4f0e6;
  --muted: #b2b0a8;
  --accent: #f7c04a;
  --accent-2: #4fd1c5;
  --accent-3: #ff7a6b;
  --card: rgba(12, 16, 22, 0.9);
  --glass: rgba(255, 255, 255, 0.06);
  --stroke: rgba(255, 255, 255, 0.12);
  --glow: 0 0 30px rgba(79, 209, 197, 0.28);
  --danger: #ff6b6b;
}

* {
  box-sizing: border-box;
}

body.arcade {
  margin: 0;
  font-family: "Oxanium", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top, #1d2330, var(--bg) 60%);
  min-height: 100vh;
  padding: 24px;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
}

body.arcade::before {
  content: "";
  position: fixed;
  inset: -10%;
  background: radial-gradient(circle at 20% 20%, rgba(247, 192, 74, 0.18), transparent 45%),
    radial-gradient(circle at 80% 25%, rgba(79, 209, 197, 0.18), transparent 45%),
    radial-gradient(circle at 50% 90%, rgba(255, 122, 107, 0.18), transparent 40%);
  z-index: 0;
  pointer-events: none;
}

.grain {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 3px 3px;
  mix-blend-mode: soft-light;
  opacity: 0.25;
  pointer-events: none;
  z-index: 0;
}

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
  width: min(1200px, 94vw);
}

.title h1 {
  margin: 4px 0 0 0;
  font-family: "Righteous", "Trebuchet MS", sans-serif;
  font-size: clamp(2.1rem, 4.5vw, 3.2rem);
  letter-spacing: 0.08em;
}

.brand {
  text-transform: uppercase;
  letter-spacing: 0.35em;
  font-size: 0.65rem;
  color: var(--muted);
}

.meta {
  display: flex;
  gap: 16px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(8, 12, 22, 0.6);
  border: 1px solid var(--stroke);
  box-shadow: var(--glow);
  font-weight: 600;
}

.meta .label {
  display: block;
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.audio-toggle {
  display: flex;
  gap: 8px;
}

.view-toggle {
  display: flex;
  gap: 8px;
}

button {
  border: none;
  padding: 12px 18px;
  border-radius: 14px;
  background: var(--accent);
  color: #241406;
  font-weight: 700;
  font-family: "Oxanium", "Trebuchet MS", sans-serif;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  letter-spacing: 0.05em;
}

button.ghost {
  background: transparent;
  border: 1px solid var(--stroke);
  color: var(--ink);
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

button.secondary {
  background: var(--accent-2);
  color: #03131b;
}

button.danger {
  background: var(--danger);
  color: #240909;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.next-node {
  background: linear-gradient(135deg, #ffe066, #ff9f1c);
  color: #2b1600;
  border: 2px solid rgba(255, 224, 102, 0.45);
  box-shadow: 0 0 22px rgba(255, 193, 77, 0.55),
    0 12px 28px rgba(0, 0, 0, 0.45);
  font-size: 1rem;
  padding: 16px 18px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  position: relative;
  overflow: hidden;
  justify-content: center;
  animation: nextPulse 1.6s ease-in-out infinite;
}

button.next-node:hover {
  box-shadow: 0 0 30px rgba(255, 193, 77, 0.75),
    0 14px 30px rgba(0, 0, 0, 0.5);
}

.next-node-content {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.next-node-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.15);
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  font-weight: 800;
  box-shadow: inset 0 0 8px rgba(255, 255, 255, 0.3);
}

.next-node-text {
  text-align: left;
}

.next-node-title {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.next-node-sub {
  font-size: 0.75rem;
  color: rgba(43, 22, 0, 0.7);
  letter-spacing: 0.12em;
  margin-top: 2px;
}

.next-node-badge {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.18em;
}


.arena {
  position: relative;
  z-index: 1;
  min-height: 420px;
  border-radius: 32px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(18, 22, 30, 0.95), rgba(8, 10, 16, 0.98));
  box-shadow: 0 35px 90px rgba(0, 0, 0, 0.55);
  padding: 32px 36px;
  overflow: hidden;
  width: min(1200px, 94vw);
}

.arena-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 20%, rgba(102, 224, 255, 0.18), transparent 50%),
    radial-gradient(circle at 80% 30%, rgba(255, 179, 71, 0.2), transparent 50%);
  opacity: 0.9;
}

.arena-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 80%, rgba(255, 255, 255, 0.08), transparent 60%);
}

.impact-line {
  position: absolute;
  top: 50%;
  left: 10%;
  right: 10%;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
  opacity: 0.4;
}

.arena-message {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: none;
  color: var(--accent-2);
  text-shadow: 0 0 14px rgba(79, 209, 197, 0.45);
}

.card-zone {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  gap: 64px;
  z-index: 2;
}

.battle-card {
  width: min(360px, 42vw);
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 900px;
  will-change: transform;
}

.battle-card .card-shell {
  width: 100%;
  border-radius: 24px;
  background: linear-gradient(160deg, rgba(20, 24, 32, 0.95), rgba(10, 12, 18, 0.95));
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.5), inset 0 0 18px rgba(255, 255, 255, 0.05);
  padding: 18px;
  transform: rotateX(10deg) rotateY(-10deg);
  transition: transform 0.25s ease;
  position: relative;
  overflow: hidden;
}

.damage-float {
  position: absolute;
  left: 50%;
  top: 26%;
  transform: translate(-50%, 0);
  font-size: 2.6rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  text-shadow: 0 0 12px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  animation: damageFloat 0.9s ease-out forwards;
  z-index: 3;
}

.damage-float.player {
  color: #ffd6d6;
  border: 1px solid rgba(255, 120, 120, 0.55);
  box-shadow: 0 0 14px rgba(255, 120, 120, 0.35);
}

.damage-float.enemy {
  color: #ff3b30;
  border: 1px solid rgba(255, 59, 48, 0.65);
  box-shadow: 0 0 18px rgba(255, 59, 48, 0.55);
}

.damage-float.neutral {
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

@keyframes damageFloat {
  0% {
    opacity: 0;
    transform: translate(-50%, 10px) scale(0.9);
  }
  25% {
    opacity: 1;
    transform: translate(-50%, -6px) scale(1.06);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -34px) scale(1);
  }
}

.status-float {
  position: absolute;
  left: 50%;
  top: 12%;
  transform: translate(-50%, 0);
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  animation: statusFloat 1s ease-out forwards;
  z-index: 3;
}

.status-float.status-poison { color: #c99bff; border: 1px solid rgba(201, 155, 255, 0.7); }
.status-float.status-bad_poison { color: #b987ff; border: 1px solid rgba(185, 135, 255, 0.7); }
.status-float.status-burn { color: #ff7b7b; border: 1px solid rgba(255, 123, 123, 0.75); }
.status-float.status-paralyze { color: #ffe26a; border: 1px solid rgba(255, 226, 106, 0.8); }
.status-float.status-freeze { color: #b5f1ff; border: 1px solid rgba(181, 241, 255, 0.8); }
.status-float.status-sleep { color: #7cc6ff; border: 1px solid rgba(124, 198, 255, 0.8); }

@keyframes statusFloat {
  0% {
    opacity: 0;
    transform: translate(-50%, 8px) scale(0.92);
  }
  25% {
    opacity: 1;
    transform: translate(-50%, -2px) scale(1.02);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -22px) scale(1);
  }
}

.battle-card.enemy .card-shell {
  transform: rotateX(10deg) rotateY(10deg);
}

.card-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  opacity: 0.6;
  mix-blend-mode: screen;
  transform: translateX(-60%);
  animation: holo 4s linear infinite;
}

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

.card-header h3 {
  margin: 0;
  font-size: 1.3rem;
}

.chip-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.rarity-chip,
.evo-chip {
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
}

.level-chip {
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  color: #c8f7ff;
  border: 1px solid rgba(160, 226, 255, 0.4);
  background: rgba(120, 200, 255, 0.12);
}

.type-badge,
.move-type {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
}

.rarity-chip {
  text-transform: none;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
}

.rarity-common {
  color: #d6d6d6;
  border-color: rgba(214, 214, 214, 0.3);
}

.rarity-rare {
  color: #7cc6ff;
  border-color: rgba(124, 198, 255, 0.4);
  box-shadow: 0 0 8px rgba(124, 198, 255, 0.25);
}

.rarity-elite {
  color: #ffb870;
  border-color: rgba(255, 184, 112, 0.45);
  box-shadow: 0 0 10px rgba(255, 184, 112, 0.25);
}

.rarity-legendary {
  color: #ffd25a;
  border-color: rgba(255, 210, 90, 0.5);
  box-shadow: 0 0 12px rgba(255, 210, 90, 0.35);
}

.evo-chip {
  color: var(--accent-2);
  border: 1px solid rgba(79, 209, 197, 0.4);
  background: rgba(79, 209, 197, 0.12);
}

.type-normal { color: #d8d8d8; border-color: rgba(216, 216, 216, 0.4); }
.type-fire { color: #ff9a5b; border-color: rgba(255, 154, 91, 0.5); }
.type-water { color: #7cc6ff; border-color: rgba(124, 198, 255, 0.5); }
.type-grass { color: #7dff9a; border-color: rgba(125, 255, 154, 0.5); }
.type-electric { color: #ffe26a; border-color: rgba(255, 226, 106, 0.6); }
.type-ice { color: #b5f1ff; border-color: rgba(181, 241, 255, 0.6); }
.type-fighting { color: #ff7b7b; border-color: rgba(255, 123, 123, 0.6); }
.type-poison { color: #c99bff; border-color: rgba(201, 155, 255, 0.6); }
.type-ground { color: #e0b67a; border-color: rgba(224, 182, 122, 0.6); }
.type-flying { color: #b7c8ff; border-color: rgba(183, 200, 255, 0.6); }
.type-psychic { color: #ff7fb8; border-color: rgba(255, 127, 184, 0.6); }
.type-bug { color: #c6ff7a; border-color: rgba(198, 255, 122, 0.6); }
.type-rock { color: #d6c17a; border-color: rgba(214, 193, 122, 0.6); }
.type-ghost { color: #b59bff; border-color: rgba(181, 155, 255, 0.6); }
.type-dragon { color: #7a8bff; border-color: rgba(122, 139, 255, 0.6); }
.type-dark { color: #c2a28a; border-color: rgba(194, 162, 138, 0.6); }
.type-steel { color: #c7d3e0; border-color: rgba(199, 211, 224, 0.6); }
.type-fairy { color: #ffb7e8; border-color: rgba(255, 183, 232, 0.6); }

.move-type.type-normal { color: #555555; background: rgba(216, 216, 216, 0.45); border-color: rgba(120, 120, 120, 0.45); }
.move-type.type-fire { color: #9a3a00; background: rgba(255, 154, 91, 0.4); border-color: rgba(255, 120, 50, 0.55); }
.move-type.type-water { color: #0b4d7a; background: rgba(124, 198, 255, 0.4); border-color: rgba(64, 150, 220, 0.55); }
.move-type.type-grass { color: #0f6b2f; background: rgba(125, 255, 154, 0.4); border-color: rgba(70, 200, 110, 0.55); }
.move-type.type-electric { color: #7a5a00; background: rgba(255, 226, 106, 0.45); border-color: rgba(255, 200, 40, 0.6); }
.move-type.type-ice { color: #0a4f63; background: rgba(181, 241, 255, 0.45); border-color: rgba(120, 210, 230, 0.6); }
.move-type.type-fighting { color: #7a1f1f; background: rgba(255, 123, 123, 0.45); border-color: rgba(220, 70, 70, 0.6); }
.move-type.type-poison { color: #4f2a8a; background: rgba(201, 155, 255, 0.45); border-color: rgba(155, 95, 235, 0.6); }
.move-type.type-ground { color: #6b4a1a; background: rgba(224, 182, 122, 0.45); border-color: rgba(200, 150, 90, 0.6); }
.move-type.type-flying { color: #3a4b88; background: rgba(183, 200, 255, 0.45); border-color: rgba(120, 150, 230, 0.6); }
.move-type.type-psychic { color: #7a1f4e; background: rgba(255, 127, 184, 0.45); border-color: rgba(230, 70, 140, 0.6); }
.move-type.type-bug { color: #4f6b1a; background: rgba(198, 255, 122, 0.45); border-color: rgba(150, 210, 80, 0.6); }
.move-type.type-rock { color: #6b5b1a; background: rgba(214, 193, 122, 0.45); border-color: rgba(190, 165, 90, 0.6); }
.move-type.type-ghost { color: #3a2a7a; background: rgba(181, 155, 255, 0.45); border-color: rgba(130, 100, 220, 0.6); }
.move-type.type-dragon { color: #1f2b7a; background: rgba(122, 139, 255, 0.45); border-color: rgba(80, 110, 230, 0.6); }
.move-type.type-dark { color: #4a2f1a; background: rgba(194, 162, 138, 0.45); border-color: rgba(160, 120, 95, 0.6); }
.move-type.type-steel { color: #3a4a5a; background: rgba(199, 211, 224, 0.5); border-color: rgba(140, 160, 185, 0.6); }
.move-type.type-fairy { color: #7a2a5a; background: rgba(255, 183, 232, 0.5); border-color: rgba(230, 120, 190, 0.6); }

.type-chip {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  background: rgba(255, 255, 255, 0.12);
}

.section-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: none;
  color: var(--accent-2);
  background: rgba(79, 209, 197, 0.14);
  border: 1px solid rgba(79, 209, 197, 0.28);
}

.card-art {
  position: relative;
  height: 160px;
  margin: 10px 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-art img {
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.4));
  animation: float 3s ease-in-out infinite;
}

.battle-card.enemy .card-art img {
  transform: scaleX(-1);
}

.card-stats {
  display: grid;
  gap: 6px;
}

.hp-bar {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  overflow: hidden;
  height: 10px;
}

.hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #6dff75, #ffcf4a, #ff6a6a);
  transition: width 0.4s ease;
}

.hp-text {
  font-size: 0.75rem;
  color: var(--muted);
}

.status-line {
  font-size: 0.75rem;
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stat-line {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--muted);
}

.impact-fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
}

.impact-fx::before {
  content: "";
  position: absolute;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.7);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.3);
  opacity: 0;
}

.impact-fx.active {
  animation: impactFlash 0.4s ease-out;
}

.impact-fx.active::before {
  animation: shockwave 0.45s ease-out;
}

.capture-fx {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 3px solid #111;
  background: linear-gradient(180deg, #ff4b4b 0%, #ff4b4b 48%, #111 48%, #111 52%, #f7f7f7 52%, #f7f7f7 100%);
  transform: translate(-50%, -50%) scale(0.2);
  opacity: 0;
  pointer-events: none;
  z-index: 3;
}

.capture-fx::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #f7f7f7;
  border: 4px solid #111;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.6);
}

.capture-fx.success {
  box-shadow: 0 0 25px rgba(102, 224, 255, 0.65);
  animation: captureSuccess 1s ease-out;
}

.capture-fx.fail {
  filter: grayscale(0.6);
  animation: captureFail 0.7s ease-out;
}

.capture-text {
  position: absolute;
  top: 20%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  font-size: clamp(1.4rem, 3vw, 2.4rem);
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  z-index: 4;
  text-shadow: 0 0 20px rgba(0, 0, 0, 0.4);
}

.capture-text.show {
  animation: captureTextPop 0.9s ease-out;
}

.capture-text.success {
  color: #6dff75;
}

.capture-text.fail {
  color: #ff6a6a;
}

.evolution-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  gap: 8px;
  font-family: "Bebas Neue", "Trebuchet MS", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #ffe9b5;
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.35s ease, transform 0.35s ease;
  background: radial-gradient(circle at center, rgba(255, 198, 99, 0.18), transparent 65%);
  text-shadow: 0 0 30px rgba(255, 216, 140, 0.6);
  pointer-events: none;
  z-index: 7;
}

.evolution-overlay.show {
  opacity: 1;
  transform: scale(1);
}

.evolution-title {
  font-size: clamp(2.4rem, 6vw, 3.4rem);
}

.evolution-name {
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  font-weight: 700;
}

.run-end-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: "Bebas Neue", "Trebuchet MS", sans-serif;
  font-size: clamp(2.6rem, 7vw, 4.2rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  opacity: 0;
  transform: scale(0.96);
  transition: opacity 0.35s ease, transform 0.35s ease;
  background: radial-gradient(circle at center, rgba(0, 0, 0, 0.35), transparent 65%);
  text-shadow: 0 0 20px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  z-index: 6;
}

.run-end-overlay.show {
  opacity: 1;
  transform: scale(1);
}

.run-end-overlay.win {
  color: #b7ffce;
  text-shadow: 0 0 26px rgba(183, 255, 206, 0.6);
}

.run-end-overlay.lose {
  color: #ffb3b3;
  text-shadow: 0 0 26px rgba(255, 179, 179, 0.6);
}

.drawer {
  position: fixed;
  top: 96px;
  right: 24px;
  width: min(360px, 92vw);
  max-height: calc(100vh - 140px);
  background: rgba(10, 14, 24, 0.96);
  border-radius: 18px;
  border: 1px solid var(--stroke);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
  padding: 14px 16px 16px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 8px;
  transform: translateX(120%);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
  z-index: 5;
  overflow: hidden;
}

.drawer.open {
  transform: translateX(0);
  opacity: 1;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.drawer h2 {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.drawer .log,
.drawer .history {
  max-height: 100%;
  overflow-y: auto;
}

.hud {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(520px, 760px) minmax(220px, 280px);
  gap: 18px;
  margin-top: 20px;
  width: min(1200px, 94vw);
  justify-content: center;
  justify-items: center;
  align-items: start;
}

.panel {
  background: rgba(10, 14, 22, 0.92);
  border-radius: 20px;
  padding: 18px;
  border: 1px solid var(--stroke);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.panel.actions {
  border-color: rgba(247, 192, 74, 0.45);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.55), 0 0 30px rgba(247, 192, 74, 0.2);
  width: 100%;
}

.panel.inventory-panel {
  border-color: rgba(79, 209, 197, 0.25);
  background: rgba(10, 14, 22, 0.82);
  width: 100%;
}

.panel h2 {
  margin: 0 0 12px 0;
  font-size: 1rem;
  letter-spacing: 0.18em;
  text-transform: none;
}

.inventory {
  display: grid;
  gap: 8px;
}

.status-section {
  display: grid;
  gap: 6px;
  padding: 8px 0;
}

.status-title {
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent-2);
}

.inventory .item {
  display: flex;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.party-line {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.party-types {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.inventory .item.captured {
  border-color: rgba(102, 224, 255, 0.6);
  box-shadow: 0 0 18px rgba(102, 224, 255, 0.45);
  animation: capturedPulse 0.9s ease-out;
}

.box-tools {
  display: grid;
  gap: 6px;
}

.box-tools input,
.box-tools select {
  width: min(260px, 100%);
  margin: 0 auto;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: rgba(0, 0, 0, 0.2);
  color: var(--ink);
  font-size: 0.85rem;
}

.box-list {
  display: grid;
  gap: 6px;
  width: min(260px, 100%);
  margin: 0 auto;
  max-height: 220px;
  overflow-y: auto;
}

.box-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.85rem;
}

.box-item span:last-child {
  color: var(--muted);
  font-size: 0.8rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(8, 12, 22, 0.75);
  z-index: 5;
}

.modal-overlay.show {
  display: flex;
}

.modal-card {
  background: rgba(10, 14, 24, 0.95);
  border: 1px solid var(--stroke);
  border-radius: 16px;
  padding: 18px;
  width: min(320px, 80vw);
  text-align: center;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.5);
}

.modal-card h3 {
  margin: 0 0 8px 0;
}

.modal-card p {
  margin: 0 0 14px 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.modal-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.action-area {
  display: grid;
  gap: 12px;
  justify-items: stretch;
  align-items: center;
}

.action-note {
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(79, 209, 197, 0.12);
  border: 1px solid rgba(79, 209, 197, 0.25);
  font-size: 0.9rem;
  color: var(--accent-2);
  text-align: center;
  width: min(520px, 100%);
  margin: 0 auto;
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 12px;
  justify-content: center;
  justify-items: stretch;
  width: min(520px, 100%);
  margin: 0 auto;
}

.button-grid button {
  width: 100%;
}

.button-grid button {
  text-transform: none;
}

.button-grid button.move-btn {
  background: #ffffff;
  color: #121212;
  border: 1px solid #e6e6e6;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.2);
}

.move-name {
  font-weight: 700;
}

.move-type {
  margin-left: 8px;
  font-size: 0.7rem;
  font-weight: 800;
  color: #0d0f12;
}

.move-pp {
  display: inline-block;
  margin-left: 8px;
  font-size: 0.7rem;
  font-weight: 800;
  color: #0d0f12;
}

.action-area > button,
.start-area > button {
  width: min(520px, 100%);
  margin: 0 auto;
}

.divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 12px 0;
}

.start-card {
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
  text-align: center;
}

.start-link {
  margin: 10px auto 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--accent-2);
  letter-spacing: 0.14em;
  text-align: center;
  cursor: pointer;
  text-decoration: none;
  width: fit-content;
  position: relative;
  text-shadow: 0 0 14px rgba(79, 209, 197, 0.45);
}

.start-link::after {
  content: " ▸";
  font-weight: 800;
}

.start-link::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 60%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-2), transparent);
  transform: translateX(-50%);
  opacity: 0.8;
}

.start-link:hover {
  color: #b4fff5;
  text-shadow: 0 0 18px rgba(79, 209, 197, 0.7);
}

label {
  display: block;
  font-size: 0.8rem;
  margin-bottom: 6px;
  color: var(--muted);
  text-align: center;
}

input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: rgba(0, 0, 0, 0.2);
  color: var(--ink);
}

.panel.actions {
  text-align: center;
}

.panel.inventory-panel {
  text-align: left;
}

.start-area,
.inventory {
  display: grid;
  gap: 10px;
  justify-items: center;
}

.panel.inventory-panel .inventory {
  justify-items: stretch;
}

.panel.inventory-panel .status-section {
  align-items: stretch;
}

.start-area input {
  max-width: 280px;
  margin: 0 auto;
}

.inventory .item {
  width: 100%;
  margin: 0;
}

.inventory .status-section {
  width: 100%;
}

.inventory .status-title {
  text-align: left;
}

.panel.inventory-panel.left .status-title,
.panel.inventory-panel.right .status-title {
  text-align: left;
}

.log {
  max-height: 240px;
  overflow-y: auto;
  display: grid;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.log .entry {
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  display: flex;
  gap: 8px;
  align-items: flex-start;
  line-height: 1.35;
}

.log .entry.log-player {
  color: #e6fff6;
  background: rgba(79, 209, 197, 0.16);
  border: 1px solid rgba(79, 209, 197, 0.35);
}

.log .entry.log-enemy {
  color: #ffecec;
  background: rgba(255, 120, 120, 0.16);
  border: 1px solid rgba(255, 120, 120, 0.35);
}

.log .entry.log-system {
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.log .entry .log-prefix {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  opacity: 0.95;
}

.log .entry.log-player .log-prefix {
  color: #54f3d8;
}

.log .entry.log-enemy .log-prefix {
  color: #ff8f8f;
}

.log .entry.log-system .log-prefix {
  color: var(--muted);
}

.log .entry .log-message {
  flex: 1;
}

.log .entry .log-damage {
  color: #ff9a5b;
  font-weight: 800;
}

.log-separator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.log-separator::before,
.log-separator::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.18);
}

.history {
  display: grid;
  gap: 8px;
  font-size: 0.85rem;
}

.history .entry {
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
}

.battle-card.attack {
  animation: cardRushPlayer 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.battle-card.enemy.attack {
  animation: cardRushEnemy 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.battle-card.hit {
  animation: cardHitPlayer 0.28s ease-out;
}

.battle-card.enemy.hit {
  animation: cardHitEnemy 0.28s ease-out;
}

.battle-card.attack .card-shell {
  animation: lungePlayer 0.4s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.battle-card.enemy.attack .card-shell {
  animation: lungeEnemy 0.4s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.battle-card.hit .card-shell {
  animation: hitShakePlayer 0.28s ease-out;
}

.battle-card.enemy.hit .card-shell {
  animation: hitShakeEnemy 0.28s ease-out;
}

.battle-card.heal .card-shell {
  animation: healGlow 0.6s ease-out;
}

.battle-card.reward .card-shell {
  animation: rewardGlow 0.6s ease-out;
}

body.shake {
  animation: screenShake 0.2s ease-out;
}

@keyframes holo {
  0% {
    transform: translateX(-60%);
  }
  50% {
    transform: translateX(0%);
  }
  100% {
    transform: translateX(60%);
  }
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-6px);
  }
}

@keyframes cardRushPlayer {
  0% {
    transform: translateX(0);
  }
  50% {
    transform: translateX(clamp(40px, 6vw, 90px));
  }
  100% {
    transform: translateX(0);
  }
}

@keyframes cardRushEnemy {
  0% {
    transform: translateX(0);
  }
  50% {
    transform: translateX(clamp(-90px, -6vw, -40px));
  }
  100% {
    transform: translateX(0);
  }
}

@keyframes cardHitPlayer {
  0% {
    transform: translateX(0);
  }
  30% {
    transform: translateX(-12px);
  }
  60% {
    transform: translateX(10px);
  }
  100% {
    transform: translateX(0);
  }
}

@keyframes cardHitEnemy {
  0% {
    transform: translateX(0);
  }
  30% {
    transform: translateX(12px);
  }
  60% {
    transform: translateX(-10px);
  }
  100% {
    transform: translateX(0);
  }
}

@keyframes lungePlayer {
  0% {
    transform: rotateX(10deg) rotateY(-10deg) translateX(0) scale(1);
  }
  45% {
    transform: rotateX(6deg) rotateY(-4deg) translateX(clamp(70px, 12vw, 170px)) scale(1.08);
  }
  70% {
    transform: rotateX(8deg) rotateY(-6deg) translateX(clamp(50px, 9vw, 130px)) scale(1.04);
  }
  100% {
    transform: rotateX(10deg) rotateY(-10deg) translateX(0) scale(1);
  }
}

@keyframes lungeEnemy {
  0% {
    transform: rotateX(10deg) rotateY(10deg) translateX(0) scale(1);
  }
  45% {
    transform: rotateX(6deg) rotateY(4deg) translateX(clamp(-170px, -12vw, -70px)) scale(1.08);
  }
  70% {
    transform: rotateX(8deg) rotateY(6deg) translateX(clamp(-130px, -9vw, -50px)) scale(1.04);
  }
  100% {
    transform: rotateX(10deg) rotateY(10deg) translateX(0) scale(1);
  }
}

@keyframes hitShakePlayer {
  0% {
    transform: rotateX(10deg) rotateY(-10deg) translateX(0);
  }
  30% {
    transform: rotateX(10deg) rotateY(-8deg) translateX(-14px) rotateZ(-1deg);
  }
  60% {
    transform: rotateX(10deg) rotateY(-12deg) translateX(10px) rotateZ(1deg);
  }
  100% {
    transform: rotateX(10deg) rotateY(-10deg) translateX(0);
  }
}

@keyframes hitShakeEnemy {
  0% {
    transform: rotateX(10deg) rotateY(10deg) translateX(0);
  }
  30% {
    transform: rotateX(10deg) rotateY(8deg) translateX(14px) rotateZ(1deg);
  }
  60% {
    transform: rotateX(10deg) rotateY(12deg) translateX(-10px) rotateZ(-1deg);
  }
  100% {
    transform: rotateX(10deg) rotateY(10deg) translateX(0);
  }
}

@keyframes healGlow {
  0% {
    box-shadow: var(--glow);
  }
  50% {
    box-shadow: 0 0 40px rgba(109, 255, 117, 0.7);
  }
  100% {
    box-shadow: var(--glow);
  }
}

@keyframes rewardGlow {
  0% {
    box-shadow: var(--glow);
  }
  50% {
    box-shadow: 0 0 40px rgba(255, 179, 71, 0.7);
  }
  100% {
    box-shadow: var(--glow);
  }
}

@keyframes capturedPulse {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.04);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes nextPulse {
  0% {
    box-shadow: 0 0 18px rgba(255, 193, 77, 0.45),
      0 10px 24px rgba(0, 0, 0, 0.35);
  }
  50% {
    box-shadow: 0 0 28px rgba(255, 193, 77, 0.8),
      0 14px 30px rgba(0, 0, 0, 0.45);
  }
  100% {
    box-shadow: 0 0 18px rgba(255, 193, 77, 0.45),
      0 10px 24px rgba(0, 0, 0, 0.35);
  }
}

@keyframes impactFlash {
  0% {
    opacity: 0;
  }
  50% {
    opacity: 1;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.6), transparent 60%);
  }
  100% {
    opacity: 0;
  }
}

@keyframes shockwave {
  0% {
    opacity: 0.8;
    transform: translate(-50%, -50%) scale(0.3);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.4);
  }
}

@keyframes captureSuccess {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.2);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  45% {
    transform: translate(-50%, -50%) rotate(8deg) scale(1);
  }
  65% {
    transform: translate(-50%, -50%) rotate(-8deg) scale(1);
  }
  85% {
    transform: translate(-50%, -50%) rotate(4deg) scale(0.95);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.05);
  }
}

@keyframes captureFail {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.2);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  45% {
    transform: translate(-50%, -50%) rotate(-10deg) scale(0.98);
  }
  70% {
    transform: translate(-50%, -50%) rotate(10deg) scale(0.9);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.85);
  }
}

@keyframes captureTextPop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
  }
  30% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.05);
  }
  70% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.95);
  }
}
@keyframes screenShake {
  0% {
    transform: translate(0);
  }
  25% {
    transform: translate(4px, -2px);
  }
  50% {
    transform: translate(-4px, 2px);
  }
  75% {
    transform: translate(3px, 1px);
  }
  100% {
    transform: translate(0);
  }
}

@media (min-width: 960px) {
  .panel.actions {
    min-height: 340px;
  }
}

@media (max-width: 960px) {
  .hud {
    grid-template-columns: 1fr;
  }

  .panel.inventory-panel {
    text-align: center;
  }

  .inventory .status-title {
    text-align: center;
  }
}

@media (max-width: 800px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .card-zone {
    flex-direction: column;
  }

  .battle-card {
    width: 100%;
  }

  .drawer {
    top: 140px;
    right: 12px;
    left: 12px;
    width: auto;
  }

  .button-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  body:not(.force-motion) * {
    animation: none !important;
    transition: none !important;
  }
}
