@font-face {
  font-family: 'Rubik 80s Fade';
  src: url('fonts/Rubik80sFade-Regular.ttf') format('truetype');
  font-display: swap;
}

@font-face {
  font-family: 'Rubik Mono One';
  src: url('fonts/RubikMonoOne-Regular.ttf') format('truetype');
  font-display: swap;
}

/* ===============GLOBAL=============== */
body {
  margin: 0;
  background: #000;
  overflow: hidden;
  font-family: 'Courier New', monospace;
  pointer-events: none;
}

:root {
  --primary-color: #0f0;
  --secondary-color: #f00;
  --gold-color: gold;
  --skull-color: #09fdd3;
  --cross-color: #ff0;
  --star-color: #ed420f;
  --worm-segment-color: purple;
  --worm-head-color: magenta;
}

#matrix-effect {
  position: fixed;
  top: 0;
  left: 0;
  z-index: -1;
  color: #0f0;
  opacity: 0.3;
}

#game {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

#player {
  position: absolute;
  width: 20px;
  height: 20px;
  background-color: #0f0;
  left: calc(50% - 10px);
  top: calc(50% - 10px);
  transition: background-color 0.3s;
}

/* ===============ENTITIES=============== */
.data-packet, .obstacle, .powerup, .enemy-skull, .enemy-cross, .enemy-star,
.enemy-worm-segment, .enemy-worm-head, .enemy-spitter, .dash-trail, .attack-animation {
  position: absolute;
  transform: translateZ(0);
}

.data-packet { color: var(--primary-color); text-shadow: 0 0 5px var(--primary-color); font-size: 20px; }
.obstacle { color: var(--secondary-color); text-shadow: 0 0 5px var(--secondary-color); font-size: 20px; }
.powerup { font-size: 24px; color: var(--gold-color); text-shadow: 0 0 10px var(--gold-color); }
.enemy-skull { color: var(--skull-color); text-shadow: 0 0 5px var(--skull-color); font-size: 20px; }
.enemy-cross { color: var(--cross-color); transform: rotate(var(--rotation)); font-size: 20px; }
.enemy-star { font-size: 24px; color: var(--star-color); text-shadow: 0 0 10px var(--star-color); }
.enemy-spitter { color: #b1fc03; font-size: 40px; }
.enemy-worm-segment { color: var(--worm-segment-color); text-shadow: 0 0 5px var(--worm-segment-color); font-size: 20px; }
.enemy-worm-head { font-weight: bold; font-size: 28px; color: var(--worm-head-color); text-shadow: 0 0 7px var(--worm-head-color); display: inline-block; transform-origin: center; }

/* ===============ANIMATION & EFFECTS =============== */
.cross-charging { animation: vibrate 0.05s infinite; }
@keyframes vibrate { 0% { transform: translateX(0); } 25% { transform: translateX(-2px); } 50% { transform: translateX(2px); } 75% { transform: translateX(-2px); } 100% { transform: translateX(0); } }

.spitter-shake { animation: shake 0.5s; }
@keyframes shake { 0%{transform:translate(1px, 1px) rotate(0deg)}10%{transform:translate(-1px,-2px) rotate(-1deg)}20%{transform:translate(-3px,0px) rotate(1deg)}30%{transform:translate(3px,2px) rotate(0deg)}40%{transform:translate(1px,-1px) rotate(1deg)}50%{transform:translate(-1px,2px) rotate(-1deg)}60%{transform:translate(-3px,1px) rotate(0deg)}70%{transform:translate(3px,1px) rotate(-1deg)}80%{transform:translate(-1px,-1px) rotate(1deg)}90%{transform:translate(1px,2px) rotate(1deg)}100%{transform:translate(1px,-2px) rotate(-1deg)} }

.slow-blink { animation: slow-blink 1s infinite; }
@keyframes slow-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.player-glow { box-shadow: 0 0 20px var(--gold-color) }

.dash-trail { width: 20px; height: 20px; background-color: #0f0; filter: blur(9px); opacity: 0.3; pointer-events: none; transition: opacity 0.5s linear; }
.attack-animation { width: 20px; height: 20px; border-radius: 50%; border: 3px solid #ff0; opacity: 0.8; pointer-events: none; transition: transform 0.5s ease-out, opacity 0.5s ease-out, filter 0.5s ease-out; transform-origin: center; transform: scale(1); }
#dash-aiming-overlay { position: fixed; left: 0; top: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 999; }

/* ===============DISPLAYS=============== */
#score, #health, #timer, #fps-counter { position: fixed; color: #0f0; font-size: 20px; }
#score { top: 80px; left: 20px; z-index: 1001; }
#health { top: 50px; left: 20px; z-index: 1001; }
#timer { top: 20px; left: 20px; z-index: 1001; }
#fps-counter { top: 10px; right: 10px; z-index: 1001; display: none; }

/* ===============DEBUG DISPLAY=============== */
#debug-console { position: fixed; bottom: 20px; right: 20px; width: 650px; background: black; color: #0f0; padding: 10px; border: 1px solid #0f0; display: none; box-shadow: 0 0 10px rgba(0, 255, 0, 0.3); z-index: 1002; pointer-events: auto; }
#console-output { height: 280px; overflow-y: auto; width: 100%; background: black; color: #0f0; border: none; resize: none; padding: 5px; }
#console-input { width: 100%; background: black; color: #0f0; border: none; outline: none; font-size: 14px; padding: 5px; }

/* ===============BASE OVERLAYS=============== */
#startup-overlay, #game-over-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #000; display: flex; justify-content: center; align-items: center; z-index: 1000; transition: opacity 2s; }
#startup-overlay { opacity: 1; }
#game-over-overlay { display: none; color: #f00; font-size: 48px; opacity: 0; transition: opacity 0.2s; }

#startup-overlay .matrix-text, #game-over-overlay .matrix-text { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 150px; font-family: 'Rubik 80s Fade'; color: #0f0; text-shadow: 0 0 10px #0f0; text-align: center; }
#game-over-overlay .matrix-text { text-shadow: 0 0 10px #f00; color: #ed420f; }

.random-chars { position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden; }
.random-chars span { position: absolute; color: var(--primary-color); font-size: 20px; opacity: 0.5; transform: translateZ(0); }

/* ===============IN-GAME SKILL BUTTONS=============== */
#skill-menu { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; display: flex; justify-content: flex-start; align-items: flex-end; z-index: 1000; pointer-events: auto; }
.button-container { display: flex; gap: 2rem; padding: 20px; }
.matrix-btn { width: 100px; height: 100px; background: #000; border: 2px solid #0f0; cursor: pointer; position: relative; transition: all 0.3s ease; display: flex; align-items: center; justify-content: center; overflow: hidden; box-shadow: inset 0 0 10px #0f03; }
.matrix-btn i { color: #0f0; font-size: 2.5rem; transition: all 0.3s ease; position: relative; z-index: 2; filter: drop-shadow(0 0 2px #0f0); animation: float 2s ease-in-out infinite; }
.matrix-btn::before { content: ''; position: absolute; width: 100%; height: 100%; background: repeating-linear-gradient(0deg, transparent 0 9px, #0f02 9px 10px), repeating-linear-gradient(90deg, transparent 0 9px, #0f02 9px 10px); animation: grid-pulse 1.5s infinite; opacity: 0.3; pointer-events: none; }
.matrix-btn:hover { box-shadow: 0 0 25px #0f06, inset 0 0 15px #0f03; transform: scale(1.1); }
.matrix-btn:active { transform: scale(0.95); filter: brightness(1.2); }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes grid-pulse { 0%, 100% { opacity: 0.3; } 50% { opacity: 0.6; } }

/* ======================================================= */
/* ================= MENU & SETTINGS CSS ================= */
/* ======================================================= */

#main-menu-overlay, #settings-menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  align-items: center;
  z-index: 1001;
  opacity: 0;
  pointer-events: none;
}

/* MODIFICATION: Center main menu, but align settings to the left */
#main-menu-overlay {
    justify-content: center;
}
#settings-menu-overlay {
    justify-content: flex-start; /* Aligns the settings panel to the left */
}

#main-menu-overlay.visible, #settings-menu-overlay.visible, #pause-menu.visible {
  display: flex;
  opacity: 1;
  pointer-events: auto;
}

#pause-menu {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: none;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.8);
  color: #0f0;
  font-size: 6em;
  font-family: 'Rubik 80s Fade';
  z-index: 1001;
  text-shadow: 0 0 10px var(--primary-color);
}

.menu-content { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.game-title { font-family: 'Rubik 80s Fade'; font-size: 7rem; color: var(--primary-color); text-shadow: none; margin-bottom: 20px; display: none; }
.menu-buttons { display: flex; flex-direction: column; align-items: center; }

.text-btn { font-family: 'Rubik 80s Fade'; font-size: 9rem; color: var(--primary-color); text-shadow: 0 0 8px var(--primary-color); background: none; border: none; padding: 15px 20px; cursor: pointer; transition: transform 0.2s ease, text-shadow 0.2s ease, color 0.2s ease; }
.text-btn:hover:not(:disabled) { transform: scale(1.1); text-shadow: 0 0 15px var(--primary-color), 0 0 25px var(--primary-color); }
.text-btn:active:not(:disabled) { transform: scale(1.05); text-shadow: 0 0 5px var(--primary-color); }
.text-btn:disabled { color: #444; text-shadow: none; cursor: not-allowed; }
.text-btn.small-btn { font-size: 1.5rem; }
.text-btn.danger-btn { color: var(--primary-color); text-shadow: 0 0 8px var(--primary-color); }
.text-btn.danger-btn:hover:not(:disabled) { text-shadow: 0 0 15px var(--primary-color), 0 0 25px var(--primary-color); }

/* ======================================================= */
/* =========== SETTINGS PANEL (ASYMMETRICAL HUD) ========= */
/* ======================================================= */

/* --- Fullscreen Background (unchanged) --- */
#scanline-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    background:
        repeating-linear-gradient(
            0deg,
            rgba(0, 0, 0, 0) 0%,
            rgba(0, 0, 0, 0.2) 50%,
            rgba(0, 0, 0, 0) 100%
        );
    background-size: auto 4px;
    z-index: -1;
    opacity: 0.5;
    animation: scanline-flicker 5s infinite;
}
@keyframes scanline-flicker {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 0.6; }
}

/* --- Redesigned Panel: structured grid, scroll, neon rails --- */
.settings-panel {
    position: relative;
    width: min(720px, 92vw);
    margin-left: 5vw;
    color: var(--primary-color);
    padding: 28px 28px 24px 28px;
    border: 1px solid rgba(0,255,0,0.35);
    border-left-width: 3px;
    border-radius: 18px;
    background:
      linear-gradient(180deg, rgba(0,18,0,0.92), rgba(0,12,0,0.88)),
      radial-gradient(1200px 400px at -10% -10%, rgba(0,255,0,0.10), transparent 60%),
      radial-gradient(800px 300px at 120% 110%, rgba(0,255,120,0.07), transparent 70%),
      repeating-linear-gradient(90deg, rgba(0,255,0,0.03) 0 1px, transparent 1px 14px);
    box-shadow: 0 0 24px rgba(0,255,0,0.18), inset 0 0 0 1px rgba(0,255,0,0.08);
    display: grid;
    grid-auto-rows: max-content;
    gap: 18px;
    max-height: min(86vh, 980px);
    overflow: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(0,255,0,0.5) transparent;
}
.settings-panel::-webkit-scrollbar { width: 10px; }
.settings-panel::-webkit-scrollbar-track { background: transparent; }
.settings-panel::-webkit-scrollbar-thumb { background: rgba(0,255,0,0.45); border-radius: 10px; }

/* Neon rail + corner nodes */
.settings-panel::before,
.settings-panel::after {
    content: "";
    position: absolute;
    pointer-events: none;
}
.settings-panel::before {
    left: 14px; top: 12px; bottom: 12px; width: 6px;
    background: linear-gradient(180deg, transparent, rgba(0,255,0,0.8) 15%, rgba(0,255,0,0.2) 50%, rgba(0,255,0,0.8) 85%, transparent);
    filter: drop-shadow(0 0 12px rgba(0,255,0,0.6));
}
.settings-panel::after {
    right: 14px; top: 12px; height: 6px; width: 120px;
    background: linear-gradient(90deg, rgba(0,255,0,0.0), rgba(0,255,0,0.6), rgba(0,255,0,0.0));
    box-shadow: 0 0 12px rgba(0,255,0,0.3);
}

/* --- Title: sticky for long lists --- */
.settings-title {
    position: sticky;
    top: 0;
    z-index: 2;
    margin: -28px -28px 8px -28px;
    padding: 0px 28px 10px 28px;
    font-family: 'Rubik 80s Fade';
    font-size: clamp(2.2rem, 3.2vw, 3.6rem);
    text-align: center;
    letter-spacing: 1px;
    color: var(--primary-color);
    background: linear-gradient(180deg, rgba(0,18,0,0.92), rgba(0,18,0,0));
    text-shadow: 0 0 10px var(--primary-color);
    border-bottom: 1px solid rgba(0,255,0,0.25);
    backdrop-filter: blur(2px);
    animation: text-flicker 5s infinite;

}
@keyframes text-flicker {
    0%,18%,22%,25%,53%,57%,100% { text-shadow:0 0 10px var(--primary-color); opacity:1; }
    20%,24%,55% { text-shadow:none; opacity:0.9; }
}

/* --- Section cards: HUD modules --- */
.settings-section {
    position: relative;
    margin: 0;
    padding: 18px 16px 14px 16px;
    border: 1px solid rgba(0,255,0,0.22);
    border-radius: 14px;
    background:
      linear-gradient(180deg, rgba(0,20,0,0.45), rgba(0,12,0,0.25)),
      repeating-linear-gradient(0deg, rgba(0,255,0,0.04) 0 1px, transparent 1px 18px);
    box-shadow: inset 0 0 0 1px rgba(0,255,0,0.06);
}
.settings-section::before {
    content: "";
    position: absolute;
    left: 10px; right: 10px; top: 10px; height: 6px;
    background:
      radial-gradient(10px 6px at left, rgba(0,255,0,0.45), transparent 70%),
      radial-gradient(10px 6px at right, rgba(0,255,0,0.45), transparent 70%);
    opacity: 0.6;
}

/* Section headings */
.settings-section h3 {
    font-family: 'Rubik Mono One';
    font-size: 1.15rem;
    margin: 0 0 14px 0;
    padding: 0 0 6px 0;
    letter-spacing: .6px;
    color: var(--gold-color);
    text-shadow: 0 0 8px rgba(255,215,0,0.35);
    border-bottom: 1px dashed rgba(0,255,0,0.22);
}

/* --- Rows & Grid --- */
.setting-item {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 18px;
    font-family: 'Rubik Mono One';
    font-size: 1.02rem;
    padding: 8px 6px;
    border-radius: 10px;
    transition: background-color .15s ease, box-shadow .15s ease;
}
.setting-item:hover {
    background-color: rgba(0,255,0,0.06);
    box-shadow: inset 0 0 0 1px rgba(0,255,0,0.06);
}

/* highlight row if any checkbox inside is checked (Firefox supports :has) */
.setting-item:has(.matrix-checkbox:checked) {
    background-color: rgba(0,255,0,0.10);
    box-shadow: inset 0 0 0 1px rgba(0,255,0,0.16), 0 0 16px rgba(0,255,0,0.10);
}

.controls-grid {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px 24px;
    align-items: center;
    font-family: 'Rubik Mono One';
    font-size: 1rem;
}

/* --- Actions area --- */
.settings-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-top: 6px;
    padding-top: 14px;
    border-top: 1px solid rgba(0, 255, 0, 0.18);
    gap: 12px;
}

/* --- Buttons: crisp neon edges --- */
.rebind-btn, .settings-actions .text-btn {
    font-family: 'Rubik Mono One';
    font-size: 0.95rem;
    line-height: 1;
    padding: 12px 18px;
    min-width: 132px;
    text-align: center;
    cursor: pointer;
    color: var(--primary-color);
    background: linear-gradient(180deg, rgba(0,25,0,0.65), rgba(0,18,0,0.55));
    border: 1px solid rgba(0,255,0,0.6);
    border-radius: 12px;
    box-shadow: 0 0 0 1px rgba(0,255,0,0.25) inset, 0 2px 10px rgba(0,255,0,0.15);
    transition: transform .12s ease, box-shadow .15s ease, background-color .15s ease, color .15s ease, border-color .15s ease;
}
.rebind-btn:hover, .settings-actions .text-btn:hover:not(:disabled) {
    background: var(--primary-color);
    color: #000;
    border-color: rgba(0,255,0,0.9);
    box-shadow: 0 0 18px rgba(0,255,0,0.6), 0 0 2px rgba(0,0,0,0.6) inset;
}
.rebind-btn:active, .settings-actions .text-btn:active:not(:disabled) {
    transform: translateY(1px);
    box-shadow: 0 0 10px rgba(0,255,0,0.45) inset;
}

/* Keyboard focus */
.rebind-btn:focus-visible, .settings-actions .text-btn:focus-visible, .matrix-checkbox:focus-visible {
    outline: 2px solid var(--gold-color);
    outline-offset: 2px;
}

/* --- Checkboxes: crisp X, stronger states --- */
.matrix-checkbox {
    appearance: none;
    width: 22px;
    height: 22px;
    border: 2px solid var(--primary-color);
    background: #000;
    cursor: pointer;
    position: relative;
    border-radius: 4px;
    transition: box-shadow 0.15s ease, background-color 0.15s ease, transform 0.1s ease;
}
.matrix-checkbox:hover { box-shadow: 0 0 10px rgba(0,255,0,0.6); }
.matrix-checkbox:active { transform: scale(0.96); }
.matrix-checkbox:checked {
    background-color: var(--primary-color);
    box-shadow: 0 0 14px rgba(0,255,0,0.7);
}
.matrix-checkbox:checked::before {
    content: 'X';
    font-family: 'Rubik Mono One';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -52%);
    font-size: 14px;
    font-weight: 900;
    color: #000;
}

/* --- Responsive tweaks --- */
@media (max-width: 720px) {
  .settings-panel { width: 95vw; padding: 22px; border-radius: 14px; }
  .settings-title { font-size: 2.2rem; }
  .settings-section { padding: 14px; }
  .setting-item, .controls-grid { grid-template-columns: 1fr; gap: 10px; }
  .rebind-btn, .settings-actions .text-btn { min-width: 112px; padding: 10px 14px; }
}