:root {
  --ink: #503d32;
  --paper: #f7f0e4;
  --line: #e3d5c5;
  --head: #f0a65a;
  --body: #ddc4a1;
  --accent: #a95e3a;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100dvh; background: var(--paper); color: var(--ink); font-family: ui-rounded, "PingFang SC", "Microsoft YaHei", sans-serif; overscroll-behavior: none; }
button, input { font: inherit; }
button { cursor: pointer; }
.app-shell { width: min(100%, 680px); margin: 0 auto; padding: max(18px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom)); }
.game-header, .bottom-panel { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.game-header { min-height: 38px; }
h1 { margin: 0; font-size: clamp(1.35rem, 5vw, 1.8rem); letter-spacing: .08em; }
.stats { display: flex; align-items: center; gap: 10px; font-size: .86rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.stats span { display: inline-flex; gap: 4px; }
.stats b { display: inline-block; min-width: 4ch; color: var(--accent); text-align: right; }
.text-button { appearance: none; border: 0; background: transparent; color: var(--accent); padding: 6px; }
.game-area { position: relative; margin-top: 16px; aspect-ratio: 1; border: 2px solid var(--line); border-radius: 12px; background: #fffaf1; overflow: hidden; touch-action: none; }
.board { display: grid; width: 100%; height: 100%; grid-template-columns: repeat(20, 1fr); grid-template-rows: repeat(20, 1fr); }
.cell { display: flex; align-items: center; justify-content: center; overflow: visible; font-size: clamp(8px, 2.45vw, 15px); line-height: 1; font-weight: 700; white-space: nowrap; user-select: none; }
.snake-head { color: var(--head); z-index: 2; }
.snake-body { color: var(--body); }
.food { transition: opacity .12s linear; }
.overlay { position: absolute; inset: 0; display: grid; place-items: center; background: color-mix(in srgb, #fffaf1 72%, transparent); z-index: 5; }
.overlay.hidden { pointer-events: none; background: transparent; }
.card { width: min(82%, 360px); padding: 24px; text-align: center; border: 1px solid var(--line); border-radius: 14px; background: #fffaf1; box-shadow: 0 10px 28px #7d5f4230; }
.card h2 { margin: 4px 0 10px; font-size: 1.6rem; }
.card p { margin: 8px 0; }
.eyebrow { color: var(--accent); font-size: .82rem; letter-spacing: .08em; }
.name-field { display: grid; gap: 6px; margin: 18px 0 12px; text-align: left; font-size: .86rem; }
.name-field input { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: #fff; color: var(--ink); }
.primary-button, .secondary-button { width: 100%; border-radius: 8px; padding: 11px; border: 1px solid var(--accent); }
.primary-button { background: var(--accent); color: #fffaf1; }
.secondary-button { margin-top: 8px; background: transparent; color: var(--accent); }
.hidden { display: none !important; }
.controls { width: min(250px, 80%); margin: 20px auto; display: grid; place-items: center; gap: 8px; }
.controls div { display: flex; gap: 8px; }
.controls button { width: 54px; height: 42px; border: 1px solid var(--line); border-radius: 9px; background: #fffaf1; color: var(--ink); font-size: 1.35rem; touch-action: manipulation; }
.controls button:active { background: #eddfcd; transform: translateY(1px); }
.bottom-panel { align-items: flex-start; border-top: 1px solid var(--line); padding-top: 14px; }
.bottom-panel h2 { margin: 0 0 8px; font-size: 1rem; }
.leaderboard { min-width: 230px; margin: 0; padding-left: 22px; font-size: .88rem; line-height: 1.8; }
.leaderboard span { color: var(--accent); float: right; padding-left: 20px; }
.achievement-list { display: grid; gap: 8px; margin: 14px 0; color: var(--accent); font-size: .84rem; }
.achievement-list span { display: grid; gap: 2px; }
.achievement-list small { color: #8a7568; }
@media (min-width: 680px) { .app-shell { padding-top: 28px; } .cell { font-size: 14px; } }
