* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: #0a0a1a;
    background-image: 
    radial-gradient(circle at 10% 20%, rgba(40, 60, 180, 0.15) 0%, transparent 20%),
    radial-gradient(circle at 90% 80%, rgba(180, 60, 180, 0.15) 0%, transparent 20%);
    color: #e0e0ff;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: 'Exo 2', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
}

@keyframes travel-overlay {
    from { opacity: 0.3; }
    to { opacity: 0.6; }
}

/* Add to styles.css */
.galaxy-shape-selector {
    display: flex;
    gap: 10px;
    margin: 15px 0;
}
    
.shape-option {
    flex: 1;
    padding: 10px;
    background: rgba(25, 30, 70, 0.8);
    border: 2px solid #5a5aaa;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
}
    
.shape-option.selected {
    border-color: #66ccff;
    box-shadow: 0 0 10px rgba(100, 200, 255, 0.7);
}
/* Mobile-first design */
.game-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    max-height: -webkit-fill-available;
    padding: 10px;
    gap: 10px;
}

header {
    text-align: center;
    padding: 15px 10px;
    background: rgba(10, 15, 40, 0.85);
    border-bottom: 3px solid #5a5aaa;
    border-radius: 0 0 15px 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 30, 0.8);
    z-index: 20;
    flex-shrink: 0;
}

h1 {
    color: #66ccff;
    text-shadow: 0 0 15px rgba(100, 180, 255, 0.8);
    font-size: 28px;
    letter-spacing: 2px;
    margin-bottom: 5px;
    font-weight: 800;
    background: linear-gradient(to right, #66ccff, #aaccff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: #88aaff;
    font-size: 14px;
    margin-bottom: 5px;
    text-shadow: 0 0 5px rgba(100, 150, 255, 0.5);
}

.main-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    overflow: hidden;
}

.map-container {
    position: relative;
    border: 3px solid #5a5aaa;
    background: #000033;
    box-shadow: 0 0 20px rgba(80, 100, 255, 0.6);
    border-radius: 10px;
    flex: 1;
    overflow: hidden;
    min-height: 200px;
    touch-action: none;
}

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

#system-container, #ship-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.system-dot {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    z-index: 2;
    box-shadow: 0 0 10px currentColor;
    pointer-events: auto;
}

.system-name {
    position: absolute;
    color: rgba(200, 220, 255, 0.8);
    font-size: 12px;
    pointer-events: none;
    z-index: 1;
    opacity: 0.7;
    transition: opacity 0.3s;
}

.system-name:hover {
    opacity: 1;
}

.selected-system {
    box-shadow: 0 0 15px #66ffff, 0 0 25px #66ffff;
    z-index: 10;
}

.ship-indicator {
    position: absolute;
    width: 24px;
    height: 24px;
    z-index: 20;
    pointer-events: none;
    transform-origin: center center;
}

.ship-indicator i {
    font-size: 24px;
    color: #66ccff;
    text-shadow: 0 0 5px rgba(100, 180, 255, 0.7);
    transition: all 0.3s ease;
}

/* New travel effect using a pseudo-element on the ship indicator */
.ship-indicator::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 0 10px white, 0 0 20px #66ffff, 0 0 30px #66ccff;
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.5s ease-out, opacity 0.5s ease-out;
    opacity: 0;
    z-index: -1; /* Place effect behind the ship icon */
}

/* Activate the effect when the .traveling class is added */
.ship-indicator.traveling::after {
    transform: translate(-50%, -50%) scale(2.5);
    opacity: 1;
    animation: travel-pulse 1s infinite alternate;
}

@keyframes travel-pulse {
    from {
        transform: translate(-50%, -50%) scale(2.5);
        opacity: 1;
    }
    to {
        transform: translate(-50%, -50%) scale(3.5);
        opacity: 0.7;
    }
}

.ui-panel {
    background: rgba(15, 20, 50, 0.95);
    border: 3px solid #5a5aaa;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 0 20px rgba(80, 100, 255, 0.4);
    display: flex;
    flex-direction: column;
    gap: 5px;
    height: 45vh;
    overflow: auto;
    flex-shrink: 1;
}

/* Add new rule for UI panel only */
.ui-panel.traveling::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 10, 30, 0.7);
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    animation: travel-overlay 1s infinite alternate;
    border-radius: 10px;
}

.panel-section {
    background: rgba(25, 30, 70, 0.8);
    border: 2px solid #6a6abb;
    border-radius: 8px;
    padding: 15px;
    padding-bottom: 2cm;
    box-shadow: inset 0 0 10px rgba(0, 0, 30, 0.7);
}

h2 {
    color: #aaccff;
    border-bottom: 2px solid #6a6abb;
    padding-bottom: 10px;
    margin-bottom: 15px;
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

h2 i {
    font-size: 18px;
    color: #66ccff;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.stat {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #5a5aaa;
    font-size: 14px;
}

.stat-value {
    color: #66ff99;
    font-weight: bold;
    font-size: 14px;
}

.market-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr 1fr auto;
    gap: 8px;
    align-items: center;
    font-size: 12px;
}

.market-header {
    font-weight: bold;
    color: #88aaff;
    padding: 6px 0;
    border-bottom: 2px solid #5a5aaa;
    font-size: 12px;
}

.market-item {
    padding: 8px 0;
    border-bottom: 1px dashed #5a5aaa;
}

.btn {
    background: linear-gradient(to bottom, #3a3a7a, #2a2a5a);
    color: #e0e0ff;
    border: 1px solid #5a5aaa;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 6px;
    font-size: 14px;
    text-align: center;
    font-weight: 600;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}

.btn:hover {
    background: linear-gradient(to bottom, #4a4a9a, #3a3a8a);
    box-shadow: 0 0 10px rgba(100, 150, 255, 0.6);
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(1px);
}

.btn-action {
    background: linear-gradient(to bottom, #4a4a9a, #3a3a7a);
    font-size: 16px; /* Adjusted from 32px */
    padding: 12px;  /* Adjusted from 100px top padding */
}

.btn-buy {
    background: linear-gradient(to bottom, #3a9a4a, #2a7a3a);
    padding: 5px 8px;
    font-size: 12px;
}

.btn-sell {
    background: linear-gradient(to bottom, #9a4a3a, #7a3a2a);
    padding: 5px 8px;
    font-size: 12px;
}

.cargo-item {
    display: grid;
    grid-template-columns: 2fr 1fr auto;
    gap: 8px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px dashed #5a5aaa;
    font-size: 12px;
}

.tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
    background: rgba(25, 30, 60, 0.7);
    border-radius: 8px;
    padding: 4px;
    flex-wrap: wrap;
}

.tab {
    flex: 1;
    padding: 10px 5px;
    text-align: center;
    background: #2a2a5a;
    cursor: pointer;
    border-radius: 6px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.3);
    font-size: 12px;
    min-width: 60px;
}

.tab i {
    display: block;
    margin-bottom: 3px;
    font-size: 14px;
}

.tab:hover {
    background: #3a3a7a;
}

.tab.active {
    background: linear-gradient(to bottom, #66ccff, #3388ff);
    color: #001133;
    box-shadow: 0 0 10px rgba(100, 180, 255, 0.7);
}

.notification {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 40, 90, 0.95);
    border: 2px solid #6a6abb;
    padding: 12px 20px;
    border-radius: 8px;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    z-index: 100;
    font-size: 16px;
    box-shadow: 0 0 20px rgba(80, 120, 255, 0.7);
    text-align: center;
    max-width: 90%;
    backdrop-filter: blur(5px);
    width: max-content;
}

/* Old travel effect styles are no longer needed */
.travel-effect, .star-trail {
    display: none;
}

/* Unified Encounter Modal Styles */
.encounter-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 20, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
    padding: 15px;
}

.encounter-container {
    background: rgba(15, 20, 50, 0.95);
    border: 3px solid #cc6666;
    border-radius: 15px;
    padding: 20px;
    width: 100%;
    max-width: 500px;
    box-shadow: 0 0 30px rgba(200, 50, 50, 0.7);
    text-align: center;
}

.ships-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 20px 0;
}

.ship-display {
    padding: 15px;
    background: rgba(30, 35, 70, 0.8);
    border-radius: 10px;
}

.ship-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 10px;
    font-size: 14px;
}

.combat-options {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 15px;
}

.combat-btn {
    padding: 12px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.combat-btn.attack {
    background: linear-gradient(to bottom, #cc6666, #aa4444);
}

.combat-btn.evade {
    background: linear-gradient(to bottom, #66cc66, #44aa44);
}

.combat-btn.escape {
    background: linear-gradient(to bottom, #6666cc, #4444aa);
}

.combat-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

/* Galaxy Size Selector Mobile */
.galaxy-size-selector {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 20px 0;
}

.size-option {
    padding: 20px;
    background: rgba(25, 30, 70, 0.8);
    border: 3px solid #5a5aaa;
    border-radius: 12px;
    cursor: pointer;
    text-align: center;
    transition: transform 0.5s ease-out, background 0.5s;
}

.size-option h3 {
    color: #66ccff;
    margin-bottom: 10px;
    font-size: 20px;
}

.size-option p {
    margin: 5px 0;
    font-size: 14px;
}

.size-option:hover {
    transform: scale(1.02);
}

.size-option.selected {
    border-color: #66ccff;
    box-shadow: 0 0 15px rgba(100, 200, 255, 0.7);
    transform: scale(1.03);
}

/* Mobile-specific styles */
.mobile-controls {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    gap: 10px;
}

.mobile-btn {
    flex: 1;
    padding: 12px;
    font-size: 14px;
}

/* Portrait vs Landscape adjustments */
@media (orientation: landscape) {
    .game-container {
        flex-direction: row;
        padding: 5px;
    }
    
    header {
        display: none;
    }
    
    .main-content {
        flex-direction: row;
        flex: 1;
    }
    
    .map-container {
        flex: 2;
    }
    
    .ui-panel {
        flex: 1;
        height: 100%;
        padding-bottom: 2cm;
    }
}

@media (max-height: 600px) {
    h1 {
        font-size: 22px;
    }
    
    .subtitle {
        font-size: 12px;
    }
    
    .tabs {
        margin-bottom: 8px;
    }
    
    .tab {
        padding: 6px 3px;
        font-size: 10px;
    }
    
    .panel-section {
        padding: 10px;
    }
    
    h2 {
        font-size: 16px;
        padding-bottom: 8px;
        margin-bottom: 10px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 5px;
    }
    
    .market-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .market-header:nth-child(3),
    .market-header:nth-child(4),
    .market-header:nth-child(5) {
        display: none;
    }
    
    .market-item {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 5px;
    }
    
    .market-item > div:last-child {
        grid-column: span 2;
    }
}

.crt-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
    linear-gradient(rgba(18, 16, 16, 0.1) 50%, rgba(0, 0, 0, 0.25) 50%), 
    linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    background-size: 100% 4px, 4px 100%;
    pointer-events: none;
    z-index: 10;
}

.init-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 20, 50, 0.95);
    border: 3px solid #5a5aaa;
    border-radius: 15px;
    margin: auto;
    box-shadow: 0 0 30px rgba(0, 0, 40, 0.8);
    max-width: 95%;
    text-align: center;
    height: 100%;
}

.system-info-panel {
    position: absolute;
    background: rgba(15, 20, 50, 0.9);
    border: 2px solid #5a5aaa;
    border-radius: 8px;
    padding: 12px;
    z-index: 30;
    max-width: 200px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 12px;
}

.upgrade-card {
    background: rgba(35, 40, 80, 0.8);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #5a5aaa;
}

.upgrade-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
}

.contract-item {
    background: rgba(40, 45, 90, 0.8);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #5a5aaa;
}

.contract-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.contract-reward {
    color: #66ff99;
    font-weight: bold;
}

.contract-details {
    font-size: 12px;
    margin: 5px 0;
}

.contract-button {
    margin-top: 8px;
    padding: 6px;
    font-size: 12px;
}

/* Camera controls */
.map-center-btn {
    position: absolute;
    bottom: 60px;
    right: 10px;
    width: 40px;
    height: 40px;
    background: rgba(20, 30, 60, 0.8);
    border: 1px solid #5a5aaa;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #66ccff;
    font-size: 18px;
    cursor: pointer;
    z-index: 50;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.map-center-btn:hover {
    background: rgba(30, 40, 80, 0.9);
    transform: scale(1.1);
}

/* Remove old move controls */
.map-move-controls {
    display: none;
}

.system-overview-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 10px;
}

.system-overview-item {
    background: rgba(30, 35, 70, 0.8);
    border-radius: 8px;
    padding: 8px;
    font-size: 12px;
}

/* Game Over Screen */
.game-over-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 3000;
    padding: 20px;
    text-align: center;
}

.game-over-stats {
    margin: 30px 0;
    font-size: 20px;
    width: 100%;
    max-width: 500px;
}

.game-over-stats div {
    margin: 15px 0;
}
