/* HUD - Dark military theme */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #0a0a0a;
    color: #00ff44;
    font-family: 'Courier New', monospace;
    user-select: none;
}

/* ---- Layout: Steam Deck as frame ---- */

#app {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    width: 100vw;
}

#deck-wrapper {
    position: relative;
    display: inline-block;
    max-width: 100vw;
    max-height: 90vh;
}

#deck-frame {
    display: block;
    width: 100%;
    height: auto;
    max-height: 88vh;
    object-fit: contain;
}

/* ---- Game screen positioned over the Deck's display ---- */

#game-screen {
    position: absolute;
    left: 20.1%;
    top: 5.5%;
    width: 59.8%;
    height: 89%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #000;
    border-radius: 6px;
}

/* ---- Top Menu Bar ---- */

#menu-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 28px;
    background: rgba(0, 0, 0, 0.7);
    border-bottom: 1px solid #222;
    padding: 0 8px;
    flex-shrink: 0;
    z-index: 10;
}

#menu-bar .menu-left {
    display: flex;
    gap: 2px;
}

#menu-bar .menu-btn {
    background: transparent;
    color: #00ff44;
    border: 1px solid #333;
    padding: 2px 10px;
    font-family: inherit;
    font-size: 11px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#menu-bar .menu-btn:hover,
#menu-bar .menu-btn.active {
    background: #1a3a1a;
    border-color: #00ff44;
}

/* ---- Dropdown Menus ---- */

#menu-dropdown {
    position: absolute;
    z-index: 100;
    display: flex;
    gap: 1px;
}

#menu-dropdown.hidden {
    display: none;
}

.menu-list,
.menu-submenu,
.menu-fields {
    background: rgba(10, 15, 10, 0.95);
    border: 1px solid #1a3a1a;
    border-top: none;
    min-width: 140px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
}

.menu-item {
    padding: 5px 12px;
    font-size: 10px;
    cursor: pointer;
    color: #00ff44;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(0, 255, 68, 0.06);
}

.menu-item:hover {
    background: rgba(0, 255, 68, 0.1);
}

.menu-item.selected::before {
    content: '\2713';
    margin-right: 6px;
    color: #00ff44;
    font-weight: bold;
}

.menu-item.has-submenu::after {
    content: '\25B6';
    float: right;
    font-size: 8px;
    opacity: 0.5;
}

.menu-fields-title {
    padding: 5px 12px;
    font-size: 9px;
    font-weight: bold;
    color: #00ff44;
    border-bottom: 1px solid rgba(0, 255, 68, 0.15);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.menu-field-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 12px;
    font-size: 9px;
    border-bottom: 1px solid rgba(0, 255, 68, 0.04);
}

.field-label {
    color: rgba(0, 255, 68, 0.6);
}

.field-value {
    color: #00ff44;
    font-weight: bold;
}

#status-indicator {
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 2px;
    padding: 2px 12px;
    border: 1px solid;
}

#status-indicator.safe {
    color: #00ff44;
    border-color: #00ff44;
}

#status-indicator.armed {
    color: #ff3333;
    border-color: #ff3333;
    animation: pulse-armed 1s ease-in-out infinite;
}

@keyframes pulse-armed {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ---- Canvas (camera + HUD) ---- */

#canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #000;
}

#hud-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Muzzle flash overlay */
#muzzle-flash {
    position: absolute;
    inset: 0;
    background: rgba(255, 200, 50, 0.15);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.05s;
}

#muzzle-flash.flash {
    opacity: 1;
}

/* ---- Steam Deck button overlays ---- */

.deck-btn {
    position: absolute;
    border: 1px solid rgba(0, 255, 68, 0.5);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    color: rgba(0, 255, 68, 0.85);
    font-family: inherit;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(0, 255, 68, 0.03);
}

.deck-btn:hover {
    border-color: rgba(0, 255, 68, 0.6);
    background: rgba(0, 255, 68, 0.1);
    color: rgba(0, 255, 68, 0.9);
}

.deck-btn.active {
    border-color: #00ff44;
    background: rgba(0, 255, 68, 0.25);
    box-shadow: 0 0 8px rgba(0, 255, 68, 0.4);
    color: #00ff44;
}

.deck-btn-fire {
    border-color: rgba(255, 51, 51, 0.6) !important;
    color: rgba(255, 51, 51, 0.85) !important;
    background: rgba(255, 51, 51, 0.08) !important;
}

.deck-btn-fire:hover {
    border-color: rgba(255, 51, 51, 0.7) !important;
    background: rgba(255, 51, 51, 0.15) !important;
    color: #ff3333 !important;
}

.deck-btn-fire.active {
    border-color: #ff3333 !important;
    background: rgba(255, 51, 51, 0.3) !important;
    box-shadow: 0 0 10px rgba(255, 51, 51, 0.5) !important;
}

.deck-btn-lrf {
    border-color: rgba(0, 255, 255, 0.6) !important;
    color: rgba(0, 255, 255, 0.85) !important;
    background: rgba(0, 255, 255, 0.08) !important;
}

.deck-btn-lrf:hover {
    border-color: rgba(0, 255, 255, 0.7) !important;
    background: rgba(0, 255, 255, 0.15) !important;
    color: #00ffff !important;
}

/* ---- Virtual Joystick ---- */

#joystick-left,
#joystick-right {
    position: absolute;
    aspect-ratio: 1;
    border-radius: 50%;
    border: 1px solid rgba(0, 255, 68, 0.3);
    background: rgba(0, 255, 68, 0.03);
    cursor: grab;
    touch-action: none;
}

#joystick-left.dragging,
#joystick-right.dragging {
    border-color: rgba(0, 255, 68, 0.6);
    background: rgba(0, 255, 68, 0.06);
    cursor: grabbing;
}

#joystick-left-knob,
#joystick-right-knob {
    position: absolute;
    width: 30%;
    height: 30%;
    border-radius: 50%;
    background: rgba(0, 255, 68, 0.4);
    border: 1px solid rgba(0, 255, 68, 0.6);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: background 0.1s;
    pointer-events: none;
}

#joystick-left.dragging #joystick-left-knob,
#joystick-right.dragging #joystick-right-knob {
    background: rgba(0, 255, 68, 0.7);
    border-color: #00ff44;
    box-shadow: 0 0 6px rgba(0, 255, 68, 0.5);
}

/* ---- Function legend ---- */

#deck-legend {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    padding: 6px 16px;
    font-size: 10px;
    color: rgba(0, 255, 68, 0.4);
    letter-spacing: 0.5px;
}

#deck-legend .legend-fire {
    color: rgba(255, 51, 51, 0.5);
}

#deck-legend .legend-lrf {
    color: rgba(0, 255, 255, 0.5);
}

/* ---- Zeroing overlay ---- */

#zero-overlay,
#cam-cal-overlay,
#zone-def-overlay,
#poi-def-overlay {
    position: absolute;
    bottom: 8%;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    z-index: 20;
}

#zero-overlay.hidden,
#cam-cal-overlay.hidden,
#zone-def-overlay.hidden,
#poi-def-overlay.hidden {
    display: none;
}

#zero-overlay .zero-info,
#cam-cal-overlay .zero-info,
#zone-def-overlay .zero-info,
#poi-def-overlay .zero-info {
    font: bold 12px monospace;
    color: #ffcc00;
    text-shadow: 0 0 4px rgba(0,0,0,0.8);
    letter-spacing: 0.5px;
}

.cam-cal-hint {
    font-size: 10px !important;
    color: #aaaaaa !important;
    margin-top: -2px;
}

#zero-overlay .zero-buttons,
#cam-cal-overlay .zero-buttons,
#zone-def-overlay .zero-buttons,
#poi-def-overlay .zero-buttons {
    display: flex;
    gap: 10px;
}

#zero-overlay button,
#cam-cal-overlay button,
#zone-def-overlay button,
#poi-def-overlay button {
    font: bold 11px monospace;
    padding: 4px 14px;
    border: 1px solid;
    cursor: pointer;
    border-radius: 3px;
}

#zero-save,
#cam-cal-save,
#zone-def-save,
#zone-def-next,
#poi-def-next,
#poi-def-finish {
    background: rgba(0, 180, 0, 0.3);
    color: #00ff44;
    border-color: #00ff44;
}

#zero-cancel,
#cam-cal-cancel,
#zone-def-cancel,
#poi-def-cancel {
    background: rgba(180, 0, 0, 0.3);
    color: #ff4444;
    border-color: #ff4444;
}

.zone-roe-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
    padding: 4px 0;
}

.zone-roe-option {
    font: 11px monospace;
    color: #cccccc;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.zone-roe-option input {
    accent-color: #ffcc00;
}

/* ---- Patrol slew speed ---- */

.patrol-speed-controls {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    z-index: 25;
    pointer-events: auto;
    padding: 6px 4px;
    border: 1px solid rgba(0, 221, 255, 0.35);
    border-radius: 4px;
    background: rgba(0, 20, 28, 0.75);
}

.patrol-speed-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 2px 0;
}

.patrol-speed-title {
    font: bold 9px monospace;
    color: #00ddff;
    letter-spacing: 0.5px;
    text-shadow: 0 0 4px rgba(0, 0, 0, 0.9);
}

#patrol-speed-value {
    font: bold 11px monospace;
    color: #00ddff;
    text-shadow: 0 0 4px rgba(0, 0, 0, 0.9);
}

.patrol-speed-tri {
    width: 0;
    height: 0;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.9));
}

.patrol-speed-up {
    border-left: 11px solid transparent;
    border-right: 11px solid transparent;
    border-bottom: 14px solid #00ddff;
}

.patrol-speed-down {
    border-left: 11px solid transparent;
    border-right: 11px solid transparent;
    border-top: 14px solid #00ddff;
}

.patrol-speed-tri:hover {
    opacity: 0.85;
}

.patrol-speed-tri:active {
    opacity: 0.65;
}
