      :root {
        --bg: #0F172A;
        --panel: rgba(15, 23, 42, 0.9);
        --text: #e2e8f0;
        --accent: #34d399;
        --danger: #fb7185;
      }

      * {
        box-sizing: border-box;
      }

      body {
        margin: 0;
        overflow: hidden;
        background: var(--bg);
        color: var(--text);
        font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
      }

      #game {
        width: 100vw;
        height: 100vh;
      }

      .hud {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        padding: 8px 16px;
        background: rgba(30, 27, 75, 0.95);
        border-bottom: 4px solid #4f46e5;
        box-shadow: 0 4px 0px rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(4px);
        z-index: 20;
        color: #e2e8f0;
        display: flex;
        flex-direction: column;
        gap: 8px;
        box-sizing: border-box;
      }

      .hud-top-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
      }

      .hud-left {
        display: flex;
        align-items: center;
        gap: 16px;
      }

      .hud-title {
        margin: 0;
        font-size: 20px;
        font-family: monospace, sans-serif;
        font-weight: 900;
        color: #fcd34d;
        text-shadow: 2px 2px 0px #000;
        letter-spacing: 2px;
        white-space: nowrap;
        display: flex;
        align-items: center;
        gap: 8px;
      }

      @media (max-width: 600px) {
        .hud-title {
          display: none;
        }
      }

      .hud-stats {
        display: flex;
        gap: 12px;
      }

      .stat-item {
        display: flex;
        align-items: center;
        gap: 6px;
        background: #312e81;
        border: 2px solid #4338ca;
        padding: 4px 8px;
        font-size: 14px;
        font-family: monospace;
        font-weight: bold;
        color: #e0e7ff;
        white-space: nowrap;
        box-shadow: 2px 2px 0px rgba(0,0,0,0.5);
      }

      .stat-icon {
        width: 16px;
        height: 16px;
        image-rendering: pixelated;
        display: block;
      }

      #coinText { color: #fde047; text-shadow: 1px 1px 0px #000; }
      #levelText { color: #fca5a5; text-shadow: 1px 1px 0px #000; }
      #collectText { color: #67e8f9; text-shadow: 1px 1px 0px #000; }
      #playerText { color: #93c5fd; text-shadow: 1px 1px 0px #000; }

      .hud-right {
        display: flex;
        gap: 8px;
      }

      .hud-btn {
        padding: 6px 12px;
        border: 2px solid;
        border-radius: 0;
        font-size: 14px;
        font-family: monospace;
        font-weight: bold;
        cursor: pointer;
        display: flex;
        align-items: center;
        gap: 6px;
        box-shadow: 2px 2px 0px rgba(0,0,0,0.5);
        transition: transform 0.1s;
      }
      .hud-btn:active {
        transform: translate(2px, 2px);
        box-shadow: none;
      }

      .level-btn {
        color: #bfdbfe;
        background: #1d4ed8;
        border-color: #60a5fa;
      }
      .level-btn:hover { background: #2563eb; }

      .inventory-btn {
        color: #fef3c7;
        background: #b45309;
        border-color: #fbbf24;
      }
      .inventory-btn:hover { background: #d97706; }

      .author-btn {
        color: #fce7f3;
        background: #be185d;
        border-color: #f472b6;
      }
      .author-btn:hover { background: #db2777; }


      .hud-bottom-row {
        width: 100%;
      }

      .progress-wrap {
        width: 100%;
      }

      .progress-track {
        width: 100%;
        height: 6px;
        border-radius: 999px;
        background: rgba(0, 0, 0, 0.6);
        overflow: hidden;
        border: 1px solid rgba(255, 255, 255, 0.1);
      }

      .progress-fill {
        width: 0%;
        height: 100%;
        border-radius: inherit;
        background: linear-gradient(90deg, #10b981, #34d399, #6ee7b7);
        box-shadow: 0 0 8px rgba(52, 211, 153, 0.6);
        transition: width 300ms cubic-bezier(0.4, 0, 0.2, 1);
      }

      /* Mobile optimizations */
      @media (max-width: 768px) {
        .hud {
          padding: 6px 8px;
        }
        .hud-top-row {
          flex-wrap: wrap;
          gap: 6px;
        }
        .hud-left {
          flex-wrap: wrap;
          gap: 6px;
        }
        .hud-stats {
          gap: 6px;
          flex-wrap: wrap;
        }
        .stat-item {
          padding: 2px 6px;
          font-size: 12px;
        }
        .stat-icon {
          width: 14px;
          height: 14px;
        }
        .hud-right {
          width: 100%;
          justify-content: flex-start;
          gap: 6px;
        }
        .hud-btn {
          padding: 4px 8px;
          font-size: 12px;
          flex: 1;
          justify-content: center;
        }
      }

      #coinFxLayer {
        position: fixed;
        inset: 0;
        pointer-events: none;
        z-index: 25;
      }

      .coin-float {
        position: fixed;
        transform: translate(-50%, -50%);
        color: #fbbf24;
        font-size: 20px;
        font-weight: 700;
        text-shadow: 0 0 12px rgba(251, 191, 36, 0.6);
        animation: coinRise 650ms ease-out forwards;
      }

      @keyframes coinRise {
        0% {
          opacity: 0;
          transform: translate(-50%, -45%);
        }
        15% {
          opacity: 1;
          transform: translate(-50%, -50%);
        }
        100% {
          opacity: 0;
          transform: translate(-50%, -160%);
        }
      }

      .intro-mask {
        position: fixed;
        inset: 0;
        display: grid;
        place-items: center;
        background: rgba(2, 6, 23, 0.7);
        z-index: 40;
      }

      .countdown-mask {
        position: fixed;
        inset: 0;
        display: none;
        place-items: center;
        background: rgba(2, 6, 23, 0.35);
        z-index: 45;
        pointer-events: none;
      }

      .countdown-number {
        font-size: clamp(72px, 18vw, 180px);
        font-weight: 900;
        color: #fef08a;
        text-shadow:
          0 0 12px rgba(250, 204, 21, 0.85),
          0 0 40px rgba(234, 179, 8, 0.55);
        opacity: 0;
        transform: scale(0.4);
      }

      .countdown-number.pop {
        animation: countdownPop 780ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
      }

      @keyframes countdownPop {
        0% {
          opacity: 0;
          transform: scale(0.4);
        }
        20% {
          opacity: 1;
          transform: scale(1.14);
        }
        75% {
          opacity: 1;
          transform: scale(1);
        }
        100% {
          opacity: 0;
          transform: scale(0.8);
        }
      }

      .intro-panel {
        width: min(92vw, 560px);
        background: rgba(15, 23, 42, 0.94);
        border: 1px solid rgba(59, 130, 246, 0.45);
        border-radius: 14px;
        box-shadow: 0 22px 58px rgba(0, 0, 0, 0.45);
        padding: 20px;
      }

      .intro-dialog {
        display: flex;
        align-items: flex-start;
        gap: 14px;
        margin-bottom: 14px;
      }

      .npc-avatar {
        width: 72px;
        height: 72px;
        flex-shrink: 0;
        position: relative;
        border-radius: 0;
        background: transparent;
      }

      .npc-avatar::before {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        width: 8px;
        height: 8px;
        background: transparent;
        box-shadow:
          8px 0 #166534,
          16px 0 #166534,
          24px 0 #166534,
          32px 0 #166534,
          40px 0 #166534,
          0 8px #166534,
          8px 8px #22c55e,
          16px 8px #22c55e,
          24px 8px #86efac,
          32px 8px #86efac,
          40px 8px #22c55e,
          48px 8px #166534,
          0 16px #166534,
          8px 16px #22c55e,
          16px 16px #86efac,
          24px 16px #86efac,
          32px 16px #86efac,
          40px 16px #86efac,
          48px 16px #22c55e,
          56px 16px #166534,
          0 24px #166534,
          8px 24px #22c55e,
          16px 24px #86efac,
          24px 24px #111827,
          32px 24px #111827,
          40px 24px #86efac,
          48px 24px #22c55e,
          56px 24px #166534,
          0 32px #166534,
          8px 32px #22c55e,
          16px 32px #86efac,
          24px 32px #f8fafc,
          32px 32px #f8fafc,
          40px 32px #86efac,
          48px 32px #22c55e,
          56px 32px #166534,
          0 40px #166534,
          8px 40px #22c55e,
          16px 40px #86efac,
          24px 40px #111827,
          32px 40px #111827,
          40px 40px #86efac,
          48px 40px #22c55e,
          56px 40px #166534,
          8px 48px #166534,
          16px 48px #22c55e,
          24px 48px #86efac,
          32px 48px #7c2d12,
          40px 48px #86efac,
          48px 48px #166534,
          16px 56px #166534,
          24px 56px #b91c1c,
          32px 56px #b91c1c,
          40px 56px #166534,
          24px 64px #ef4444,
          32px 64px #ef4444;
      }

      .intro-dialog-main {
        min-width: 0;
        flex: 1;
      }

      .intro-title {
        margin: 0 0 10px;
        font-size: 22px;
        color: #93c5fd;
      }

      .intro-text {
        margin: 0 0 14px;
        line-height: 1.6;
        min-height: 1.6em;
      }

      .intro-text.typing-cursor::after {
        content: "|";
        margin-left: 2px;
        color: #93c5fd;
        animation: cursorBlink 1s steps(1, end) infinite;
      }

      .intro-exchange {
        margin: 0 0 14px;
        padding: 10px 12px;
        border: 1px solid rgba(250, 204, 21, 0.45);
        border-radius: 10px;
        background: rgba(180, 83, 9, 0.2);
      }

      .intro-exchange p {
        margin: 0;
        color: #fde68a;
        font-size: 14px;
        line-height: 1.5;
      }

      .intro-exchange p + p {
        margin-top: 4px;
      }

      @keyframes cursorBlink {
        0%,
        49% {
          opacity: 1;
        }
        50%,
        100% {
          opacity: 0;
        }
      }

      .start-btn {
        border: 1px solid rgba(56, 189, 248, 0.6);
        border-radius: 10px;
        padding: 10px 14px;
        color: #e0f2fe;
        background: rgba(2, 132, 199, 0.28);
        cursor: pointer;
      }

      .start-btn:hover {
        border-color: rgba(125, 211, 252, 0.9);
      }

      .start-btn:disabled {
        opacity: 0.7;
      }

      .quiz-mask {
        position: fixed;
        inset: 0;
        display: none;
        place-items: center;
        background: rgba(2, 6, 23, 0.5);
        z-index: 30;
      }

      .quiz-panel {
        width: min(92vw, 460px);
        background: var(--panel);
        border: 1px solid rgba(52, 211, 153, 0.35);
        border-radius: 14px;
        padding: 18px;
        box-shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
        position: relative;
        overflow: hidden;
      }

      .quiz-title {
        margin: 0 0 8px;
        font-size: clamp(34px, 6.2vw, 46px);
        line-height: 1.1;
        font-weight: 800;
        color: #86efac;
        text-shadow: 0 0 16px rgba(134, 239, 172, 0.35);
      }

      .quiz-text {
        margin: 0 0 12px;
        line-height: 1.4;
        font-size: 24px;
        font-weight: 800;
      }

      .knowledge-tip {
        margin: 0 0 12px;
        padding: 8px 10px;
        border-radius: 8px;
        border: 1px solid rgba(147, 197, 253, 0.45);
        background: rgba(30, 64, 175, 0.2);
        color: #dbeafe;
        font-size: 13px;
        line-height: 1.5;
      }

      .knowledge-tip.hidden {
        display: none;
      }

      .options {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
      }

      .opt-btn {
        width: 100%;
        border: 4px solid;
        border-radius: 0;
        color: #f8fafc;
        min-height: 84px;
        padding: 12px;
        text-align: center;
        cursor: pointer;
        font-weight: 900;
        font-family: monospace, sans-serif;
        font-size: clamp(20px, 4.4vw, 28px);
        line-height: 1.2;
        text-shadow: 2px 2px 0px rgba(0,0,0,0.5);
        box-shadow: 4px 4px 0px rgba(0,0,0,0.6);
        transition: transform 0.1s;
      }

      .opt-btn:hover {
        transform: translate(2px, 2px);
        box-shadow: 2px 2px 0px rgba(0,0,0,0.6);
      }

      .opt-btn:active {
        transform: translate(4px, 4px);
        box-shadow: none;
      }

      .opt-red {
        background: #dc2626;
        border-color: #f87171;
      }

      .opt-blue {
        background: #2563eb;
        border-color: #60a5fa;
      }

      .opt-green {
        background: #16a34a;
        border-color: #4ade80;
      }

      .opt-yellow {
        background: #d97706;
        border-color: #fbbf24;
        color: #fffbeb;
      }

      .quiz-footer {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-top: 12px;
      }

      .msg {
        min-height: 20px;
        font-size: 14px;
      }

      .ok {
        color: var(--accent);
      }

      .bad {
        color: var(--danger);
      }

      .ghost-btn {
        border: 1px solid rgba(148, 163, 184, 0.4);
        border-radius: 10px;
        color: #cbd5e1;
        background: transparent;
        padding: 8px 10px;
        cursor: pointer;
      }

      .ghost-btn:hover {
        border-color: rgba(148, 163, 184, 0.75);
      }

      .reward-tip {
        margin: 10px 0 0;
        font-size: 14px;
        font-weight: 700;
        color: #fbbf24;
        text-align: right;
      }

      .success-burst {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%) scale(0.5);
        font-size: clamp(36px, 9vw, 60px);
        font-weight: 900;
        letter-spacing: 1px;
        color: #fef08a;
        text-shadow:
          0 0 12px rgba(250, 204, 21, 0.8),
          0 0 36px rgba(250, 204, 21, 0.5);
        opacity: 0;
        pointer-events: none;
      }

      .success-burst.show {
        animation: successPop 760ms cubic-bezier(0.2, 0.95, 0.36, 1) forwards;
      }

      @keyframes successPop {
        0% {
          opacity: 0;
          transform: translate(-50%, -50%) scale(0.35) rotate(-8deg);
        }
        20% {
          opacity: 1;
          transform: translate(-50%, -58%) scale(1.08) rotate(4deg);
        }
        55% {
          opacity: 1;
          transform: translate(-50%, -54%) scale(1) rotate(-2deg);
        }
        100% {
          opacity: 0;
          transform: translate(-50%, -72%) scale(0.9) rotate(0deg);
        }
      }

      @keyframes optionHoverPulse {
        from {
          transform: translateY(-2px) scale(1.02);
        }
        to {
          transform: translateY(-4px) scale(1.04);
        }
      }

      #joystick {
        position: fixed;
        bottom: 30px;
        left: 30px;
        width: 100px;
        height: 100px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.15);
        border: 2px solid rgba(255, 255, 255, 0.3);
        display: none;
        z-index: 35;
        touch-action: none;
      }

      #joystickKnob {
        position: absolute;
        left: 50%;
        top: 50%;
        width: 44px;
        height: 44px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.35);
        border: 2px solid rgba(255, 255, 255, 0.5);
        transform: translate(-50%, -50%);
      }

      .complete-mask {
        position: fixed;
        inset: 0;
        display: none;
        place-items: center;
        background: rgba(2, 6, 23, 0.78);
        z-index: 50;
      }

      .complete-panel {
        width: min(92vw, 520px);
        border-radius: 14px;
        background: rgba(15, 23, 42, 0.95);
        border: 1px solid rgba(74, 222, 128, 0.45);
        box-shadow: 0 24px 56px rgba(0, 0, 0, 0.5);
        padding: 22px;
      }

      .complete-title {
        margin: 0 0 10px;
        color: #86efac;
        font-size: 28px;
      }

      .complete-text {
        margin: 0 0 14px;
        line-height: 1.6;
      }

      .next-btn {
        border: 1px solid rgba(74, 222, 128, 0.6);
        border-radius: 10px;
        padding: 10px 14px;
        color: #dcfce7;
        background: rgba(22, 163, 74, 0.25);
        cursor: pointer;
      }

      .next-btn:hover {
        border-color: rgba(134, 239, 172, 0.9);
      }

      .level-panel {
        position: fixed;
        inset: 0;
        display: none;
        place-items: center;
        background: rgba(2, 6, 23, 0.72);
        z-index: 55;
      }

      .level-panel-card {
        width: min(92vw, 420px);
        border-radius: 12px;
        background: rgba(15, 23, 42, 0.96);
        border: 1px solid rgba(59, 130, 246, 0.45);
        box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
        padding: 16px;
      }

      .level-panel-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        margin-bottom: 12px;
      }

      .level-panel-title {
        margin: 0;
        font-size: 20px;
        color: #93c5fd;
      }

      .level-options {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 10px;
      }

      .level-option-btn {
        border: 1px solid rgba(148, 163, 184, 0.45);
        border-radius: 10px;
        background: rgba(30, 41, 59, 0.8);
        color: #e2e8f0;
        min-height: 44px;
        cursor: pointer;
      }

      .level-option-btn.active {
        border-color: rgba(74, 222, 128, 0.9);
        background: rgba(22, 163, 74, 0.32);
        color: #dcfce7;
      }

      .level-option-range {
        display: block;
        margin-top: 2px;
        font-size: 11px;
        color: #93c5fd;
        opacity: 0.95;
      }

      .auth-mask {
        position: fixed;
        inset: 0;
        display: none;
        place-items: center;
        background: rgba(2, 6, 23, 0.8);
        z-index: 70;
      }

      .entry-mask {
        position: fixed;
        inset: 0;
        display: none;
        place-items: center;
        background: rgba(2, 6, 23, 0.86);
        z-index: 68;
      }

      .entry-actions {
        display: grid;
        gap: 10px;
        margin-bottom: 8px;
      }

      .entry-msg {
        min-height: 20px;
        font-size: 13px;
        color: #fca5a5;
      }

      .auth-card {
        width: min(92vw, 420px);
        border-radius: 12px;
        background: rgba(15, 23, 42, 0.96);
        border: 1px solid rgba(56, 189, 248, 0.45);
        box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
        padding: 16px;
      }

      .auth-title {
        margin: 0 0 10px;
        color: #93c5fd;
        font-size: 20px;
      }

      .auth-row {
        display: flex;
        gap: 8px;
        margin-bottom: 8px;
      }

      .auth-input {
        flex: 1;
        border: 1px solid rgba(148, 163, 184, 0.45);
        background: #0f172a;
        color: #e2e8f0;
        border-radius: 8px;
        padding: 8px 10px;
      }

      .auth-msg {
        min-height: 20px;
        font-size: 13px;
        color: #fca5a5;
      }

      .author-mask {
        position: fixed;
        inset: 0;
        display: none;
        place-items: center;
        background: rgba(2, 6, 23, 0.82);
        z-index: 60;
      }

      .author-card {
        width: min(92vw, 430px);
        border-radius: 14px;
        background: rgba(15, 23, 42, 0.96);
        border: 1px solid rgba(244, 114, 182, 0.45);
        box-shadow: 0 20px 56px rgba(0, 0, 0, 0.45);
        padding: 16px;
        text-align: center;
      }

      .author-title {
        margin: 0 0 10px;
        color: #fbcfe8;
        font-size: 21px;
      }

      .author-desc {
        margin: 8px 0;
        color: #e2e8f0;
        font-size: 14px;
        line-height: 1.6;
      }

      .author-qrcode {
        width: min(58vw, 210px);
        border-radius: 10px;
        border: 1px solid rgba(148, 163, 184, 0.4);
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
        margin: 8px auto 12px;
        display: block;
      }
