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

body {
    overflow: hidden;
    background-color: #000;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    /* Prevent pull-to-refresh and overscroll effects */
    overscroll-behavior: none;
    /* Prevent text selection on touch */
    -webkit-user-select: none;
    user-select: none;
    /* Prevent touch callout on iOS */
    -webkit-touch-callout: none;
    /* Prevent tap highlight */
    -webkit-tap-highlight-color: transparent;
}

#container {
    width: 100vw;
    height: 100vh;
}

#info {
    position: absolute;
    top: 20px;
    left: 20px;
    color: #fff;
    z-index: 100;
    pointer-events: none;
}

#info h1 {
    font-size: 24px;
    font-weight: 300;
    margin-bottom: 8px;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

#info p {
    font-size: 12px;
    opacity: 0.7;
}

/* Planet label styling */
.planet-label {
    color: #fff;
    font-size: 12px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    text-shadow: 0 0 4px rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.sun-label {
    color: #ffd700;
    font-size: 14px;
    font-weight: bold;
}

.moon-label {
    font-size: 10px;
    padding: 2px 6px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.15);
    opacity: 0.85;
}

.spacecraft-label {
    color: #88ffaa;
    font-size: 11px;
    background: rgba(0, 40, 20, 0.7);
    border: 1px solid rgba(136, 255, 170, 0.4);
}

/* Time Controls */
#controls {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.7);
    padding: 12px 20px;
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 100;
}

#controls button {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

#controls button:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.1);
}

#controls button:active {
    transform: scale(0.95);
}

#controls button.active {
    background: rgba(100, 180, 255, 0.4);
    border-color: rgba(100, 180, 255, 0.8);
}

#pauseBtn {
    width: 50px !important;
    height: 50px !important;
    font-size: 20px !important;
}

#speedDisplay {
    color: #fff;
    font-size: 14px;
    min-width: 50px;
    text-align: center;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    margin-left: 8px;
}

/* Date Display */
#dateDisplay {
    position: absolute;
    top: 20px;
    right: 20px;
    color: #fff;
    font-size: 14px;
    padding: 14px 18px;
    background: rgba(0, 0, 0, 0.75);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 100;
    min-width: 200px;
}

#simDate {
    font-weight: 300;
    display: block;
    margin-bottom: 10px;
}

#moonPhaseDisplay {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    font-size: 12px;
}

#moonPhaseIcon {
    font-size: 20px;
    line-height: 1;
}

#moonPhaseName {
    opacity: 0.85;
    flex: 1;
}

.date-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
}

#datePicker {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    color: #fff;
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
    flex: 1;
}

#datePicker::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}

#datePicker:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

#datePicker:focus {
    outline: none;
    border-color: rgba(100, 180, 255, 0.8);
}

#resetDateBtn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    color: #fff;
    padding: 6px 10px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#resetDateBtn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

#resetDateBtn:active {
    transform: scale(0.95);
}

/* Planet Info Panel */
#infoPanel {
    position: absolute;
    top: 180px;
    right: 20px;
    width: 320px;
    max-height: calc(100vh - 220px);
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.85);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 20px;
    color: #fff;
    z-index: 100;
    transition: all 0.3s ease;
}

#infoPanel.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(20px);
}

#closePanelBtn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

#closePanelBtn:hover {
    opacity: 1;
}

#infoPanel h2 {
    font-size: 22px;
    font-weight: 400;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.info-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.info-label {
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
}

.info-item span:last-child {
    font-size: 14px;
    text-align: right;
}

.info-item.full-width {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.info-item.full-width span:last-child {
    text-align: left;
    line-height: 1.4;
}

.features-text {
    font-size: 13px !important;
    color: rgba(255, 255, 255, 0.85);
}

.info-item.dynamic-info {
    background: rgba(100, 180, 255, 0.1);
    padding: 6px 8px;
    border-radius: 4px;
    border-left: 2px solid rgba(100, 180, 255, 0.5);
}

.info-item.dynamic-info .info-label {
    color: rgba(100, 180, 255, 0.9);
}

#unfocusBtn {
    width: 100%;
    margin-top: 16px;
    padding: 10px;
    background: rgba(100, 180, 255, 0.3);
    border: 1px solid rgba(100, 180, 255, 0.5);
    color: #fff;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

#unfocusBtn:hover {
    background: rgba(100, 180, 255, 0.5);
}

#unfocusBtn.hidden {
    display: none;
}

/* Mini Map */
#miniMap {
    position: absolute;
    bottom: 100px;
    left: 20px;
    width: 180px;
    height: 180px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    overflow: hidden;
    z-index: 100;
}

#miniMapCanvas {
    width: 100%;
    height: 100%;
}

/* Settings Panel */
#settingsPanel {
    position: absolute;
    top: 80px;
    left: 20px;
    z-index: 100;
}

#settingsToggle {
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 22px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
}

#settingsToggle:hover {
    background: rgba(255, 255, 255, 0.2);
}

#settingsContent {
    position: absolute;
    top: 50px;
    left: 0;
    width: 200px;
    background: rgba(0, 0, 0, 0.85);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 16px;
    transition: all 0.3s ease;
}

#settingsContent.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
}

#settingsContent h3 {
    color: #fff;
    font-size: 14px;
    font-weight: 400;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

#settingsContent label {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-size: 13px;
    padding: 8px 0;
    cursor: pointer;
}

#settingsContent label:hover {
    color: #88ccff;
}

#settingsContent input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Fullscreen Button */
#fullscreenBtn {
    position: absolute;
    bottom: 30px;
    right: 20px;
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 20px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 100;
    transition: all 0.2s;
}

#fullscreenBtn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* Sound Toggle Button */
#soundBtn {
    position: absolute;
    bottom: 30px;
    right: 80px;
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 20px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 100;
    transition: all 0.2s;
}

#soundBtn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

#soundBtn.playing {
    background: rgba(100, 180, 255, 0.3);
    border-color: rgba(100, 180, 255, 0.6);
}

/* Utility */
.hidden {
    opacity: 0;
    pointer-events: none;
}

/* ==================== */
/* Mobile Responsiveness */
/* ==================== */

/* Tablets and smaller */
@media (max-width: 1024px) {
    #infoPanel {
        width: 250px;
        padding: 16px;
    }
    
    #infoPanel h2 {
        font-size: 18px;
    }
    
    .info-label {
        font-size: 11px;
    }
    
    .info-item span:last-child {
        font-size: 12px;
    }
}

/* Mobile landscape and portrait */
@media (max-width: 768px) {
    #info h1 {
        font-size: 18px;
    }
    
    #info p {
        font-size: 10px;
        max-width: 200px;
    }
    
    /* Date display */
    #dateDisplay {
        top: 10px;
        right: 10px;
        font-size: 12px;
        padding: 10px 12px;
        min-width: 160px;
    }
    
    #simDate {
        margin-bottom: 8px;
    }
    
    #moonPhaseDisplay {
        margin-bottom: 8px;
        padding: 6px 8px;
    }
    
    #moonPhaseIcon {
        font-size: 16px;
    }
    
    .date-controls {
        padding-top: 8px;
    }
    
    #datePicker {
        font-size: 11px;
        padding: 4px 6px;
    }
    
    #resetDateBtn {
        padding: 4px 8px;
        font-size: 12px;
    }
    
    /* Time controls - make more compact */
    #controls {
        bottom: 20px;
        padding: 8px 14px;
        gap: 6px;
    }
    
    #controls button {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
    
    #pauseBtn {
        width: 44px !important;
        height: 44px !important;
        font-size: 18px !important;
    }
    
    #speedDisplay {
        font-size: 12px;
        min-width: 40px;
        padding: 4px 8px;
    }
    
    /* Info panel - slide from bottom on mobile */
    #infoPanel {
        top: auto;
        bottom: 90px;
        right: 10px;
        left: 10px;
        width: auto;
        max-height: 45vh;
        overflow-y: auto;
        padding: 14px;
    }
    
    #infoPanel h2 {
        font-size: 16px;
        margin-bottom: 12px;
        padding-bottom: 8px;
    }
    
    .info-grid {
        gap: 8px;
    }
    
    .info-item {
        flex-wrap: wrap;
    }
    
    #unfocusBtn {
        padding: 8px;
        margin-top: 12px;
    }
    
    /* Mini map - smaller on mobile */
    #miniMap {
        width: 120px;
        height: 120px;
        bottom: 90px;
        left: 10px;
    }
    
    #miniMapCanvas {
        width: 120px;
        height: 120px;
    }
    
    /* Settings panel */
    #settingsPanel {
        top: 60px;
        left: 10px;
    }
    
    #settingsToggle {
        width: 38px;
        height: 38px;
        font-size: 18px;
    }
    
    #settingsContent {
        width: 180px;
        padding: 12px;
        top: 44px;
    }
    
    #settingsContent h3 {
        font-size: 12px;
    }
    
    #settingsContent label {
        font-size: 12px;
        padding: 6px 0;
    }
    
    /* Fullscreen and sound buttons */
    #fullscreenBtn,
    #soundBtn {
        width: 38px;
        height: 38px;
        font-size: 16px;
        bottom: 20px;
    }
    
    #fullscreenBtn {
        right: 10px;
    }
    
    #soundBtn {
        right: 58px;
    }
}

/* Small mobile phones */
@media (max-width: 480px) {
    #info {
        top: 10px;
        left: 10px;
    }
    
    #info h1 {
        font-size: 16px;
        margin-bottom: 4px;
    }
    
    #info p {
        font-size: 9px;
        max-width: 160px;
    }
    
    /* Time controls - even more compact */
    #controls {
        bottom: 15px;
        padding: 6px 10px;
        gap: 4px;
        border-radius: 25px;
    }
    
    #controls button {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
    
    #pauseBtn {
        width: 40px !important;
        height: 40px !important;
        font-size: 16px !important;
    }
    
    #speedDisplay {
        font-size: 10px;
        min-width: 35px;
        padding: 3px 6px;
        margin-left: 4px;
    }
    
    /* Date display */
    #dateDisplay {
        font-size: 11px;
        padding: 8px 10px;
        min-width: 140px;
    }
    
    #simDate {
        margin-bottom: 6px;
        font-size: 11px;
    }
    
    #moonPhaseDisplay {
        margin-bottom: 6px;
        padding: 4px 6px;
        font-size: 10px;
    }
    
    #moonPhaseIcon {
        font-size: 14px;
    }
    
    .date-controls {
        padding-top: 6px;
        gap: 4px;
    }
    
    #datePicker {
        font-size: 10px;
        padding: 3px 5px;
    }
    
    #resetDateBtn {
        padding: 3px 6px;
        font-size: 11px;
    }
    
    /* Info panel */
    #infoPanel {
        bottom: 75px;
        padding: 12px;
        max-height: 40vh;
    }
    
    #closePanelBtn {
        font-size: 20px;
        top: 8px;
        right: 8px;
    }
    
    /* Mini map - hide on very small screens or make tiny */
    #miniMap {
        width: 90px;
        height: 90px;
        bottom: 75px;
        left: 10px;
    }
    
    #miniMapCanvas {
        width: 90px;
        height: 90px;
    }
    
    /* Settings */
    #settingsPanel {
        top: 50px;
    }
    
    #settingsToggle {
        width: 34px;
        height: 34px;
        font-size: 16px;
    }
    
    #settingsContent {
        width: 160px;
        padding: 10px;
        top: 40px;
    }
    
    /* Bottom buttons */
    #fullscreenBtn,
    #soundBtn {
        width: 34px;
        height: 34px;
        font-size: 14px;
        bottom: 15px;
    }
    
    #soundBtn {
        right: 52px;
    }
}

/* Landscape mode on mobile - adjust layout */
@media (max-height: 500px) and (orientation: landscape) {
    #info {
        top: 8px;
        left: 10px;
    }
    
    #info h1 {
        font-size: 14px;
        margin-bottom: 2px;
    }
    
    #info p {
        font-size: 9px;
    }
    
    #dateDisplay {
        top: 8px;
        padding: 6px 10px;
        font-size: 11px;
    }
    
    #controls {
        bottom: 10px;
        padding: 6px 12px;
    }
    
    #controls button {
        width: 30px;
        height: 30px;
    }
    
    #pauseBtn {
        width: 36px !important;
        height: 36px !important;
    }
    
    /* Info panel - side panel in landscape */
    #infoPanel {
        top: 140px;
        bottom: auto;
        right: 10px;
        left: auto;
        width: 220px;
        max-height: calc(100vh - 160px);
    }
    
    /* Mini map - smaller in landscape */
    #miniMap {
        width: 100px;
        height: 100px;
        bottom: 50px;
        left: 10px;
    }
    
    #miniMapCanvas {
        width: 100px;
        height: 100px;
    }
    
    #settingsPanel {
        top: 45px;
    }
    
    #fullscreenBtn,
    #soundBtn {
        bottom: 10px;
        width: 32px;
        height: 32px;
    }
    
    #soundBtn {
        right: 50px;
    }
}

/* Safe area support for devices with notches */
@supports (padding: env(safe-area-inset-bottom)) {
    #controls {
        bottom: calc(20px + env(safe-area-inset-bottom));
    }
    
    #fullscreenBtn,
    #soundBtn {
        bottom: calc(20px + env(safe-area-inset-bottom));
    }
    
    #info {
        left: calc(20px + env(safe-area-inset-left));
    }
    
    #dateDisplay {
        right: calc(20px + env(safe-area-inset-right));
    }
    
    #miniMap {
        left: calc(20px + env(safe-area-inset-left));
        bottom: calc(100px + env(safe-area-inset-bottom));
    }
    
    #infoPanel {
        right: calc(20px + env(safe-area-inset-right));
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    #controls button {
        min-width: 44px;
        min-height: 44px;
    }
    
    #pauseBtn {
        min-width: 52px !important;
        min-height: 52px !important;
    }
    
    #settingsToggle,
    #fullscreenBtn,
    #soundBtn {
        min-width: 44px;
        min-height: 44px;
    }
    
    #settingsContent label {
        padding: 10px 0;
    }
    
    #settingsContent input[type="checkbox"] {
        width: 20px;
        height: 20px;
    }
    
    /* Remove hover effects that don't work well on touch */
    #controls button:hover,
    #settingsToggle:hover,
    #fullscreenBtn:hover,
    #soundBtn:hover {
        transform: none;
    }
    
    #controls button:active,
    #settingsToggle:active,
    #fullscreenBtn:active,
    #soundBtn:active {
        transform: scale(0.95);
        background: rgba(255, 255, 255, 0.3);
    }
}
