:root {
  --bg: #1b1420;
  --ink: #fff8ef;
  --muted: #c9b9c4;
  --accent: #ffb547;
  --card: #2a2030;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); overflow: hidden; }
body { font-family: -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; }

#app { position: relative; height: 100%; max-width: 480px; margin: 0 auto; display: flex; flex-direction: column; user-select: none; -webkit-user-select: none; }

.hud { display: flex; align-items: center; gap: 14px; padding: max(12px, env(safe-area-inset-top)) 12px 6px; }
.home { width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.1); color: var(--ink); text-decoration: none; display: grid; place-items: center; font-size: 22px; line-height: 1; }
.stat small { display: block; font-size: 11px; color: var(--muted); }
.stat b { font-size: 24px; font-variant-numeric: tabular-nums; }
.stat.moves { margin-left: auto; text-align: right; }
.stat.moves b { color: var(--accent); }

.goal { position: relative; height: 8px; margin: 4px 16px 10px; border-radius: 4px; background: rgba(255,255,255,.1); }
.goal-bar { height: 100%; width: 0; border-radius: 4px; background: linear-gradient(90deg, #ff7aa8, var(--accent)); transition: width .3s; }
.goal i { position: absolute; top: -4px; width: 16px; height: 16px; margin-left: -8px; border-radius: 50%; background: var(--card); box-shadow: 0 0 0 2px rgba(255,255,255,.2); }
.goal i::after { content: "★"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; color: rgba(255,255,255,.3); }
.goal i.on::after { color: var(--accent); }

.board { flex: 1; min-height: 0; display: grid; place-items: center; padding: 0 8px; }
#world { display: block; touch-action: none; }
.tip { margin: 8px 16px max(12px, env(safe-area-inset-bottom)); text-align: center; font-size: 12px; color: var(--muted); line-height: 1.5; }

.toast { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); padding: 10px 18px; border-radius: 999px; background: rgba(0,0,0,.75); font-weight: 800; white-space: nowrap; opacity: 0; pointer-events: none; z-index: 4; }
.toast.show { animation: toast 1.8s ease-out; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.9); } 12%, 75% { opacity: 1; transform: translate(-50%, 0) scale(1); } 100% { opacity: 0; } }

.over { position: absolute; inset: 0; display: none; place-items: center; background: rgba(20,10,25,.8); z-index: 5; }
.over.show { display: grid; }
.over .card { width: min(320px, 86%); text-align: center; padding: 24px 20px; border-radius: 24px; background: var(--card); box-shadow: 0 6px 0 rgba(0,0,0,.4); }
.over h2 { margin: 0; color: var(--accent); }
.stars { font-size: 36px; letter-spacing: 6px; color: var(--accent); }
.stars .off { color: rgba(255,255,255,.18); }
.big { margin: 4px 0; font-size: 48px; font-weight: 900; font-variant-numeric: tabular-nums; }
.sub { margin: 0; color: var(--muted); min-height: 1.2em; }
.primary, .ghost { display: block; width: 100%; margin-top: 10px; padding: 13px; border-radius: 999px; font-weight: 800; text-decoration: none; text-align: center; }
.primary { background: var(--accent); color: #3b1d05; }
.ghost { background: rgba(255,255,255,.1); color: var(--ink); }

.loading { position: absolute; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 6; }
.loading.hide { display: none; }
