@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700&family=Press+Start+2P&display=swap');

:root {
    --engine-bg: #0a0a0c;
    --engine-panel: #141418;
    --engine-border: #2a2a35;
    --engine-accent: #00d4ff;
    --engine-accent-hover: #0088ff;
    --engine-danger: #ff003c;
    --text-main: #e0e0e0;
    --text-dim: #888899;
}

body.engine-mode {
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--engine-bg);
    color: var(--text-main);
    font-family: 'Outfit', sans-serif;
    overflow: hidden; /* No scrolling */
    display: flex;
    flex-direction: column;
}

/* TOP BAR */
.engine-top-bar {
    height: 50px;
    background: var(--engine-panel);
    border-bottom: 1px solid var(--engine-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    z-index: 100;
}

.engine-logo {
    font-family: 'Press Start 2P', monospace;
    font-size: 14px;
    color: var(--engine-accent);
    text-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
    display: flex;
    align-items: center;
    gap: 10px;
}

.engine-nav {
    display: flex;
    gap: 15px;
}

.engine-btn {
    background: transparent;
    border: 1px solid var(--engine-border);
    color: var(--text-main);
    padding: 8px 15px;
    font-family: 'Outfit', sans-serif;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 4px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.engine-btn:hover, .engine-btn:active {
    border-color: var(--engine-accent);
    color: var(--engine-accent);
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.2);
}

.engine-btn.danger:hover, .engine-btn.danger:active {
    border-color: var(--engine-danger);
    color: var(--engine-danger);
    box-shadow: 0 0 10px rgba(255, 0, 60, 0.2);
}

/* MAIN VIEWPORT */
.engine-viewport {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at center, #111116 0%, var(--engine-bg) 100%);
    position: relative;
    padding: 20px;
}

/* PORTFOLIO OVERLAY */
.portfolio-overlay {
    position: absolute;
    top: 50px; /* Below top bar */
    left: 0;
    width: 100%;
    height: calc(100vh - 50px);
    background: rgba(10, 10, 12, 0.95);
    backdrop-filter: blur(10px);
    z-index: 200;
    display: flex;
    justify-content: center;
    align-items: center;
    transform: translateY(-100%);
    opacity: 0;
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.5s ease;
}

.portfolio-overlay.active {
    transform: translateY(0);
    opacity: 1;
}

.overlay-close {
    position: absolute;
    top: 30px;
    right: 30px;
}

#btn-close-portfolio {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 30px;
    cursor: pointer;
    transition: color 0.2s;
}

#btn-close-portfolio:hover,
#btn-close-portfolio:active {
    color: var(--engine-danger);
    text-shadow: 0 0 15px var(--engine-danger);
}

.overlay-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: auto auto;
    gap: 30px;
    max-width: 1200px;
    width: 90%;
}

.overlay-card {
    background: rgba(20, 20, 24, 0.6);
    border: 1px solid var(--engine-border);
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    position: relative;
    overflow: hidden;
}

.overlay-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 2px;
    background: linear-gradient(90deg, transparent, var(--engine-accent), transparent);
    opacity: 0.5;
}

.overlay-card h2 {
    font-family: 'Press Start 2P', monospace;
    font-size: 14px;
    color: var(--engine-accent);
    margin-top: 0;
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Character Card */
.character-card {
    grid-column: 1 / -1;
}

.char-details {
    display: flex;
    gap: 30px;
    align-items: center;
}

.char-details img {
    width: 150px;
    height: 150px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid var(--engine-border);
}

.char-stats h3 {
    font-size: 32px;
    margin: 0 0 5px 0;
}

.char-stats .title {
    color: var(--engine-accent);
    font-weight: bold;
    letter-spacing: 2px;
    margin-bottom: 15px;
    text-transform: uppercase;
}

.char-stats .desc {
    color: var(--text-dim);
    line-height: 1.6;
}

/* Skill Tree Card */
.skill-tree-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.st-item {
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.05);
    padding: 12px 15px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    transition: all 0.2s;
}

.st-item:hover, .st-item:active {
    border-color: var(--engine-accent);
    background: rgba(0, 212, 255, 0.05);
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.1);
    transform: translateX(5px);
}

.st-item i {
    color: var(--engine-accent);
    font-size: 18px;
}

/* Achievements */
.ach-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.ach-item {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    padding: 15px;
    background: rgba(255,255,255,0.02);
    border-left: 3px solid transparent;
    transition: all 0.2s;
}

.ach-item:hover, .ach-item:active {
    border-left-color: var(--engine-accent);
    background: rgba(255,255,255,0.05);
}

/* Music toggle button (styled inline in HTML, no hover/active state existed) */
#btn-music-toggle:hover, #btn-music-toggle:active {
    background: rgba(0, 212, 255, 0.2) !important;
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.4);
}

.ach-item i {
    font-size: 24px;
    margin-top: 5px;
}

.glow-blue { color: #00d4ff; text-shadow: 0 0 10px #00d4ff; }
.glow-orange { color: #ff6b00; text-shadow: 0 0 10px #ff6b00; }

.ach-item h4 {
    margin: 0 0 5px 0;
    font-size: 18px;
}

.ach-item p {
    margin: 0;
    color: var(--text-dim);
    font-size: 14px;
    line-height: 1.5;
}

/* Game Overlays (Copied from game-dev.css to ensure functionality remains) */
.game-ui-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(5,5,5,0.8);
    display: flex; justify-content: center; align-items: center;
    z-index: 10;
}
.game-ui-content {
    background: rgba(20,20,20,0.9);
    border: 1px solid #333;
    padding: 30px; text-align: center; border-radius: 8px;
    box-shadow: 0 0 30px rgba(0,0,0,0.8);
}
#gameTitle {
    font-family: 'Press Start 2P', monospace;
    font-size: 20px; color: var(--engine-accent);
    margin-bottom: 20px; text-shadow: 0 0 10px var(--engine-accent);
}
.btn {
    padding: 10px 20px; border: 1px solid; background: transparent;
    cursor: pointer; font-family: 'Outfit', sans-serif;
    font-weight: 600; text-transform: uppercase;
    transition: all 0.2s; border-radius: 4px;
}
.btn:hover, .btn:active {
    background: rgba(255,255,255,0.1);
}

/* Retro buttons (leaderboard close, revive yes/no) — colored per-instance via inline style */
.retro-btn {
    padding: 10px 24px;
    background: rgba(0,0,0,0.6);
    border: 1px solid;
    border-radius: 4px;
    font-family: 'Press Start 2P', monospace;
    font-size: 11px;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}
.retro-btn:hover, .retro-btn:active {
    background: rgba(255,255,255,0.12);
    box-shadow: 0 0 15px currentColor;
}
.game-hud {
    position: absolute; top: 0; left: 0; width: 100%;
    padding: 15px; box-sizing: border-box;
    font-family: 'Press Start 2P', monospace; font-size: 10px;
    color: var(--engine-accent); text-shadow: 0 0 5px var(--engine-accent);
    z-index: 5; pointer-events: none;
}
.upgrade-btn {
    display: flex; align-items: center; gap: 15px;
    padding: 15px; background: rgba(0,255,65,0.05);
    border: 1px solid rgba(0,255,65,0.2);
    border-radius: 8px; cursor: pointer;
    transition: all 0.2s ease; text-align: left;
}
.upgrade-btn:hover, .upgrade-btn:active {
    background: rgba(0,255,65,0.15);
    border-color: #00ff41;
    box-shadow: 0 0 15px rgba(0,255,65,0.3);
    transform: scale(1.02);
}
.upgrade-icon i {
    font-size: 24px; color: #00ff41;
}
.upgrade-details h4 { margin: 0 0 5px 0; color: #fff; font-size: 16px; }
.upgrade-details p { margin: 0; color: #aaa; font-size: 12px; }

/* ============ v3.0 AEGIS PROTOCOL — GAME UI ============ */

/* Player HUD */
.game-hud {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.hud-left, .hud-right { width: 240px; }
.hud-right { text-align: right; }
.hud-center { flex: 1; text-align: center; }

.hud-label {
    font-size: 9px;
    letter-spacing: 1px;
    color: var(--engine-accent);
    text-shadow: 0 0 5px rgba(0, 212, 255, 0.6);
}

.hp-segments {
    display: flex;
    gap: 3px;
    margin-top: 5px;
    flex-wrap: wrap;
    max-width: 240px;
}

.hp-seg {
    width: 14px;
    height: 8px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(0, 212, 255, 0.25);
    transform: skewX(-12deg);
}

.hp-seg.on {
    background: var(--engine-accent);
    box-shadow: 0 0 6px rgba(0, 212, 255, 0.8);
}

.hp-seg.on.low {
    background: var(--engine-danger);
    box-shadow: 0 0 8px rgba(255, 0, 60, 0.9);
    animation: hpBlink 0.6s infinite;
}

@keyframes hpBlink { 50% { opacity: 0.4; } }

.dash-track {
    width: 120px;
    height: 5px;
    margin-top: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

#dashBar {
    height: 100%;
    width: 100%;
    background: #00ff41;
    box-shadow: 0 0 8px #00ff41;
    transition: width 0.05s linear;
}

.xp-track {
    width: 240px;
    height: 6px;
    margin-top: 5px;
    margin-left: auto;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

#playerXPBar {
    height: 100%;
    width: 0%;
    background: #00ff41;
    box-shadow: 0 0 10px #00ff41;
    transition: width 0.2s;
}

.perk-icons {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.perk-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    font-size: 10px;
    color: #00ff41;
    background: rgba(0, 255, 65, 0.08);
    border: 1px solid rgba(0, 255, 65, 0.35);
    border-radius: 3px;
}

.perk-chip b {
    position: absolute;
    bottom: -5px;
    right: -5px;
    font-size: 8px;
    color: #fff;
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(0, 255, 65, 0.5);
    border-radius: 2px;
    padding: 0 2px;
}

.combo-counter {
    display: none;
    font-family: 'Press Start 2P', monospace;
    font-size: 13px;
    color: #ffaa00;
    text-shadow: 0 0 12px rgba(255, 170, 0, 0.9);
    animation: comboPulse 0.4s infinite alternate;
    margin-top: 4px;
}

@keyframes comboPulse { from { transform: scale(1); } to { transform: scale(1.08); } }

/* Boss Bar */
.boss-bar {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    width: 62%;
    z-index: 6;
    pointer-events: none;
    font-family: 'Press Start 2P', monospace;
}

.boss-bar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 5px;
}

.boss-name {
    font-size: 10px;
    color: #ff003c;
    text-shadow: 0 0 8px rgba(255, 0, 60, 0.8);
}

.boss-shield-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 7px;
    color: var(--engine-accent);
    border: 1px solid rgba(0, 212, 255, 0.5);
    padding: 3px 6px;
    border-radius: 3px;
    background: rgba(0, 212, 255, 0.08);
    text-shadow: 0 0 6px rgba(0, 212, 255, 0.8);
}

.boss-phases { display: flex; gap: 4px; }

.phase-pip {
    font-size: 7px;
    color: #555;
    border: 1px solid #333;
    padding: 3px 5px;
    border-radius: 2px;
    background: rgba(0, 0, 0, 0.5);
}

.phase-pip.active {
    color: #ff003c;
    border-color: #ff003c;
    text-shadow: 0 0 6px rgba(255, 0, 60, 0.9);
}

.boss-hp-track {
    position: relative;
    height: 10px;
    background: rgba(0, 0, 0, 0.65);
    border: 1px solid rgba(255, 0, 60, 0.5);
    border-radius: 2px;
    overflow: hidden;
}

.boss-hp-ghost {
    position: absolute;
    top: 0; left: 0; height: 100%;
    width: 100%;
    background: rgba(255, 255, 255, 0.55);
}

.boss-hp-fill {
    position: absolute;
    top: 0; left: 0; height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #ff003c, #ff6b00);
    box-shadow: 0 0 12px rgba(255, 0, 60, 0.7);
}

.boss-bar.phase-2 .boss-hp-fill { background: linear-gradient(90deg, #ff6b00, #ffaa00); }
.boss-bar.phase-3 .boss-hp-fill { background: linear-gradient(90deg, #c400ff, #ff003c); animation: hpBlink 0.5s infinite; }

/* Start screen extras */
.controls-hint {
    margin-top: 14px;
    font-size: 9px;
    letter-spacing: 1px;
    color: #667;
    font-family: 'Press Start 2P', monospace;
    line-height: 1.8;
}

.stack-tag {
    font-size: 10px;
    color: #ffaa00;
    border: 1px solid rgba(255, 170, 0, 0.5);
    padding: 1px 4px;
    border-radius: 2px;
    vertical-align: middle;
}

/* Loaders */
.page-transition-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background-color: var(--engine-bg); z-index: 9999;
    display: flex; justify-content: center; align-items: center;
    transition: opacity 0.5s ease; opacity: 1; pointer-events: none;
}
.transition-loader {
    width: 50px; height: 50px;
    border: 3px solid rgba(0, 212, 255, 0.1);
    border-top-color: var(--engine-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* MOBILE RESPONSIVENESS */
@media (max-width: 900px) {
    .engine-viewport {
        flex-direction: column;
        padding: 5px;
    }
    .game-container {
        width: 100% !important;
        max-width: 100vw !important;
        height: auto !important;
        aspect-ratio: 4 / 3 !important;
        max-height: calc(100vh - 70px) !important;
        border-radius: 8px;
    }
    .ai-terminal {
        width: 100% !important;
        height: 200px !important;
        margin-top: 10px;
    }
    .engine-top-bar {
        padding: 0 10px;
    }
    .engine-nav {
        gap: 5px;
    }
    .engine-btn {
        padding: 6px 10px;
        font-size: 10px;
    }
    #gameTitle {
        font-size: 16px;
    }
    .controls-hint {
        font-size: 8px;
        line-height: 1.4;
    }
    #dashBtn {
        bottom: 80px !important;
        right: 15px !important;
        width: 50px !important;
        height: 50px !important;
    }

    /* In-game HUD: the desktop layout uses fixed 240px columns which
       don't fit small/landscape phone widths — let them scale instead. */
    .game-hud {
        padding: 8px 10px;
    }
    .hud-left, .hud-right {
        width: auto;
        max-width: 38vw;
    }
    .hud-label {
        font-size: 7px;
    }
    .hp-segments {
        max-width: 100%;
    }
    .hp-seg {
        width: 10px;
        height: 7px;
    }
    .dash-track {
        width: 90px;
    }
    .xp-track {
        width: 100%;
        max-width: 38vw;
    }
    .perk-chip {
        width: 18px;
        height: 18px;
        font-size: 8px;
    }
    .combo-counter {
        font-size: 10px;
    }
    .boss-bar {
        width: 94%;
    }
    .boss-name, .boss-shield-tag {
        font-size: 6px;
    }
    #btn-music-toggle {
        top: 8px !important;
        right: 8px !important;
        padding: 6px 9px !important;
    }
}

/* Short landscape phones (game forces landscape on mobile) */
@media (max-width: 900px) and (max-height: 430px) {
    .game-hud {
        padding: 6px 8px;
    }
    .hud-label {
        font-size: 6px;
    }
    .dash-track, .xp-track {
        max-width: 30vw;
    }
    #dashBtn {
        bottom: 15px !important;
        right: 15px !important;
        width: 44px !important;
        height: 44px !important;
    }
    .controls-hint {
        display: none; /* redundant once actually playing on a cramped screen */
    }
}
