:root{
    --bg:#0f1724; --text:#a50000; --ui:#4aa50e; --panel: rgb(78, 1, 1);
    --ghost-size:84px; --font-sans: Inter, system-ui, Arial, sans-serif;
  }
  .theme-night {
    --text: #ffefa7;
    --ui: #0ea5a4;
    --panel: rgba(255, 255, 255, 0.03);
    background-image: url('images/night.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
  }

  .theme-forest {
    --text: #00b7ff;
    --ui: #ff0000;
    --panel: rgba(255, 255, 255, 0.03);
    background-image: url('images/forest.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
  }

  .theme-horror {
    --text: #ffdede;
    --ui: #ff4d4f;
    --panel: rgba(255, 255, 255, 0.04);
    background-image: url('images/horror.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
  }

  .theme-nes-horror {
    --text:#c7c3a6; 
    --ui:#d14d4d; 
    --panel: rgba(255,255,255,0.02);
    filter: contrast(1.05) saturate(0.95);
    background-image: url('images/nes-horror.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
  }

  html,body{ height:100%; margin:0; font-family:var(--font-sans); background:var(--bg); color:var(--text); overflow:hidden; -webkit-tap-highlight-color: transparent; }

  #hud{ position:fixed; left:12px; top:12px; z-index:60; background:linear-gradient(180deg, rgba(122, 0, 0, 0.137), rgba(51, 0, 0, 0.082)); padding:10px 12px; border-radius:12px; backdrop-filter: blur(6px); box-shadow: 0 6px 18px rgba(128, 0, 0, 0.733); min-width:170px; }
  #score{ font-size:20px; font-weight:700; }
  #timeLeft{ font-size:13px; opacity:0.9; margin-top:6px; }
  #levelInfo{ font-size:13px; opacity:0.9; margin-top:6px; }

  #controls{ position:fixed; right:12px; top:12px; z-index:60; display:flex; gap:8px; }
  .btn{ background:linear-gradient(180deg, rgb(122, 0, 0), rgb(51, 0, 0)); border:1px solid rgb(34, 0, 0); color:var(--text); padding:8px 12px; border-radius:10px; cursor:pointer; font-weight:700; min-width:44px; box-shadow: 0 8px 24px rgb(92, 0, 0); }
  .btn:active{ transform:translateY(1px); }

  #menu{ position:fixed; left:50%; top:50%; transform:translate(-50%,-50%); background:linear-gradient(180deg, rgb(122, 0, 0), rgb(51, 0, 0)); padding:18px; border-radius:12px; z-index:70; text-align:center; width:92%; max-width:640px; box-shadow:0 10px 40px rgb(107, 0, 0); }
  #menu h1{ margin:0 0 8px 0; font-size:26px; letter-spacing:0.5px; }
  #menu p{ margin:0 0 12px 0; opacity:0.9; }
  #menu .row{ display:flex; gap:8px; justify-content:center; flex-wrap:wrap; margin-bottom:10px; }
  input[type="number"]{ width:84px; padding:6px 8px; border-radius:8px; border:1px solid rgb(255, 0, 0); background:transparent; color:var(--text); font-weight:700; }

  #ghost{ position:fixed; width:var(--ghost-size); height:var(--ghost-size); z-index:50; cursor:pointer; touch-action:none; user-select:none; transition:transform .08s linear; -webkit-user-drag:none; display:none; }
  .theme-horror #ghost, .theme-nes-horror #ghost{ filter: drop-shadow(0 6px 16px rgba(255, 20, 20, 0.514)); }

  #recordsBox{ position:fixed; right:12px; bottom:12px; z-index:60; background:linear-gradient(180deg, rgba(122, 0, 0, 0.137), rgba(51, 0, 0, 0.123)); padding:12px; border-radius:12px; font-size:13px; max-width:260px; box-shadow: 0 8px 24px rgb(92, 0, 0); }
  #recordsBox .title{ font-weight:900; margin-bottom:8px; }

  #powers{ position:fixed; left:12px; bottom:12px; z-index:60; display:flex; gap:8px; flex-wrap:wrap; box-shadow: 0 8px 24px rgb(92, 0, 0); }
  .power{ padding:8px 10px; border-radius:10px; border:1px solid rgba(255,255,255,0.06); background:linear-gradient(180deg, rgb(119, 1, 1), rgb(65, 1, 1)); font-weight:700; font-size:13px; cursor:pointer; }
  .power[disabled]{ opacity:0.45; cursor:default; }

  #stats{ position:fixed; left:12px; top:120px; z-index:60; background:linear-gradient(180deg, rgba(122, 0, 0, 0.103), rgba(51, 0, 0, 0.075)); padding:10px 12px; border-radius:10px; font-size:13px; width:178px; box-shadow: 0 8px 24px rgb(92, 0, 0); }
  #stats div{ margin-bottom:6px; }

  #fxCanvas{ position:fixed; inset:0; z-index:40; pointer-events:none; }

  .theme-nes-horror::after{
    content:""; position:fixed; inset:0; pointer-events:none; background-image: linear-gradient(rgba(0, 255, 34, 0.39) 1px, transparent 1px); background-size:100% 4px; mix-blend-mode:overlay; z-index:9999;
  }

  @media (max-width:640px){
    #hud{ min-width:140px; left:8px; top:8px; padding:8px; }
    #controls{ right:8px; top:8px; gap:6px; }
    :root{ --ghost-size:72px; }
    #menu{ padding:14px;  }
  }