:root {
  --bg0: #14070c;
  --bg1: #2a0f18;
  --card: #1c0d14;
  --line: #4a1d2b;
  --text: #fde2e4;
  --muted: #c4a4ad;
  --accent: #e11d48;
  --accent2: #7c3aed;
  --ok: #22c55e;
  --warn: #f59e0b;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(225, 29, 72, 0.25), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(124, 58, 237, 0.22), transparent 55%),
    linear-gradient(180deg, var(--bg0), var(--bg1) 40%, #0b0508);
  min-height: 100%;
}
a { color: #fda4af; text-decoration: none; }
.container { max-width: 1100px; margin: 0 auto; padding: 20px 16px 48px; }
.header { text-align: center; margin-bottom: 18px; }
.header h1 {
  margin: 0 0 8px;
  font-size: 28px;
  letter-spacing: 0.04em;
  text-shadow: 0 0 24px rgba(225, 29, 72, 0.35);
}
.header p { margin: 0; color: var(--muted); }
.layout {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  align-items: start;
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
}
.card {
  background: rgba(28, 13, 20, 0.92);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.35);
}
.card h2 { margin: 0 0 12px; font-size: 18px; }
.intro-text, .warm-tip, .consent-text, .field-hint, .play-tips {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
}
.warm-tip {
  margin: 12px 0 16px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(225, 29, 72, 0.12);
  border: 1px solid rgba(225, 29, 72, 0.35);
  white-space: normal;
}
.form-group { margin-bottom: 12px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--muted); }
.input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #12060b;
  color: var(--text);
  font-size: 15px;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 999px;
  padding: 11px 18px;
  background: linear-gradient(135deg, var(--accent), #9f1239);
  color: white;
  font-weight: 700;
  cursor: pointer;
}
.btn-secondary {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}
.btn-retry { background: linear-gradient(135deg, var(--accent2), #5b21b6); }
.loading, .empty { color: var(--muted); padding: 18px 8px; text-align: center; }

.level-list { display: flex; flex-direction: column; gap: 10px; }
.level-item {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #16080f;
  cursor: pointer;
}
.level-item.locked { opacity: 0.55; cursor: not-allowed; }
.level-item.exhausted { opacity: 0.7; }
.level-icon { font-size: 22px; }
.level-info { flex: 1; min-width: 0; }
.level-info h3 { margin: 0 0 4px; font-size: 15px; }
.level-info p { margin: 0; color: var(--muted); font-size: 12px; }
.attempts-line { margin-top: 4px !important; color: #fda4af !important; }
.level-badge {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.badge-locked { background: #292524; color: #a8a29e; }
.badge-ready { background: rgba(124, 58, 237, 0.25); color: #ddd6fe; }
.badge-done { background: rgba(34, 197, 94, 0.25); color: #86efac; }
.retry-btn {
  margin-top: 8px;
  border: 1px solid var(--line);
  background: #1f0b14;
  color: var(--text);
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
}

.leaderboard-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.leaderboard-table th, .leaderboard-table td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.leaderboard-table th { color: var(--muted); font-size: 12px; }
.lb-me { background: rgba(245, 158, 11, 0.12); }
.lb-caption { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.my-rank-box {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(124,58,237,.25), rgba(225,29,72,.18));
  font-size: 13px;
  font-weight: 600;
}
.my-rank-box.muted { background: #1c1418; color: var(--muted); font-weight: 500; }
.my-rank-hint { margin-top: 4px; font-size: 12px; font-weight: 500; color: #fda4af; }
.lb-status {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px; padding: 8px 10px; border-radius: 8px;
  background: #12060b; border: 1px solid var(--line); font-size: 12px; font-weight: 600;
}
.lb-live-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #ef4444;
  box-shadow: 0 0 0 0 rgba(239,68,68,.55);
  animation: lb-dot-pulse 1.2s ease-out infinite;
}
.lb-countdown { color: #fda4af; margin-left: auto; }
.lb-shell.is-refreshing { box-shadow: 0 0 0 2px rgba(239,68,68,.25); }
.lb-loading-pulse { animation: lb-loading-blink .7s ease-in-out infinite; color: #fda4af; font-weight: 700; }
.lb-shell.lb-flash { animation: lb-soft-flash .55s ease; }
@keyframes lb-dot-pulse {
  0% { box-shadow: 0 0 0 0 rgba(239,68,68,.55); }
  70% { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
  100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
}
@keyframes lb-loading-blink {
  0%,100% { opacity: 1; } 50% { opacity: .45; }
}
@keyframes lb-soft-flash {
  0% { box-shadow: 0 0 0 0 rgba(124,58,237,.45); }
  100% { box-shadow: 0 0 0 8px rgba(124,58,237,0); }
}

.puzzle-header, .play-top {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px;
}
.timer {
  font-variant-numeric: tabular-nums;
  font-size: 22px; font-weight: 800; color: #fb7185;
}
.attempts-info { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.sheep-board-wrap {
  overflow: auto;
  max-width: 100%;
  padding: 8px;
  border-radius: 12px;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--line);
}
.sheep-board { position: relative; margin: 0 auto; }
.sheep-tile {
  position: absolute;
  border: none;
  border-radius: 8px;
  padding: 0;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.sheep-tile-body {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  /* 暗紫色麻将边 */
  background: linear-gradient(160deg, #5b21b6 0%, #3b0764 45%, #2e1065 100%);
  box-shadow:
    0 5px 0 #1e1b4b,
    0 8px 14px rgba(0,0,0,0.4),
    inset 0 1px 0 rgba(255,255,255,0.18);
  padding: 4px 4px 10px 4px;
  position: relative;
}
.sheep-tile-face {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: calc(100% - 2px);
  border-radius: 5px;
  /* 灰白牌面 */
  background: linear-gradient(180deg, #f8fafc 0%, #e5e7eb 100%);
  border: 1px solid rgba(255,255,255,0.65);
  box-shadow: inset 0 0 0 1px rgba(88, 28, 135, 0.12);
  overflow: hidden;
}
.sheep-tile-art {
  width: 86%;
  height: 86%;
  object-fit: contain;
  pointer-events: none;
  /* 素材黑底融进灰白牌面观感：略提亮 */
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.15));
}
.sheep-tile-fallback { font-size: 22px; color: #6b21a8; }
.sheep-tile-edge {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 1px;
  text-align: center;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: rgba(237, 233, 254, 0.9);
  text-shadow: 0 1px 0 rgba(0,0,0,0.35);
  pointer-events: none;
  font-family: "Segoe UI", Impact, sans-serif;
}
.sheep-tile.is-blocked {
  cursor: not-allowed;
}
.sheep-tile.is-blocked .sheep-tile-body {
  filter: brightness(0.62) saturate(0.75);
  box-shadow: 0 3px 0 #1e1b4b, 0 4px 8px rgba(0,0,0,0.3);
}
.sheep-tile.is-blocked .sheep-tile-face {
  background: linear-gradient(180deg, #d1d5db 0%, #9ca3af 100%);
}
.sheep-tile.is-free:active .sheep-tile-body {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #1e1b4b, 0 3px 8px rgba(0,0,0,0.35);
}
.slot-wrap { margin-top: 14px; }
.slot-wrap h3 { margin: 0 0 8px; font-size: 14px; color: var(--muted); }
.sheep-slot {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.sheep-slot-cell {
  aspect-ratio: 7/9;
  border-radius: 8px;
  border: 1px dashed #5b21b6;
  background: #12060b;
  display: flex; align-items: center; justify-content: center;
  padding: 3px;
}
.sheep-slot-cell.filled {
  border-style: solid;
  background: linear-gradient(160deg, #5b21b6, #2e1065);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12);
}
.sheep-slot-art {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: linear-gradient(180deg, #f8fafc, #e5e7eb);
  border-radius: 4px;
  padding: 2px;
}
.result-panel { text-align: center; margin-top: 16px; }
.result-panel .time { font-size: 28px; font-weight: 800; color: #fb7185; margin: 8px 0; }
.result-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 12px; }
.result-hint { color: var(--muted); font-size: 12px; }

.lang-switcher {
  position: fixed; top: 10px; right: 10px; z-index: 50;
  display: flex; gap: 6px; align-items: center;
  background: rgba(20,7,12,.85); border: 1px solid var(--line);
  padding: 6px 8px; border-radius: 999px;
}
.lang-label { font-size: 12px; color: var(--muted); }
.lang-select {
  background: transparent; color: var(--text); border: none; font-size: 12px;
}
.reward-img { max-width: 100%; border-radius: 12px; border: 1px solid var(--line); }
.stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px;
}
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: center;
}
.stat b { display: block; font-size: 22px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.admin-table th, .admin-table td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; }
