:root {
  --bg: #fff8f0;
  --bg2: #ffffff;
  --ink: #33272a;
  --ink-soft: #7a6b70;
  --brand: #ff5a5f;
  --brand-deep: #d94a4f;
  --accent: #ffb4a2;
  --line: #f0e3da;
  --panel: #ffffff;
  --shadow: 0 10px 30px rgba(51, 39, 42, .10);
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1f191c;
    --bg2: #2a2226;
    --ink: #f5e9e3;
    --ink-soft: #b7a6a8;
    --brand: #ff6b70;
    --brand-deep: #e0555a;
    --line: #3d3236;
    --panel: #2a2226;
    --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
}
#board, .chip, .btn { -webkit-tap-highlight-color: transparent; }
#board { user-select: none; -webkit-user-select: none; }
a { color: var(--brand-deep); text-decoration: none; }
a:hover { text-decoration: underline; }

/* header */
.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 1040px; margin: 0 auto; padding: 14px 20px;
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 1.15rem; color: var(--ink); letter-spacing: .2px; }
.brand:hover { text-decoration: none; }
.brand-mark { margin-right: 6px; }
.site-nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.site-nav > a { color: var(--ink-soft); font-size: .92rem; }
.site-nav > a:hover { color: var(--brand-deep); text-decoration: none; }
.lang-switch { position: relative; }
.lang-switch summary {
  list-style: none; cursor: pointer; color: var(--ink-soft); font-size: .92rem;
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px; user-select: none;
}
.lang-switch summary::-webkit-details-marker { display: none; }
.lang-switch[open] .lang-menu { display: grid; }
.lang-menu {
  display: none; position: absolute; right: 0; top: 130%; z-index: 30;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); padding: 6px; min-width: 160px;
}
.lang-menu a { display: block; padding: 6px 10px; border-radius: 8px; color: var(--ink); font-size: .92rem; }
.lang-menu a:hover { background: var(--bg); text-decoration: none; }
.lang-menu a[aria-current="true"] { color: var(--brand-deep); font-weight: 700; }

/* layout */
main { max-width: 1040px; margin: 0 auto; padding: 0 20px; }
.hero { text-align: center; padding: 34px 0 10px; }
.hero h1 { font-size: clamp(1.6rem, 4.5vw, 2.6rem); margin: 0 0 8px; letter-spacing: -.5px; }
.tagline { color: var(--ink-soft); margin: 0 auto; max-width: 640px; font-size: 1.02rem; }

/* game layout: mobile = single column, ≥940px = board + side panel */
.game-section { margin: 18px auto 8px; max-width: 920px; }
.game-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.game-board { width: 100%; max-width: 560px; margin: 0 auto; }
.game-side { display: flex; flex-direction: row; flex-wrap: wrap; gap: 10px; justify-content: center; }
.side-card {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 14px; min-height: 56px;
}
.daily-count { font-weight: 800; color: var(--brand-deep); font-variant-numeric: tabular-nums; }
.evo-mini { font-size: 1.12rem; line-height: 1.6; }
.evo-mini i { font-style: normal; color: var(--ink-soft); font-size: .78rem; margin: 0 1px; }
.next-card #next { border-radius: 8px; }
/* share sheet: social network grid */
.share-sheet { align-items: center; }
.sheet {
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: var(--shadow); padding: 16px 18px 14px; width: min(94%, 380px);
  max-height: 96%; overflow: auto;
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.sheet-title { font-weight: 800; font-size: 1.05rem; }
.sheet-close {
  border: none; background: var(--bg2); color: var(--ink-soft); width: 30px; height: 30px;
  border-radius: 50%; cursor: pointer; font-size: 13px; line-height: 1;
}
.sheet-close:hover { color: var(--brand-deep); }
.sheet-net { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px 6px; margin-bottom: 12px; }
.net-btn { display: flex; flex-direction: column; align-items: center; gap: 5px; background: none; border: none; cursor: pointer; padding: 0; }
.net-ico { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: transform .12s; }
.net-btn:hover .net-ico { transform: scale(1.08); }
.net-ico svg { width: 22px; height: 22px; }
.net-name { font-size: .66rem; color: var(--ink-soft); }
.net-ico.x { background: #111; }
.net-ico.telegram { background: #229ED9; }
.net-ico.reddit { background: #FF4500; }
.net-ico.whatsapp { background: #25D366; }
.net-ico.facebook { background: #1877F2; }
.net-ico.instagram { background: linear-gradient(45deg, #F58529, #DD2A7B 55%, #8134AF); }
.net-ico.email { background: #8a8a8a; }
.net-ico.more { background: var(--ink-soft); }
.sheet-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.btn.small { padding: 8px 14px; font-size: .85rem; }
.sheet-url { text-align: center; color: var(--ink-soft); font-size: .76rem; margin: 10px 0 0; word-break: break-all; }
.streak-chip { font-weight: 700; font-size: .9rem; color: var(--brand-deep); }
.lb-card { flex-direction: column; align-items: stretch; gap: 8px; }
.lb-head { display: flex; gap: 6px; }
.lb-tab {
  flex: 1; border: none; background: var(--bg2); color: var(--ink-soft);
  border-radius: 999px; padding: 6px 8px; font-size: .8rem; font-weight: 700; cursor: pointer;
}
.lb-tab:hover { color: var(--brand-deep); }
.lb-tab.active { background: var(--brand); color: #fff; }
.lb-list { list-style: none; margin: 0; padding: 0; font-size: .88rem; }
.lb-list li { display: flex; gap: 8px; align-items: center; padding: 4px 6px; border-top: 1px dashed var(--line); }
.lb-list li:first-child { border-top: 0; padding-top: 0; }
.lb-rank { color: var(--ink-soft); min-width: 18px; }
.lb-score { font-weight: 800; font-variant-numeric: tabular-nums; }
.lb-mode { margin-left: auto; color: var(--ink-soft); font-size: .78rem; }
.lb-empty { color: var(--ink-soft); justify-content: center; }
/* podium: gold / silver / bronze */
.medal {
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 13px; color: #fff; flex: none; position: relative;
}
.medal .crown { position: absolute; top: -14px; right: -10px; font-size: 14px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.35)); }
.lb-list li.top1, .top-runs li.top1 { background: linear-gradient(90deg, rgba(255,193,7,.20), rgba(255,193,7,.02)); }
.lb-list li.top2, .top-runs li.top2 { background: linear-gradient(90deg, rgba(176,190,197,.22), rgba(176,190,197,.02)); }
.lb-list li.top3, .top-runs li.top3 { background: linear-gradient(90deg, rgba(205,127,50,.18), rgba(205,127,50,.02)); }
.lb-list li.top1, .lb-list li.top2, .lb-list li.top3,
.top-runs li.top1, .top-runs li.top2, .top-runs li.top3 {
  border-radius: 10px; border-top: 0; padding-top: 6px; padding-bottom: 6px; margin-top: 2px;
}
.lb-list li.top1 .medal { background: linear-gradient(135deg, #ffe082, #ff9800); box-shadow: 0 0 0 2px rgba(255,213,79,.45), 0 0 16px rgba(255,160,0,.65); }
.lb-list li.top2 .medal { background: linear-gradient(135deg, #eceff1, #90a4ae); box-shadow: 0 0 0 2px rgba(207,216,220,.5), 0 0 12px rgba(144,164,174,.6); }
.lb-list li.top3 .medal { background: linear-gradient(135deg, #ffcc9e, #b5651d); box-shadow: 0 0 0 2px rgba(255,171,145,.45), 0 0 12px rgba(181,101,29,.6); }
.lb-list li.top1 .lb-score, .top-runs li.top1 .lb-score {
  font-size: 1.06rem;
  background: linear-gradient(135deg, #ffd54f, #ff8f00);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lb-list li.top2 .lb-score, .top-runs li.top2 .lb-score {
  background: linear-gradient(135deg, #eceff1, #78909c);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lb-list li.top3 .lb-score, .top-runs li.top3 .lb-score {
  background: linear-gradient(135deg, #ffab73, #b5651d);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.top-runs .medal { margin-right: 2px; }
@media (prefers-reduced-motion: no-preference) {
  .lb-list li.top1 .medal, .top-runs li.top1 .medal { animation: lbPulse 1.8s ease-in-out infinite; }
  @keyframes lbPulse {
    0%, 100% { box-shadow: 0 0 0 2px rgba(255,213,79,.45), 0 0 12px rgba(255,160,0,.5); }
    50% { box-shadow: 0 0 0 3px rgba(255,213,79,.6), 0 0 24px rgba(255,160,0,.9); }
  }
}
@media (max-width: 559px) {
  .lb-card { flex: 1 1 100%; }
}
@media (min-width: 940px) {
  .game-grid { grid-template-columns: minmax(0, 560px) 300px; justify-content: center; align-items: start; }
  .game-side { flex-direction: column; align-items: stretch; }
  .evo-mini { justify-content: center; flex-wrap: wrap; }
}
@media (max-width: 559px) {
  .evo-mini { display: none; }
  .side-card { flex: 1 1 42%; justify-content: center; }
}
/* landscape phones: shrink board to fit the viewport height */
@media (max-height: 660px) and (orientation: landscape) {
  .stage { max-width: calc((100dvh - 240px) * .72); margin: 0 auto; }
  .hero { padding: 8px 0 2px; }
  .hero h1 { font-size: 1.3rem; }
}
.hud {
  display: flex; align-items: stretch; gap: 8px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 10px; box-shadow: var(--shadow); margin-bottom: 10px;
}
.hud-cell { display: flex; flex-direction: column; min-width: 64px; padding: 0 6px; }
.hud-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); }
.hud-value { font-size: 1.25rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.hud-cell.chips { flex-direction: row; align-items: center; gap: 6px; margin-left: auto; }
.chip {
  border: 1px solid var(--line); background: var(--bg2); color: var(--ink);
  border-radius: 999px; padding: 6px 12px; font-size: .82rem; cursor: pointer; font-weight: 600;
}
.chip:hover { border-color: var(--brand); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip.icon { padding: 6px 10px; }
.stage {
  position: relative; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line); box-shadow: var(--shadow); background: #fdf1e3;
}
@media (prefers-color-scheme: dark) { .stage { background: #241d20; } }
#board { display: block; width: 100%; height: auto; touch-action: none; cursor: crosshair; }
.overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 18px; text-align: center;
}
.start-hint { pointer-events: none; }
.start-hint span {
  background: rgba(51, 39, 42, .72); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: .95rem; animation: bob 1.6s ease-in-out infinite;
}
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@media (prefers-reduced-motion: reduce) { .start-hint span { animation: none; } }
.gameover .panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: var(--shadow); padding: 16px 20px 12px; max-width: 340px; width: 100%;
  max-height: 94%; overflow-y: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.go-title { margin: 0 0 4px; font-size: 1.25rem; }
.go-newbest { color: var(--brand-deep); font-weight: 800; margin: 0 0 2px; font-size: .92rem; }
.go-score { font-size: 2.3rem; font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1.1; }
.go-score-row { margin: 2px 0; }
.go-biggest, .go-daily, .go-countdown { color: var(--ink-soft); font-size: .86rem; margin: 2px 0; }
.go-actions { display: flex; gap: 8px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }
.btn {
  border: 1px solid var(--line); background: var(--bg2); color: var(--ink);
  border-radius: 12px; padding: 9px 16px; font-size: .92rem; font-weight: 700; cursor: pointer;
}
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-deep); }
.top-runs {
  margin: 10px 0 0; padding: 0; list-style: none; color: var(--ink-soft);
  font-size: .82rem; max-height: 148px; overflow-y: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.top-runs li { display: flex; justify-content: space-between; padding: 3px 0; border-top: 1px dashed var(--line); }
.share-toast {
  position: absolute; inset: auto; left: 50%; bottom: 18px; transform: translateX(-50%);
  background: rgba(51, 39, 42, .85); color: #fff; border-radius: 999px; padding: 10px 18px;
  font-size: .95rem; white-space: nowrap; max-width: 92%;
}
.next-card #next { border-radius: 8px; }
.kb-hint { text-align: center; color: var(--ink-soft); font-size: .85rem; margin: 10px 0 0; }
/* battle banner (async duel via share links) */
#battle-banner {
  text-align: center; margin: 0 0 10px;
  background: linear-gradient(90deg, #ff8a5c, #ff5a5f);
  color: #fff; font-weight: 800; font-size: .9rem;
  border-radius: 999px; padding: 8px 18px;
  box-shadow: 0 6px 18px rgba(255, 90, 95, .35);
}
.go-daily.battle-win {
  background: linear-gradient(90deg, rgba(255, 193, 7, .22), rgba(255, 193, 7, .05));
  border-radius: 10px; padding: 6px 10px; font-weight: 800; color: var(--brand-deep);
}
.top-runs-toggle {
  display: block; margin: 6px auto 0; background: none; border: none;
  color: var(--brand-deep); font-weight: 700; font-size: .8rem; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.top-runs-toggle:hover { text-decoration: underline; }
/* pager: glass segmented pill */
.lb-pager {
  display: inline-flex; align-items: center; gap: 2px;
  align-self: center; margin-top: 8px;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 999px;
  padding: 4px; box-shadow: 0 2px 8px rgba(51, 39, 42, .08);
}
.lb-pager button {
  width: 32px; height: 32px; border-radius: 50%; border: none;
  background: transparent; color: var(--ink-soft); cursor: pointer;
  font-size: .85rem; line-height: 1; display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s, transform .15s;
}
.lb-pager button:hover:not(:disabled) { background: var(--brand); color: #fff; transform: scale(1.06); }
.lb-pager button:active:not(:disabled) { transform: scale(.94); }
.lb-pager button:disabled { opacity: .28; cursor: default; }
.lb-page {
  min-width: 46px; text-align: center; font-size: .8rem; font-weight: 800;
  color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: .04em;
}
.noscript-msg { font-weight: 700; color: var(--brand-deep); text-align: center; }

/* content sections */
.content { margin: 40px auto; max-width: 760px; }
.content h2 { font-size: 1.45rem; margin: 0 0 12px; letter-spacing: -.3px; }
.steps { padding-left: 20px; }
.steps li { margin: 10px 0; }
.steps strong { display: block; }
.evo-chart {
  list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 0;
}
.evo-chart li {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 12px; min-width: 84px; font-size: .85rem; color: var(--ink-soft);
}
.evo-chart .em { font-size: 1.7rem; }
.tips-list { padding-left: 20px; }
.tips-list li { margin: 8px 0; }
.faq-item { margin: 14px 0; }
.faq-item h3 { margin: 0 0 4px; font-size: 1.05rem; }
.faq-item p { margin: 0; color: var(--ink-soft); }

/* footer */
.site-footer {
  max-width: 1040px; margin: 30px auto 0; padding: 22px 20px 40px;
  border-top: 1px solid var(--line); color: var(--ink-soft); font-size: .9rem;
}
.lang-row { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0 0 12px; }
.copyright { margin-top: 12px; font-size: .8rem; }

@media (max-width: 560px) {
  .site-nav > a { display: none; }
  .hud-cell { min-width: 54px; }
  .hud-value { font-size: 1.05rem; }
  main { padding: 0 12px; }
  .site-header { padding: 12px; }
  .chip { padding: 8px 13px; }
  .content { margin: 30px auto; }
}
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
