:root {
    --phosphor-green: #33FF66;
    --phosphor-green-dim: #1A8C3D;
    --steel-blue: #4A7BA8;
    --steel-blue-light: #6B9CC8;
    --steel-blue-dark: #2B4E6B;
    --faded-red: #CC6666;
    --faded-red-bright: #FF8888;
    --gray-blue: #3A4A5A;
    --gray-blue-light: #5A6A7A;
    --dark-bg: #0a0a0a;
    --darker-bg: #050508;
    --white: #FFFFFF;
    --text-primary: #33FF66;
    --text-secondary: #4A7BA8;
    --text-dim: #2A5A6A;
    --map-brightness: 1;
}

body.map-bright {
    --map-brightness: 1.4;
    --dark-bg: #1a1a1a;
    --darker-bg: #0f0f0f;
    --text-secondary: #6B9CC8;
    --gray-blue: #5A6A7A;
    --gray-blue-light: #7A8A9A;
}

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

html, body {
    height: 100%;
    overflow: hidden;
    font-family: 'VT323', monospace;
    background-color: var(--dark-bg);
    color: var(--text-primary);
}

.crt-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15),
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: 10000;
    opacity: 0.6;
}

.crt-overlay::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, transparent 50%, rgba(0, 0, 0, 0.4) 100%);
    pointer-events: none;
}

.norad-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: linear-gradient(180deg, var(--gray-blue) 0%, var(--gray-blue-dark) 100%);
    border-bottom: 2px solid var(--steel-blue);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-left h1 {
    font-size: 24px;
    font-weight: 400;
    color: var(--phosphor-green);
    text-shadow: 0 0 8px var(--phosphor-green), 0 0 16px var(--phosphor-green-dim);
    letter-spacing: 2px;
}

.blink {
    color: var(--phosphor-green);
    animation: blink 1s step-end infinite;
}

@keyframes blink {
    50% { opacity: 0; }
}

.header-right {
    display: flex;
    align-items: center;
    gap: 24px;
    font-size: 18px;
}

#system-status {
    color: var(--phosphor-green);
    text-shadow: 0 0 4px var(--phosphor-green);
}

#timestamp-display {
    color: var(--steel-blue-light);
    min-width: 120px;
}

.main-container {
    display: flex;
    height: calc(100vh - 120px);
}

.control-panel {
    width: 280px;
    background: var(--darker-bg);
    border-right: 2px solid var(--gray-blue);
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.panel-section {
    border: 1px solid var(--gray-blue);
    padding: 12px;
    background: rgba(10, 15, 20, 0.8);
}

.panel-section h3 {
    font-size: 16px;
    font-weight: 400;
    color: var(--steel-blue-light);
    margin-bottom: 12px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--gray-blue);
    letter-spacing: 1px;
}

.input-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.input-row .file-upload {
    flex: 1;
}

.file-upload {
    display: block;
    width: 100%;
}

.file-upload input[type="file"] {
    display: none;
}

.file-upload span {
    display: block;
    padding: 10px;
    text-align: center;
    background: var(--gray-blue-dark);
    color: var(--phosphor-green);
    border: 1px solid var(--phosphor-green);
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
}

.file-upload span:hover {
    background: var(--phosphor-green);
    color: var(--dark-bg);
    box-shadow: 0 0 12px var(--phosphor-green);
}

.btn-secondary {
    display: block;
    width: 100%;
    padding: 10px;
    text-align: center;
    background: var(--gray-blue-dark);
    color: var(--steel-blue-light);
    border: 1px solid var(--steel-blue-light);
    cursor: pointer;
    font-size: 16px;
    font-family: 'VT323', monospace;
    transition: all 0.2s;
    margin-top: 10px;
}

.btn-secondary:hover {
    background: var(--steel-blue-light);
    color: var(--dark-bg);
    box-shadow: 0 0 12px var(--steel-blue-light);
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.info-text {
    margin-top: 8px;
    font-size: 14px;
    color: var(--text-secondary);
    word-break: break-all;
}

.button-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.button-row button {
    flex: 1;
    padding: 8px 4px;
    font-family: 'VT323', monospace;
    font-size: 14px;
    background: var(--gray-blue-dark);
    color: var(--phosphor-green);
    border: 1px solid var(--phosphor-green);
    cursor: pointer;
    transition: all 0.2s;
}

.button-row button:hover:not(:disabled) {
    background: var(--phosphor-green);
    color: var(--dark-bg);
    box-shadow: 0 0 8px var(--phosphor-green);
}

.button-row button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.speed-control label {
    font-size: 14px;
    color: var(--text-secondary);
}

.speed-btn {
    padding: 4px 10px;
    font-family: 'VT323', monospace;
    font-size: 14px;
    background: transparent;
    color: var(--steel-blue-light);
    border: 1px solid var(--steel-blue);
    cursor: pointer;
    transition: all 0.2s;
}

.speed-btn:hover, .speed-btn.active {
    background: var(--steel-blue);
    color: var(--dark-bg);
}

.speed-info {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-dim);
    text-align: center;
    font-style: italic;
}

.grid-input {
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.grid-input label {
    font-size: 14px;
    color: var(--text-secondary);
}

.grid-input input {
    width: 80px;
    padding: 6px 8px;
    font-family: 'VT323', monospace;
    font-size: 16px;
    background: var(--dark-bg);
    color: var(--phosphor-green);
    border: 1px solid var(--gray-blue);
    border-radius: 0;
    text-transform: uppercase;
}

.grid-input input:focus {
    outline: none;
    border-color: var(--phosphor-green);
    box-shadow: 0 0 4px var(--phosphor-green-dim);
}

.gap-option {
    margin-top: 12px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
}

.checkbox-label input[type="checkbox"] {
    appearance: none;
    width: 16px;
    height: 16px;
    border: 1px solid var(--gray-blue);
    background: var(--dark-bg);
    cursor: pointer;
    position: relative;
}

.checkbox-label input[type="checkbox"]:checked {
    background: var(--steel-blue);
    border-color: var(--steel-blue-light);
}

.checkbox-label input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--dark-bg);
    font-size: 12px;
}

.checkbox-label span {
    color: var(--text-secondary);
}

.state-option {
    margin-top: 8px;
}

.bright-option {
    margin-top: 8px;
}

.bright-option .checkbox-label span {
    color: var(--phosphor-green);
    text-shadow: 0 0 4px var(--phosphor-green-dim);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 16px;
    border-bottom: 1px dashed var(--gray-blue);
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-row span:first-child {
    color: var(--text-secondary);
}

.stat-row span:last-child {
    color: var(--phosphor-green);
    text-shadow: 0 0 4px var(--phosphor-green-dim);
}

.contact-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.contact-field {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
}

.contact-field .label {
    color: var(--text-dim);
}

.contact-field .value {
    color: var(--phosphor-green);
    text-align: right;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.map-container {
    flex: 1;
    position: relative;
    background: var(--dark-bg);
}

#map {
    width: 100%;
    height: 100%;
    background: var(--dark-bg);
}

#map .leaflet-container {
    background: var(--dark-bg);
}

#map .leaflet-tile-pane {
    filter: brightness(calc(0.75 * var(--map-brightness))) saturate(calc(0.5 * var(--map-brightness))) contrast(1.1);
}

#map .leaflet-tile {
    image-rendering: pixelated;
}

#map .leaflet-control-zoom {
    border: none !important;
    background: transparent !important;
}

#map .leaflet-control-zoom a {
    background: var(--gray-blue-dark) !important;
    color: var(--phosphor-green) !important;
    border: 1px solid var(--phosphor-green) !important;
}

#map .leaflet-control-attribution {
    background: rgba(0, 0, 0, 0.7) !important;
    color: var(--text-dim) !important;
    font-size: 10px;
}

#map .leaflet-control-attribution a {
    color: var(--text-secondary) !important;
}

.gap-indicator, .midnight-indicator {
    position: absolute;
    top: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    pointer-events: none;
}

.gap-indicator.hidden, .midnight-indicator.hidden, .loading-indicator.hidden {
    display: none;
}

.gap-content {
    background: rgba(10, 10, 15, 0.9);
    border: 2px solid var(--faded-red);
    padding: 20px 40px;
    text-align: center;
    animation: gapAppear 0.5s ease-out, gapFadeOut 1s ease-out 2s forwards;
}

@keyframes gapAppear {
    0% { opacity: 0; transform: scale(0.8); }
    100% { opacity: 1; transform: scale(1); }
}

@keyframes gapFadeOut {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

.gap-type {
    display: block;
    font-size: 24px;
    color: var(--faded-red);
    text-shadow: 0 0 8px var(--faded-red);
    margin-bottom: 8px;
}

.gap-info {
    font-size: 18px;
    color: var(--text-secondary);
}

.midnight-content {
    background: rgba(10, 10, 15, 0.9);
    border: 2px solid var(--phosphor-green);
    padding: 20px 60px;
    text-align: center;
    animation: midnightFlash 0.5s ease-out;
}

@keyframes midnightFlash {
    0% { opacity: 0; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.05); }
    100% { opacity: 1; transform: scale(1); }
}

.midnight-text {
    font-size: 28px;
    color: var(--phosphor-green);
    text-shadow: 0 0 12px var(--phosphor-green), 0 0 24px var(--phosphor-green-dim);
    letter-spacing: 4px;
}

.loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 3000;
    pointer-events: none;
}

.loading-content {
    background: rgba(10, 10, 15, 0.95);
    border: 2px solid var(--faded-red);
    padding: 30px 50px;
    text-align: center;
    animation: loadingPulse 0.5s ease-out;
}

@keyframes loadingPulse {
    0% { opacity: 0; transform: scale(0.8); }
    100% { opacity: 1; transform: scale(1); }
}

.loading-type {
    display: block;
    font-size: 28px;
    color: var(--faded-red);
    text-shadow: 0 0 10px var(--faded-red);
    margin-bottom: 12px;
    letter-spacing: 2px;
}

.loading-info {
    font-size: 16px;
    color: var(--text-secondary);
    animation: loadingBlink 1s ease-in-out infinite;
}

@keyframes loadingBlink {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

.status-bar {
    display: flex;
    justify-content: space-between;
    padding: 6px 16px;
    background: var(--gray-blue-dark);
    border-top: 1px solid var(--gray-blue);
    font-size: 14px;
}

#status-left {
    color: var(--phosphor-green);
}

#status-right {
    color: var(--text-dim);
}

.marker-station {
    background: var(--phosphor-green) !important;
    box-shadow: 0 0 12px var(--phosphor-green), 0 0 24px var(--phosphor-green-dim);
}

.marker-contact {
    background: var(--steel-blue-light) !important;
    box-shadow: 0 0 8px var(--steel-blue-light);
}

.marker-contact.active {
    background: var(--steel-blue) !important;
    box-shadow: 0 0 12px var(--steel-blue-light), 0 0 24px var(--steel-blue);
    animation: activePulse 1s ease-in-out infinite;
}

@keyframes activePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.contact-marker-animated circle {
    transform-origin: center;
    animation: markerAppear 0.4s ease-out forwards;
}

@keyframes markerAppear {
    0% {
        transform: scale(2.5);
        opacity: 0.5;
    }
    100% {
        transform: scale(1);
        opacity: 0.9;
    }
}

.contact-arc {
    stroke: var(--steel-blue-light);
    stroke-width: 2;
    fill: none;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    filter: drop-shadow(0 0 4px var(--steel-blue-light));
}

.contact-arc.completed {
    stroke: var(--steel-blue);
    stroke-dashoffset: 0;
    transition: stroke 0.3s;
}

.contact-arc.active {
    stroke: var(--steel-blue-light);
    filter: drop-shadow(0 0 6px var(--steel-blue-light));
}

.contact-arc.new {
    animation: drawArc 0.5s ease-out forwards;
}

@keyframes drawArc {
    to { stroke-dashoffset: 0; }
}

.tooltip-norad {
    background: rgba(10, 15, 20, 0.95) !important;
    border: 1px solid var(--phosphor-green) !important;
    border-radius: 0 !important;
    color: var(--phosphor-green) !important;
    font-family: 'VT323', monospace !important;
    padding: 8px 12px !important;
    font-size: 16px !important;
}

.tooltip-norad::before {
    border-color: transparent !important;
}

.contact-popup .leaflet-popup-content-wrapper {
    background: rgba(10, 15, 20, 0.95);
    border: 1px solid var(--steel-blue-light);
    border-radius: 0;
    box-shadow: 0 0 15px rgba(74, 123, 168, 0.4);
    animation: popupAppear 1s ease-out forwards;
}

.contact-popup .leaflet-popup-content {
    margin: 8px 12px;
    font-family: 'VT323', monospace;
}

.contact-popup .leaflet-popup-tip {
    background: rgba(10, 15, 20, 0.95);
}

.popup-callsign {
    font-size: 20px;
    color: var(--steel-blue-light);
    text-shadow: 0 0 8px var(--steel-blue-light);
    margin-bottom: 4px;
}

.popup-details {
    font-size: 12px;
    color: var(--text-secondary);
}

.popup-no-location .popup-callsign {
    color: #FF6666;
    text-shadow: 0 0 8px #FF4444;
}

.popup-no-location .leaflet-popup-content-wrapper {
    border-color: #FF4444;
    box-shadow: 0 0 15px rgba(255, 68, 68, 0.4);
}

@keyframes popupAppear {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    30% {
        opacity: 1;
        transform: scale(1.1);
    }
    50% {
        transform: scale(1);
    }
    90% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

.temp-label {
    background: rgba(10, 15, 20, 0.95);
    border: 1px solid var(--steel-blue-light);
    color: var(--steel-blue-light);
    font-family: 'VT323', monospace;
    font-size: 16px;
    text-align: center;
    padding: 4px 12px;
    pointer-events: none;
    text-shadow: 0 0 4px var(--steel-blue-light);
    box-shadow: 0 0 10px rgba(74, 123, 168, 0.3);
}

.temp-label-text {
    display: block;
}

@media (max-width: 768px) {
    .main-container {
        flex-direction: column;
    }

    .control-panel {
        width: 100%;
        max-height: 40vh;
        border-right: none;
        border-bottom: 2px solid var(--gray-blue);
    }

    .norad-header h1 {
        font-size: 18px;
    }

    .header-right {
        font-size: 14px;
        gap: 12px;
    }
}
