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

html,
body {
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background:
    radial-gradient(circle at 10% 0, rgba(148, 163, 253, 0.15), transparent 60%),
    radial-gradient(circle at 90% 100%, rgba(52, 211, 153, 0.15), transparent 60%),
    radial-gradient(circle at 50% 10%, rgba(251, 191, 36, 0.08), transparent 55%),
    radial-gradient(circle at 50% 100%, rgba(15, 23, 42, 0.85), #020617 55%, #000000);
  color: #f9fafb;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
}

body.level-1 {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.8), rgba(0, 0, 0, 0.92));
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.game-container {
  width: 100%;
  max-width: 960px;
  height: calc(100vh - 32px);
  background:
    radial-gradient(circle at top left, rgba(76, 29, 149, 0.85), transparent 60%),
    radial-gradient(circle at bottom right, rgba(6, 78, 59, 0.85), transparent 60%),
    linear-gradient(145deg, rgba(15, 23, 42, 0.96), rgba(2, 6, 23, 0.98));
  border-radius: 24px;
  box-shadow:
    0 0 40px rgba(125, 211, 252, 0.32),
    0 24px 80px rgba(0, 0, 0, 0.8);
  padding: 24px 20px 28px;
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(148, 163, 184, 0.35);
  display: flex;
  flex-direction: column;
}

.game-header {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.game-container > main {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center; /* main 内垂直居中 */
  justify-content: center; /* main 内水平居中 */
  padding: 10px 0;
}

.game-header h1 {
  font-size: 1.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow: 0 0 18px rgba(251, 191, 36, 0.55);
}

.game-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  font-size: 0.95rem;
  color: #e5e7eb;
}

.stat-item {
  padding: 6px 10px;
  border-radius: 999px;
  background: radial-gradient(circle at top, rgba(15, 23, 42, 0.95), rgba(15, 23, 42, 0.86));
  border: 1px solid rgba(148, 163, 184, 0.55);
  box-shadow: 0 0 14px rgba(15, 23, 42, 0.85);
}

.game-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

#btn-restart, #btn-next-level, #btn-play-again, #btn-close-modal {
  border: none;
  cursor: pointer;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 500;
  background: linear-gradient(135deg, #7c3aed, #f97316);
  color: #f9fafb;
  box-shadow: 0 10px 30px rgba(148, 163, 253, 0.7);
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

#btn-restart:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 40px rgba(249, 115, 22, 0.9);
}

#btn-restart:active {
  transform: translateY(0);
  box-shadow: 0 8px 22px rgba(79, 70, 229, 0.4);
}

button:disabled {
  opacity: 0.6;
  cursor: default;
  box-shadow: none;
}

select {
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.9rem;
  border: 1px solid rgba(75, 85, 99, 0.9);
  background-color: rgba(15, 23, 42, 0.95);
  color: #e5e7eb;
  outline: none;
}

.game-grid {
  display: grid;
  gap: 12px;
  justify-content: center;
}

.game-grid.grid-level-1 {
  grid-template-columns: repeat(3, 150px);
}

.game-grid.grid-level-2 {
  grid-template-columns: repeat(6, 80px);
}

.card {
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: 16px;
}

.card--pursuer {
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  background: url('assets/img/bg-pursuer.jpg') no-repeat center / cover;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.card--escaper {
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  background: url('assets/img/bg-escaper.jpg') no-repeat center / cover;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}


.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 16px;
  transform-style: preserve-3d;
  transition: transform 0.4s ease, opacity 0.25s ease;
  cursor: pointer;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.9);
}

.card.is-flipped .card-inner,
.card.is-matched .card-inner {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  backface-visibility: hidden;
}

.card-front {
  transform: rotateY(180deg); /* 初始状态下正面朝里，被隐藏 */
  background:
    radial-gradient(circle at 20% 0, rgba(251, 146, 60, 0.5), transparent 60%),
    radial-gradient(circle at 80% 100%, rgba(59, 130, 246, 0.45), transparent 60%),
    linear-gradient(145deg, #020617, #0b1120);
  color: #fefce8;
  font-size: 2rem;
  font-weight: 600;
}

.card-front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 16px;
  display: block;
  filter: contrast(1.05) saturate(1.05);
}

.card-back {
  background:
    linear-gradient(145deg, #020617, #020617 40%, #000000);
  border: 1px solid rgba(252, 211, 77, 0.9);
  position: relative;
  overflow: hidden;
}

.card--pursuer .card-back {
  background:
    radial-gradient(circle at top, rgba(239, 68, 68, 0.65), transparent 55%),
    radial-gradient(circle at bottom, rgba(147, 51, 234, 0.7), transparent 60%),
    linear-gradient(145deg, #111827, #020617 50%, #000000);
}

.card--escaper .card-back {
  background:
    radial-gradient(circle at top, rgba(56, 189, 248, 0.7), transparent 55%),
    radial-gradient(circle at bottom, rgba(45, 212, 191, 0.75), transparent 60%),
    linear-gradient(145deg, #020617, #0f172a 50%, #000000);
}

.card-back::before {
  content: '';
  position: absolute;
  width: 140%;
  height: 140%;
  background-image: linear-gradient(
    135deg,
    rgba(148, 163, 184, 0.1) 25%,
    transparent 25%,
    transparent 50%,
    rgba(148, 163, 184, 0.1) 50%,
    rgba(148, 163, 184, 0.1) 75%,
    transparent 75%,
    transparent
  );
  background-size: 18px 18px;
  opacity: 0.75;
  transform: translate(-20px, -20px) rotate(8deg);
}

.card-back__symbol {
  position: relative;
  z-index: 1;
  width: 60%;
  height: 60%;
  border-radius: 22px;
  border: 2px solid rgba(248, 250, 252, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f9fafb;
  font-weight: 700;
  letter-spacing: 0.18em;
  font-size: 0.85rem;
  text-transform: uppercase;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.9), 0 18px 35px rgba(15, 23, 42, 0.9);
  background: radial-gradient(circle at top, rgba(248, 250, 252, 0.08), transparent 70%);
}

.card.is-matched .card-inner {
  box-shadow: 0 0 0 2px #22c55e, 0 18px 45px rgba(34, 197, 94, 0.7);
  opacity: 0;
  transform: rotateY(180deg) scale(0.9); /* 翻转并缩小，模拟“消除”效果 */
}

.card.is-matched .card-back {
  border-color: #22c55e;
}

.card.disabled {
  pointer-events: none;
}

.card.is-matched {
  background: none;
}

.game-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 20;
}

.game-modal.hidden {
  display: none;
}

.game-modal__content {
  max-width: 400px;
  width: 100%;
  background:
    radial-gradient(circle at top left, rgba(148, 163, 253, 0.2), transparent 60%),
    radial-gradient(circle at bottom right, rgba(52, 211, 153, 0.25), transparent 60%),
    linear-gradient(145deg, #020617, #020617 40%, #000000);
  border-radius: 20px;
  padding: 20px 20px 18px;
  border: 1px solid rgba(75, 85, 99, 0.9);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.75);
  text-align: center;
}

.game-modal__content h2 {
  font-size: 1.4rem;
  margin-bottom: 10px;
  letter-spacing: 0.06em;
  text-shadow: 0 0 18px rgba(249, 115, 22, 0.9);
}

.game-modal__content p {
  font-size: 0.95rem;
  color: #e5e7eb;
  margin-bottom: 14px;
}

.game-modal__actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}

@media (max-width: 640px) {
  .game-container {
    padding: 18px 14px 20px;
    border-radius: 18px;
    height: calc(100vh - 32px);
  }

  .game-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .game-header h1 {
    font-size: 1.3rem;
  }

  .game-controls {
    width: 100%;
    justify-content: space-between;
  }
}

