:root {
  --ink: #17233b;
  --paper: #fff8e7;
  --white: #ffffff;
  --blue: #3c5cff;
  --blue-dark: #2440d8;
  --coral: #ff6a5e;
  --mint: #56d9b0;
  --yellow: #ffd95a;
  --violet: #9c7bff;
  --muted: #667085;
  --line: 3px solid var(--ink);
  --shadow: 6px 6px 0 var(--ink);
  --radius: 22px;
  font-family: Inter, ui-rounded, "Arial Rounded MT Bold", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 2%, rgba(255, 217, 90, .42), transparent 20rem),
    radial-gradient(circle at 92% 20%, rgba(86, 217, 176, .26), transparent 24rem),
    var(--paper);
  font-size: 16px;
  line-height: 1.55;
}
a { color: inherit; }
button, input { font: inherit; }
button { color: inherit; }
:focus-visible { outline: 4px solid var(--yellow); outline-offset: 3px; }

.skip-link { position: fixed; top: -5rem; left: 1rem; z-index: 99; background: var(--ink); color: white; padding: .75rem 1rem; border-radius: 12px; }
.skip-link:focus { top: 1rem; }
.wrap { width: min(1160px, calc(100% - 32px)); margin-inline: auto; }

.site-header { padding: 20px 0 10px; }
.nav {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  background: rgba(255,255,255,.78); border: var(--line); border-radius: 18px;
  padding: 10px 12px 10px 16px; backdrop-filter: blur(14px); box-shadow: 4px 4px 0 rgba(23,35,59,.9);
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 950; letter-spacing: -.04em; font-size: 1.25rem; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; background: var(--blue); color: white; border: 2px solid var(--ink); border-radius: 11px; transform: rotate(-5deg); }
.nav-links { display: flex; align-items: center; gap: 8px; }
.nav-links a, .nav-links button { border: 0; background: transparent; text-decoration: none; font-weight: 800; padding: 9px 12px; border-radius: 10px; cursor: pointer; }
.nav-links a:hover, .nav-links button:hover { background: var(--yellow); }
.lang-switch { border: 2px solid var(--ink) !important; background: white !important; }

.hero { display: grid; grid-template-columns: 1.08fr .92fr; align-items: center; gap: clamp(28px, 6vw, 74px); padding: clamp(48px, 7vw, 88px) 0 58px; }
.eyebrow { display: inline-flex; gap: 8px; align-items: center; margin: 0 0 14px; padding: 7px 11px; border: 2px solid var(--ink); border-radius: 999px; background: var(--mint); font-weight: 900; font-size: .875rem; }
.eyebrow-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ink); }
h1, h2, h3, p { margin-top: 0; }
h1 { max-width: 700px; margin-bottom: 22px; font-size: clamp(3.25rem, 7.2vw, 6.6rem); line-height: .96; letter-spacing: -.075em; font-weight: 950; }
h1 .accent { color: var(--blue); text-decoration: underline; text-decoration-thickness: .11em; text-decoration-color: var(--coral); text-underline-offset: .08em; }
.hero-title { max-width: none; line-height: 1.02; letter-spacing: -.065em; }
.hero-title-en { font-size: clamp(3.15rem, 5vw, 5.2rem); }
.hero-title-zh { font-size: clamp(3.15rem, 5.5vw, 5.35rem); }
.hero-title-line { display: block; width: max-content; max-width: 100%; white-space: nowrap; }
.hero-title-line + .hero-title-line { margin-top: .1em; }
.lede { max-width: 610px; margin-bottom: 28px; color: #48546b; font-size: clamp(1.05rem, 1.8vw, 1.25rem); font-weight: 650; }
.button-row { display: flex; flex-wrap: wrap; gap: 13px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 48px; padding: 11px 18px; border: var(--line); border-radius: 14px; box-shadow: 4px 4px 0 var(--ink); background: white; color: var(--ink); text-decoration: none; font-weight: 900; cursor: pointer; transition: transform .16s ease, box-shadow .16s ease; }
.btn:hover { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
.btn-primary { background: var(--blue); color: white; }
.btn-coral { background: var(--coral); }
.btn-small { min-height: 42px; padding: 8px 14px; font-size: .925rem; }

.daily-card { position: relative; max-width: 490px; justify-self: end; background: var(--blue); color: white; border: var(--line); border-radius: 34px; padding: clamp(22px, 4vw, 34px); box-shadow: 11px 11px 0 var(--ink); transform: rotate(1.4deg); overflow: hidden; }
.daily-card::before { content: ""; position: absolute; width: 170px; height: 170px; border: 24px solid rgba(255,255,255,.13); border-radius: 50%; right: -72px; top: -58px; }
.daily-top { display: flex; justify-content: space-between; align-items: center; gap: 15px; margin-bottom: 24px; }
.daily-label { font-size: .85rem; font-weight: 950; letter-spacing: .08em; text-transform: uppercase; }
.date-chip { padding: 6px 10px; border: 2px solid var(--ink); border-radius: 10px; background: var(--yellow); color: var(--ink); font-weight: 900; }
.mini-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; margin: 22px 0 26px; }
.mini-grid span { display: grid; place-items: center; aspect-ratio: 1; border: 2px solid var(--ink); border-radius: 9px; background: rgba(255,255,255,.14); font-weight: 950; }
.mini-grid .path { background: var(--yellow); color: var(--ink); }
.daily-card h2 { position: relative; margin-bottom: 8px; font-size: clamp(1.7rem, 3vw, 2.4rem); line-height: 1; letter-spacing: -.04em; }
.daily-card p { color: rgba(255,255,255,.86); }

.section { padding: 52px 0; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 26px; }
.section-kicker { margin-bottom: 4px; color: var(--blue); font-size: .85rem; letter-spacing: .12em; text-transform: uppercase; font-weight: 950; }
.section h2 { margin-bottom: 0; font-size: clamp(2rem, 4vw, 3.5rem); letter-spacing: -.055em; line-height: 1; }
.game-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.game-card { min-height: 330px; display: flex; flex-direction: column; border: var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); background: white; }
.game-card:nth-child(2) { background: var(--yellow); }
.game-card:nth-child(3) { background: var(--mint); }
.card-art { display: grid; place-items: center; height: 150px; margin-bottom: 20px; border: 2px solid var(--ink); border-radius: 16px; background: var(--paper); overflow: hidden; }
.path-art { font-size: 2.5rem; letter-spacing: .18em; color: var(--blue); font-weight: 950; }
.block-art { display: grid; grid-template-columns: repeat(4, 27px); gap: 4px; transform: rotate(-5deg); }
.block-art i { width: 27px; aspect-ratio: 1; border: 2px solid var(--ink); border-radius: 5px; background: var(--coral); }
.block-art i:nth-child(3n) { background: var(--blue); }
.snake-art { font-size: 3.5rem; font-weight: 950; letter-spacing: -.2em; color: var(--blue); transform: rotate(-6deg); }
.game-meta { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: .84rem; font-weight: 800; }
.game-card h3 { margin: 14px 0 8px; font-size: 1.55rem; letter-spacing: -.035em; }
.game-card p { flex: 1; color: #4c586f; }
.card-link { align-self: flex-start; font-weight: 950; text-decoration-thickness: 2px; text-underline-offset: 4px; }

.stats-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 32px; }
.stat { border: 2px solid var(--ink); border-radius: 16px; background: white; padding: 17px; }
.stat strong { display: block; font-size: 1.7rem; letter-spacing: -.04em; }
.stat span { color: var(--muted); font-weight: 700; font-size: .9rem; }
.recent-panel { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 18px; border: 2px solid var(--ink); border-radius: 16px; padding: 15px 18px; background: white; }
.recent-panel[hidden] { display: none; }
.recent-panel strong { white-space: nowrap; }
.recent-list { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; }
.recent-link { padding: 7px 11px; border: 2px solid var(--ink); border-radius: 10px; background: var(--paper); font-weight: 850; text-decoration: none; }
.recent-link:hover { background: var(--yellow); }

.site-footer { padding: 36px 0 50px; }
.footer-inner { display: flex; justify-content: space-between; align-items: center; gap: 20px; border-top: 2px solid var(--ink); padding-top: 24px; color: var(--muted); }
.footer-links { display: flex; gap: 18px; }

@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; padding-top: 44px; }
  .daily-card { justify-self: stretch; max-width: none; transform: none; }
  .game-grid { grid-template-columns: 1fr; }
  .game-card { min-height: 0; }
  .stats-strip { grid-template-columns: 1fr; }
  .recent-panel { align-items: flex-start; flex-direction: column; }
  .recent-list { justify-content: flex-start; }
}
@media (max-width: 620px) {
  .wrap { width: min(100% - 22px, 1160px); }
  .nav-links a:not(.lang-switch) { display: none; }
  .nav { padding-left: 12px; }
  h1 { font-size: clamp(3rem, 13.5vw, 4.4rem); }
  .hero-title-en, .hero-title-zh { font-size: clamp(3rem, 13vw, 3.45rem); }
  .hero { padding-top: 34px; }
  .section { padding: 40px 0; }
  .footer-inner { align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* Game surfaces */
.game-main { padding: 30px 0 68px; }
.game-breadcrumb { display: flex; align-items: center; gap: 8px; margin: 8px 0 22px; color: var(--muted); font-weight: 800; font-size: .9rem; }
.game-breadcrumb a { text-underline-offset: 3px; }
.play-layout { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 28px; align-items: start; }
.play-panel { min-width: 0; border: var(--line); border-radius: 28px; background: white; box-shadow: 9px 9px 0 var(--ink); overflow: hidden; }
.play-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; padding: 24px 26px 20px; border-bottom: 2px solid var(--ink); background: var(--yellow); }
.play-header h1 { margin: 0 0 6px; font-size: clamp(2.15rem, 5vw, 4rem); line-height: .95; }
.play-header p { margin: 0; color: #4c586f; font-weight: 650; }
.score-cluster { display: flex; gap: 8px; }
.score-box { min-width: 82px; border: 2px solid var(--ink); border-radius: 13px; padding: 7px 10px; background: white; text-align: center; }
.score-box span { display: block; color: var(--muted); font-size: .72rem; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; }
.score-box strong { font-size: 1.3rem; }
.play-stage { position: relative; min-height: 470px; display: grid; place-items: center; padding: clamp(16px, 4vw, 34px); background: #f6f1ff; touch-action: none; }
.game-toolbar { display: flex; flex-wrap: wrap; gap: 10px; padding: 16px 20px 20px; border-top: 2px solid var(--ink); }
.tool-btn { min-height: 42px; border: 2px solid var(--ink); border-radius: 12px; padding: 8px 13px; background: white; font-weight: 900; cursor: pointer; }
.tool-btn:hover { background: var(--yellow); }
.tool-btn.primary { background: var(--blue); color: white; }
.side-stack { display: grid; gap: 18px; }
.info-card { border: var(--line); border-radius: 20px; padding: 20px; background: white; box-shadow: 5px 5px 0 var(--ink); }
.info-card.mint { background: var(--mint); }
.info-card.coral { background: var(--coral); }
.info-card h2 { margin: 0 0 9px; font-size: 1.2rem; letter-spacing: -.025em; }
.info-card p, .info-card ol { margin-bottom: 0; color: #3e4a61; }
.info-card ol { padding-left: 1.25rem; }
.record-line { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 2px dashed rgba(23,35,59,.26); font-weight: 800; }
.record-line:last-child { border-bottom: 0; }

.path-board { width: min(100%, 500px); display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; user-select: none; }
.path-cell { position: relative; display: grid; place-items: center; aspect-ratio: 1; border: 2px solid var(--ink); border-radius: 10px; background: white; font-weight: 950; font-size: clamp(.85rem, 2.5vw, 1.2rem); cursor: pointer; }
.path-cell.visited { background: var(--blue); color: white; }
.path-cell.visited::after { content: ""; position: absolute; inset: 22%; border-radius: 50%; background: rgba(255,255,255,.26); }
.path-cell.checkpoint { background: var(--yellow); color: var(--ink); }
.path-cell.checkpoint.visited { background: var(--coral); }
.path-cell.hint { animation: hintPulse .7s ease 2; }
@keyframes hintPulse { 50% { transform: scale(.82); background: var(--mint); } }

.block-wrap { width: min(100%, 540px); }
.block-board { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; padding: 8px; border: var(--line); border-radius: 16px; background: var(--ink); }
.block-cell { aspect-ratio: 1; border: 0; border-radius: 5px; background: #fffdf6; cursor: pointer; padding: 0; }
.block-cell.filled { background: var(--blue); box-shadow: inset 0 -4px 0 rgba(0,0,0,.16); }
.block-cell.preview { background: var(--mint); }
.block-cell.invalid { background: var(--coral); }
.piece-tray { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.piece { min-height: 92px; display: grid; place-items: center; border: 2px solid var(--ink); border-radius: 14px; background: white; cursor: pointer; }
.piece[disabled] { opacity: .25; cursor: default; }
.piece.selected { background: var(--yellow); box-shadow: 0 0 0 4px var(--blue); }
.piece-grid { display: grid; gap: 3px; }
.piece-dot { width: 16px; aspect-ratio: 1; border: 2px solid var(--ink); border-radius: 4px; background: var(--coral); }
.piece-dot.empty { opacity: 0; }

.snake-stage { background: var(--ink); }
#snake-canvas { display: block; width: min(100%, 500px); height: auto; aspect-ratio: 1; border: 3px solid white; border-radius: 16px; background: #0f1830; image-rendering: pixelated; touch-action: none; }
.dpad { display: none; grid-template-columns: repeat(3, 54px); grid-template-rows: repeat(2, 48px); justify-content: center; gap: 6px; margin-top: 16px; }
.dpad button { border: 2px solid var(--ink); border-radius: 12px; background: var(--yellow); font-size: 1.3rem; font-weight: 950; }
.dpad .up { grid-column: 2; }.dpad .left { grid-column: 1; grid-row: 2; }.dpad .down { grid-column: 2; grid-row: 2; }.dpad .right { grid-column: 3; grid-row: 2; }

.stage-overlay { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(255,248,231,.88); backdrop-filter: blur(5px); z-index: 5; }
.stage-overlay[hidden] { display: none; }
.overlay-card { max-width: 360px; border: var(--line); border-radius: 20px; padding: 24px; background: white; box-shadow: var(--shadow); text-align: center; }
.overlay-card h2 { margin-bottom: 8px; }
.overlay-card p { color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: 28px; z-index: 90; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; padding: 11px 16px; border: 2px solid var(--ink); border-radius: 12px; background: var(--ink); color: white; font-weight: 850; transition: .18s ease; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
dialog { width: min(520px, calc(100% - 28px)); border: var(--line); border-radius: 24px; padding: 0; color: var(--ink); background: white; box-shadow: 10px 10px 0 var(--ink); }
dialog::backdrop { background: rgba(23,35,59,.62); backdrop-filter: blur(4px); }
.dialog-body { padding: 26px; }
.dialog-body h2 { margin-bottom: 8px; font-size: 1.8rem; }
.dialog-body p { color: #4c586f; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.result-grid { white-space: pre; padding: 14px; border-radius: 12px; background: #f2efff; font-size: 1.15rem; letter-spacing: .1em; text-align: center; }

.prose { width: min(760px, calc(100% - 32px)); margin: 0 auto; padding: 58px 0 80px; }
.prose h1 { font-size: clamp(3rem, 7vw, 5rem); }
.prose h2 { margin-top: 2.4rem; font-size: 1.65rem; }
.prose p, .prose li { color: #47536a; }
.prose-card { border: var(--line); border-radius: 22px; padding: clamp(20px, 4vw, 34px); background: white; box-shadow: var(--shadow); }

@media (max-width: 900px) {
  .play-layout { grid-template-columns: 1fr; }
  .side-stack { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 620px) {
  .play-header { flex-direction: column; padding: 20px; }
  .score-cluster { width: 100%; }
  .score-box { flex: 1; }
  .play-stage { min-height: 390px; padding: 12px; }
  .game-toolbar { padding-inline: 12px; }
  .side-stack { grid-template-columns: 1fr; }
  .dpad { display: grid; }
  .path-board { gap: 3px; }
  .path-cell { border-radius: 7px; }
}
