* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Microsoft JhengHei", "PingFang TC", sans-serif;
  background: linear-gradient(180deg, #8ec9f0 0%, #cdeaff 55%, #d9f7d1 100%);
  overflow-x: hidden;
  position: relative;
  padding-bottom: 40px;
}

/* --- background clouds --- */
.sky { position: absolute; inset: 0; overflow: hidden; z-index: 0; pointer-events: none; }
.cloud {
  position: absolute;
  background: #fff;
  border-radius: 50px;
  opacity: 0.8;
  filter: blur(1px);
}
.cloud::before, .cloud::after {
  content: "";
  position: absolute;
  background: #fff;
  border-radius: 50%;
}
.c1 { width: 120px; height: 40px; top: 40px; left: 5%; animation: drift 40s linear infinite; }
.c1::before { width: 60px; height: 60px; top: -25px; left: 10px; }
.c1::after { width: 50px; height: 50px; top: -18px; left: 55px; }
.c2 { width: 100px; height: 35px; top: 120px; left: 60%; animation: drift 55s linear infinite; }
.c2::before { width: 50px; height: 50px; top: -20px; left: 8px; }
.c2::after { width: 40px; height: 40px; top: -15px; left: 45px; }
.c3 { width: 80px; height: 30px; top: 20px; left: 80%; animation: drift 30s linear infinite; }
.c3::before { width: 40px; height: 40px; top: -15px; left: 5px; }
.c3::after { width: 35px; height: 35px; top: -12px; left: 35px; }

@keyframes drift {
  from { transform: translateX(0); }
  to { transform: translateX(-120vw); }
}

h1 {
  position: relative;
  z-index: 1;
  text-align: center;
  color: #2c3e50;
  text-shadow: 2px 2px 0 #fff;
  margin: 20px 0 10px;
  font-size: clamp(20px, 4vw, 32px);
}

.arena {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 20px 60px;
  gap: 10px;
}

.fighter {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

.name-tag {
  font-weight: bold;
  color: #333;
  margin-bottom: 6px;
  font-size: clamp(12px, 2.2vw, 16px);
  white-space: nowrap;
}

.hp-bar {
  width: 90%;
  max-width: 200px;
  height: 14px;
  background: #ddd;
  border: 2px solid #333;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 10px;
}
.hp-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #7ee787, #2ecc71);
  transition: width 0.6s ease;
}
.hp-fill.low { background: linear-gradient(90deg, #ff8a65, #e74c3c); }

.sprite-wrap {
  position: relative;
  width: 140px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sprite.cat {
  font-size: 90px;
  line-height: 1;
  filter: drop-shadow(0 6px 4px rgba(0,0,0,0.2));
  transition: transform 0.15s;
}

/* CSS-drawn pikachu-like electric mouse (original design) */
.sprite.pikachu {
  position: relative;
  width: 100px;
  height: 90px;
  transition: transform 0.15s;
}
.pika-ear {
  position: absolute;
  top: -55px;
  width: 18px;
  height: 60px;
  background: #ffd54f;
  border: 3px solid #4a3b00;
  border-radius: 50% 50% 0 0;
}
.pika-ear::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 3px;
  width: 9px;
  height: 22px;
  background: #2c2c2c;
  border-radius: 50% 50% 0 0;
}
.pika-ear-l { left: 12px; transform: rotate(-15deg); }
.pika-ear-r { right: 12px; transform: rotate(15deg); }
.pika-face {
  position: absolute;
  inset: 0;
  background: #ffd54f;
  border: 3px solid #4a3b00;
  border-radius: 50%;
}
.pika-cheek {
  position: absolute;
  top: 45px;
  width: 20px;
  height: 16px;
  background: #ff5252;
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(255,82,82,0.8);
}
.pika-cheek-l { left: -4px; }
.pika-cheek-r { right: -4px; }
.pika-eye {
  position: absolute;
  top: 30px;
  width: 10px;
  height: 14px;
  background: #222;
  border-radius: 50%;
}
.pika-eye-l { left: 26px; }
.pika-eye-r { right: 26px; }

.hand-choice {
  position: absolute;
  bottom: -6px;
  font-size: 36px;
  opacity: 0;
  transform: scale(0.5);
  transition: all 0.3s ease;
}
.hand-choice.show { opacity: 1; transform: scale(1); }

.battle-zone {
  position: relative;
  width: 140px;
  height: 140px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}
.vs {
  font-size: 24px;
  font-weight: 900;
  color: #ff6f00;
  text-shadow: 2px 2px 0 #fff;
}

.result {
  position: relative;
  z-index: 1;
  text-align: center;
  font-size: clamp(16px, 3vw, 22px);
  font-weight: bold;
  color: #2c3e50;
  min-height: 32px;
  margin-bottom: 16px;
  padding: 0 10px;
}

.choices {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 0 10px;
}

.choice-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 34px;
  background: #fff;
  border: 3px solid #333;
  border-radius: 16px;
  padding: 12px 20px;
  cursor: pointer;
  box-shadow: 0 4px 0 #333;
  transition: transform 0.1s, box-shadow 0.1s;
}
.choice-btn span { font-size: 14px; font-weight: bold; color: #333; }
.choice-btn:hover:not(:disabled) { transform: translateY(-3px); }
.choice-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 #333; }
.choice-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.score-board {
  position: relative;
  z-index: 1;
  text-align: center;
  margin-top: 20px;
  font-size: 16px;
  font-weight: bold;
  color: #34495e;
}

.restart-btn {
  display: block;
  margin: 20px auto 0;
  font-size: 18px;
  font-weight: bold;
  padding: 10px 28px;
  background: #ff6f00;
  color: #fff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 0 #b34700;
  position: relative;
  z-index: 1;
}
.restart-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #b34700; }

/* ---------- attack effects ---------- */

.rocket {
  position: fixed;
  font-size: 40px;
  z-index: 50;
  transform: rotate(90deg);
  animation: rocketFly 0.6s ease-in forwards;
  pointer-events: none;
}
@keyframes rocketFly {
  from { left: var(--start-x); top: var(--start-y); opacity: 1; }
  to   { left: var(--end-x); top: var(--end-y); opacity: 1; }
}

.explosion {
  position: fixed;
  font-size: 70px;
  z-index: 51;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.2);
  animation: boom 0.5s ease-out forwards;
}
@keyframes boom {
  0% { transform: translate(-50%, -50%) scale(0.2); opacity: 1; }
  60% { transform: translate(-50%, -50%) scale(1.4); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.6); opacity: 0; }
}

.lightning-bolt {
  position: fixed;
  font-size: 90px;
  z-index: 50;
  pointer-events: none;
  transform: translate(-50%, -100%);
  animation: strikeDown 0.45s cubic-bezier(.2,.9,.3,1) forwards;
}
@keyframes strikeDown {
  0% { top: -20vh; opacity: 0; }
  40% { opacity: 1; }
  70% { top: var(--target-y); opacity: 1; }
  100% { top: var(--target-y); opacity: 0; }
}

.screen-flash {
  position: fixed;
  inset: 0;
  background: #fff;
  opacity: 0;
  z-index: 49;
  pointer-events: none;
  animation: flash 0.3s ease-out forwards;
}
@keyframes flash {
  0% { opacity: 0.9; }
  100% { opacity: 0; }
}

.shake {
  animation: shakeAnim 0.5s;
}
@keyframes shakeAnim {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px) rotate(-4deg); }
  40% { transform: translateX(9px) rotate(3deg); }
  60% { transform: translateX(-7px) rotate(-2deg); }
  80% { transform: translateX(6px) rotate(2deg); }
}

.flash-hit {
  filter: brightness(2.5) saturate(0.3);
}

.victory-pose {
  animation: bounceWin 0.6s infinite alternate;
}
@keyframes bounceWin {
  from { transform: translateY(0) scale(1); }
  to   { transform: translateY(-14px) scale(1.08); }
}

.ko-text {
  position: fixed;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.5) rotate(-8deg);
  font-size: 64px;
  font-weight: 900;
  color: #ff1744;
  text-shadow: 4px 4px 0 #fff, -2px -2px 0 #fff;
  z-index: 60;
  animation: koPop 0.5s ease-out forwards;
  pointer-events: none;
}
@keyframes koPop {
  0% { transform: translate(-50%, -50%) scale(0.2) rotate(-8deg); opacity: 0; }
  60% { transform: translate(-50%, -50%) scale(1.2) rotate(-8deg); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1) rotate(-8deg); opacity: 1; }
}

@media (max-width: 480px) {
  .sprite-wrap { width: 100px; height: 100px; }
  .sprite.cat { font-size: 60px; }
  .sprite.pikachu { width: 70px; height: 65px; }
  .pika-ear { top: -38px; height: 42px; }
  .battle-zone { width: 60px; height: 100px; }
}
