body.jelly-page {
  max-width: 820px;
  padding-top: 18px;
}

.game-top {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.back {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  font-size: 0.84rem;
  color: var(--text);
  text-decoration: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: border-color 0.15s, color 0.15s, transform 0.15s;
}

.back:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.game-title {
  flex: 1 1 200px;
  min-width: 0;
}

.game-title h1 {
  margin: 0;
  font-size: clamp(1.35rem, 4vw, 1.8rem);
  font-weight: 900;
  letter-spacing: 0.04em;
}

.game-title p {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: var(--sub);
}

.pill-btn {
  padding: 8px 15px;
  font: inherit;
  font-size: 0.84rem;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s, transform 0.15s;
}

.pill-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.pill-btn:active {
  transform: translateY(0) scale(0.98);
}

/* ---------- 状态栏 ---------- */

.jelly-hud {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 12px 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
}

.stat {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.stat span {
  font-size: 1.25rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.stat small {
  font-size: 0.66rem;
  color: var(--sub);
  letter-spacing: 0.06em;
}

.goal {
  flex: 1 1 190px;
  min-width: 160px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.goal-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.72rem;
  color: var(--sub);
}

.goal-top b {
  color: var(--accent);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

#best {
  white-space: nowrap;
  opacity: 0.85;
}

.progress {
  height: 8px;
  overflow: hidden;
  background: var(--line);
  border-radius: 999px;
}

#bar {
  width: 0;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.2s ease;
}

/* ---------- 棋盘 ---------- */

.jelly-stage {
  position: relative;
  width: 100%;
  max-width: 640px;
  aspect-ratio: 1 / 1;
  margin: 14px auto 0;
  overflow: hidden;
  border-radius: 26px;
  background: radial-gradient(120% 100% at 50% 0%, #fff1f6 0%, #ffe3ed 52%, #ffd3e2 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.75), var(--shadow);
  -webkit-user-select: none;
  user-select: none;
}

@media (prefers-color-scheme: dark) {
  .jelly-stage {
    background: radial-gradient(120% 100% at 50% 0%, #2a2027 0%, #211920 55%, #191216 100%);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06), var(--shadow);
  }
}

#board {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- 提示条 ---------- */

.toast {
  position: absolute;
  top: 14px;
  left: 50%;
  z-index: 3;
  padding: 8px 16px;
  font-size: 0.78rem;
  color: var(--bg);
  white-space: nowrap;
  pointer-events: none;
  background: var(--text);
  border-radius: 999px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
  animation: toast-in 0.26s ease;
  transform: translateX(-50%);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, -6px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* ---------- 过关 / 结束弹层 ---------- */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(30, 20, 25, 0.38);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.overlay[hidden] {
  display: none;
}

.overlay-card {
  width: 100%;
  max-width: 320px;
  padding: 28px 30px 24px;
  text-align: center;
  background: var(--card);
  border-radius: 24px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
  animation: pop-in 0.38s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.overlay-card .emoji {
  margin: 0;
  font-size: 2.4rem;
  line-height: 1;
}

.overlay-card h2 {
  justify-content: center;
  margin: 10px 0 6px;
  font-size: 1.2rem;
}

.overlay-card h2::before {
  display: none;
}

.overlay-card p {
  margin: 0 0 18px;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--sub);
}

#ov-primary {
  width: 100%;
  padding: 11px 20px;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(255, 106, 61, 0.35);
  transition: transform 0.15s, box-shadow 0.15s;
}

#ov-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 26px rgba(255, 106, 61, 0.42);
}

#ov-primary:active {
  transform: translateY(0) scale(0.98);
}

.link-btn {
  margin-top: 12px;
  padding: 4px 8px;
  font: inherit;
  font-size: 0.82rem;
  color: var(--sub);
  text-decoration: underline;
  text-underline-offset: 3px;
  background: none;
  border: none;
  cursor: pointer;
}

.link-btn:hover {
  color: var(--accent);
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(0.86);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ---------- 排行榜 ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(20, 15, 18, 0.5);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.modal[hidden] {
  display: none;
}

.modal-card {
  width: 100%;
  max-width: 420px;
  max-height: 82vh;
  padding: 22px 22px 20px;
  overflow: auto;
  background: var(--card);
  border-radius: 24px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.3);
  animation: pop-in 0.3s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.modal-head h2 {
  font-size: 1.05rem;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  font: inherit;
  font-size: 0.9rem;
  color: var(--sub);
  background: var(--bg);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.icon-btn:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.rank-list {
  display: grid;
  gap: 8px;
  margin: 14px 0;
  padding: 0;
  list-style: none;
}

.rank-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  font-size: 0.84rem;
  background: var(--bg);
  border-radius: 12px;
}

.rank-list .no {
  width: 22px;
  font-weight: 900;
  color: var(--sub);
  font-variant-numeric: tabular-nums;
}

.rank-list .who {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-list .meta {
  font-size: 0.68rem;
  color: var(--sub);
  white-space: nowrap;
}

.rank-list .pts {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.rank-list li:nth-child(1) .no { color: #e0a100; }
.rank-list li:nth-child(2) .no { color: #9aa3ad; }
.rank-list li:nth-child(3) .no { color: #c47b4a; }

.rank-empty {
  margin: 20px 0;
  text-align: center;
  font-size: 0.86rem;
  color: var(--sub);
}

.name-field {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  font-size: 0.82rem;
  color: var(--sub);
}

.name-field input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  font: inherit;
  font-size: 0.86rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}

.name-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.rank-note {
  margin: 10px 0 0;
  font-size: 0.72rem;
  line-height: 1.5;
  color: var(--sub);
  opacity: 0.8;
}

/* ---------- 说明与移动端 ---------- */

.hint {
  margin: 14px 2px 0;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--sub);
}

@media (max-width: 560px) {
  .game-top { gap: 10px; }
  .game-title { flex-basis: 100%; order: 3; }
  .game-title p { display: none; }
  .jelly-hud { gap: 12px; padding: 10px 14px; }
  .stat span { font-size: 1.1rem; }
  .goal { flex-basis: 100%; }
  .jelly-hud .pill-btn { flex: 1 1 0; text-align: center; }
  .jelly-stage { border-radius: 20px; }
  .hint { font-size: 0.78rem; }
  .overlay-card { padding: 24px 22px 20px; }
  .modal-card { padding: 20px 18px 18px; }
}
