/* 盛宴 · 拉斐尔1 机制练习（键盘移动 + 怪物行进） */
@import url("https://fonts.googleapis.com/css2?family=Cinzel:wght@500;700&family=Noto+Serif+SC:wght@400;600;700&display=swap");

:root {
  --ink: #0d0b08;
  --gold: #c9a227;
  --green: #7dce5a;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --player-size: 72px;
  --ball-size: 48px;
  --monster-size: 86px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
  background: var(--ink);
  color: #f2ead8;
  font-family: "Noto Serif SC", "Songti SC", serif;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

.practice {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 2rem;
}

.practice__bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse at 50% 18%, rgba(90, 160, 80, 0.16), transparent 55%),
    linear-gradient(165deg, #12160f 0%, #0d0b08 60%, #141810 100%);
}

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: clamp(1rem, 3vw, 1.6rem) clamp(1.2rem, 4vw, 2.5rem);
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.88rem;
  letter-spacing: 0.18em;
  color: rgba(242, 234, 216, 0.78);
  border-bottom: 1px solid transparent;
  transition: color 0.3s, border-color 0.3s;
}

.back::before {
  content: "←";
  font-family: "Cinzel", serif;
}

.back:hover {
  color: #f7efd6;
  border-color: var(--gold);
}

.topbar__mark {
  font-family: "Cinzel", "Noto Serif SC", serif;
  font-size: 0.82rem;
  letter-spacing: 0.32em;
  text-indent: 0.32em;
  color: rgba(201, 162, 39, 0.85);
}

.practice__main {
  position: relative;
  z-index: 2;
  width: min(1000px, calc(100% - 2rem));
  margin: 0 auto;
  display: grid;
  gap: 0.9rem;
}

.practice__head {
  text-align: center;
}

.practice__title {
  font-family: "Cinzel", "Noto Serif SC", serif;
  font-size: clamp(1.4rem, 4vw, 2rem);
  letter-spacing: 0.24em;
  text-indent: 0.24em;
}

.practice__tip {
  margin-top: 0.55rem;
  font-size: 0.88rem;
  line-height: 1.75;
  color: rgba(242, 234, 216, 0.7);
}

.arena-wrap {
  display: grid;
  gap: 0.45rem;
}

.arena-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  color: rgba(242, 234, 216, 0.65);
  padding: 0 0.2rem;
}

.row__dir {
  color: var(--gold);
}

.arena {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  min-height: 340px;
  background:
    radial-gradient(ellipse at 50% 50%, rgba(40, 60, 30, 0.35), transparent 65%),
    linear-gradient(180deg, rgba(18, 22, 14, 0.92), rgba(10, 12, 8, 0.96));
  border: 1px solid rgba(201, 162, 39, 0.28);
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.45);
  outline: none;
  overflow: hidden;
  touch-action: none;
}

.arena:focus-visible {
  border-color: rgba(140, 200, 110, 0.7);
  box-shadow:
    inset 0 0 60px rgba(0, 0, 0, 0.45),
    0 0 0 2px rgba(125, 206, 90, 0.25);
}

.link-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
  overflow: visible;
}

.link-line {
  stroke: #7dce5a;
  stroke-width: 3;
  stroke-linecap: round;
  filter: drop-shadow(0 0 6px rgba(125, 206, 90, 0.85));
  opacity: 0;
}

.link-line.is-active {
  opacity: 1;
}

.balls-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.ball {
  position: absolute;
  width: var(--ball-size);
  height: var(--ball-size);
  border-radius: 50%;
  border: 2px solid transparent;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 2;
  transition: opacity 0.2s;
}

.ball--green {
  background:
    radial-gradient(circle at 35% 30%, #e8ffc8, #7dce5a 45%, #2f6b28 100%);
  box-shadow:
    0 0 16px rgba(125, 206, 90, 0.45),
    inset 0 -8px 16px rgba(0, 0, 0, 0.25);
}

.ball--dark {
  background:
    radial-gradient(circle at 35% 30%, #c07090, #5a2a6e 45%, #1a0a22 100%);
  box-shadow:
    0 0 16px rgba(120, 40, 100, 0.4),
    inset 0 -8px 16px rgba(0, 0, 0, 0.35);
}

.ball.is-linked {
  border-color: #e8ffc8;
  box-shadow:
    0 0 0 3px rgba(125, 206, 90, 0.45),
    0 0 22px rgba(125, 206, 90, 0.65);
}

.ball.is-target-zone::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px dashed rgba(125, 206, 90, 0.35);
  pointer-events: none;
}

.ball.is-swapping {
  z-index: 6;
  transition: left 0.5s var(--ease), top 0.5s var(--ease);
}

.ball.is-eaten {
  opacity: 0;
  visibility: hidden;
}

.monster {
  position: absolute;
  width: var(--monster-size);
  height: calc(var(--monster-size) * 1.35);
  transform: translate(-50%, -50%);
  z-index: 3;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.monster__hp {
  width: 70%;
  height: 7px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.2);
  overflow: hidden;
  flex-shrink: 0;
}

.monster__hp > i {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #8b1e1e, #e04545);
  transform-origin: left center;
  transition: transform 0.2s linear;
}

.monster__img {
  width: 100%;
  height: auto;
  max-height: calc(100% - 12px);
  object-fit: contain;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.55));
  transform-origin: center center;
}

.monster.is-dead {
  opacity: 0.35;
  filter: grayscale(0.8);
}

.monster.is-dead .monster__img {
  animation: none;
}

.monster.is-complete {
  z-index: 4;
}

.monster.is-complete .monster__img {
  filter:
    drop-shadow(0 0 10px rgba(255, 214, 90, 0.95))
    drop-shadow(0 0 22px rgba(201, 162, 39, 0.85))
    drop-shadow(0 8px 14px rgba(0, 0, 0, 0.45));
  animation: gold-pulse 1.4s ease-in-out infinite;
}

.monster.is-complete::before {
  content: "";
  position: absolute;
  inset: 8% 12% 18%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 220, 120, 0.45), transparent 70%);
  pointer-events: none;
  z-index: -1;
  animation: gold-glow 1.4s ease-in-out infinite;
}

@keyframes gold-pulse {
  0%,
  100% {
    filter:
      drop-shadow(0 0 8px rgba(255, 214, 90, 0.75))
      drop-shadow(0 0 18px rgba(201, 162, 39, 0.65))
      drop-shadow(0 8px 14px rgba(0, 0, 0, 0.45));
  }
  50% {
    filter:
      drop-shadow(0 0 16px rgba(255, 230, 140, 1))
      drop-shadow(0 0 32px rgba(255, 200, 60, 0.95))
      drop-shadow(0 8px 14px rgba(0, 0, 0, 0.45));
  }
}

@keyframes gold-glow {
  0%,
  100% {
    opacity: 0.55;
    transform: scale(0.95);
  }
  50% {
    opacity: 1;
    transform: scale(1.12);
  }
}

.player {
  position: absolute;
  width: var(--player-size);
  height: var(--player-size);
  object-fit: contain;
  transform: translate(-50%, -50%) scaleX(1);
  transform-origin: center center;
  z-index: 4;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.55));
}

.player.is-left {
  transform: translate(-50%, -50%) scaleX(-1);
}

.player.is-right {
  transform: translate(-50%, -50%) scaleX(1);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
}

.btn {
  appearance: none;
  border: 1px solid rgba(201, 162, 39, 0.45);
  background: rgba(26, 22, 16, 0.85);
  color: #f7efd6;
  font: inherit;
  font-size: 0.9rem;
  letter-spacing: 0.16em;
  padding: 0.65rem 1.2rem;
  cursor: pointer;
  transition: border-color 0.25s, transform 0.25s, background 0.25s;
}

.btn:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
}

.btn--primary {
  background: linear-gradient(180deg, rgba(40, 72, 36, 0.92), rgba(18, 28, 14, 0.94));
  border-color: rgba(140, 200, 110, 0.55);
}

.status {
  min-height: 1.5rem;
  text-align: center;
  font-size: 0.95rem;
  letter-spacing: 0.12em;
  color: rgba(242, 234, 216, 0.75);
}

.status.is-win {
  color: var(--green);
  text-shadow: 0 0 18px rgba(125, 206, 90, 0.45);
}

.status.is-hint {
  color: rgba(201, 162, 39, 0.9);
}

.status.is-lose {
  color: #e07070;
}

@media (max-width: 640px) {
  .arena {
    aspect-ratio: 4 / 5;
    min-height: 400px;
  }

  :root {
    --player-size: 58px;
    --ball-size: 48px;
    --monster-size: 70px;
  }
}
