
  :root { --hp-color: #e0523f; --accent: #6ee7c8; }
  * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
  html, body { margin: 0; padding: 0; overflow: hidden; height: 100%; background: #0d1117; font-family: -apple-system, system-ui, sans-serif; touch-action: none; }
  #canvas-wrap { position: fixed; inset: 0; }
  canvas { display: block; width: 100%; height: 100%; }

  /* HUD */
  #hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
  #hp-bar-wrap {
    position: absolute; top: 14px; left: 14px; width: 200px; height: 18px;
    background: rgba(0,0,0,0.45); border: 1px solid rgba(255,255,255,0.2); border-radius: 4px; overflow: hidden;
  }
  #hp-bar { height: 100%; width: 100%; background: var(--hp-color); transition: width 0.15s ease; }
  #hp-label { position: absolute; top: 34px; left: 14px; color: #ddd; font-size: 12px; letter-spacing: 0.02em; }

  #status { position: absolute; top: 14px; right: 14px; color: #9aa4af; font-size: 12px; text-align: right; line-height: 1.5; }

  #score-wrap {
    position: absolute; top: 52px; right: 14px; color: #fff; font-size: 15px;
    text-align: right; font-weight: 700; letter-spacing: 0.03em;
  }
  #score-wrap .wave { color: #9aa4af; font-size: 11px; font-weight: 400; }
  #best-wrap {
        position: absolute; top: 92px; right: 14px; color: #e5b95c; font-size: 12px;
        text-align: right; font-weight: 600; letter-spacing: 0.02em; font-family: 'Courier New', monospace;
      }

      /* Barra de HP do BOSS (topo central) — visível só quando tem boss vivo */
      #boss-hp-wrap {
        position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
        width: 320px; max-width: 62vw; height: 15px;
        background: rgba(0,0,0,0.55); border: 1px solid rgba(255,90,60,0.6);
        border-radius: 6px; overflow: hidden; display: none;
        box-shadow: 0 0 14px rgba(255,60,50,0.35);
      }
      #boss-hp-wrap.show { display: block; }
      #boss-hp-label {
        position: absolute; top: 16px; left: 0; right: 0;
        color: #ff8a7a; font-size: 10px; font-weight: 700;
        letter-spacing: 0.1em; text-align: center; text-shadow: 0 1px 3px #000;
      }
      #boss-hp-bar {
        height: 100%; width: 100%;
        background: linear-gradient(90deg, #7a1a1a, #e0523f, #ff6f55);
        transition: width 0.15s ease;
      }

    /* Killstreak flair */
    #killstreak {
      position: absolute; top: 38%; left: 50%; transform: translate(-50%, -50%);
      color: #fff; font-size: 26px; font-weight: 800; letter-spacing: 0.06em;
      text-shadow: 0 2px 10px rgba(0,0,0,0.6); opacity: 0;
      transition: transform 0.09s ease, opacity 0.25s ease;
      pointer-events: none; user-select: none; white-space: nowrap;
    }

  /* Barra de XP + nível */
  #xp-wrap {
    position: absolute; top: 54px; left: 14px; width: 200px; height: 10px;
    background: rgba(0,0,0,0.45); border: 1px solid rgba(255,255,255,0.2); border-radius: 4px; overflow: hidden;
  }
  #xp-bar { height: 100%; width: 0%; background: #7ec8e3; transition: width 0.2s ease; }
  #xp-label { position: absolute; top: 66px; left: 14px; color: #9aa4af; font-size: 10px; }

  /* Ouro */
  #gold-wrap {
    position: absolute; top: 14px; left: 14px; margin-left: 210px; color: #ffd166;
    font-size: 14px; font-weight: 700;
  }

  /* Overlay fim de jogo */
  #overlay {
    position: fixed; inset: 0; z-index: 20; display: none;
    align-items: center; justify-content: center; flex-direction: column;
    background: rgba(8, 10, 14, 0.78); backdrop-filter: blur(4px);
    color: #fff; text-align: center; gap: 10px; padding: 24px;
  }
  #overlay.show { display: flex; }
  #overlay h1 { font-size: 42px; margin: 0; letter-spacing: 0.05em; }
  #overlay h1.win { color: #6ee7c8; }
  #overlay h1.lose { color: #e0523f; }
  #overlay .sub { color: #9aa4af; font-size: 14px; }
  #restart-btn {
    margin-top: 14px; padding: 14px 32px; font-size: 16px; font-weight: 700;
    color: #0d1117; background: #6ee7c8; border: none; border-radius: 8px;
    cursor: pointer; letter-spacing: 0.03em; pointer-events: auto;
  }
  #restart-btn:active { transform: scale(0.96); }

  /* Menu inicial */
  #menu {
    position: fixed; inset: 0; z-index: 25; display: flex;
    align-items: center; justify-content: center; flex-direction: column;
    background: linear-gradient(180deg, #0e1a14 0%, #16251c 100%);
    color: #fff; text-align: center; gap: 12px; padding: 24px;
  }
  #menu.hidden { display: none; }
  #menu h1 { font-size: 52px; margin: 0; color: #6ee7c8; letter-spacing: 0.06em; }
  #menu .sub { color: #9aa4af; font-size: 14px; }
  #menu .hint { color: #556; font-size: 12px; margin-top: 8px; }
  #start-btn {
    margin-top: 10px; padding: 16px 48px; font-size: 20px; font-weight: 700;
    color: #0d1117; background: #6ee7c8; border: none; border-radius: 12px;
    cursor: pointer; letter-spacing: 0.05em;
  }
  #start-btn:active { transform: scale(0.96); }

  /* Painel de inventário / crafting / venda */
  #inventory-panel {
    position: fixed; left: 14px; bottom: 14px; z-index: 12; width: 230px;
    background: rgba(12, 16, 20, 0.82); border: 1px solid rgba(255,255,255,0.18);
    border-radius: 10px; padding: 12px; color: #ddd; font-size: 12px;
    pointer-events: auto; backdrop-filter: blur(4px);
  }
  #inventory-panel h3 { margin: 0 0 8px; font-size: 13px; color: #6ee7c8; letter-spacing: 0.03em; }
  #inv-list { display: flex; flex-direction: column; gap: 3px; margin-bottom: 10px; }
  .inv-row { display: flex; justify-content: space-between; }
  .inv-row b { color: #fff; }
  #craft-list { display: flex; flex-direction: column; gap: 5px; }
  .craft-btn {
    padding: 6px 8px; font-size: 11px; background: #2a3a34; color: #cfe;
    border: 1px solid rgba(255,255,255,0.15); border-radius: 6px; cursor: pointer;
    text-align: left;
  }
  .craft-btn:disabled { opacity: 0.4; cursor: not-allowed; }
  .craft-btn:active { background: #3a4a44; }
  #sell-hint { color: #9aa4af; font-size: 11px; margin-top: 8px; border-top: 1px solid rgba(255,255,255,0.1); padding-top: 8px; }
  #toggle-inv {
    position: fixed; left: 14px; bottom: 14px; z-index: 13; padding: 8px 12px;
    background: #6ee7c8; border: none; border-radius: 8px; color: #0d1117;
    font-weight: 700; cursor: pointer; font-size: 12px;
  }

  #toggle-shop, #toggle-quests, #toggle-build {
    position: fixed; z-index: 13; padding: 8px 12px;
    background: #ffd166; border: none; border-radius: 8px; color: #0d1117;
    font-weight: 700; cursor: pointer; font-size: 12px;
  }
  #toggle-shop { left: 118px; bottom: 14px; }
  #toggle-quests { left: 190px; bottom: 14px; background: #6ec8ff; }
  #toggle-build { left: 262px; bottom: 14px; background: #b06eff; color: #fff; }

  #build-panel {
    position: fixed; left: 14px; bottom: 54px; z-index: 12; width: 230px;
    background: rgba(12,16,20,0.92); border: 1px solid rgba(255,255,255,0.18);
    border-radius: 10px; padding: 12px; color: #ddd; font-size: 12px;
  }

  /* Equipamentos / inventário de itens */
  #toggle-equip {
    position: fixed; left: 14px; bottom: 52px; z-index: 13; padding: 8px 12px;
    background: #e0523f; border: none; border-radius: 8px; color: #fff;
    font-weight: 700; cursor: pointer; font-size: 12px;
  }
  #inv-panel {
    position: fixed; left: 14px; bottom: 94px; z-index: 12; width: 240px; max-height: 52vh;
    background: rgba(12,16,20,0.9); border: 1px solid rgba(255,255,255,0.18);
    border-radius: 10px; padding: 12px; color: #ddd; font-size: 12px;
    pointer-events: auto; backdrop-filter: blur(4px); overflow-y: auto;
  }
  #inv-panel h3 { margin: 0 0 8px; font-size: 13px; color: #e0523f; letter-spacing: 0.03em; }
  #equip-slots, #equip-list { display: flex; flex-direction: column; gap: 4px; }
  .equip-slot.on { background: rgba(110,231,200,0.08); border-radius: 6px; padding: 3px 4px; }
  .equip-slot.off { opacity: 0.6; }
  .equip-btn {
    background: #2a3a34; color: #6ee7c8; border: 1px solid rgba(110,231,200,0.4);
    border-radius: 6px; padding: 5px 9px; cursor: pointer; font-size: 11px; font-weight: 700;
    min-height: 32px; touch-action: manipulation; white-space: nowrap;
  }
  .equip-btn.unequip { background: #3a2a2a; color: #f0a0a0; border-color: rgba(224,82,63,0.4); }
  .equip-btn:disabled { opacity: 0.65; pointer-events: none; }
  .equip-btn:active { transform: scale(0.96); }
  #build-panel h3 { margin: 0 0 8px; font-size: 13px; color: #b06eff; }
  .build-btn {
    background: #2a342a; color: #b06eff; border: 1px solid rgba(176,110,255,0.4);
    border-radius: 6px; padding: 4px 12px; cursor: pointer; font-size: 14px; font-weight: 700; width: 32px;
  }
  .build-btn:disabled { opacity: 0.3; cursor: not-allowed; }
  #title-label { color: #b06eff; font-size: 11px; margin-top: 6px; font-weight: 700; }

  #shop-panel, #quest-panel {
    position: fixed; left: 14px; bottom: 54px; z-index: 12; width: 230px;
    background: rgba(12, 16, 20, 0.9); border: 1px solid rgba(255,255,255,0.18);
    border-radius: 10px; padding: 12px; color: #ddd; font-size: 12px;
    backdrop-filter: blur(4px);
  }
  #shop-panel h3, #quest-panel h3 { margin: 0 0 8px; font-size: 13px; color: #ffd166; }
  .shop-row { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; }
  .shop-btn {
    background: #2a3a34; color: #ffd166; border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px; padding: 4px 10px; cursor: pointer; font-size: 11px; font-weight: 700;
  }
  .shop-btn:disabled { opacity: 0.4; cursor: not-allowed; }
  #quest-list { display: flex; flex-direction: column; gap: 6px; }
  .quest-item { padding: 5px 6px; border-radius: 6px; background: rgba(255,255,255,0.05); }
  .quest-item.done { color: #6ee7c8; text-decoration: line-through; }

  /* Modal de diálogo de NPC */
  #quest-dialog {
    position: fixed; inset: 0; z-index: 30; display: none;
    align-items: center; justify-content: center;
    background: rgba(6, 8, 12, 0.72); backdrop-filter: blur(3px);
  }
  #quest-dialog.show { display: flex; }
  .qd-box {
    width: min(440px, 92vw); max-height: 88vh; background: #141a22;
    border: 1px solid rgba(255,255,255,0.16); border-radius: 14px;
    padding: 18px 20px; color: #eaeef3; box-shadow: 0 18px 50px rgba(0,0,0,0.6);
    pointer-events: auto; text-align: left; overflow-y: auto;
  }
  .qd-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
  .qd-avatar {
    width: 46px; height: 46px; border-radius: 50%; flex: 0 0 auto;
    border: 2px solid rgba(255,255,255,0.25); box-shadow: inset 0 0 0 4px rgba(0,0,0,0.25);
  }
  .qd-name { font-size: 18px; font-weight: 800; letter-spacing: 0.04em; }
  .qd-quest-tag { font-size: 12px; color: #ffd166; letter-spacing: 0.02em; margin-top: 2px; }
  .qd-text {
    font-size: 15px; line-height: 1.55; min-height: 96px; max-height: 40vh; overflow-y: auto;
    color: #d7dde4; background: rgba(0,0,0,0.25); border-radius: 10px; padding: 12px 14px; margin-bottom: 14px;
  }
  .qd-btns { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
  .qd-btn {
    padding: 14px 20px; font-size: 15px; font-weight: 700; border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.2); color: #0d1117; cursor: pointer;
    min-height: 48px; touch-action: manipulation;
  }
  .qd-btn.primary { background: #6ee7c8; }
  .qd-btn.gold { background: #ffd166; }
  .qd-btn.callout { background: #b06eff; color: #fff; }
  .qd-btn.ghost { background: transparent; color: #9aa4af; border-color: rgba(255,255,255,0.15); }
  .qd-btn:active { transform: scale(0.96); }
  .qd-btn[hidden] { display: none; }

  /* Hint "aperte E" perto de NPC com quest */
  #npc-hint {
    position: fixed; left: 50%; bottom: 150px; transform: translateX(-50%); z-index: 14;
    background: rgba(10,14,20,0.85); border: 1px solid #6ee7c8; color: #6ee7c8;
    padding: 8px 16px; border-radius: 999px; font-size: 13px; font-weight: 700;
    letter-spacing: 0.02em; pointer-events: none; white-space: nowrap;
    box-shadow: 0 0 18px rgba(110,231,200,0.25);
  }

  /* Botão contextual de interação com NPC (funciona em todas as plataformas) */
  #interact-btn {
    position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 30;
    display: none; align-items: center; justify-content: center; gap: 8px;
    padding: 16px 30px; font-size: 18px; font-weight: 800; letter-spacing: 0.02em;
    color: #0d1117; background: #6ee7c8; border: none; border-radius: 999px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.5), 0 0 22px rgba(110,231,200,0.4);
    cursor: pointer; touch-action: manipulation; white-space: nowrap;
  }
  #interact-btn:active { transform: translateX(-50%) scale(0.95); }
  .skill-button {
    position: fixed; right: 14px; bottom: 88px; z-index: 13; padding: 14px 18px;
    background: #9b6bff; border: 2px solid #b06eff; border-radius: 50%; color: #fff;
    font-weight: 700; font-size: 14px; cursor: pointer; width: 72px; height: 72px;
    display: flex; align-items: center; justify-content: center; text-align: center;
    line-height: 1.1; box-shadow: 0 0 14px rgba(155,107,255,0.5);
  }
  .skill-button:disabled { opacity: 0.5; }

  #toggle-map {
    position: fixed; top: 14px; left: 14px; z-index: 13; padding: 8px 12px;
    background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.25);
    border-radius: 8px; color: #fff; font-weight: 700; cursor: pointer; font-size: 12px;
  }
  #minimap-panel {
    position: fixed; top: 54px; left: 14px; z-index: 12;
    background: rgba(12,16,20,0.92); border: 1px solid rgba(255,255,255,0.2);
    border-radius: 10px; padding: 8px;
  }
  #minimap-canvas { border-radius: 6px; display: block; }
  #minimap-label { color: #9aa4af; font-size: 11px; text-align: center; margin-top: 4px; }

  /* Flash de dano (vermelho na tela) */
  #damage-flash {
    position: fixed; inset: 0; z-index: 15; pointer-events: none;
    background: radial-gradient(circle, rgba(224,82,63,0) 0%, rgba(224,82,63,0.45) 100%);
    opacity: 0; transition: opacity 0.15s ease-out;
  }

  /* Joystick (mobile only) */
  #joystick-zone {
    position: absolute; left: 24px; bottom: 24px; width: 120px; height: 120px;
    border-radius: 50%; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.15);
    pointer-events: auto; display: none;
  }
  #joystick-stick {
    position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px;
    border-radius: 50%; background: rgba(255,255,255,0.25); border: 1px solid rgba(255,255,255,0.4);
  }

  #attack-btn {
    position: absolute; right: 28px; bottom: 32px; width: 78px; height: 78px; border-radius: 50%;
    background: rgba(224,82,63,0.25); border: 2px solid var(--hp-color); color: #fff; font-size: 13px;
    pointer-events: auto; display: none; align-items: center; justify-content: center; letter-spacing: 0.02em;
  }
  #attack-btn:active { background: rgba(224,82,63,0.5); }

  #weapon-switch {
    position: absolute; right: 28px; bottom: 122px; display: flex; flex-direction: column; gap: 8px;
    pointer-events: auto;
  }
  .weapon-btn {
    width: 52px; height: 52px; border-radius: 50%; background: rgba(255,255,255,0.12);
    border: 2px solid rgba(255,255,255,0.3); color: #fff; font-size: 22px;
    pointer-events: auto; display: flex; align-items: center; justify-content: center; cursor: pointer;
  }
  .weapon-btn.active { border-color: #ffd166; background: rgba(255,209,102,0.25); }

  #desktop-hint {
    position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
    color: #6b7480; font-size: 12px; letter-spacing: 0.02em;
  }

  #enemy-banner {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -160%);
    color: #ffd7d0; font-size: 13px; opacity: 0; transition: opacity 0.3s ease;
  }
