:root {
  --ink: #3f4d48;
  --ink-soft: #6c776f;
  --paper: #fffdf7;
  --dad: #73b7e7;
  --dad-deep: #397fae;
  --mom: #f3ce55;
  --mom-deep: #a77c16;
  --daughter: #f3a3bb;
  --daughter-deep: #b85e7a;
  --green: #74a76a;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: var(--ink);
  background: #fbefd0;
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body { min-height: 100vh; margin: 0; overflow-x: hidden; background: linear-gradient(180deg, #fff6d9, #e8f1d8); }
button, a { font: inherit; }
button { color: inherit; }
.page-dots { position: fixed; inset: 0; pointer-events: none; opacity: .34; background-image: radial-gradient(#d9b86a 1.2px, transparent 1.2px); background-size: 31px 31px; }

.topbar, .game-shell, .rules { position: relative; z-index: 1; width: min(1180px, calc(100% - 30px)); margin-inline: auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 22px 0 14px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; color: #435b49; font-family: Georgia, "Microsoft YaHei", serif; font-size: clamp(30px, 4vw, 49px); line-height: 1; }
h2 { margin-bottom: 10px; font-size: clamp(25px, 3vw, 37px); line-height: 1.1; }
.eyebrow { margin-bottom: 7px; color: #8a7243; font-size: 12px; font-weight: 900; letter-spacing: .13em; }
.top-actions { display: flex; gap: 9px; }
.circle-button { display: grid; width: 46px; height: 46px; place-items: center; border: 3px solid rgba(255,255,255,.86); border-radius: 50%; background: rgba(255,253,247,.86); box-shadow: 0 5px 0 rgba(102,92,61,.1); color: #53664f; cursor: pointer; font-size: 23px; font-weight: 900; text-decoration: none; }
.circle-button:hover { transform: translateY(-2px); }
.circle-button:focus-visible, button:focus-visible, a:focus-visible { outline: 5px solid rgba(97,143,197,.42); outline-offset: 4px; }

.game-shell { display: grid; grid-template-columns: minmax(0, 1fr) minmax(285px, 340px); gap: 20px; align-items: stretch; }
.board-panel, .panel-card, .rules { border: 3px solid rgba(255,255,255,.82); background: rgba(255,253,247,.9); box-shadow: 0 18px 55px rgba(75,77,49,.13), 0 7px 0 rgba(88,94,55,.08); }
.board-panel { padding: 14px; border-radius: 38px; }
.game-board { position: relative; min-height: 570px; overflow: hidden; border-radius: 28px; background: linear-gradient(180deg, #bde3ed 0 48%, #a9d384 49% 100%); }
.game-board::after { position: absolute; right: -70px; bottom: 36px; left: -60px; height: 180px; content: ""; border-radius: 50% 50% 0 0; background: #8cc071; opacity: .75; }
.board-spaces { position: absolute; z-index: 3; inset: 0; margin: 0; padding: 0; list-style: none; }
.board-space { position: absolute; display: grid; width: clamp(42px, 6.1vw, 66px); aspect-ratio: 1; place-items: center; border: 4px solid rgba(255,255,255,.92); border-radius: 18px; background: #fff9e9; box-shadow: 0 7px 0 rgba(79,78,52,.14), 0 10px 16px rgba(70,76,52,.1); transform: translate(-50%, -50%) rotate(var(--tilt, 0deg)); transition: background .22s, transform .22s; }
.board-space::after { color: rgba(74,83,62,.5); content: attr(data-number); font-family: Georgia, serif; font-size: 12px; font-weight: 900; }
.board-space.is-start::before { position: absolute; top: -8px; padding: 3px 7px; content: "起点"; color: #fff; border-radius: 99px; background: #678f60; font-size: 9px; font-weight: 900; }
.board-space.owner-dad { background: var(--dad); }
.board-space.owner-mom { background: var(--mom); }
.board-space.owner-daughter { background: var(--daughter); }
.board-space.just-painted { transform: translate(-50%, -50%) rotate(var(--tilt, 0deg)) scale(1.15); }

.center-scene {
  position: absolute;
  z-index: 1;
  inset: 20% 17% 17%;
  overflow: hidden;
  border: 5px solid rgba(255,255,255,.82);
  border-radius: 38px;
  background-color: #bde9f6;
  background-image: url("assets/pig-family-background.png");
  background-position: center;
  background-size: cover;
  box-shadow: 0 11px 28px rgba(58,91,55,.2), inset 0 0 0 2px rgba(255,255,255,.35);
}

.player-token { position: absolute; z-index: 6; display: grid; width: 55px; height: 67px; place-items: center; border: 3px solid #fff; border-radius: 24px; box-shadow: 0 7px 13px rgba(68,67,46,.22); transform: translate(calc(-50% + var(--token-x, 0px)), calc(-70% + var(--token-y, 0px))); transition: top .17s ease, left .17s ease, transform .2s; }
.player-token span { font-size: 31px; line-height: 1; }
.player-token small { font-size: 10px; font-weight: 900; }
.dad-token { background: #d9effc; --token-x: -17px; --token-y: -12px; }
.mom-token { background: #fff0a9; --token-x: 17px; --token-y: -12px; }
.daughter-token { background: #fbd9e4; --token-x: 0px; --token-y: 15px; }
.player-token.is-active { transform: translate(calc(-50% + var(--token-x, 0px)), calc(-70% + var(--token-y, 0px))) scale(1.13); }

.sparkles { position: absolute; z-index: 9; inset: 0; pointer-events: none; }
.spark { position: absolute; font-size: 24px; animation: sparkle .8s ease-out forwards; }
.score-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; padding-top: 12px; }
.score-chip { display: grid; min-width: 0; padding: 9px 11px; grid-template-columns: auto 1fr auto; gap: 5px; align-items: center; border-radius: 18px; }
.score-chip span { font-size: 24px; }
.score-chip b { font-size: 13px; }
.score-chip strong { font-size: 24px; }
.score-chip small { grid-column: 2 / -1; color: rgba(55,62,54,.67); font-size: 10px; font-weight: 800; }
.dad-score { background: #d9effc; }
.mom-score { background: #fff0a9; }
.daughter-score { background: #fbd9e4; }

.control-panel { display: flex; }
.panel-card { width: 100%; padding: clamp(25px, 3vw, 34px); border-radius: 34px; }
.turn-card { display: flex; flex-direction: column; justify-content: center; }
.turn-pill { display: flex; width: fit-content; margin-bottom: 24px; padding: 8px 12px; gap: 8px; align-items: center; border-radius: 999px; background: #d9effc; }
.turn-pill[data-player="mom"] { background: #fff0a9; }
.turn-pill[data-player="daughter"] { background: #fbd9e4; }
.turn-pill span { font-size: 27px; }
.turn-pill b { font-size: 13px; }
.turn-card > p:not(.eyebrow):not(.progress-copy) { min-height: 3.2em; color: var(--ink-soft); font-weight: 700; line-height: 1.6; }
.dice-button { display: grid; width: 174px; min-height: 177px; margin: 18px auto 25px; place-items: center; border: 0; border-radius: 38px; background: linear-gradient(145deg, #fff, #f8edd1); box-shadow: inset 0 0 0 5px rgba(255,255,255,.9), 0 13px 0 #d8bd72, 0 18px 26px rgba(90,75,45,.17); cursor: pointer; }
.dice-button:hover { transform: translateY(-3px); }
.dice-button:active { transform: translateY(7px); box-shadow: inset 0 0 0 5px rgba(255,255,255,.9), 0 6px 0 #d8bd72; }
.dice-button:disabled { cursor: wait; opacity: .72; }
.dice-button span { display: grid; width: 94px; height: 94px; place-items: center; border-radius: 25px; background: #fff; box-shadow: 0 6px 16px rgba(80,68,43,.13); color: #57714e; font-family: Georgia, serif; font-size: 58px; font-weight: 900; }
.dice-button b { color: #735d2d; font-size: 18px; }
.dice-button.is-rolling span { animation: roll .22s linear infinite; }
.progress-copy { margin: 0 0 8px; color: var(--ink-soft); font-size: 12px; font-weight: 900; text-align: center; }
.progress-track { height: 13px; overflow: hidden; border-radius: 99px; background: #ece4cf; }
.progress-track i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--dad), var(--mom), var(--daughter)); transition: width .3s; }

.meet-card, .result-card { text-align: center; }
.meet-card { background: linear-gradient(150deg, #fffdf7, #f9e4c9); }
.meet-avatars { margin: 30px 0 20px; font-size: clamp(58px, 8vw, 88px); letter-spacing: -.18em; filter: drop-shadow(0 8px 2px rgba(87,72,45,.13)); animation: meet .75s ease-in-out infinite alternate; }
.meet-card > p:not(.eyebrow) { color: var(--ink-soft); font-size: 18px; font-weight: 700; line-height: 1.7; }
.primary-button { width: 100%; margin-top: 22px; padding: 16px 20px; border: 0; border-radius: 18px; background: #65955d; box-shadow: 0 7px 0 #477641; color: #fff; cursor: pointer; font-weight: 900; }
.primary-button:hover { transform: translateY(-2px); }
.trophy { display: block; margin: 10px 0 15px; font-size: 76px; animation: bob 1s ease-in-out infinite alternate; }
.ranking-list { display: grid; margin: 25px 0; padding: 0; gap: 10px; list-style: none; }
.ranking-item { display: grid; padding: 11px 14px; grid-template-columns: auto auto 1fr auto; gap: 8px; align-items: center; border-radius: 18px; text-align: left; }
.ranking-item .rank { font-size: 20px; font-weight: 900; }
.ranking-item .avatar { font-size: 30px; }
.ranking-item strong { text-align: right; }
.ranking-item[data-player="dad"] { background: #d9effc; }
.ranking-item[data-player="mom"] { background: #fff0a9; }
.ranking-item[data-player="daughter"] { background: #fbd9e4; }

.rules { display: flex; margin-top: 18px; margin-bottom: 34px; padding: 15px 24px; align-items: center; justify-content: space-around; border-radius: 26px; }
.rules div { display: flex; gap: 10px; align-items: center; }
.rules div > span { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 50%; background: #f2d878; font-weight: 900; }
.rules p { margin: 0; }
.rules b, .rules small { display: block; }
.rules small { margin-top: 2px; color: var(--ink-soft); font-size: 10px; font-weight: 700; }
.rules > i { color: #9b9a78; font-style: normal; font-weight: 900; }

[hidden] { display: none !important; }
@keyframes roll { to { transform: rotate(90deg); } }
@keyframes bob { to { transform: translateY(-8px) rotate(4deg); } }
@keyframes meet { to { transform: scale(1.08); } }
@keyframes sparkle { from { opacity: 1; transform: translateY(0) scale(.6) rotate(0); } to { opacity: 0; transform: translateY(-90px) scale(1.3) rotate(120deg); } }

@media (max-width: 900px) {
  .game-shell { grid-template-columns: 1fr; }
  .game-board { min-height: 600px; }
  .control-panel { min-height: 470px; }
}

@media (max-width: 620px) {
  .topbar, .game-shell, .rules { width: min(100% - 18px, 1180px); }
  .topbar { align-items: flex-start; }
  .topbar .eyebrow { display: none; }
  h1 { max-width: 6em; }
  .circle-button { width: 40px; height: 40px; }
  .board-panel { padding: 8px; border-radius: 28px; }
  .game-board { min-height: 430px; border-radius: 22px; }
  .board-space { width: 42px; border-width: 3px; border-radius: 13px; }
  .player-token { width: 42px; height: 53px; border-radius: 17px; }
  .player-token span { font-size: 24px; }
  .player-token small { font-size: 8px; }
  .center-scene { inset: 22% 17% 19%; border-width: 3px; border-radius: 23px; }
  .score-chip { padding: 7px; grid-template-columns: auto 1fr; }
  .score-chip span { font-size: 20px; }
  .score-chip strong { grid-column: 1 / -1; font-size: 21px; text-align: center; }
  .score-chip small { display: none; }
  .rules { padding: 14px 10px; }
  .rules div { flex-direction: column; gap: 4px; text-align: center; }
  .rules small { display: none; }
}

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