/* 128-bit Retro Styling */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: linear-gradient(45deg, #1a1208, #2a1f10, #3a2810);
    font-family: 'Courier New', monospace;
    overflow: hidden;
    color: #ffb347;
}

#gameContainer {
    position: relative;
    width: 100vw;
    height: 100vh;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    background: #000;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

#ui {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}


/* Custom cursor when modal is open */
body.modal-open {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="%23ffb347" d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z" filter="drop-shadow(0 0 3px %23ffb347)"/></svg>'), auto;
}

body.modal-open canvas {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="%23ffb347" d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z" filter="drop-shadow(0 0 3px %23ffb347)"/></svg>'), auto;
}

body.modal-open .modal {
    cursor: default;
}

/* pulse animation removed */






/* Retro scanline effect */
#gameCanvas::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(transparent 50%, rgba(255, 179, 71, 0.03) 50%);
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 1;
}

/* Glitch effect for 128-bit aesthetic */
@keyframes glitch {
    0% { transform: translate(0); }
    20% { transform: translate(-2px, 2px); }
    40% { transform: translate(-2px, -2px); }
    60% { transform: translate(2px, 2px); }
    80% { transform: translate(2px, -2px); }
    100% { transform: translate(0); }
}

.glitch {
    animation: glitch 0.3s infinite;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: linear-gradient(135deg, #1a1208, #2a1f10);
    margin: 5% auto;
    padding: 0;
    border: 2px solid #ffb347;
    border-radius: 10px;
    width: 80%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 0 20px rgba(255, 179, 71, 0.3);
}

.modal-header {
    background: rgba(255, 179, 71, 0.1);
    padding: 20px;
    border-bottom: 1px solid #ffb347;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    color: #ffb347;
    margin: 0;
    text-shadow: 0 0 10px #ffb347;
    font-family: 'Courier New', monospace;
}

.close {
    color: #ffb347;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
}

.close:hover {
    color: #ff0000;
}

.modal-body {
    padding: 20px;
}

.settings-section {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 179, 71, 0.3);
}

.settings-section:last-child {
    border-bottom: none;
}

.settings-section h3 {
    color: #ffb347;
    margin-bottom: 15px;
    text-shadow: 0 0 5px #ffb347;
    font-family: 'Courier New', monospace;
}

.control-buttons, .maze-buttons, .language-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
}

.control-btn, .maze-btn, .language-btn {
    background: rgba(255, 179, 71, 0.1);
    border: 2px solid #ffb347;
    color: #ffb347;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    transition: all 0.3s;
    text-shadow: 0 0 5px #ffb347;
}

.control-btn:hover, .maze-btn:hover, .language-btn:hover {
    background: rgba(255, 179, 71, 0.2);
    box-shadow: 0 0 10px rgba(255, 179, 71, 0.5);
}

.control-btn.active, .maze-btn.active, .language-btn.active {
    background: rgba(255, 179, 71, 0.3);
    box-shadow: 0 0 15px rgba(255, 179, 71, 0.7);
}

.maze-description {
    background: rgba(0, 0, 0, 0.5);
    padding: 10px;
    border-radius: 5px;
    border: 1px solid rgba(255, 179, 71, 0.3);
}

.maze-description p {
    color: #ffb347;
    margin: 0;
    font-size: 12px;
    opacity: 0.8;
}

.info-grid {
    display: grid;
    gap: 10px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 3px;
    border: 1px solid rgba(255, 179, 71, 0.2);
}

.info-label {
    color: #ffb347;
    font-weight: bold;
    opacity: 0.8;
}

.info-item span:last-child {
    color: #ffb347;
    font-family: 'Courier New', monospace;
}

/* Mode buttons */
.mode-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 15px;
}

.mode-btn {
    background: rgba(255, 179, 71, 0.1);
    border: 2px solid #ffb347;
    color: #ffb347;
    padding: 12px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    transition: all 0.3s;
    text-shadow: 0 0 5px #ffb347;
}

.mode-btn:hover {
    background: rgba(255, 179, 71, 0.2);
    box-shadow: 0 0 10px rgba(255, 179, 71, 0.5);
}

.mode-btn.active {
    background: rgba(255, 179, 71, 0.3);
    box-shadow: 0 0 15px rgba(255, 179, 71, 0.7);
}

.character-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
}

.character-btn {
    background: rgba(255, 179, 71, 0.1);
    border: 2px solid #ffb347;
    color: #ffb347;
    padding: 8px;
    border-radius: 5px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    transition: all 0.3s;
    text-shadow: 0 0 5px #ffb347;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.character-preview {
    width: 96px;
    height: 96px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.character-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
}

.character-label {
    font-size: 12px;
}

.character-btn:hover {
    background: rgba(255, 179, 71, 0.2);
    box-shadow: 0 0 10px rgba(255, 179, 71, 0.5);
}

.character-btn.active {
    background: rgba(255, 179, 71, 0.3);
    box-shadow: 0 0 15px rgba(255, 179, 71, 0.7);
}

/* Toolbox modal - matches settings modal design */
#toolbox-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

#toolbox-modal .modal-content {
    background: linear-gradient(135deg, #1a1208, #2a1f10);
    margin: 5% auto;
    padding: 0;
    border: 2px solid #ffb347;
    border-radius: 10px;
    width: 80%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 0 20px rgba(255, 179, 71, 0.3);
}

#toolbox-modal .modal-header {
    background: rgba(255, 179, 71, 0.1);
    padding: 20px;
    border-bottom: 1px solid #ffb347;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#toolbox-modal .modal-header h2 {
    color: #ffb347;
    margin: 0;
    text-shadow: 0 0 10px #ffb347;
    font-family: 'Courier New', monospace;
}

#toolbox-modal .close-toolbox {
    color: #ffb347;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
}

#toolbox-modal .close-toolbox:hover {
    color: #ff0000;
}

#toolbox-modal .modal-body {
    padding: 20px;
}

.toolbox-section {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 179, 71, 0.3);
}

.toolbox-section:last-child {
    border-bottom: none;
}

.toolbox-section h3 {
    color: #ffb347;
    margin-bottom: 15px;
    text-shadow: 0 0 5px #ffb347;
    font-family: 'Courier New', monospace;
}

.tool-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 15px;
}

.tool-btn {
    background: rgba(255, 179, 71, 0.1);
    border: 2px solid #ffb347;
    color: #ffb347;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    transition: all 0.3s;
    text-shadow: 0 0 5px #ffb347;
}

.tool-btn:hover {
    background: rgba(255, 179, 71, 0.2);
    box-shadow: 0 0 10px rgba(255, 179, 71, 0.5);
}

.tool-btn.active {
    background: rgba(255, 179, 71, 0.3);
    box-shadow: 0 0 15px rgba(255, 179, 71, 0.7);
}

.toolbox-info {
    background: rgba(0, 0, 0, 0.5);
    padding: 10px;
    border-radius: 5px;
    border: 1px solid rgba(255, 179, 71, 0.3);
}

.toolbox-info p {
    color: #ffb347;
    margin: 0;
    font-size: 12px;
    opacity: 0.8;
}

/* ===== HUD: damage vignette ===== */
#damage-vignette {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9000;
    opacity: 0;
    transition: opacity 0.18s ease-out;
    background: radial-gradient(ellipse at center,
        rgba(255, 0, 0, 0) 35%,
        rgba(255, 30, 30, 0.45) 80%,
        rgba(160, 0, 0, 0.85) 100%);
    mix-blend-mode: screen;
}

/* ===== HUD: muzzle flash ===== */
#muzzle-flash {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 8500;
    opacity: 0;
    transition: opacity 0.06s ease-out;
    background: radial-gradient(ellipse at center,
        rgba(255, 240, 180, 0.35) 0%,
        rgba(255, 200, 80, 0.12) 30%,
        rgba(0, 0, 0, 0) 60%);
    mix-blend-mode: screen;
}

/* ===== HUD: objective banner ===== */
#objective-banner {
    position: fixed;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    align-items: center;
    gap: 10px;
    padding: 8px 18px;
    background: linear-gradient(135deg, rgba(0,0,0,0.78), rgba(42,24,8,0.82));
    border: 1px solid rgba(255,179,71,0.55);
    border-radius: 999px;
    color: #ffd28a;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 0.5px;
    text-shadow: 0 0 6px rgba(255,179,71,0.7);
    box-shadow: 0 4px 16px rgba(255,179,71,0.18), inset 0 0 12px rgba(255,179,71,0.08);
    z-index: 1500;
    pointer-events: none;
}
#objective-banner .ob-sep { opacity: 0.45; }
#objective-banner .ob-level { color: #ffe8b8; }
#objective-banner .ob-enemies { color: #ff9a7a; }
#objective-banner .ob-flags { color: #b8ff9a; }
#objective-banner .ob-score { color: #ffd28a; }

/* ===== HUD: minimap ===== */
#minimap-wrap {
    position: fixed;
    top: 14px;
    right: 14px;
    width: 168px;
    height: 184px;
    background: linear-gradient(135deg, rgba(0,0,0,0.82), rgba(20,12,4,0.82));
    border: 2px solid #ffb347;
    border-radius: 12px;
    padding: 6px;
    box-shadow: 0 4px 20px rgba(255,179,71,0.25), inset 0 0 18px rgba(255,179,71,0.06);
    z-index: 1500;
    display: none;
    pointer-events: none;
    font-family: 'Courier New', monospace;
}
#minimap-wrap canvas {
    display: block;
    width: 156px;
    height: 156px;
    background: rgba(0,0,0,0.6);
    border-radius: 6px;
    image-rendering: pixelated;
}
#minimap-wrap .mm-label {
    text-align: center;
    color: #ffb347;
    font-size: 10px;
    letter-spacing: 2px;
    margin-top: 4px;
    opacity: 0.7;
}

/* ===== HUD: health bar (bottom-left, segmented) ===== */
#health-bar {
    position: fixed;
    bottom: 18px;
    left: 18px;
    background: linear-gradient(135deg, rgba(0,0,0,0.85), rgba(40,8,8,0.85));
    border: 2px solid #ff7676;
    border-radius: 10px;
    padding: 10px 14px;
    color: #ffb347;
    font-family: 'Courier New', monospace;
    z-index: 1500;
    display: none;
    pointer-events: none;
    box-shadow: 0 4px 16px rgba(255,80,80,0.25);
}
#health-bar .hb-label {
    font-size: 11px;
    letter-spacing: 2px;
    opacity: 0.8;
    margin-bottom: 6px;
}
#health-bar .hb-pips {
    display: flex;
    gap: 3px;
    margin-bottom: 6px;
}
#health-bar .hb-pip {
    width: 18px;
    height: 14px;
    border-radius: 3px;
    background: #6dff7a;
    box-shadow: 0 0 8px rgba(109,255,122,0.65);
    transition: background 0.2s, box-shadow 0.2s, opacity 0.2s;
}
#health-bar .hb-pip.lost {
    background: rgba(255,255,255,0.08);
    box-shadow: none;
}
#health-bar .hb-pip.low { background: #ffd34a; box-shadow: 0 0 8px rgba(255,211,74,0.65); }
#health-bar .hb-pip.crit { background: #ff5a5a; box-shadow: 0 0 10px rgba(255,90,90,0.85); }
#health-bar .hb-text {
    font-size: 12px;
    color: #ffd28a;
    text-align: right;
    letter-spacing: 1px;
}
#health-bar.pulse { animation: hb-pulse 0.35s ease-out; }
@keyframes hb-pulse {
    0%   { transform: scale(1); filter: brightness(1); }
    40%  { transform: scale(1.04); filter: brightness(1.5); }
    100% { transform: scale(1); filter: brightness(1); }
}

/* ===== HUD: quickbar / inventory grid ===== */
#inventory-grid-ui {
    gap: 6px !important;
    padding: 6px 10px;
    background: linear-gradient(180deg, rgba(0,0,0,0.55), rgba(0,0,0,0.85));
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.45);
    backdrop-filter: blur(2px);
}

.qb-slot {
    position: relative;
    width: 54px;
    height: 54px;
    border-radius: 10px;
    border: 2px solid rgba(255,179,71,0.55);
    background: linear-gradient(135deg, rgba(0,0,0,0.85), rgba(42,24,8,0.85));
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.18s ease,
        border-color 0.18s ease, background 0.18s ease, filter 0.18s ease;
    font-family: 'Courier New', monospace;
    user-select: none;
}
.qb-slot:hover {
    transform: translateY(-2px) scale(1.06);
    border-color: #ffd28a;
    background: linear-gradient(135deg, rgba(60,36,10,0.95), rgba(28,16,4,0.95));
}

/* The shortcut digit, top-left. */
.qb-slot .qb-key {
    position: absolute;
    top: 3px;
    left: 3px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 4px;
    background: rgba(0,0,0,0.85);
    color: #ffb347;
    font-size: 10px;
    font-weight: bold;
    line-height: 16px;
    text-align: center;
    letter-spacing: 0.5px;
    box-shadow: inset 0 0 0 1px rgba(255,179,71,0.35);
}

/* The icon (emoji or glyph). */
.qb-slot .qb-icon {
    font-size: 26px;
    line-height: 1;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.6));
    transition: transform 0.18s ease, filter 0.18s ease;
}

/* Stack count, bottom-right. */
.qb-slot .qb-count {
    position: absolute;
    bottom: 2px;
    right: 4px;
    color: #ffd28a;
    font-size: 11px;
    font-weight: bold;
    text-shadow: 0 0 4px #000, 0 1px 0 #000;
    letter-spacing: 0.5px;
}

/* Empty slot: heavily dimmed, dashed border. */
.qb-slot.qb-empty {
    border-style: dashed;
    border-color: rgba(255,179,71,0.18);
    background: linear-gradient(135deg, rgba(0,0,0,0.55), rgba(20,12,4,0.55));
}
.qb-slot.qb-empty .qb-icon { opacity: 0.18; filter: grayscale(100%); }
.qb-slot.qb-empty .qb-key { opacity: 0.55; }

/* Not owned (placeholder weapon icon): grayscale. */
.qb-slot.qb-unavail .qb-icon { opacity: 0.35; filter: grayscale(100%); }
.qb-slot.qb-unavail .qb-key { opacity: 0.6; }

/* === Selected state — unmistakable === */
.qb-slot.qb-selected {
    border: 2px solid #fff2c4;
    background: linear-gradient(135deg, rgba(255,179,71,0.42), rgba(120,60,12,0.65));
    box-shadow:
        0 0 0 2px #ffb347,
        0 0 22px 4px rgba(255,179,71,0.55),
        inset 0 0 14px rgba(255,255,255,0.18);
    transform: translateY(-4px) scale(1.10);
    z-index: 2;
}
.qb-slot.qb-selected .qb-icon {
    transform: scale(1.1);
    filter: drop-shadow(0 0 6px rgba(255,220,140,0.8))
            drop-shadow(0 2px 3px rgba(0,0,0,0.55));
}
/* Inverted shortcut chip on selected — high-contrast pill. */
.qb-slot.qb-selected .qb-key {
    background: #ffe1a0;
    color: #1a1004;
    box-shadow: 0 0 8px rgba(255,225,160,0.85);
}
.qb-slot.qb-selected .qb-count {
    color: #fff;
    text-shadow: 0 0 6px rgba(0,0,0,0.85);
}
/* Bottom indicator caret under selected slot — like a tab marker. */
.qb-slot.qb-selected::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -10px;
    width: 26px;
    height: 3px;
    border-radius: 2px;
    background: #ffd28a;
    box-shadow: 0 0 8px rgba(255,210,138,0.9);
    transform: translateX(-50%);
    animation: qb-glow 1.6s ease-in-out infinite;
}
/* Triangular caret above slot — second redundancy cue. */
.qb-slot.qb-selected::before {
    content: '';
    position: absolute;
    left: 50%;
    top: -9px;
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-top: 8px solid #ffd28a;
    transform: translateX(-50%);
    filter: drop-shadow(0 0 4px rgba(255,210,138,0.9));
}
@keyframes qb-glow {
    0%, 100% { opacity: 0.65; transform: translateX(-50%) scaleX(1);   }
    50%      { opacity: 1.0;  transform: translateX(-50%) scaleX(1.15); }
}

/* Drop-target highlight while dragging an item over a slot. */
.qb-slot.qb-drop-target {
    border-color: #ffd060;
    background: linear-gradient(135deg, rgba(255,160,40,0.35), rgba(80,40,8,0.6));
    box-shadow: 0 0 12px rgba(255,179,71,0.45);
}

/* "More" button at the end of the bar. */
.qb-more {
    width: 54px;
    height: 54px;
    border-radius: 10px;
    border: 2px solid rgba(255,179,71,0.55);
    background: linear-gradient(135deg, rgba(0,0,0,0.85), rgba(42,24,8,0.85));
    color: #ffd28a;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.12s ease, background 0.18s ease, border-color 0.18s ease;
}
.qb-more:hover {
    transform: translateY(-2px) scale(1.06);
    border-color: #ffd28a;
    background: linear-gradient(135deg, rgba(60,36,10,0.95), rgba(28,16,4,0.95));
}

/* ===== Settings: audio row ===== */
.audio-row { color: #ffb347; font-family: 'Courier New', monospace; font-size: 13px; }
.audio-row input[type="range"] { accent-color: #ffb347; }
