/* 盛宴 · 拉斐尔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;
  --green-bright: #b8f08a;
  --red: #d64545;
  --red-bright: #ff7a6e;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --cols: 8;
  --rows: 5;
  --player-size: 52px;
  --mate-size: 44px;
}

*,
*::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(920px, calc(100% - 2rem));
  margin: 0 auto;
  display: grid;
  gap: 0.85rem;
}

.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);
}

.hud {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.55rem 1.1rem;
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  color: rgba(242, 234, 216, 0.78);
}

.hud__item {
  padding: 0.25rem 0;
  border-bottom: 1px solid rgba(201, 162, 39, 0.22);
}

.arena {
  position: relative;
  width: 100%;
  aspect-ratio: 8 / 5.2;
  min-height: 280px;
  padding: clamp(0.6rem, 1.8vw, 1rem);
  background:
    radial-gradient(ellipse at 50% 45%, rgba(50, 80, 40, 0.35), transparent 58%),
    linear-gradient(180deg, rgba(18, 22, 14, 0.96), rgba(8, 10, 6, 0.98));
  border: 1px solid rgba(201, 162, 39, 0.28);
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  outline: none;
  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.5),
    0 0 0 2px rgba(90, 160, 80, 0.25);
}

.board {
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  grid-template-rows: repeat(var(--rows), 1fr);
  gap: 3px;
  width: 100%;
  height: 100%;
}

.cell {
  position: relative;
  border: 1px solid rgba(201, 162, 39, 0.14);
  background: rgba(28, 34, 22, 0.75);
  overflow: hidden;
  transition: background 0.25s, border-color 0.25s, box-shadow 0.25s;
}

.cell--start {
  background:
    radial-gradient(circle at 50% 60%, rgba(201, 162, 39, 0.22), transparent 70%),
    rgba(36, 40, 24, 0.85);
  border-color: rgba(201, 162, 39, 0.35);
}

.cell--start::after {
  content: "起";
  position: absolute;
  left: 0.3rem;
  top: 0.2rem;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  color: rgba(201, 162, 39, 0.7);
  pointer-events: none;
}

.cell--goal {
  background:
    linear-gradient(180deg, rgba(90, 200, 90, 0.35), rgba(30, 90, 40, 0.55)),
    rgba(20, 40, 18, 0.9);
  border-color: rgba(140, 230, 120, 0.65);
  box-shadow: inset 0 0 18px rgba(90, 200, 90, 0.35);
}

.cell--goal::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 42%;
  height: 120%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, rgba(160, 255, 140, 0.55), transparent 75%);
  filter: blur(2px);
  pointer-events: none;
  animation: goal-beam 1.6s ease-in-out infinite;
}

.cell--goal::after {
  content: "目标";
  position: absolute;
  right: 0.25rem;
  bottom: 0.15rem;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  color: rgba(200, 255, 170, 0.85);
  z-index: 1;
  pointer-events: none;
}

@keyframes goal-beam {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
}

.cell--path {
  background:
    linear-gradient(180deg, rgba(255, 220, 120, 0.42), rgba(201, 162, 39, 0.28)),
    rgba(60, 48, 18, 0.9);
  border-color: rgba(240, 210, 110, 0.9);
  box-shadow:
    inset 0 0 14px rgba(255, 214, 100, 0.45),
    0 0 10px rgba(201, 162, 39, 0.25);
}

.cell--path::before {
  content: "";
  position: absolute;
  inset: 16%;
  border: 1px solid rgba(255, 230, 150, 0.55);
  box-shadow: inset 0 0 8px rgba(255, 220, 120, 0.35);
  pointer-events: none;
}

.cell--block {
  background:
    radial-gradient(circle at 50% 50%, rgba(40, 30, 50, 0.95), rgba(12, 10, 16, 0.98)),
    #1a1218;
  border-color: rgba(120, 90, 150, 0.55);
  box-shadow: inset 0 0 16px rgba(80, 40, 120, 0.45);
}

.cell--block::before {
  content: "";
  position: absolute;
  inset: 22%;
  border-radius: 50%;
  border: 2px solid rgba(160, 120, 200, 0.55);
  background: radial-gradient(circle, rgba(80, 50, 110, 0.7), transparent 70%);
  pointer-events: none;
}

.cell--block::after {
  content: "阻";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.7rem;
  color: rgba(200, 170, 230, 0.75);
  z-index: 1;
  pointer-events: none;
}

.cell--mate-block {
  border-color: rgba(150, 110, 190, 0.7);
  box-shadow: inset 0 0 18px rgba(100, 60, 150, 0.55);
}

.cell--mate-block::after {
  content: "阻";
}

.cell--red {
  border-color: rgba(214, 69, 69, 0.35);
}

.cell--red.is-warn {
  background: rgba(90, 20, 20, 0.75);
  border-color: rgba(255, 100, 90, 0.75);
  box-shadow: inset 0 0 18px rgba(214, 69, 69, 0.55);
  animation: red-warn 0.45s ease-in-out infinite;
}

.cell--red.is-strike {
  background: rgba(180, 30, 30, 0.9);
  border-color: rgba(255, 150, 130, 0.95);
  box-shadow:
    inset 0 0 24px rgba(255, 80, 60, 0.8),
    0 0 16px rgba(214, 69, 69, 0.45);
}

.cell--red.is-warn::after,
.cell--red.is-strike::after {
  content: "红";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(255, 210, 200, 0.95);
  pointer-events: none;
  z-index: 1;
}

@keyframes red-warn {
  0%,
  100% {
    opacity: 0.75;
  }
  50% {
    opacity: 1;
  }
}

.orb {
  position: absolute;
  left: 50%;
  top: 46%;
  width: min(42%, 36px);
  height: min(42%, 36px);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 28%, #e8ffd0, #6fcf4a 48%, #2f7a28 100%);
  box-shadow:
    0 0 0 2px rgba(255, 220, 180, 0.35),
    0 0 16px rgba(90, 200, 80, 0.55);
  z-index: 2;
  pointer-events: none;
  animation: orb-float 1.8s ease-in-out infinite;
}

.orb.is-taken {
  display: none;
}

@keyframes orb-float {
  0%,
  100% {
    transform: translate(-50%, -50%);
  }
  50% {
    transform: translate(-50%, calc(-50% - 4px));
  }
}

.mate-mark {
  position: absolute;
  left: 0.28rem;
  bottom: 0.15rem;
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  color: rgba(180, 200, 255, 0.7);
  pointer-events: none;
  z-index: 1;
}

.mates {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.player,
.mate {
  position: absolute;
  width: var(--player-size);
  height: auto;
  transform: translate(-50%, -68%);
  z-index: 5;
  pointer-events: none;
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.55));
  transition: left 0.12s linear, top 0.12s linear;
  will-change: left, top;
}

.mate {
  width: var(--mate-size);
  opacity: 0.8;
  z-index: 4;
}

.mate--0 {
  filter:
    drop-shadow(0 6px 10px rgba(0, 0, 0, 0.5))
    hue-rotate(200deg)
    saturate(0.85);
}

.mate--1 {
  filter:
    drop-shadow(0 6px 10px rgba(0, 0, 0, 0.5))
    hue-rotate(120deg)
    saturate(0.9);
}

.mate--2 {
  filter:
    drop-shadow(0 6px 10px rgba(0, 0, 0, 0.5))
    hue-rotate(40deg)
    saturate(0.95);
}

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

.player.is-hit,
.mate.is-hit {
  animation: hit-flash 0.45s ease;
}

@keyframes hit-flash {
  0%,
  100% {
    filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.55));
  }
  40% {
    filter:
      drop-shadow(0 8px 12px rgba(0, 0, 0, 0.55))
      brightness(1.6)
      saturate(0.2);
  }
}

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

.status.is-win {
  color: var(--green-bright);
}

.status.is-warn {
  color: var(--red-bright);
}

.status.is-hint {
  color: rgba(240, 216, 120, 0.92);
}

.controls {
  display: flex;
  justify-content: center;
}

.btn {
  appearance: none;
  border: 1px solid rgba(140, 200, 110, 0.55);
  background: linear-gradient(180deg, rgba(40, 72, 36, 0.92), rgba(18, 28, 14, 0.94));
  color: #f7efd6;
  font-family: inherit;
  font-size: 0.92rem;
  letter-spacing: 0.18em;
  text-indent: 0.18em;
  padding: 0.7rem 1.5rem;
  cursor: pointer;
  transition: transform 0.25s var(--ease), box-shadow 0.25s, border-color 0.25s;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.35),
    0 10px 28px rgba(0, 0, 0, 0.45),
    0 0 24px rgba(90, 160, 80, 0.2);
}

.btn:hover,
.btn:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(180, 230, 140, 0.85);
  outline: none;
}

@media (max-width: 640px) {
  :root {
    --player-size: 40px;
    --mate-size: 34px;
  }

  .practice__tip {
    font-size: 0.8rem;
  }

  .cell--start::after,
  .cell--goal::after,
  .cell--block::after,
  .mate-mark {
    font-size: 0.52rem;
  }
}
