html, body, #root {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    color: rgba(255, 255, 255, 0.87);
    background-color: #000000; 
    font-family: Arial, Helvetica, sans-serif;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

#app {
    position: relative;
    width: 100%;
    height: 100%;
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: none;
}

#game-container {
    width: 100%;
    height: 100%;
    touch-action: none;
}

#game-container canvas {
    touch-action: none;
}


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

#hud button,
#hud a,
#hud input,
#hud [role="button"],
#hud .interactive {
    pointer-events: auto;
}

.spritePosition {
    margin: 10px 0 0 10px;
    font-size: 0.8em;
}

.button {
    width: 140px;
    margin: 10px;
    padding: 10px;
    background-color: #000000;
    color: rgba(255, 255, 255, 0.87);
    border: 1px solid rgba(255, 255, 255, 0.87);
    cursor: pointer;
    transition: all 0.3s;

    &:hover {
        border: 1px solid #0ec3c9;
        color: #0ec3c9;
    }

    &:active {
        background-color: #0ec3c9;
    }

    /* Disabled styles */
    &:disabled {
        cursor: not-allowed;
        border: 1px solid rgba(255, 255, 255, 0.3);
        color: rgba(255, 255, 255, 0.3);
    }
}

.overlay-screen {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(10, 12, 18, 0.72);
    z-index: 50;
}

.menu-card, .mission-card {
    background: #1b1f29;
    border: 2px solid #3a4152;
    border-radius: 14px;
    padding: 28px 32px;
    max-width: 420px;
    text-align: center;
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}

.menu-card h1 {
    margin: 0 0 4px;
    font-size: 1.9em;
    color: #f4c430;
}

.menu-card h2 {
    margin: 0 0 14px;
    font-size: 1.1em;
    color: #e2e8f0;
    font-weight: 500;
}

.title-bad { color: #ef4444 !important; }
.title-good { color: #22c55e !important; }

.narrative-card {
    max-width: 580px;
    background: linear-gradient(160deg, #1b1f29 0%, #121620 100%);
    border: 2px solid #f4c430;
    box-shadow: 0 0 40px rgba(244, 196, 48, 0.25), 0 12px 40px rgba(0,0,0,0.6);
    backdrop-filter: blur(6px);
    max-height: 92vh;
    overflow-y: auto;
}

.game-title {
    margin: 0;
    font-size: 2em;
    letter-spacing: 0.5px;
    color: #f4c430;
    text-shadow: 0 0 18px rgba(244, 196, 48, 0.5);
}

.game-subtitle {
    margin: 2px 0 2px;
    font-size: 1.3em;
    color: #22c55e;
    font-weight: 700;
}

.game-subtitle-sm {
    margin: 0 0 10px;
    font-size: 0.95em;
    color: #f4c430;
    font-weight: 600;
}

.game-tagline {
    margin: 0 0 16px;
    font-size: 0.88em;
    font-style: italic;
    color: #cbd5e1;
}

.narrative-box {
    margin: 0 0 20px;
    padding: 14px 16px;
    background: rgba(34, 197, 94, 0.08);
    border-left: 3px solid #22c55e;
    border-radius: 8px;
    text-align: left;
    font-size: 0.86em;
    line-height: 1.55;
    color: #e2e8f0;
}

.instructions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
    text-align: left;
}

@media (max-width: 480px) {
    .instructions-grid { grid-template-columns: 1fr; }
}

.instruction-badge {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: rgba(20, 23, 31, 0.85);
    border: 1px solid #3a4152;
    border-radius: 8px;
    padding: 10px;
}

.badge-icon {
    font-size: 1.3em;
    line-height: 1;
}

.badge-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.badge-text b {
    font-size: 0.82em;
    color: #f4c430;
}

.badge-text span {
    font-size: 0.74em;
    color: #94a3b8;
    line-height: 1.35;
}

.btn-start-mission {
    width: 100%;
    padding: 14px 28px;
    font-size: 1.1em;
    letter-spacing: 0.5px;
    box-shadow: 0 0 20px rgba(244, 196, 48, 0.4);
}

.menu-hint {
    margin: 10px 0 0;
    font-size: 0.74em;
    color: #64748b;
}

.menu-desc {
    font-size: 0.92em;
    line-height: 1.5;
    color: #cbd5e1;
    margin-bottom: 14px;
}

.menu-controls {
    list-style: none;
    padding: 0;
    margin: 0 0 18px;
    text-align: left;
    font-size: 0.85em;
    color: #94a3b8;
}

.menu-controls li { margin: 4px 0; }

.final-stats {
    font-size: 0.9em;
    color: #f4c430;
    margin-bottom: 14px;
}

.btn-primary {
    background: #f4c430;
    color: #1b1f29;
    border: none;
    border-radius: 8px;
    padding: 12px 28px;
    font-size: 1em;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s, background 0.15s;
}

.btn-primary:hover { background: #ffd84a; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(1px); }

.top-bar {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.stat-block {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(20, 23, 31, 0.8);
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid #3a4152;
}

.stat-label {
    font-size: 0.72em;
    color: #94a3b8;
    min-width: 42px;
}

.bar-track {
    width: 90px;
    height: 8px;
    background: #2c3038;
    border-radius: 4px;
    overflow: hidden;
}

.bar-fill { height: 100%; border-radius: 4px; transition: width 0.2s; }
.ubuntu-fill { background: #22d3ee; }
.alert-fill { background: #22c55e; }
.alert-flash { animation: alertPulse 0.6s infinite; }

@keyframes alertPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.stat-value {
    font-size: 0.78em;
    color: #e2e8f0;
    min-width: 30px;
}

.resource-chip {
    background: rgba(20, 23, 31, 0.8);
    border: 1px solid #3a4152;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 0.82em;
    color: #f4c430;
}

.mobile-action-buttons {
    position: absolute;
    bottom: 24px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    pointer-events: none;
    z-index: 45;
}

/* Hide touch controls on fine desktop pointers with hover */
@media (hover: hover) and (pointer: fine) {
    .mobile-action-buttons,
    .mobile-dpad-cluster {
        display: none !important;
    }
}

/* Ergonomic On-Screen D-Pad */
.mobile-dpad-cluster {
    position: absolute;
    bottom: 24px;
    left: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    pointer-events: none;
    z-index: 45;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.dpad-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.dpad-center-hub {
    width: 22px;
    height: 22px;
    background: rgba(30, 41, 59, 0.4);
    border-radius: 4px;
}

.dpad-btn {
    pointer-events: auto;
    width: 54px;
    height: 54px;
    min-width: 50px;
    min-height: 50px;
    border-radius: 12px;
    border: 2px solid #38bdf8;
    background: rgba(15, 23, 42, 0.85);
    color: #38bdf8;
    font-size: 1.35rem;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), inset 0 0 8px rgba(56, 189, 248, 0.15);
    transition: transform 0.08s ease, background 0.08s ease, border-color 0.08s ease;
}

.dpad-btn:active,
.dpad-btn.dpad-active {
    transform: scale(0.92);
    background: rgba(56, 189, 248, 0.35);
    border-color: #7dd3fc;
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6), inset 0 0 14px rgba(56, 189, 248, 0.5);
}

.btn-action {
    pointer-events: auto;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid #f4c430;
    background: rgba(20, 23, 31, 0.88);
    color: #f4c430;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5), inset 0 0 8px rgba(244, 196, 48, 0.2);
    transition: transform 0.08s ease, background 0.08s ease;
}

.btn-action-badge {
    font-size: 1.25rem;
    font-weight: 900;
    line-height: 1;
}

.btn-action-sub {
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.btn-action:active {
    transform: scale(0.9);
    background: rgba(244, 196, 48, 0.35);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6), inset 0 0 12px rgba(244, 196, 48, 0.5);
}

.btn-action-f {
    border-color: #ef4444;
    color: #ef4444;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5), inset 0 0 8px rgba(239, 68, 68, 0.2);
}

.btn-action-f:active {
    background: rgba(239, 68, 68, 0.35);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6), inset 0 0 12px rgba(239, 68, 68, 0.5);
}

.btn-pause {
    margin-left: auto;
    background: rgba(20, 23, 31, 0.8);
    border: 1px solid #3a4152;
    color: #e2e8f0;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 1em;
    cursor: pointer;
}

.objective-tracker {
    position: absolute;
    top: 60px;
    left: 10px;
    background: rgba(20, 23, 31, 0.85);
    border: 1px solid #22d3ee;
    border-radius: 8px;
    padding: 8px 12px;
    max-width: 260px;
}

.objective-title { font-size: 0.85em; font-weight: 700; color: #22d3ee; }
.objective-desc { font-size: 0.78em; color: #cbd5e1; margin-top: 2px; }
.objective-distance { font-size: 0.72em; color: #94a3b8; margin-top: 2px; }

.vendor-modal {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 23, 31, 0.95);
    border: 2px solid #8b5cf6;
    border-radius: 10px;
    padding: 12px 16px;
    min-width: 260px;
    text-align: center;
}

.vendor-title { font-size: 0.9em; font-weight: 700; color: #8b5cf6; margin-bottom: 8px; }

.vendor-item-btn {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    background: #2c3038;
    border: 1px solid #3a4152;
    color: #e2e8f0;
    border-radius: 6px;
    padding: 8px 10px;
    margin-bottom: 6px;
    cursor: pointer;
    font-size: 0.82em;
}

.vendor-item-btn:hover { border-color: #8b5cf6; }
.vendor-price { color: #f4c430; }
.vendor-hint { font-size: 0.7em; color: #94a3b8; margin-top: 4px; }

.mission-card h2 { color: #22d3ee; margin-top: 0; }
.mission-card p { color: #cbd5e1; font-size: 0.9em; line-height: 1.5; }
.mission-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 14px;
}