  * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }
  html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: #050a1f;
  }
  body {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 0; left: 0;
  }

  #app {
    position: relative;
    width: 100vw;
    height: 100vh;
    max-width: 500px;
    max-height: 100vh;
    margin: 0 auto;
    overflow: hidden;
    background: linear-gradient(180deg, #0a1532 0%, #1a1f3a 60%, #0f1530 100%);
  }

  /* === 通用 === */
  .screen {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    transition: opacity 0.4s ease;
    opacity: 1;
  }
  .screen.hidden {
    opacity: 0;
    pointer-events: none;
  }

  /* 背景云 */
  .bg-cloud {
    position: absolute;
    pointer-events: none;
    color: #1c2752;
    opacity: 0.7;
  }

  /* === 加载页 === */
  #loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
  }
  .loading-mooncake-wrap {
    position: relative;
    width: 130px;
    height: 130px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .loading-mooncake {
    width: 100%;
    height: 100%;
    animation: floatMoon 1.6s ease-in-out infinite;
  }
  @keyframes floatMoon {
    0%, 100% { transform: translateY(0) rotate(-3deg); }
    50% { transform: translateY(-14px) rotate(3deg); }
  }
  .loading-trail {
    position: absolute;
    top: 4px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 4px;
  }
  .loading-trail span {
    width: 3px;
    height: 10px;
    background: rgba(180, 195, 235, 0.45);
    border-radius: 2px;
    animation: trailWiggle 1.4s ease-in-out infinite;
  }
  .loading-trail span:nth-child(2) { animation-delay: 0.15s; }
  .loading-trail span:nth-child(3) { animation-delay: 0.3s; }
  @keyframes trailWiggle {
    0%, 100% { transform: scaleY(1); opacity: 0.4; }
    50% { transform: scaleY(0.6); opacity: 0.8; }
  }
  .loading-shadow {
    margin-top: 30px;
    width: 130px;
    height: 16px;
    background: radial-gradient(ellipse at center, rgba(0,0,0,0.5) 0%, rgba(0,0,0,0) 70%);
    filter: blur(2px);
    animation: shadowPulse 1.6s ease-in-out infinite;
  }
  @keyframes shadowPulse {
    0%, 100% { transform: scaleX(1); opacity: 0.7; }
    50% { transform: scaleX(0.7); opacity: 0.4; }
  }
  .loading-bar {
    margin-top: 36px;
    width: 200px;
    height: 6px;
    background: rgba(255,255,255,0.12);
    border-radius: 3px;
    overflow: hidden;
  }
  .loading-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #d4a857, #f5d68a, #d4a857);
    background-size: 200% 100%;
    border-radius: 3px;
    animation: fillBar 2.6s cubic-bezier(0.4, 0, 0.2, 1) forwards, shimmer 1.5s linear infinite;
  }
  @keyframes fillBar { to { width: 100%; } }
  @keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
  }
  .loading-text {
    margin-top: 18px;
    color: #c9d2e8;
    font-size: 14px;
    letter-spacing: 4px;
  }
  .footer-credit {
    position: absolute;
    bottom: 32px;
    font-size: 12px;
    color: rgba(255,255,255,0.35);
    letter-spacing: 1px;
  }

  /* === 规则弹窗 === */
  #rules-popup {
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
  }
  .rules-overlay {
    position: absolute;
    width: 100%; height: 100%;
    background: rgba(8, 14, 38, 0.78);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
  }
  .rules-modal {
    position: relative;
    width: 84%;
    max-width: 380px;
    background: linear-gradient(180deg, #fefcf3 0%, #f6efd8 100%);
    border-radius: 14px;
    padding: 28px 22px 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6), inset 0 0 0 2px rgba(212, 168, 87, 0.6);
    color: #5a3818;
    animation: modalIn 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  }
  @keyframes modalIn {
    0% { transform: scale(0.6); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
  }
  .rules-title {
    text-align: center;
    font-size: 20px;
    font-weight: bold;
    color: #b8761d;
    margin-bottom: 16px;
    letter-spacing: 4px;
    position: relative;
    padding: 0 30px;
  }
  .rules-title::before,
  .rules-title::after {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: 1px;
    width: 30px;
    background: linear-gradient(90deg, transparent, #b8761d, transparent);
  }
  .rules-title::before { left: 0; }
  .rules-title::after { right: 0; }
  .rules-text {
    font-size: 14px;
    line-height: 1.8;
    margin-bottom: 22px;
    color: #6a4a25;
    text-align: center;
  }
  .cards {
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    gap: 6px;
  }
  .card {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
  }
  .card-score {
    font-size: 22px;
    font-weight: bold;
    margin-bottom: 4px;
    line-height: 1;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.05);
  }
  .card-score.plus { color: #2c8a3e; }
  .card-score.minus { color: #d23a3a; }
  .card-icon {
    width: 64px; height: 64px;
  }
  .card-name {
    font-size: 12px;
    color: #6a4a25;
    background: rgba(212, 168, 87, 0.18);
    padding: 4px 10px;
    border-radius: 12px;
    border: 1px solid rgba(212, 168, 87, 0.45);
    margin-top: 8px;
    white-space: nowrap;
  }
  .close-btn {
    position: absolute;
    top: 12px; right: 12px;
    width: 32px; height: 32px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
  }
  .close-btn:active { transform: scale(0.9); }
  .start-btn {
    display: block;
    margin: 22px auto 0;
    padding: 12px 40px;
    background: linear-gradient(135deg, #d4a857, #b8761d);
    border: none;
    border-radius: 30px;
    color: #fff;
    font-size: 16px;
    font-weight: bold;
    letter-spacing: 4px;
    box-shadow: 0 6px 20px rgba(184, 118, 29, 0.45);
    cursor: pointer;
  }
  .start-btn:active { transform: scale(0.96); }

  /* === 游戏页 === */
  #game-screen {
    z-index: 5;
  }
  .top-bar {
    position: absolute;
    top: 0; left: 0; right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 14px 10px;
    z-index: 3;
    gap: 8px;
  }
  .stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(20, 25, 50, 0.75);
    border-radius: 24px;
    padding: 4px 14px 4px 4px;
    border: 1px solid rgba(212, 168, 87, 0.25);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
  }
  .stat-icon {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, #d4a857, #b8861d);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.3);
  }
  .stat-icon svg { width: 22px; height: 22px; }
  .stat-info { display: flex; flex-direction: column; line-height: 1.1; }
  .stat-label {
    font-size: 10px;
    color: rgba(255,255,255,0.6);
    letter-spacing: 1px;
  }
  .stat-value {
    font-size: 16px;
    font-weight: bold;
    color: #f5d68a;
    font-family: "Courier New", monospace;
    margin-top: 1px;
  }
  .music-btn {
    width: 38px; height: 38px;
    background: rgba(20, 25, 50, 0.75);
    border: 1px solid rgba(212, 168, 87, 0.25);
    border-radius: 50%;
    color: #f5d68a;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
  }
  .music-btn.muted { color: rgba(245, 214, 138, 0.3); }
  .music-btn:active { transform: scale(0.92); }

  .game-area {position: absolute; top: 0; left: 0; right: 0; bottom: 0; overflow: hidden; }

  .falling-mooncake {
    position: absolute;
    width: 80px; height: 80px;
    will-change: transform;
    pointer-events: none;
    top: 0; left: 0;
  }
  .falling-mooncake .moon-svg { width: 100%; height: 100%; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.4));}
  .moon-trail { position: absolute; top: -10px; left: 50%; transform: translateX(-50%); display: flex; gap: 3px; opacity: 0.7;}
  .moon-trail span { width: 3px; height: 8px; background: rgba(255,255,255,0.5);  border-radius: 1px;}

  .score-popup { position: absolute; font-size: 28px; font-weight: bold;  pointer-events: none;
    transform: translate(-50%, -50%);  animation: popupFloat 1.1s ease-out forwards;
    text-shadow: 0 2px 6px rgba(0,0,0,0.6), 0 0 12px currentColor; z-index: 4;
    font-family: "Courier New", monospace;  }
  .score-popup.plus { color: #6cd97a; }
  .score-popup.minus { color: #ff7070; }
  @keyframes popupFloat {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
    25% { opacity: 1; transform: translate(-50%, -90%) scale(1.35); }
    100% { opacity: 0; transform: translate(-50%, -180%) scale(1); }
  }

  .bag { position: absolute; bottom: 26px; width: 150px; height: 110px; z-index: 4;
    will-change: left;
    left: 50%;
    transform: translateX(-50%);
  }
  .bag-svg {
    width: 100%; height: 100%;
    filter: drop-shadow(0 -2px 10px rgba(212, 168, 87, 0.35));
  }
  .bag.tilt-left { transform: translateX(-50%) rotate(-8deg); }
  .bag.tilt-right { transform: translateX(-50%) rotate(8deg); }

  /* 中间提示 */
  .hint-toast {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(20, 25, 50, 0.85);
    border: 1px solid rgba(212, 168, 87, 0.5);
    border-radius: 16px;
    padding: 16px 24px;
    color: #f5d68a;
    font-size: 18px;
    font-weight: bold;
    letter-spacing: 2px;
    z-index: 5;
    pointer-events: none;
    animation: hintIn 0.4s ease-out, hintOut 0.5s ease-in 1.2s forwards;
    text-align: center;
    line-height: 1.5;
  }
  .hint-toast small {
    display: block;
    font-size: 12px;
    color: rgba(245, 214, 138, 0.6);
    margin-top: 4px;
    font-weight: normal;
    letter-spacing: 1px;
  }
  @keyframes hintIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  }
  @keyframes hintOut {
    to { opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
  }

  /* 暂停按钮 */
  .pause-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 38px; height: 38px;
    background: rgba(20, 25, 50, 0.75);
    border: 1px solid rgba(212, 168, 87, 0.25);
    border-radius: 50%;
    color: #f5d68a;
    font-size: 14px;
    cursor: pointer;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
  }

  /* === 结束页 === */
  #gameover-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(8, 14, 38, 0.92);
    z-index: 30;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
  }
  .gameover-title {
    font-size: 32px;
    color: #f5d68a;
    margin-bottom: 18px;
    letter-spacing: 8px;
    text-shadow: 0 0 20px rgba(212, 168, 87, 0.5);
  }
  .gameover-label {
    font-size: 14px;
    color: rgba(255,255,255,0.6);
    margin-bottom: 8px;
    letter-spacing: 2px;
  }
  .gameover-score {
    font-size: 80px;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 24px rgba(212, 168, 87, 0.7);
    line-height: 1;
    font-family: "Courier New", monospace;
  }
  .gameover-rank {
    font-size: 16px;
    color: #d4a857;
    margin-top: 16px;
    padding: 8px 22px;
    border: 1px solid #d4a857;
    border-radius: 20px;
    background: rgba(212, 168, 87, 0.1);
  }
  .gameover-stats {
    display: flex;
    gap: 24px;
    margin-top: 22px;
  }
  .gameover-stat {
    text-align: center;
  }
  .gameover-stat-num {
    font-size: 22px;
    color: #fff;
    font-weight: bold;
  }
  .gameover-stat-num.bad { color: #ff7070; }
  .gameover-stat-num.good { color: #6cd97a; }
  .gameover-stat-lbl {
    font-size: 11px;
    color: rgba(255,255,255,0.5);
    margin-top: 2px;
  }
  .restart-btn {
    margin-top: 36px;
    padding: 12px 40px;
    background: linear-gradient(135deg, #d4a857, #b8761d);
    border: none;
    border-radius: 30px;
    color: #fff;
    font-size: 16px;
    font-weight: bold;
    letter-spacing: 4px;
    box-shadow: 0 6px 20px rgba(212, 168, 87, 0.4);
    cursor: pointer;
  }
  .restart-btn:active { transform: scale(0.96); }