
    * { box-sizing: border-box; }
    body {
      margin: 0;
      overflow: hidden;
      font-family: "Pretendard", "Malgun Gothic", system-ui, sans-serif;
      background: radial-gradient(circle at top, #1e3a5f 0%, #111827 48%, #030712 100%);
      color: #fff;
      user-select: none;
    }

    #wrap {
      width: 100vw;
      height: 100vh;
      min-height: 100dvh;
      display: grid;
      place-items: center;
      position: relative;
    }

    canvas {
      background: #0f172a;
      border: 4px solid rgba(255,255,255,0.18);
      border-radius: 26px;
      box-shadow: 0 25px 90px rgba(0,0,0,0.58);
      max-width: 96vw;
      max-height: 82vh;
    }

    .panel {
      position: absolute;
      inset: 0;
      display: flex;
      background: rgba(4, 8, 18, 0.74);
      backdrop-filter: blur(7px);
      z-index: 10;
      padding: 24px;
      overflow-y: auto;
    }

    .card {
      margin: auto;
      width: min(940px, 95vw);
      background: rgba(255, 255, 255, 0.105);
      border: 1px solid rgba(255, 255, 255, 0.22);
      border-radius: 30px;
      padding: 30px;
      box-shadow: 0 24px 70px rgba(0,0,0,0.46);
    }

    h1 {
      margin: 0 0 10px;
      font-size: clamp(32px, 5vw, 60px);
      letter-spacing: -1px;
    }

    .subtitle {
      color: #dbeafe;
      font-size: 18px;
      line-height: 1.62;
      margin-bottom: 20px;
    }

    .grid {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 12px;
      margin: 18px 0;
    }

    .info {
      background: rgba(0,0,0,0.23);
      border-radius: 18px;
      padding: 14px 16px;
      line-height: 1.55;
      color: #eef6ff;
      min-height: 94px;
    }

    button, select {
      appearance: none;
      border: 0;
      border-radius: 16px;
      padding: 13px 18px;
      font-size: 16px;
      font-weight: 900;
      cursor: pointer;
      color: #0f172a;
      background: #facc15;
      box-shadow: 0 8px 0 #a16207;
      transition: transform .08s, box-shadow .08s, filter .1s;
    }

    button:hover { filter: brightness(1.07); }
    button:active {
      transform: translateY(6px);
      box-shadow: 0 2px 0 #a16207;
    }

    select {
      width: 265px;
      background: #e0f2fe;
      box-shadow: none;
      margin-right: 10px;
    }

    .row {
      display: flex;
      gap: 12px;
      align-items: center;
      flex-wrap: wrap;
      margin-top: 18px;
    }

    .tabs {
      display: flex;
      justify-content: center;
      gap: 10px;
      margin-bottom: 8px;
    }

    .tab-btn {
      background: rgba(255, 255, 255, 0.1);
      color: #cbd5e1;
      box-shadow: none;
      border: 1px solid rgba(255, 255, 255, 0.2);
      padding: 10px 20px;
      transform: none;
    }

    .tab-btn:hover { filter: brightness(1.1); }
    .tab-btn:active { transform: none; box-shadow: none; }

    .tab-btn.active {
      background: #38bdf8;
      color: #0f172a;
      border-color: #38bdf8;
      box-shadow: 0 4px 0 #0284c7;
      font-weight: 1000;
    }

    .tab-content {
      display: none;
      animation: fadeIn 0.2s ease-in;
    }

    .tab-content.active {
      display: block;
    }

    @keyframes fadeIn {
      from { opacity: 0; transform: translateY(5px); }
      to { opacity: 1; transform: translateY(0); }
    }

    #hud {
      position: absolute;
      top: 14px;
      left: 50%;
      transform: translateX(-50%);
      width: min(1120px, 96vw);
      display: flex;
      justify-content: space-between;
      gap: 7px;
      z-index: 3;
      pointer-events: none;
      font-weight: 950;
      text-shadow: 0 2px 4px rgba(0,0,0,0.6);
    }

    .hudBox {
      background: rgba(7, 13, 28, 0.72);
      border: 1px solid rgba(255,255,255,0.16);
      border-radius: 16px;
      padding: 9px 10px;
      min-width: 82px;
      text-align: center;
      font-size: 14px;
    }

    #questionBox {
      position: absolute;
      top: 78px;
      left: 50%;
      transform: translateX(-50%);
      width: min(820px, 91vw);
      background: rgba(12, 20, 36, .88);
      border: 2px solid rgba(250,204,21,.75);
      border-radius: 23px;
      padding: 12px 18px;
      text-align: center;
      z-index: 4;
      box-shadow: 0 16px 54px rgba(0,0,0,.36);
      display: none;
    }

    #questionText {
      font-size: clamp(22px, 3.6vw, 34px);
      font-weight: 1000;
      color: #fef3c7;
    }

    #questionSub {
      color: #dbeafe;
      font-size: 14px;
      margin-top: 4px;
    }


    #mainMenuBtn {
      position: absolute;
      top: 76px;
      right: 24px;
      z-index: 6;
      padding: 10px 14px;
      border-radius: 999px;
      font-size: 14px;
      box-shadow: 0 6px 0 #7c2d12;
      background: #fb923c;
      color: #111827;
    }

    #mainMenuBtn:active {
      transform: translateY(5px);
      box-shadow: 0 1px 0 #7c2d12;
    }

    #quitGameBtn {
      position: absolute;
      top: 122px;
      right: 24px;
      z-index: 6;
      padding: 10px 14px;
      border-radius: 999px;
      font-size: 14px;
      box-shadow: 0 6px 0 #991b1b;
      background: #f87171;
      color: #111827;
    }

    #quitGameBtn:active {
      transform: translateY(5px);
      box-shadow: 0 1px 0 #991b1b;
    }

    #activeItems {
      position: absolute;
      right: 24px;
      top: 172px;
      z-index: 4;
      display: flex;
      flex-direction: column;
      gap: 8px;
      pointer-events: none;
      align-items: flex-end;
      max-width: 280px;
    }

    .buff {
      background: rgba(15, 23, 42, .78);
      border: 1px solid rgba(255,255,255,.18);
      border-radius: 999px;
      padding: 8px 12px;
      font-weight: 900;
      font-size: 14px;
      color: #f8fafc;
      box-shadow: 0 8px 22px rgba(0,0,0,.25);
    }

    #weaponInfo {
      position: absolute;
      left: 24px;
      top: 82px;
      z-index: 4;
      background: rgba(15, 23, 42, .78);
      border: 1px solid rgba(255,255,255,.18);
      border-radius: 18px;
      padding: 10px 13px;
      font-weight: 900;
      font-size: 14px;
      color: #f8fafc;
      pointer-events: none;
      box-shadow: 0 8px 22px rgba(0,0,0,.25);
      max-width: 310px;
      line-height: 1.45;
    }


    #missionInfo {
      position: absolute;
      left: 24px;
      top: 142px;
      z-index: 4;
      background: rgba(15, 23, 42, .80);
      border: 1px solid rgba(250,204,21,.42);
      border-radius: 18px;
      padding: 10px 13px;
      font-weight: 900;
      font-size: 14px;
      color: #fef9c3;
      pointer-events: none;
      box-shadow: 0 8px 22px rgba(0,0,0,.25);
      max-width: 340px;
      line-height: 1.45;
    }

    #achievementPop {
      position: absolute;
      top: 138px;
      left: 50%;
      transform: translateX(-50%) translateY(-12px);
      z-index: 7;
      background: linear-gradient(180deg, rgba(254,243,199,.96), rgba(250,204,21,.96));
      color: #111827;
      border: 2px solid rgba(255,255,255,.75);
      border-radius: 999px;
      padding: 12px 22px;
      font-weight: 1000;
      box-shadow: 0 14px 40px rgba(0,0,0,.36);
      opacity: 0;
      pointer-events: none;
      transition: opacity .25s, transform .25s;
      max-width: 92vw;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    #achievementPop.show {
      opacity: 1;
      transform: translateX(-50%) translateY(0);
    }

    #toast {
      position: absolute;
      left: 50%;
      bottom: 28px;
      transform: translateX(-50%);
      background: rgba(15, 23, 42, .86);
      border: 1px solid rgba(255,255,255,.18);
      border-radius: 999px;
      padding: 12px 20px;
      font-weight: 900;
      z-index: 5;
      opacity: 0;
      transition: opacity .25s, transform .25s;
      pointer-events: none;
      white-space: nowrap;
      max-width: 92vw;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    #toast.show {
      opacity: 1;
      transform: translateX(-50%) translateY(-6px);
    }

    #levelUpPanel {
      position: absolute;
      inset: 0;
      display: none;
      background: rgba(4, 8, 18, 0.50);
      backdrop-filter: blur(4px);
      z-index: 8;
      padding: 24px;
      overflow-y: auto;
    }

    #levelUpPanel.show { display: flex; }

    .levelCard {
      margin: auto;
      width: min(900px, 95vw);
      background: rgba(15, 23, 42, .95);
      border: 2px solid rgba(250, 204, 21, .72);
      border-radius: 30px;
      padding: 26px;
      box-shadow: 0 24px 80px rgba(0,0,0,.55);
      text-align: center;
    }

    .levelCard h2 {
      font-size: clamp(28px, 4vw, 44px);
      margin: 0 0 8px;
      color: #fef3c7;
    }

    .upgradeGrid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 14px;
      margin-top: 20px;
    }

    .upgradeBtn {
      min-height: 184px;
      padding: 16px;
      border-radius: 22px;
      background: linear-gradient(180deg, #fef3c7, #fde047);
      color: #111827;
      box-shadow: 0 8px 0 #a16207;
      text-align: left;
      line-height: 1.42;
      white-space: normal;
    }

    .upgradeBtn .emoji {
      display: block;
      font-size: 38px;
      margin-bottom: 8px;
      text-align: center;
    }

    .upgradeBtn .title {
      display: block;
      font-size: 19px;
      font-weight: 1000;
      margin-bottom: 7px;
      text-align: center;
    }

    .upgradeBtn .desc {
      display: block;
      font-size: 14px;
      font-weight: 800;
      color: #334155;
    }

    .hidden { display: none !important; }

    .small {
      color: #cbd5e1;
      font-size: 14px;
      line-height: 1.6;
    }

    kbd {
      display: inline-block;
      background: rgba(255,255,255,.18);
      border: 1px solid rgba(255,255,255,.25);
      border-bottom-width: 3px;
      border-radius: 7px;
      padding: 2px 7px;
      font-weight: 900;
      color: #fff;
    }

    @media (max-width: 760px) {
      .panel {
        align-items: start;
        justify-items: center;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        padding: 10px;
      }

      .panel .card,
      .levelCard {
        width: 100%;
        margin: 6px 0 24px;
        padding: 18px;
        border-radius: 22px;
      }

      h1 { font-size: clamp(28px, 9vw, 42px); }
      .subtitle { font-size: 15px; line-height: 1.5; margin-bottom: 12px; }
      .grid { grid-template-columns: 1fr; gap: 9px; margin: 10px 0; }
      .info { min-height: 0; padding: 12px 14px; font-size: 14px; }
      .tabs { gap: 6px; }
      .tab-btn { flex: 1; padding: 9px 8px; font-size: 13px; }
      .row { gap: 9px; margin-top: 12px; }
      .row > button, .row > select { width: 100%; margin-right: 0; }
      #startBtn { min-height: 52px; font-size: 18px; }
      .small { font-size: 12px; }

      canvas {
        width: calc(100vw - 8px);
        max-width: none;
        max-height: none;
        border-width: 3px;
        border-radius: 18px;
      }

      #hud {
        top: 8px;
        width: calc(100vw - 8px);
        gap: 3px;
      }

      .hudBox {
        flex: 1 1 0;
        min-width: 0;
        padding: 7px 2px;
        border-radius: 12px;
        font-size: clamp(8px, 2.45vw, 11px);
        line-height: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: clip;
      }

    #mainMenuBtn {
      position: absolute;
      top: 76px;
      right: 24px;
      z-index: 6;
      padding: 10px 14px;
      border-radius: 999px;
      font-size: 14px;
      box-shadow: 0 6px 0 #7c2d12;
      background: #fb923c;
      color: #111827;
    }

    #mainMenuBtn:active {
      transform: translateY(5px);
      box-shadow: 0 1px 0 #7c2d12;
    }

    #quitGameBtn {
      position: absolute;
      top: 122px;
      right: 24px;
      z-index: 6;
      padding: 10px 14px;
      border-radius: 999px;
      font-size: 14px;
      box-shadow: 0 6px 0 #991b1b;
      background: #f87171;
      color: #111827;
    }

    #quitGameBtn:active {
      transform: translateY(5px);
      box-shadow: 0 1px 0 #991b1b;
    }

    #activeItems { top: auto; bottom: 76px; right: 10px; }
      #weaponInfo { left: 10px; top: auto; bottom: 122px; font-size: 12px; max-width: 240px; }
      #missionInfo { left: 10px; top: auto; bottom: 178px; font-size: 12px; max-width: 260px; }
      #achievementPop { top: 154px; font-size: 13px; }
      .upgradeGrid { grid-template-columns: 1fr; }
      select { width: 100%; }
    }

    /* Mobile Joystick */
    #joystickZone {
      position: absolute;
      bottom: max(22px, env(safe-area-inset-bottom));
      left: max(18px, env(safe-area-inset-left));
      width: 128px;
      height: 128px;
      z-index: 100;
      border-radius: 50%;
      background: rgba(255, 255, 255, 0.15);
      border: 2px solid rgba(255, 255, 255, 0.3);
      display: none;
      touch-action: none;
    }
    #joystickStick {
      position: absolute;
      top: 50%;
      left: 50%;
      width: 56px;
      height: 56px;
      margin-left: -28px;
      margin-top: -28px;
      border-radius: 50%;
      background: rgba(255, 255, 255, 0.58);
      box-shadow: 0 4px 10px rgba(0,0,0,0.3);
      pointer-events: none;
      transition: transform 0.04s;
    }
    #dashBtn {
      position: absolute;
      bottom: max(30px, env(safe-area-inset-bottom));
      right: max(22px, env(safe-area-inset-right));
      width: 78px;
      height: 78px;
      z-index: 100;
      border-radius: 50%;
      background: rgba(250, 204, 21, 0.9);
      border: 2px solid rgba(255, 255, 255, 0.55);
      display: none;
      touch-action: none;
      color: #000;
      font-weight: bold;
      font-size: 17px;
      align-items: center;
      justify-content: center;
      box-shadow: 0 6px 0 #a16207;
      user-select: none;
    }
    #dashBtn:active { transform: translateY(5px); box-shadow: 0 1px 0 #a16207; }

    @media (max-width: 768px), (pointer: coarse) {
      body.game-running #joystickZone { display: block; }
      body.game-running #dashBtn { display: flex; }
    }
