:root {
  color-scheme: light;
  --bg-top: #edf6e9;
  --bg-bottom: #dfeedd;
  --paper: #ffffff;
  --ink: #111111;
  --green: #38ab3d;
  --green-deep: #26822b;
  --green-soft: #d8f0d5;
  --gold: #ffc928;
  --gold-deep: #f0a300;
  --line: #1f8e35;
  --shadow: 0 18px 50px rgba(28, 48, 21, 0.14);
  --board-border: #1d1d1d;
  --font-display: "Arial Black", "Microsoft YaHei", "PingFang SC",
    "Hiragino Sans GB", sans-serif;
  --font-body: "Trebuchet MS", "Microsoft YaHei", "PingFang SC",
    "Hiragino Sans GB", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.72), transparent 32%),
    radial-gradient(circle at 85% 10%, rgba(67, 183, 72, 0.13), transparent 24%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  color: var(--ink);
}

button {
  font: inherit;
}

#app {
  min-height: 100vh;
  padding: 16px;
}

.app-shell {
  max-width: 760px;
  margin: 0 auto;
}

[hidden] {
  display: none !important;
}

.hero-card,
.game-card {
  position: relative;
  overflow: hidden;
  border: 2px solid rgba(17, 17, 17, 0.12);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0.96)),
    linear-gradient(180deg, #eef7e9, #f8fbf6);
  box-shadow: var(--shadow);
}

.hero-card {
  padding: 24px 20px 28px;
}

.hero-card.is-result {
  padding-top: 30px;
}

.game-card {
  padding: 18px 14px 24px;
}

.festival-label {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #23853b;
}

.hero-line {
  width: 100%;
  height: 8px;
  margin-top: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, #2c9f3d 0 58%, #ffc52e 58% 85%, #289a38 85%);
}

.hero-line.is-compact {
  max-width: 220px;
}

.hero-stars {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.hero-stars span {
  width: 12px;
  height: 12px;
  background: radial-gradient(circle at 50% 50%, #1e1e1e 0 45%, transparent 48%);
  transform: rotate(45deg);
  box-shadow: 0 0 0 6px rgba(56, 171, 61, 0.14);
}

.happy-label {
  margin: 12px 0 0;
  font-size: 1.55rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: var(--gold-deep);
}

.happy-label.is-small {
  margin-top: 0;
  font-size: 1rem;
}

.hero-title,
.game-title {
  margin: 4px 0 0;
  font-family: var(--font-display);
  font-weight: 900;
  line-height: 0.94;
  letter-spacing: -0.04em;
}

.hero-title {
  font-size: clamp(3rem, 12vw, 5.25rem);
}

.hero-title.is-result {
  font-size: clamp(2.5rem, 10vw, 4.4rem);
}

.game-title {
  font-size: clamp(2rem, 6vw, 3rem);
}

.rule-banner {
  margin: 18px 0 0;
  padding: 11px 14px;
  border: 2px solid rgba(17, 17, 17, 0.18);
  background: linear-gradient(180deg, #ffd13c, #ffbf00);
  font-size: 1rem;
  font-weight: 900;
  line-height: 1.4;
}

.rule-banner.is-game {
  margin-top: 16px;
  font-size: 0.96rem;
}

.cover-preview {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin: 22px 0 20px;
  padding: 16px;
  border: 2px solid rgba(17, 17, 17, 0.12);
  background: rgba(255, 255, 255, 0.8);
}

.preview-dot,
.preview-zongzi {
  aspect-ratio: 1;
  border-radius: 50%;
}

.preview-dot {
  background: radial-gradient(circle at 34% 34%, #ffffff 0 42%, #edeae4 64%, #d8d0c5 100%);
  box-shadow: inset 0 -2px 4px rgba(157, 144, 124, 0.18);
}

.preview-dot.is-path {
  background: radial-gradient(circle at 35% 30%, #8cf38c 0 42%, #44c74c 64%, #1c8e2e 100%);
}

.preview-zongzi {
  position: relative;
  background: linear-gradient(180deg, #58d463, #27a138);
  clip-path: polygon(50% 4%, 96% 92%, 4% 92%);
  border-radius: 20% 20% 12% 12%;
  transform: translateY(-6%);
}

.preview-zongzi::before,
.preview-zongzi::after {
  content: "";
  position: absolute;
  top: 18%;
  width: 16%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.15);
}

.preview-zongzi::before {
  left: 30%;
}

.preview-zongzi::after {
  right: 30%;
}

.primary-button,
.ghost-button {
  min-height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  border: 2px solid transparent;
  font-weight: 900;
  letter-spacing: 0.03em;
  cursor: pointer;
}

.primary-button {
  width: 100%;
  background: linear-gradient(180deg, #32b63d, #258c31);
  color: #ffffff;
  box-shadow: 0 14px 26px rgba(37, 140, 49, 0.24);
}

.ghost-button {
  background: rgba(255, 255, 255, 0.75);
  border-color: rgba(17, 17, 17, 0.12);
  color: var(--ink);
}

.game-header,
.level-head,
.action-row,
.modal-actions,
.action-stack {
  display: flex;
  gap: 12px;
}

.game-header,
.level-head {
  justify-content: space-between;
  align-items: flex-end;
}

.header-copy {
  text-align: right;
}

.progress-row {
  display: flex;
  gap: 8px;
  margin: 16px 0 10px;
  flex-wrap: wrap;
}

.progress-step {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(38, 130, 43, 0.08);
  color: rgba(17, 17, 17, 0.7);
  font-size: 0.9rem;
  font-weight: 800;
}

.progress-step.is-current {
  background: #1d1d1d;
  color: #ffffff;
}

.progress-step.is-complete {
  background: rgba(38, 130, 43, 0.22);
  color: #155f23;
}

.level-head {
  align-items: center;
  margin-bottom: 14px;
}

.level-kicker,
.level-subtitle,
.result-copy,
.modal-body,
.tip-text {
  margin: 0;
}

.level-kicker {
  font-size: 0.92rem;
  font-weight: 800;
  color: #247637;
}

.level-title {
  margin: 6px 0 4px;
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  line-height: 1.05;
}

.level-subtitle,
.result-copy,
.modal-body,
.tip-text {
  font-size: 0.98rem;
  line-height: 1.55;
  color: rgba(17, 17, 17, 0.72);
}

.status-panel {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.status-pill,
.progress-pill {
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 900;
}

.status-pill {
  background: rgba(255, 201, 40, 0.3);
}

.progress-pill {
  background: rgba(38, 130, 43, 0.12);
  color: #1c672b;
}

.board-shell {
  position: relative;
  overflow: hidden;
  border: 2px solid var(--board-border);
  background: linear-gradient(180deg, #ffffff, #fbfbfb);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
  touch-action: none;
}

.board-path,
.board-grid {
  position: absolute;
  inset: 0;
}

.board-path {
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.board-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows), minmax(0, 1fr));
}

.board-shell::before {
  content: "";
  display: block;
  padding-top: calc(var(--rows) / var(--cols) * 100%);
}

.board-cell {
  position: relative;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
}

.board-cell::before {
  content: "";
  width: 56%;
  aspect-ratio: 1;
  border-radius: 50%;
}

.board-cell.is-blocked::before {
  content: none;
}

.board-cell.is-safe::before {
  background: radial-gradient(circle at 34% 34%, #ffffff 0 43%, #ece8e1 66%, #dad0c3 100%);
  box-shadow:
    inset 0 -3px 6px rgba(168, 152, 129, 0.24),
    0 4px 10px rgba(130, 118, 102, 0.08);
}

.board-cell.is-safe.is-visited::before {
  background: radial-gradient(circle at 34% 28%, #9af59b 0 42%, #46cb4f 66%, #1b8b2d 100%);
  box-shadow:
    inset 0 -3px 6px rgba(13, 82, 24, 0.28),
    0 0 0 5px rgba(56, 171, 61, 0.12);
}

.board-cell.is-safe.is-endpoint::before {
  transform: scale(1.14);
  box-shadow:
    inset 0 -3px 6px rgba(13, 82, 24, 0.28),
    0 0 0 8px rgba(255, 201, 40, 0.28),
    0 0 22px rgba(56, 171, 61, 0.35);
}

.board-cell.is-safe.is-start::after {
  content: "";
  position: absolute;
  width: 20%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.86);
}

.board-cell.is-blocked {
  z-index: 2;
}

.zongzi-sprite {
  position: relative;
  grid-area: 1 / 1;
  width: 72%;
  aspect-ratio: 1;
  background: linear-gradient(180deg, #61d96c, #28a33a);
  clip-path: polygon(50% 6%, 96% 90%, 4% 90%);
  border-radius: 20% 20% 12% 12%;
  filter: drop-shadow(0 10px 10px rgba(29, 109, 42, 0.2));
  transform: translateY(-8%);
}

.zongzi-sprite::before,
.zongzi-sprite::after {
  content: "";
  position: absolute;
  top: 16%;
  width: 18%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.14);
}

.zongzi-sprite::before {
  left: 27%;
}

.zongzi-sprite::after {
  right: 27%;
}

.board-path-glow,
.board-path-line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
}

.board-path-glow {
  stroke: rgba(255, 201, 40, 0.54);
  stroke-width: 0.28;
}

.board-path-line {
  stroke: var(--line);
  stroke-width: 0.18;
}

.tip-text {
  min-height: 1.6em;
  margin-top: 14px;
}

.action-row {
  margin-top: 18px;
}

.action-row > *,
.modal-actions > *,
.action-stack > * {
  flex: 1;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(17, 17, 17, 0.36);
}

.modal-card {
  width: min(100%, 360px);
  padding: 22px 18px 18px;
  border-radius: 24px;
  background: #ffffff;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.24);
}

.modal-kicker {
  margin: 0 0 8px;
  color: #247637;
  font-size: 0.92rem;
  font-weight: 900;
}

.modal-title {
  margin: 0 0 8px;
  font-size: 1.7rem;
  line-height: 1.08;
}

.modal-actions {
  margin-top: 18px;
}

.action-stack {
  margin-top: 22px;
  flex-direction: column;
}

@media (max-width: 639px) {
  #app {
    padding: 12px;
  }

  .hero-card {
    padding: 20px 16px 24px;
  }

  .game-card {
    padding: 16px 12px 18px;
  }

  .game-header,
  .level-head,
  .action-row,
  .modal-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .header-copy,
  .status-panel {
    text-align: left;
    align-items: flex-start;
  }
}

@media (min-width: 640px) {
  #app {
    padding: 28px;
  }

  .game-card {
    padding: 24px 22px 28px;
  }

  .rule-banner {
    font-size: 1.08rem;
  }

  .board-cell::before {
    width: 52%;
  }
}
