* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-night: #090b12;
  --bg-stage: #17131f;
  --panel: rgba(18, 16, 22, 0.86);
  --panel-strong: rgba(28, 24, 35, 0.94);
  --ink: #f7efe1;
  --muted: #c7bbab;
  --gold: #d9b46b;
  --gold-bright: #f6d89a;
  --blue: #76b9ff;
  --blue-deep: #18365f;
  --red: #f06c5c;
  --red-deep: #5e1616;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

body {
  min-height: 100vh;
  overflow: hidden;
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top, rgba(78, 88, 134, 0.2), transparent 30%),
    radial-gradient(circle at 50% 80%, rgba(210, 125, 70, 0.18), transparent 24%),
    linear-gradient(180deg, #0c1019, #171520 48%, #120e18);
}

.game {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100vh;
  padding: 12px 18px 10px;
  overflow: hidden;
  isolation: isolate;
}

.scene-backdrop,
.stage-floor,
.combatant-aura,
.card-shine {
  pointer-events: none;
}

.scene-backdrop {
  position: absolute;
  inset: 0;
  z-index: -1;
}

.fog,
.stars {
  position: absolute;
  inset: 0;
}

.fog-left {
  background:
    radial-gradient(circle at 10% 45%, rgba(91, 127, 215, 0.28), transparent 28%),
    radial-gradient(circle at 28% 72%, rgba(76, 132, 230, 0.16), transparent 22%);
  filter: blur(18px);
  animation: driftLeft 12s ease-in-out infinite alternate;
}

.fog-right {
  background:
    radial-gradient(circle at 90% 40%, rgba(199, 78, 55, 0.32), transparent 28%),
    radial-gradient(circle at 72% 75%, rgba(245, 171, 87, 0.13), transparent 24%);
  filter: blur(22px);
  animation: driftRight 15s ease-in-out infinite alternate;
}

.stars {
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.6) 1px, transparent 1.5px),
    radial-gradient(circle, rgba(255, 230, 180, 0.45) 1px, transparent 1.5px);
  background-position: 0 0, 22px 34px;
  background-size: 90px 90px, 130px 130px;
  opacity: 0.28;
}

.top-ui {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  border: 1px solid rgba(232, 203, 145, 0.18);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(30, 26, 34, 0.94), rgba(14, 14, 19, 0.88)),
    rgba(0, 0, 0, 0.35);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 16px;
  font-weight: 700;
  color: var(--gold-bright);
}

.chapter-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-align: right;
  color: #fff1ca;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.45);
}

.log {
  align-self: center;
  margin-top: 10px;
  min-width: min(460px, 84vw);
  padding: 10px 18px;
  border: 1px solid rgba(245, 212, 146, 0.2);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(22, 18, 17, 0.88), rgba(10, 10, 12, 0.94));
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  color: #fff2d0;
  box-shadow: 0 14px 24px rgba(0, 0, 0, 0.35);
  animation: logFloat 2.6s ease-in-out infinite;
}

.battlefield {
  position: relative;
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 16px 4px;
  gap: 30px;
}

.stage-floor {
  position: absolute;
  left: 50%;
  bottom: 20px;
  width: min(820px, 80vw);
  height: 110px;
  transform: translateX(-50%);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(220, 178, 99, 0.3), rgba(83, 46, 32, 0.1) 40%, transparent 72%);
  filter: blur(8px);
}

.combatant {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: min(300px, 28vw);
  animation: riseIn 0.8s ease both;
}

.hero {
  align-self: flex-end;
}

.enemy {
  align-self: flex-start;
  animation-delay: 0.1s;
}

.combatant-aura {
  position: absolute;
  inset: 10px 24px auto;
  height: 160px;
  border-radius: 50%;
  filter: blur(22px);
  opacity: 0.75;
}

.hero-aura {
  background: radial-gradient(circle, rgba(86, 165, 255, 0.45), transparent 68%);
}

.enemy-aura {
  background: radial-gradient(circle, rgba(228, 96, 84, 0.48), transparent 70%);
}

.avatar-frame {
  position: relative;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
}

.hero-avatar {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, #7dc8ff, #274a7c 50%, #101627 90%);
  border: 4px solid rgba(149, 210, 255, 0.85);
  font-size: 68px;
  animation: idleFloat 3.6s ease-in-out infinite;
}

.enemy-avatar {
  width: 190px;
  height: 190px;
  border-radius: 24px;
  background:
    radial-gradient(circle at 50% 35%, #ca443d, #5c1117 58%, #18070c 95%);
  border: 4px solid rgba(255, 168, 150, 0.8);
  font-size: 82px;
  animation: bossHover 2.8s ease-in-out infinite;
}

.combatant-panel {
  width: 100%;
  padding: 12px 14px 12px;
  border: 1px solid rgba(225, 197, 133, 0.22);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(39, 31, 37, 0.94), rgba(18, 14, 19, 0.96));
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.34);
}

.enemy-panel {
  border-color: rgba(255, 145, 129, 0.26);
}

.combatant-role {
  margin-bottom: 6px;
  color: var(--gold);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.combatant-name {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(22px, 2.3vw, 30px);
  line-height: 1.05;
  text-shadow: 0 4px 10px rgba(0, 0, 0, 0.36);
}

.enemy-name {
  color: #fff3dd;
}

.healthbar {
  width: 100%;
  height: 16px;
  margin-top: 10px;
  overflow: hidden;
  border: 2px solid rgba(255, 233, 191, 0.16);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
}

.health-fill {
  height: 100%;
  width: 100%;
  background:
    linear-gradient(90deg, #922f2e, #d74b40 50%, #ff957e);
  box-shadow: inset 0 0 16px rgba(255, 245, 224, 0.18);
  transition: width 0.35s ease;
}

.player-health-fill {
  background:
    linear-gradient(90deg, #2f5e99, #5ea0ff 48%, #9ed7ff);
}

.combatant-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  font-size: 14px;
  font-weight: 700;
}

.enemy-meta {
  color: #ffe0ce;
}

.status {
  min-height: 20px;
  margin-top: 8px;
  color: #ffd777;
  font-size: 14px;
  font-weight: 700;
}

.intent-banner {
  margin-bottom: -8px;
  padding: 8px 14px;
  border: 1px solid rgba(237, 186, 102, 0.3);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(50, 24, 18, 0.96), rgba(24, 13, 15, 0.92));
  color: #ffd58a;
  font-size: 16px;
  font-weight: 900;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.34);
  animation: intentPulse 2.2s ease-in-out infinite;
}

.intent-banner.intent-attack {
  border-color: rgba(255, 129, 110, 0.55);
  background: linear-gradient(180deg, rgba(98, 30, 23, 0.98), rgba(46, 13, 15, 0.95));
  color: #ffd4cb;
  box-shadow:
    0 14px 28px rgba(0, 0, 0, 0.34),
    0 0 22px rgba(218, 77, 66, 0.25);
}

.intent-banner.intent-defense {
  border-color: rgba(113, 189, 255, 0.55);
  background: linear-gradient(180deg, rgba(24, 49, 90, 0.98), rgba(12, 24, 53, 0.95));
  color: #d9efff;
  box-shadow:
    0 14px 28px rgba(0, 0, 0, 0.34),
    0 0 22px rgba(86, 165, 255, 0.24);
}

.hand {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 10px;
  padding: 0 6px 2px;
  perspective: 1200px;
}

.card {
  position: relative;
  width: 140px;
  min-height: 190px;
  padding: 12px 12px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  border: 2px solid rgba(255, 236, 201, 0.18);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(83, 70, 55, 0.28), transparent 32%),
    linear-gradient(180deg, #44372b, #1e1821 74%);
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.34);
  cursor: pointer;
  transform-origin: bottom center;
  transition:
    transform 0.22s ease,
    box-shadow 0.22s ease,
    filter 0.22s ease;
  animation: cardEnter 0.7s ease both;
}

.card:nth-child(1) {
  transform: translateY(14px) rotate(-8deg);
  animation-delay: 0.05s;
}

.card:nth-child(2) {
  transform: translateY(6px) rotate(-4deg);
  animation-delay: 0.12s;
}

.card:nth-child(3) {
  transform: translateY(0) rotate(0deg);
  animation-delay: 0.19s;
}

.card:nth-child(4) {
  transform: translateY(6px) rotate(4deg);
  animation-delay: 0.26s;
}

.card:nth-child(5) {
  transform: translateY(14px) rotate(8deg);
  animation-delay: 0.33s;
}

.card:hover {
  transform: translateY(-14px) scale(1.04) rotate(0deg);
  box-shadow: 0 26px 40px rgba(0, 0, 0, 0.44);
  z-index: 3;
}

.card.attack {
  border-color: rgba(235, 109, 96, 0.8);
}

.card.defense {
  border-color: rgba(91, 196, 255, 0.8);
}

.card.debuff {
  border-color: rgba(236, 198, 84, 0.8);
}

.card.disabled {
  cursor: not-allowed;
  filter: grayscale(0.2) brightness(0.78);
  opacity: 0.7;
}

.card.disabled:hover {
  filter: grayscale(0.2) brightness(0.78);
}

.card.played {
  animation: cardCast 0.36s ease;
}

.card-shine {
  position: absolute;
  inset: -35% auto auto -25%;
  width: 72px;
  height: 210%;
  transform: rotate(20deg);
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.18), transparent);
  opacity: 0.4;
}

.card-energy {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 3px solid rgba(255, 247, 229, 0.9);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffcf72, #f1931d 60%, #9d4700);
  color: #fff7ea;
  font-size: 20px;
  font-weight: 900;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.card h3 {
  margin-top: 44px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  line-height: 1.05;
  text-align: center;
  text-wrap: balance;
}

.card-type {
  margin-top: 8px;
  min-height: 24px;
  display: flex;
  align-items: center;
  color: var(--gold);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}

.card p {
  margin-top: 12px;
  flex: 1;
  display: flex;
  align-items: flex-start;
  color: #f6ead2;
  font-size: 15px;
  line-height: 1.22;
  text-align: center;
  text-wrap: balance;
}

.bottom-ui {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 2px;
}

.energy {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  border: 4px solid rgba(255, 245, 214, 0.85);
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, #ffec9d, #ff9f33 50%, #aa3c06 85%);
  color: #fff7e8;
  font-size: 24px;
  font-weight: 900;
  box-shadow:
    0 0 0 8px rgba(255, 186, 70, 0.12),
    0 16px 26px rgba(0, 0, 0, 0.35);
  animation: energyPulse 2s ease-in-out infinite;
}

.end-turn {
  padding: 12px 22px;
  border: 1px solid rgba(255, 232, 180, 0.22);
  border-radius: 16px;
  background:
    linear-gradient(180deg, #5f73ee, #3943a5);
  color: #f7f4ff;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 16px 24px rgba(0, 0, 0, 0.28);
  transition: transform 0.2s ease, filter 0.2s ease;
}

.end-turn:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
}

.hero.hit .hero-avatar,
.enemy.hit .enemy-avatar {
  animation: shakeHit 0.24s linear 1;
}

.hero.blocked .combatant-panel,
.enemy.blocked .combatant-panel {
  animation: blockFlash 0.38s ease;
}

.victory {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 20px;
  background:
    radial-gradient(circle, rgba(255, 240, 188, 0.12), transparent 25%),
    rgba(7, 6, 12, 0.9);
  backdrop-filter: blur(8px);
}

.victory h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(56px, 8vw, 92px);
  color: #ffefbe;
  text-shadow: 0 0 26px rgba(236, 200, 114, 0.35);
}

.victory button {
  padding: 15px 30px;
  border: 1px solid rgba(255, 233, 187, 0.18);
  border-radius: 16px;
  background: linear-gradient(180deg, #586ef2, #37439d);
  color: white;
  font-size: 22px;
  cursor: pointer;
}

@keyframes driftLeft {
  from { transform: translate3d(-1.5%, 0, 0); }
  to { transform: translate3d(1.5%, 2%, 0); }
}

@keyframes driftRight {
  from { transform: translate3d(1.2%, -1%, 0); }
  to { transform: translate3d(-1.2%, 1.4%, 0); }
}

@keyframes logFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes idleFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-9px); }
}

@keyframes bossHover {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px) scale(1.01); }
}

@keyframes intentPulse {
  0%, 100% { box-shadow: 0 14px 28px rgba(0, 0, 0, 0.34); }
  50% { box-shadow: 0 16px 34px rgba(228, 154, 72, 0.18); }
}

@keyframes cardEnter {
  from {
    opacity: 0;
    transform: translateY(80px) scale(0.88);
  }
  to {
    opacity: 1;
  }
}

@keyframes cardCast {
  0% { transform: translateY(-14px) scale(1.02); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes energyPulse {
  0%, 100% {
    box-shadow:
      0 0 0 8px rgba(255, 186, 70, 0.12),
      0 16px 26px rgba(0, 0, 0, 0.35);
  }
  50% {
    box-shadow:
      0 0 0 12px rgba(255, 186, 70, 0.18),
      0 16px 30px rgba(0, 0, 0, 0.42);
  }
}

@keyframes shakeHit {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(10px); }
  50% { transform: translateX(-8px); }
  75% { transform: translateX(6px); }
}

@keyframes blockFlash {
  0% { box-shadow: 0 0 0 rgba(118, 185, 255, 0); }
  50% { box-shadow: 0 0 0 3px rgba(118, 185, 255, 0.35); }
  100% { box-shadow: 0 0 0 rgba(118, 185, 255, 0); }
}

@media (max-width: 1200px) {
  body {
    overflow-y: auto;
  }

  .game {
    min-height: auto;
  }

  .battlefield {
    flex-direction: column;
    padding-top: 28px;
    gap: 28px;
  }

  .combatant {
    width: min(100%, 520px);
  }

  .hand {
    flex-wrap: wrap;
    gap: 18px;
    padding-top: 18px;
  }

  .card,
  .card:nth-child(1),
  .card:nth-child(2),
  .card:nth-child(3),
  .card:nth-child(4),
  .card:nth-child(5) {
    transform: none;
  }
}

@media (max-height: 900px) {
  .battlefield {
    padding-top: 10px;
    gap: 18px;
  }

  .hero-avatar {
    width: 130px;
    height: 130px;
    font-size: 58px;
  }

  .enemy-avatar {
    width: 168px;
    height: 168px;
    font-size: 70px;
  }

  .combatant {
    width: min(270px, 26vw);
  }

  .card {
    width: 126px;
    min-height: 174px;
  }

  .card h3 {
    font-size: 18px;
  }

  .card p {
    font-size: 14px;
  }
}

@media (max-width: 760px) {
  .game {
    padding: 12px 12px 16px;
  }

  .top-ui {
    flex-direction: column;
    align-items: flex-start;
  }

  .chapter-title {
    text-align: left;
    font-size: 20px;
  }

  .stats {
    font-size: 16px;
    gap: 12px;
  }

  .log {
    min-width: 0;
    width: 100%;
    font-size: 16px;
  }

  .hero-avatar {
    width: 156px;
    height: 156px;
    font-size: 72px;
  }

  .enemy-avatar {
    width: 220px;
    height: 220px;
    font-size: 100px;
  }

  .combatant-meta {
    flex-direction: column;
    gap: 6px;
    font-size: 18px;
  }

  .card {
    width: min(100%, 320px);
    min-height: 210px;
  }

  .card h3 {
    font-size: 28px;
  }

  .card p {
    font-size: 20px;
  }

  .bottom-ui {
    position: sticky;
    bottom: 0;
    padding-top: 10px;
    background: linear-gradient(180deg, transparent, rgba(10, 10, 14, 0.85) 22%);
  }
}
