:root {
      --font-main: 'Fredoka', 'Zen Maru Gothic', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
      --font-num: 'Outfit', 'Fredoka', 'Zen Maru Gothic', 'Microsoft JhengHei', sans-serif;
      
      --primary-color: #ff9b26;
      --primary-dark: #d87010;
      --accent-gold: #ffd13b;
      --gold-glow: rgba(255, 209, 59, 0.6);
      --danger-purple: #a855f7;
      --danger-red: #ff4757;
      --danger-lightning: #00d2d3;
      --wood-dark: #3e2723;
      --wood-mid: #5d4037;
      --wood-light: #8d6e63;
      --wood-border: #271406;
      --text-main: #3e2723;
    }

    * {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
      user-select: none;
      -webkit-user-select: none;
      font-family: var(--font-main);
    }

    button, input, select, textarea {
      font-family: inherit;
    }

    html, body {
      width: 100%;
      height: 100%;
      overflow: hidden;
      background: #0f2e14;
      font-family: var(--font-main);
      position: fixed;
    }

    #canvasContainer {
      position: absolute;
      top: 0;
      left: 0;
      width: 100vw;
      height: 100vh;
      display: block;
      background: #81ecec;
    }

    #gameCanvas {
      width: 100%;
      height: 100%;
      display: block;
      image-rendering: -webkit-optimize-contrast;
      image-rendering: crisp-edges;
    }

    /* 頂部高級電玩導航欄 */
    .top-floating-bar {
      position: absolute;
      top: 16px;
      left: 50%;
      transform: translateX(-50%);
      background: linear-gradient(180deg, rgba(62, 39, 35, 0.95) 0%, rgba(39, 20, 6, 0.98) 100%);
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
      border: 3px solid #ffd13b;
      border-radius: 40px;
      padding: 8px 26px;
      display: flex;
      align-items: center;
      gap: 16px;
      z-index: 5;
      box-shadow: 0 12px 35px rgba(0, 0, 0, 0.65), inset 0 2px 4px rgba(255, 255, 255, 0.25), 0 0 20px var(--gold-glow);
    }

    .top-title {
      font-size: 20px;
      font-weight: 900;
      color: #ffd13b;
      display: flex;
      align-items: center;
      gap: 10px;
      white-space: nowrap;
      text-shadow: 0 2px 4px rgba(0,0,0,0.8), 0 0 12px rgba(255, 209, 59, 0.5);
      letter-spacing: 1px;
    }

    .header-btn {
      background: linear-gradient(180deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.05) 100%);
      border: 2px solid rgba(255, 255, 255, 0.45);
      border-radius: 24px;
      padding: 7px 18px;
      font-size: 15px;
      font-weight: 800;
      color: #fff;
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 6px;
      transition: all 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
      white-space: nowrap;
      text-shadow: 0 1px 3px rgba(0,0,0,0.6);
      box-shadow: inset 0 1px 2px rgba(255,255,255,0.3);
    }

    .header-btn:hover {
      background: linear-gradient(180deg, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0.15) 100%);
      border-color: #ffd13b;
      transform: translateY(-2px) scale(1.04);
      box-shadow: 0 6px 16px rgba(0,0,0,0.4), 0 0 10px rgba(255,209,59,0.4);
    }

    .header-btn:active {
      transform: translateY(1px) scale(0.98);
    }

    /* 商業級遊戲視窗覆蓋層 */
    .game-overlay {
      position: absolute;
      top: 0;
      left: 0;
      width: 100vw;
      height: 100vh;
      background: radial-gradient(circle at center, rgba(30, 15, 5, 0.82) 0%, rgba(10, 5, 2, 0.95) 100%);
      backdrop-filter: blur(10px);
      -webkit-backdrop-filter: blur(10px);
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      z-index: 10;
      padding: 20px;
      text-align: center;
      transition: opacity 0.3s ease;
    }

    .game-overlay.hidden {
      opacity: 0;
      pointer-events: none;
    }

    .modal-card {
      background: linear-gradient(180deg, #fffdf7 0%, #fff3d6 60%, #ffeaa7 100%);
      border: 8px solid var(--wood-dark);
      border-radius: 32px;
      padding: 30px 40px;
      max-width: 760px;
      width: 94%;
      color: var(--text-main);
      box-shadow: 0 28px 70px rgba(0, 0, 0, 0.9), inset 0 4px 8px #ffffff, inset 0 -4px 8px rgba(93, 64, 55, 0.2);
      animation: popIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
      position: relative;
    }

    /* 🌟 大螢幕大尺寸旗艦開始選單 (Widescreen Grand Start Menu) */
    .modal-card-large {
      max-width: 1240px;
      width: 92vw;
      max-height: 90vh;
      overflow-y: auto;
      padding: 30px 42px;
      border-radius: 36px;
      border-width: 10px;
    }

    .modal-card-large::-webkit-scrollbar {
      width: 8px;
    }
    .modal-card-large::-webkit-scrollbar-thumb {
      background: #deb887;
      border-radius: 4px;
    }

    .start-dashboard-grid {
      display: grid;
      grid-template-columns: 1fr 1.35fr;
      gap: 22px;
      margin: 14px 0 18px;
      text-align: left;
    }

    .dashboard-panel {
      background: rgba(255, 255, 255, 0.72);
      backdrop-filter: blur(6px);
      -webkit-backdrop-filter: blur(6px);
      border: 3px solid #deb887;
      border-radius: 22px;
      padding: 18px 22px;
      display: flex;
      flex-direction: column;
      gap: 12px;
      box-shadow: 0 8px 24px rgba(0,0,0,0.05);
    }

    .panel-header {
      display: flex;
      align-items: center;
      gap: 10px;
      font-size: 17px;
      font-weight: 900;
      color: #873600;
      border-bottom: 2px dashed #deb887;
      padding-bottom: 6px;
    }

    .stage-roadmap-grid {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 8px;
    }

    .stage-roadmap-card {
      background: #ffffff;
      border: 2px solid #e0c9a6;
      border-radius: 14px;
      padding: 9px 12px;
      display: flex;
      flex-direction: column;
      gap: 2px;
      transition: all 0.15s ease;
    }

    .stage-roadmap-card:hover {
      border-color: #e67e22;
      transform: translateY(-2px);
      box-shadow: 0 4px 12px rgba(230, 126, 34, 0.2);
    }

    .stage-card-title {
      font-size: 13.5px;
      font-weight: 900;
      color: #d35400;
      display: flex;
      align-items: center;
      gap: 6px;
    }

    .stage-card-desc {
      font-size: 11px;
      font-weight: 600;
      color: #7f8c8d;
    }

    .controls-card-list {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 8px;
    }

    .controls-card-item {
      background: #ffffff;
      border: 2px solid #e0c9a6;
      border-radius: 12px;
      padding: 7px 12px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      font-size: 12.5px;
      font-weight: 800;
      color: #5d4037;
    }

    .item-guide-grid-large {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 10px;
    }

    .guide-item-large {
      background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 248, 235, 0.95) 100%);
      border: 3px solid #deb887;
      border-radius: 16px;
      padding: 10px 14px;
      display: flex;
      align-items: center;
      gap: 12px;
      box-shadow: 0 5px 14px rgba(0,0,0,0.06), inset 0 1px 2px #fff;
      transition: transform 0.15s ease;
    }

    .guide-item-large:hover {
      transform: translateY(-2px);
      border-color: #e67e22;
      box-shadow: 0 8px 20px rgba(230, 126, 34, 0.2);
    }

    .guide-icon-large {
      font-size: 34px;
      width: 44px;
      height: 44px;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
      filter: drop-shadow(0 3px 6px rgba(0,0,0,0.18));
    }

    .action-btn-large {
      font-size: 24px;
      padding: 16px 64px;
      border-radius: 24px;
      box-shadow: 0 10px 0 #3e1b05, 0 20px 40px rgba(0,0,0,0.5), inset 0 2px 4px rgba(255,255,255,0.4);
    }

    .modal-card::before, .modal-card::after {
      content: '★';
      position: absolute;
      top: 14px;
      font-size: 22px;
      color: #f39c12;
      text-shadow: 0 1px 3px rgba(0,0,0,0.3);
    }
    .modal-card::before { left: 18px; }
    .modal-card::after { right: 18px; }

    @keyframes popIn {
      0% { transform: scale(0.8); opacity: 0; }
      100% { transform: scale(1); opacity: 1; }
    }

    .modal-title {
      font-size: 36px;
      font-weight: 900;
      color: #d35400;
      text-shadow: 3px 3px 0 #ffffff, 4px 4px 0 #bdc3c7;
      margin-bottom: 4px;
      letter-spacing: 1px;
    }

    .modal-subtitle {
      font-size: 14.5px;
      font-weight: 700;
      color: #6d4c2d;
      margin-bottom: 14px;
      line-height: 1.5;
    }

    .stage-roadmap-box {
      background: #ffffff;
      border: 2px solid #deb887;
      border-radius: 14px;
      padding: 8px 14px;
      margin-bottom: 14px;
      display: flex;
      justify-content: space-around;
      font-size: 12px;
      font-weight: 800;
      color: #795548;
    }

    .stage-pill {
      display: flex;
      align-items: center;
      gap: 4px;
    }

    .item-guide-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 10px;
      margin: 12px 0 16px;
      text-align: left;
    }

    .guide-item {
      background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 248, 235, 0.95) 100%);
      border: 3px solid #deb887;
      border-radius: 16px;
      padding: 9px 12px;
      display: flex;
      align-items: center;
      gap: 10px;
      box-shadow: 0 5px 12px rgba(0,0,0,0.06), inset 0 1px 2px #fff;
      transition: transform 0.15s ease;
    }

    .guide-item:hover {
      transform: translateY(-2px);
      border-color: #e67e22;
    }

    .guide-icon {
      font-size: 32px;
      width: 38px;
      height: 38px;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
      filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
    }

    .guide-info .name {
      font-size: 13.5px;
      font-weight: 900;
      color: #873600;
      margin-bottom: 2px;
    }

    .guide-info .desc {
      font-size: 11px;
      font-weight: 600;
      color: #636e72;
      line-height: 1.25;
    }

    .gameover-score-box {
      background: #ffffff;
      border: 4px dashed #e67e22;
      border-radius: 20px;
      padding: 18px 24px;
      margin: 16px 0;
      box-shadow: inset 0 3px 8px rgba(0,0,0,0.06);
    }

    .score-row {
      display: flex;
      justify-content: space-between;
      align-items: center;
      font-size: 17px;
      margin-bottom: 8px;
      font-weight: 700;
      color: #5d4037;
    }

    .score-row span:last-child {
      font-family: var(--font-num);
    }

    .score-row.final {
      font-size: 34px;
      color: #e74c3c;
      font-weight: 900;
      border-top: 3px solid #f1f2f6;
      padding-top: 10px;
      margin-top: 10px;
      text-shadow: 1px 1px 0 #fff;
    }

    /* 🎖️ 銅牌、銀牌、金牌、白金、鑽石、鴨神全套段位稱號勳章樣式 */
    .rank-badge {
      display: inline-flex;
      flex-direction: column;
      align-items: center;
      gap: 4px;
      padding: 12px 34px;
      border-radius: 28px;
      margin: 10px 0;
      border: 4px solid #fff;
      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
      animation: rankPulse 2.2s infinite ease-in-out;
    }

    .rank-badge-medal {
      font-size: 13px;
      font-weight: 900;
      letter-spacing: 1px;
      text-transform: uppercase;
      opacity: 0.95;
    }

    .rank-badge-title {
      font-size: 21px;
      font-weight: 900;
      letter-spacing: 0.5px;
      text-shadow: 0 2px 4px rgba(0,0,0,0.35);
    }

    .rank-badge-desc {
      font-size: 12px;
      font-weight: 700;
      opacity: 0.92;
    }

    /* 🌱 新手小幼鴨 */
    .rank-rookie {
      background: linear-gradient(135deg, #a8e063 0%, #56ab2f 100%);
      color: #ffffff;
      border-color: #d4fc79;
      box-shadow: 0 6px 20px rgba(86, 171, 47, 0.4);
    }

    /* 🥉 銅牌 (Bronze) */
    .rank-bronze {
      background: linear-gradient(135deg, #f39c12 0%, #d35400 50%, #8b4513 100%);
      color: #ffffff;
      border-color: #f5cd79;
      box-shadow: 0 6px 22px rgba(211, 84, 0, 0.45);
      text-shadow: 0 2px 4px rgba(93, 33, 0, 0.5);
    }

    /* 🥈 銀牌 (Silver) */
    .rank-silver {
      background: linear-gradient(135deg, #f5f6fa 0%, #718093 50%, #2f3640 100%);
      color: #ffffff;
      border-color: #ffffff;
      box-shadow: 0 6px 22px rgba(113, 128, 147, 0.5);
      text-shadow: 0 2px 4px rgba(0,0,0,0.45);
    }

    /* 🥇 金牌 (Gold) */
    .rank-gold {
      background: linear-gradient(135deg, #fff9d2 0%, #f1c40f 35%, #e67e22 100%);
      color: #ffffff;
      border-color: #ffffff;
      box-shadow: 0 8px 26px rgba(241, 196, 15, 0.55);
      text-shadow: 0 2px 4px rgba(160, 82, 45, 0.6);
    }

    /* 💎 白金 (Platinum) */
    .rank-platinum {
      background: linear-gradient(135deg, #e0f7fa 0%, #00cec9 45%, #0984e3 100%);
      color: #ffffff;
      border-color: #81ecec;
      box-shadow: 0 8px 28px rgba(0, 206, 201, 0.55);
      text-shadow: 0 2px 4px rgba(9, 132, 227, 0.6);
    }

    /* 👑 鑽石 (Diamond) */
    .rank-diamond {
      background: linear-gradient(135deg, #f8a5c2 0%, #e056fd 45%, #686de0 100%);
      color: #ffffff;
      border-color: #ffcccc;
      box-shadow: 0 10px 32px rgba(224, 86, 253, 0.6);
      text-shadow: 0 2px 5px rgba(104, 109, 224, 0.7);
    }

    /* 🌌 鴨神・傳說級 (Godlike) */
    .rank-god {
      background: linear-gradient(135deg, #ff9ff3 0%, #feca57 25%, #ff6b6b 50%, #48dbfb 75%, #1dd1a1 100%);
      background-size: 300% 300%;
      animation: rankRainbow 3s ease infinite, rankPulse 1.8s infinite ease-in-out;
      color: #ffffff;
      border-color: #ffffff;
      box-shadow: 0 12px 36px rgba(255, 107, 107, 0.65), inset 0 2px 8px rgba(255,255,255,0.6);
      text-shadow: 0 2px 6px rgba(0,0,0,0.6);
    }

    @keyframes rankRainbow {
      0% { background-position: 0% 50%; }
      50% { background-position: 100% 50%; }
      100% { background-position: 0% 50%; }
    }

    @keyframes rankPulse {
      0%, 100% { transform: scale(1); }
      50% { transform: scale(1.03); }
    }

    .action-btn {
      background: linear-gradient(180deg, #ff793f 0%, #e65100 100%);
      color: white;
      border: 4px solid #3e1b05;
      border-radius: 20px;
      padding: 14px 44px;
      font-size: 22px;
      font-weight: 900;
      cursor: pointer;
      margin-top: 8px;
      box-shadow: 0 8px 0 #3e1b05, 0 16px 30px rgba(0,0,0,0.5), inset 0 2px 4px rgba(255,255,255,0.3);
      transition: all 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
      display: inline-flex;
      align-items: center;
      gap: 10px;
      letter-spacing: 0.8px;
      text-shadow: 0 2px 4px rgba(0,0,0,0.4);
    }

    .action-btn:hover {
      background: linear-gradient(180deg, #ff8b57 0%, #ef6c00 100%);
      transform: translateY(-3px);
      box-shadow: 0 11px 0 #3e1b05, 0 20px 35px rgba(0,0,0,0.55), inset 0 2px 4px rgba(255,255,255,0.4);
    }

    .action-btn:active {
      transform: translateY(5px);
      box-shadow: 0 3px 0 #3e1b05, 0 6px 12px rgba(0,0,0,0.4);
    }

    .controls-hint {
      position: absolute;
      top: 78px;
      right: 24px;
      background: rgba(30, 15, 5, 0.88);
      backdrop-filter: blur(8px);
      -webkit-backdrop-filter: blur(8px);
      border-radius: 16px;
      padding: 10px 16px;
      color: #fff;
      font-size: 13px;
      font-weight: 800;
      display: flex;
      flex-direction: column;
      gap: 6px;
      pointer-events: none;
      z-index: 4;
      border: 2px solid rgba(255, 209, 59, 0.45);
      box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
    }

    .controls-hint-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      white-space: nowrap;
    }

    .key-badge {
      background: linear-gradient(180deg, #ffffff 0%, #dfe6e9 100%);
      color: #2d3436;
      padding: 3px 10px;
      border-radius: 6px;
      font-weight: 900;
      font-family: var(--font-num);
      font-size: 14px;
      border: 2px solid #b2bec3;
      box-shadow: 0 2px 0 #636e72;
    }

    /* 📱 手機專屬人體工學雙手手把 (Dual-Thumb Cluster Touch Controls) */
    .touch-controls {
      display: none;
      position: absolute;
      bottom: calc(18px + env(safe-area-inset-bottom, 0px));
      left: 0;
      width: 100%;
      padding: 0 calc(16px + env(safe-area-inset-right, 0px)) 0 calc(16px + env(safe-area-inset-left, 0px));
      justify-content: space-between;
      align-items: flex-end;
      z-index: 20;
      pointer-events: none;
      user-select: none;
      -webkit-user-select: none;
    }

    .touch-cluster {
      display: flex;
      gap: 12px;
      pointer-events: auto;
    }

    .touch-cluster-left {
      align-items: center;
    }

    .touch-cluster-right {
      align-items: center;
    }

    .touch-btn {
      width: 72px;
      height: 72px;
      border-radius: 50%;
      background: rgba(30, 15, 5, 0.65);
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
      border: 3px solid rgba(255, 255, 255, 0.7);
      color: white;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      touch-action: none;
      cursor: pointer;
      box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45), inset 0 2px 4px rgba(255, 255, 255, 0.35);
      transition: all 0.08s ease;
      -webkit-tap-highlight-color: transparent;
      user-select: none;
      -webkit-user-select: none;
    }

    .touch-icon {
      font-size: 24px;
      line-height: 1;
      text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
    }

    .touch-label {
      font-size: 11px;
      font-weight: 900;
      font-family: var(--font-main);
      color: rgba(255, 255, 255, 0.9);
      margin-top: 2px;
      text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    }

    .touch-btn-move {
      background: linear-gradient(135deg, rgba(84, 160, 255, 0.75) 0%, rgba(46, 134, 222, 0.85) 100%);
      border-color: #74b9ff;
    }

    .touch-btn-dash {
      background: linear-gradient(135deg, rgba(255, 159, 67, 0.85) 0%, rgba(238, 82, 83, 0.9) 100%);
      border-color: #ff9f43;
      width: 76px;
      height: 76px;
    }

    .touch-btn-jump {
      background: linear-gradient(135deg, rgba(29, 209, 161, 0.85) 0%, rgba(16, 172, 132, 0.9) 100%);
      border-color: #1dd1a1;
      width: 76px;
      height: 76px;
    }

    .touch-btn:active,
    .touch-btn.active {
      transform: scale(0.90);
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6), inset 0 3px 6px rgba(0, 0, 0, 0.4);
      filter: brightness(1.25);
    }

    /* 📱 響應式手機佈局規則 (Mobile Responsive Breakpoints) */
    @media (max-width: 960px) {
      .start-dashboard-grid { grid-template-columns: 1fr; gap: 14px; }
      .modal-card-large { width: 95vw; padding: 20px 22px; max-height: 94vh; }
      .item-guide-grid-large { grid-template-columns: 1fr; }
      .stage-roadmap-grid { grid-template-columns: repeat(2, 1fr); }
      .controls-card-list { grid-template-columns: 1fr; }
    }

    @media (max-width: 768px) {
      .touch-controls { display: flex; }
      .controls-hint { display: none; }
      .top-floating-bar {
        top: calc(10px + env(safe-area-inset-top, 0px));
        left: 10px;
        right: 10px;
        transform: none;
        padding: 6px 10px;
        gap: 6px;
        justify-content: space-between;
        width: calc(100% - 20px);
        max-width: 100%;
      }
      .top-title { font-size: 13px; }
      .header-btn { font-size: 11px; padding: 5px 8px; border-radius: 10px; }
      .modal-card { width: 92vw; padding: 18px 16px; border-radius: 24px; border-width: 6px; }
      .modal-title { font-size: 26px !important; }
      .modal-subtitle { font-size: 13px !important; }
      .stage-roadmap-grid { grid-template-columns: 1fr; }
      .action-btn { padding: 12px 28px; font-size: 18px; }
    }

    @media (max-height: 500px) and (orientation: landscape) {
      /* 橫屏遊戲優化 (Mobile Landscape) */
      .top-floating-bar { padding: 4px 10px; }
      .touch-btn { width: 62px; height: 62px; }
      .touch-icon { font-size: 20px; }
      .touch-label { font-size: 9.5px; }
      .modal-card { max-height: 96vh; overflow-y: auto; padding: 12px 18px; }
      .modal-title { font-size: 22px !important; }
    }