:root {
  --court: #2a1840;
  --gold: #fdb927;
  --purple: #552583;
  --ink: #1a1024;
  --wood: #c48a3a;
  --wood-dark: #8a5a22;
  --paper: #fff7e8;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 20% 0%, #6b3aa0 0%, transparent 45%),
    linear-gradient(180deg, #1c0f2d 0%, #12091c 100%);
  color: var(--paper);
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  user-select: none;
  touch-action: none;
}

.app {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 18px 16px 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 16px;
}

h1 {
  margin: 0;
  font-size: 32px;
  letter-spacing: 2px;
  color: var(--gold);
}

.topbar p {
  margin: 6px 0 0;
  color: #e8d7ff;
  opacity: 0.85;
}

.scores {
  display: flex;
  gap: 10px;
}

.score-card {
  min-width: 92px;
  padding: 8px 14px;
  border-radius: 14px;
  background: rgba(85, 37, 131, 0.7);
  border: 1px solid rgba(253, 185, 39, 0.45);
  text-align: right;
}

.score-card span {
  display: block;
  font-size: 12px;
  color: #f7e7b0;
}

.score-card strong {
  font-size: 26px;
  line-height: 1.2;
}

.stage {
  display: grid;
  grid-template-columns: 120px minmax(280px, 420px) 150px;
  justify-content: center;
  gap: 16px;
  align-items: start;
}

.panel {
  background: rgba(255, 247, 232, 0.08);
  border: 1px solid rgba(253, 185, 39, 0.28);
  border-radius: 18px;
  padding: 12px;
}

.panel span,
.legend-panel span {
  display: block;
  margin-bottom: 10px;
  color: var(--gold);
  font-size: 13px;
}

.next-wrap {
  position: relative;
  width: 88px;
  height: 88px;
  margin: 0 auto;
}

.next-wrap img,
.next-wrap i {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

.next-wrap img {
  object-fit: cover;
  background: #7ec8ff;
}

.next-wrap i {
  box-shadow: inset 0 0 0 5px var(--gold);
  pointer-events: none;
}

.board {
  position: relative;
  width: 420px;
  max-width: 100%;
  height: 640px;
  margin: 0 auto;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 80px),
    repeating-linear-gradient(
      90deg,
      #d59a46 0 28px,
      #c88834 28px 56px
    );
  border: 10px solid #6b4014;
  border-radius: 22px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
}

.dead-label {
  position: absolute;
  top: 108px;
  right: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(180, 30, 30, 0.8);
  color: #fff;
  font-size: 12px;
  pointer-events: none;
}

.legend-panel ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 7px;
}

.legend-panel li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #f6e6c6;
}

.legend-panel img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: #7ec8ff;
}

.legend-panel .max-item img {
  width: 36px;
  height: 36px;
}

.hint {
  text-align: center;
  color: #dcc8f5;
  margin: 16px 0 0;
}

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(10, 4, 18, 0.62);
  padding: 20px;
}

.overlay.hidden {
  display: none;
}

.modal {
  width: min(420px, 100%);
  background: linear-gradient(180deg, #3b1d67, #24103f);
  border: 2px solid var(--gold);
  border-radius: 24px;
  padding: 28px 24px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

.modal h2 {
  margin: 0 0 8px;
  color: var(--gold);
}

.modal p {
  margin: 0 0 10px;
  line-height: 1.6;
}

.modal-score {
  font-size: 20px;
}

button {
  margin-top: 10px;
  border: 0;
  border-radius: 999px;
  padding: 12px 28px;
  background: var(--gold);
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}

.toast {
  position: fixed;
  left: 50%;
  top: 18%;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(253, 185, 39, 0.95);
  color: #2a1400;
  font-weight: 700;
  z-index: 5;
}

@media (max-width: 820px) {
  .stage {
    grid-template-columns: 1fr;
  }

  .panel {
    display: none;
  }

  .board {
    width: min(420px, 100%);
    height: min(640px, calc(100vh - 180px));
  }
}
