* { box-sizing: border-box; }
:root { --accent: #ffc47a; --text: #f2f0ec; --muted: #a6b0c1; --gap: 10px; --pad: 12px; }
body { margin: 0; min-height: 100svh; background: radial-gradient(ellipse at 35% 0%, #253040 0, #11151e 65%); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; }
button, a { font: inherit; }
button { cursor: pointer; border: 0; transition: background .15s, opacity .15s; }
button:disabled { cursor: default; opacity: .4; }
.shell { max-width: 760px; margin: auto; padding: clamp(22px, 3vh, 32px) 28px 24px; }
.page-nav { margin-bottom: 20px; }
.back-link { color: var(--muted); font-size: 13px; text-decoration: none; display: flex; gap: 10px; align-items: center; }
.back-link:hover { color: var(--text); }
.window-button { background: #ffffff08; border: 1px solid #ffffff16; color: var(--muted); border-radius: 8px; }
.page-nav { flex-wrap: wrap; }.nav-tools { display: flex; gap: 7px; margin-left: auto; }
.feedback-toggle { background: #ffffff06; color: var(--muted); border: 1px solid #ffffff14; border-radius: 8px; font-size: 11px; padding: 7px 9px; min-height: 34px; white-space: nowrap; }
.feedback-toggle[aria-pressed="true"] { color: #f1c996; border-color: #ffc47a30; }.feedback-toggle:hover { background: #ffffff0c; }
.heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.eyebrow { font-size: 11px; color: var(--muted); letter-spacing: .12em; margin: 0 0 8px; }
.eyebrow > span { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 6px; background: var(--accent); }
h1 { font-size: clamp(44px, 8vw, 60px); line-height: 1; letter-spacing: -.065em; margin: 0; font-weight: 800; }
h1 > span { color: var(--accent); }
.heading-note { font-size: 13px; line-height: 1.8; color: var(--muted); text-align: right; padding-right: 4px; }
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 32px; align-items: start; }
.board-section { min-width: 0; }
.board-decision { display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:center; gap:12px; margin-bottom:10px; }
.board-decision .board-hud { flex-wrap:wrap; margin:0; gap:6px; }
.board-preview { display:flex; align-items:center; gap:8px; }
.board-preview .section-label { font-size:10px; }
.board-preview .preview-row { margin:0; gap:8px; }
.board-preview .preview-card { flex:none; width:40px; height:48px; border-radius:7px; }
.board-preview .preview-card .value { font-size:24px; transform:translateY(-5px); }
.board-preview .preview-card .face { transform:scale(.65); bottom:10%; }
.board-preview .preview-row > p { max-width:90px; font-size:10px; line-height:1.6; }
.board-hud { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 25px; margin-bottom: 10px; font-size: 11px; color: var(--muted); }
.board-hud strong { color: var(--accent); font-size: 15px; padding-left: 4px; font-variant-numeric: tabular-nums; }.target-note { font-size: 10px; color: #8492a7; }
.streak { border: 1px solid #ffffff12; border-radius: 20px; padding: 4px 10px; font-size: 10px; white-space: nowrap; background: #ffffff04; }
.streak[data-level="active"] { color: #ffce87; background: #ffc47a14; border-color: #ffc47a55; }.streak[data-level="hot"] { color: #ffb5c5; background: #f18b9b16; border-color: #f18b9b55; }
.board-frame { position: relative; border-radius: 20px; box-shadow: 0 16px 40px #0003; }
.board { position: relative; width: 100%; aspect-ratio: 1; background: #3a4556; border-radius: 20px; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; box-shadow: inset 0 1px 0 #ffffff14; }
.slots, .tiles { position: absolute; inset: var(--pad); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: repeat(4, minmax(0, 1fr)); gap: var(--gap); pointer-events: none; }
.slots i { background: #2b3443; border-radius: 11px; box-shadow: inset 0 2px 4px #0002; }
.tile { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 11px; color: #3a424e; background: #f1ebdf; box-shadow: inset 0 -5px 0 #d4ccbd, 0 2px 3px #0002; overflow: hidden; min-width: 0; }
.tile::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 1px 0 #ffffff50; pointer-events: none; }
.tile .value { font-size: clamp(24px, 4vw, 42px); font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.035em; transform: translateY(-9px); }
.tile.big .value { font-size: clamp(21px, 3.4vw, 32px); }
.tile.huge .value { font-size: clamp(15px, 2.6vw, 25px); }
.tile[data-value="1"], .rule-one { background: #7dc7e9; color: #183e58; box-shadow: inset 0 -5px 0 #56aaca; }
.tile[data-value="2"], .rule-two { background: #f18b9b; color: #692c40; box-shadow: inset 0 -5px 0 #d1697c; }
.tile[data-value="6"] { background: #f6dfac; box-shadow: inset 0 -5px 0 #d9c08a; }
.tile[data-value="12"] { background: #ffc47a; box-shadow: inset 0 -5px 0 #dba05a; }
.tile[data-value="24"] { background: #efab85; box-shadow: inset 0 -5px 0 #cf8869; }
.tile[data-value="48"] { background: #a3c9ad; box-shadow: inset 0 -5px 0 #7fab8b; }
.tile[data-value="96"] { background: #b9afe2; box-shadow: inset 0 -5px 0 #958bbc; }
.tile.advanced { background: #c5b6f0; box-shadow: inset 0 -5px 0 #a18bd4; }
.face { position: absolute; bottom: 17%; width: 25px; height: 12px; opacity: .8; }
.face::before { content: ""; position: absolute; left: 2px; top: 0; width: 4px; height: 5px; border-radius: 50%; background: currentColor; box-shadow: 17px 0 currentColor; }
.face::after { content: ""; position: absolute; bottom: 0; left: 10px; width: 7px; height: 4px; border: 2px solid currentColor; border-top: 0; border-radius: 0 0 5px 5px; }
.tile[data-value="1"] .face::after { left: 11px; height: 3px; width: 6px; border: 0; border-radius: 4px; background: currentColor; }
.tile[data-value="2"] .face::after { width: 5px; height: 6px; border: 2px solid currentColor; border-radius: 50%; }
.tile.moving { animation: arrive 160ms cubic-bezier(.2,.8,.2,1) both; }
.tile.merged .value { animation: celebrate 420ms 120ms cubic-bezier(.2,.8,.2,1) both; }
.tile.merged .face { animation: happy-face 420ms 120ms ease both; }
.tile.merged::after { animation: card-glow 600ms 120ms ease both; }
@keyframes arrive { from { transform: translate(var(--from-x, 0px), var(--from-y, 0px)); } to { transform: translate(0, 0); } }
@keyframes celebrate { 25% { transform: translateY(-9px) scale(.82, 1.15); } 50% { transform: translateY(-12px) scale(1.23, .95); } 75% { transform: translateY(-9px) scale(.98, 1.06); } }
@keyframes happy-face { 40% { transform: translateY(-3px) rotate(-10deg); } 70% { transform: translateY(1px) rotate(8deg); } }
@keyframes card-glow { 30% { background: #fff4cb65; box-shadow: inset 0 0 0 2px #fff8da; } }
.effects-layer { position: absolute; inset: 0; border-radius: 20px; overflow: hidden; z-index: 1; pointer-events: none; }
.merge-ring, .merge-spark, .floating-score, .milestone-confetti { position: absolute; pointer-events: none; }
.merge-ring { border: 3px solid var(--spark-color); border-radius: 50%; box-shadow: 0 0 18px #ffc47a66; animation: ring-expand 650ms 120ms ease-out both; }
@keyframes ring-expand { from { opacity: .95; transform: translate(-50%, -50%) scale(.2); } to { opacity: 0; transform: translate(-50%, -50%) scale(1.45); } }
.merge-spark { width: 6px; height: 6px; border-radius: 2px; background: var(--spark-color); box-shadow: 0 0 6px var(--spark-color); animation: spark-burst 680ms 120ms cubic-bezier(.15,.7,.35,1) both; }
@keyframes spark-burst { from { opacity: 1; transform: translate(-50%, -50%) scale(.5); } 30% { opacity: 1; } to { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(var(--spin)) scale(.25); } }
.floating-score { color: #fff4cc; font-size: clamp(16px, 3vw, 22px); font-weight: 850; text-shadow: 0 2px 8px #101319, 0 0 12px #ffc47a; animation: score-float 850ms 120ms ease-out both; }
@keyframes score-float { from { opacity: 0; transform: translate(-50%, -20%); } 25% { opacity: 1; } 60% { opacity: 1; } to { opacity: 0; transform: translate(-50%, -190%); } }
.milestone-confetti { width: 6px; height: 11px; border-radius: 2px; background: var(--spark-color); animation: confetti-fall 950ms 80ms ease-out both; }
@keyframes confetti-fall { from { opacity: 0; transform: rotate(0deg); } 15% { opacity: 1; } 70% { opacity: 1; } to { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--spin)); } }
.board-frame.merge-impact { animation: merge-impact 450ms 110ms ease-out; }.board-frame.milestone-impact { animation: milestone-impact 650ms 110ms ease-out; }
@keyframes merge-impact { 30% { box-shadow: 0 0 0 2px #ffce8740, 0 0 35px #ffc47a30, 0 16px 40px #0003; } }
@keyframes milestone-impact { 20% { transform: translateY(-3px) rotate(-.35deg); box-shadow: 0 0 0 3px #ffc47a85, 0 0 65px #ffc47a55; } 45% { transform: translateY(1px) rotate(.35deg); } 70% { transform: none; } }
.stats .score-pop { display: inline-block; animation: scoreboard-pop 430ms 120ms ease-out; }
@keyframes scoreboard-pop { 35% { transform: scale(1.2); color: #fff3c9; text-shadow: 0 0 16px #ffc47a80; } }
.celebration-banner { position: absolute; top: 10%; left: 50%; z-index: 2; pointer-events: none; text-align: center; padding: 12px 24px; background: linear-gradient(135deg, #302641ee, #453322ee); border: 1px solid #ffe0ab99; border-radius: 16px; box-shadow: 0 8px 30px #0006, 0 0 32px #ffc47a35; transform: translateX(-50%); min-width: 170px; animation: banner-arrive 350ms cubic-bezier(.2,1.45,.4,1) both; }
.celebration-banner span { display: block; color: #ffdda3; font-size: 13px; font-weight: 700; white-space: nowrap; }
.celebration-banner strong { display: block; font-size: 28px; margin-top: 4px; color: #fff4d1; font-variant-numeric: tabular-nums; }
.celebration-banner[data-kind="milestone"] strong { font-size: 40px; }.celebration-banner[data-kind="milestone"] { background: linear-gradient(135deg, #47324fee, #67442bee); }
@keyframes banner-arrive { from { opacity: 0; transform: translate(-50%, 8px) scale(.65); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }
.effects-off .tile.merged .value, .effects-off .tile.merged .face, .effects-off .tile.merged::after { animation: none; }
.board.bump { animation: bump 160ms ease; }
@keyframes bump { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.board-caption { color: var(--muted); font-size: 11px; text-align: center; margin: 17px 0 0; line-height: 1.8; }
.board-caption > span { margin-right: 6px; color: var(--accent); }
.message { min-height: 36px; margin: 10px 0 0; font-size: 12px; color: var(--accent); text-align: center; line-height: 1.7; }
.control-panel { background: #1c2330; border: 1px solid #ffffff0c; border-radius: 18px; padding: 18px; }
.section-label { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; letter-spacing: .08em; }
.section-label > span { color: var(--accent); font-size: 18px; line-height: 1; }
.preview-row { display: flex; gap: 14px; align-items: center; margin-top: 12px; }
.preview-card { width: 66px; height: 78px; flex: none; transform: rotate(-5deg); }
.preview-card .value { font-size: 31px; }
.preview-row > p { font-size: 11px; color: var(--muted); line-height: 1.9; margin: 0; }
.stats { margin-top: 16px; padding-top: 16px; border-top: 1px solid #ffffff0e; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stats > div { min-width: 0; }
.stats span { display: block; color: var(--muted); font-size: 11px; margin-bottom: 5px; }
.stats strong { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; word-break: break-all; }
.stats > div:first-child strong { color: var(--accent); }
.run-info { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; margin-top: 16px; }
.run-info b { font-weight: 600; color: var(--text); }
.actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.primary, .secondary { min-height: 42px; border-radius: 9px; padding: 10px 14px; font-size: 12px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.primary { background: var(--accent); color: #2e2319; }
.primary:hover { background: #ffd39b; }
.secondary { background: #ffffff06; border: 1px solid #ffffff16; color: var(--text); }
.secondary:hover:not(:disabled) { background: #ffffff0e; }
.secondary kbd { color: var(--muted); font: inherit; font-size: 11px; margin-left: auto; }

.game-help { border-top: 1px solid #ffffff0e; margin-top: 12px; padding-top: 8px; }
.game-help summary { font-size: 11px; color: var(--muted); }
.game-help p { font-size: 11px; }
.rule-equation { display: flex; align-items: center; gap: 7px; margin: 8px 0; }
.rule-equation span { display: grid; place-items: center; width: 32px; height: 38px; border-radius: 5px; color: #3a424e; background: #f1ebdf; font-size: 19px; font-weight: 750; }
.rule-equation span.rule-one { background: #7dc7e9; color: #183e58; }.rule-equation span.rule-two { background: #f18b9b; color: #692c40; }
.rule-equation b { font-weight: 400; }
footer { display: flex; justify-content: space-between; color: #8390a4; font-size: 10px; gap: 16px; margin-top: 18px; }
.game-over { position: absolute; inset: 0; z-index: 2; padding: 28px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; background: #192331ed; backdrop-filter: blur(5px); border-radius: 20px; }
.game-over h2 { margin: 6px 0 8px; font-size: 26px; letter-spacing: -.04em; }
.game-over .final-score { color: var(--accent); font-size: clamp(36px, 8vw, 54px); margin: 4px 0; font-weight: 800; font-variant-numeric: tabular-nums; }
#final-detail { color: var(--muted); font-size: 12px; line-height: 1.8; margin: 5px 0 22px; }
.end-actions { display: flex; gap: 8px; }
@media (max-width: 680px) {
  :root { --gap: 8px; --pad: 10px; }
  .shell { max-width: 480px; padding: 20px 18px max(20px, env(safe-area-inset-bottom)); }
  .page-nav { margin-bottom: 20px; }.heading { margin-bottom: 22px; }.heading-note { font-size: 11px; }
  .nav-tools { gap: 5px; }.feedback-toggle { font-size: 10px; padding: 6px 7px; }
  .game-layout { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .control-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; padding: 18px; }
  .stats { grid-area: 1 / 1 / auto / -1; display: flex; flex-direction: row; justify-content:space-between; gap: 12px; margin: 0; padding: 0; border: 0; }
  .board-preview { grid-area:auto; gap:6px; }.board-preview .section-label { white-space:nowrap; line-height:1.4; }.board-preview .section-label span { display:none; }
  .board-preview .preview-row { margin:0; gap:6px; }.board-preview .preview-card { width:36px; height:44px; }.board-preview .preview-card .value { font-size:24px; }
  .board-preview .preview-row > p { display:none; }
  .stats > div { display: flex; align-items: center; justify-content: space-between; gap: 8px; }.stats span { margin: 0; }.stats strong { font-size: 21px; }
  .preview-card { width: 54px; height: 64px; }.preview-card .value { font-size: 28px; }.preview-row { gap: 10px; margin-top: 10px; }.preview-row p { font-size: 10px; }
  .run-info { grid-area: 2 / 1 / 3 / 3; border-top: 1px solid #ffffff0e; padding-top: 12px; margin: 0; }
  .actions { grid-area: 3 / 1 / 4 / 3; display: grid; grid-template-columns: 1fr 1fr; margin: 0; }
  .game-help { grid-area: 4 / 1 / 5 / 3; margin: 0; padding-top: 8px; }
  .tile .value { font-size: clamp(24px, 8vw, 39px); }.tile.big .value { font-size: clamp(21px, 6.5vw, 30px); }.tile.huge .value { font-size: clamp(15px, 5vw, 23px); }
  .board-caption { font-size: 10px; margin-top: 13px; }.message { min-height: 22px; margin-top: 8px; }footer { margin-top: 22px; }
}
@media (max-width: 350px) { .shell { padding-inline: 12px; }.control-panel { padding: 14px; gap: 14px 12px; }.preview-row { gap: 7px; }.stats strong { font-size: 18px; } }
@media (max-width: 350px) { body:not(.game-window) .page-nav { gap:8px; } body:not(.game-window) .nav-tools .window-button { padding:6px 7px; font-size:10px; } }
.game-window .shell { max-width: 760px; padding: 12px 16px; }
.game-window .page-nav { margin-bottom: 10px; }.game-window .heading { margin-bottom: 14px; }.game-window h1 { font-size: 36px; }
.game-window .heading-note, .game-window .eyebrow, .game-window footer { display: none; }
.game-window .game-layout { grid-template-columns: minmax(0, 1fr) 180px; gap: 16px; }
.game-window .control-panel { display: block; padding: 12px; }.game-window .preview-card { width: 45px; height: 54px; }.game-window .preview-row p { font-size: 10px; }
.game-window .board-preview .preview-row p { display:none; }.game-window .board-preview .preview-card { width:36px; height:44px; }
.game-window .stats { display: grid; margin-top: 14px; padding-top: 12px; border-top: 1px solid #ffffff0e; gap: 8px; }
.game-window .stats > div { display: block; }.game-window .stats strong { font-size: 18px; }.game-window .stats span { font-size: 10px; margin-bottom: 4px; }
.game-window .run-info { margin-top: 10px; padding: 0; border: 0; font-size: 10px; }.game-window .actions { margin-top: 12px; gap: 6px; }
.game-window .primary, .game-window .secondary { min-height: 32px; padding: 7px 10px; font-size: 11px; }
.game-window .board-caption { margin-top: 10px; font-size: 9px; }.game-window .message { font-size: 10px; min-height: 28px; }
.game-window .board-hud { margin-bottom: 6px; font-size: 10px; }.game-window .target-note { display: none; }.game-window .streak { padding: 3px 7px; }
.game-window .feedback-toggle { min-height: 30px; padding: 6px 7px; font-size: 10px; }
@media (prefers-reduced-motion: reduce) { .tile.moving, .tile.merged .value, .tile.merged .face, .tile.merged::after, .board.bump, .board-frame.merge-impact, .board-frame.milestone-impact, .stats .score-pop, .celebration-banner { animation: none; } button { transition: none; } }

/* 新牌接棒：入场高光与预览换牌让每一步的变化更易辨认。 */
.tile.incoming::after { content:""; position:absolute; inset:0; border:2px solid #fff1c5; border-radius:inherit; pointer-events:none; animation:entry-highlight .48s ease-out both; }
.preview-card.preview-deal { animation:preview-deal .35s ease-out; }
@keyframes entry-highlight { from { opacity:.85; } to { opacity:0; } }
@keyframes preview-deal { 35% { transform:translateY(-4px) rotate(3deg); filter:brightness(1.15); } }
.effects-off .tile.incoming::after,.effects-off .preview-deal,.effects-off .board.bump { animation:none; }
.effects-off .tile.incoming::after { display:none; }
@media(prefers-reduced-motion:reduce) { .tile.incoming::after { display:none; }.preview-card.preview-deal { animation:none; } }
