/* Planet description box below planet name */
.planet-description-container {
    display: flex;
    margin: 0.5rem 0 1rem 0;
    padding: 0.75rem 1rem;
    background: rgba(30, 30, 40, 0.85);
    color: #ffe082;
    border-radius: 8px;
    font-size: 1rem;
    line-height: 1.4;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    max-width: 480px;
    width: 100%;
    text-align: left;
    letter-spacing: 0.01em;
    border: solid 1px #ffd700;
}
.planet-description-container svg {
    width: 150px;
    margin-right: 15px;
}
/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    background: linear-gradient(135deg, #0f0f23 0%, #1a1a3a 100%);
    color: #e0e0e0;
    min-height: 100vh;
    font-size: 16px;
    line-height: 1.4;
}

/* Layout */
#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.game-header {
    background: rgba(0, 0, 0, 0.5);
    padding: 1rem;
    text-align: center;
    border-bottom: 2px solid #ffd700;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.game-header h1 {
    color: #ffd700;
    font-size: 1.5rem;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
    margin: 0;
    flex: 1;
    text-align: center;
}

.turn-token {
    font-size: 0.8rem;
    color: #aaa;
}

.game-main {
    flex: 1;
    padding: 1rem;
    position: relative;
}

/* View containers */
.view-container {
    max-width: 480px;
    margin: 0 auto;
    animation: fadeIn 0.3s ease-in;
}

.view-container.hidden {
    display: none;
}

.view-header {
    display: flex;
    flex-flow: column;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #444;
}

.view-header h2 {
    color: #ffd700;
    font-size: 1.25rem;
}

/* Buttons */
.btn, .nav-btn {
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(74, 144, 226, 0.3);
}

.btn:hover, .nav-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.4);
}

.btn:active, .nav-btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, #28a745 0%, #1e7e34 100%);
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.3);
}

.btn-warning {
    background: linear-gradient(135deg, #ffc107 0%, #e0a800 100%);
    color: #212529;
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.3);
}

.nav-btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

/* Player status */
.player-status {
    background: rgba(255, 255, 255, 0.05);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
}

.status-item {
    text-align: center;
}

.status-item .label {
    font-weight: bold;
    color: #ffd700;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
}

/* Inventory */
.inventory {
    margin-bottom: 1.5rem;
}

.inventory h3 {
    color: #ffd700;
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.inventory-items {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.inventory-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.9rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Actions */
.actions h3 {
    color: #ffd700;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.action-list {
    display: grid;
    gap: 0.75rem;
}

.action-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(255, 215, 0, 0.3);
    color: #e0e0e0;
    padding: 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    font-size: 1rem;
}

.action-btn:hover {
    background: rgba(255, 215, 0, 0.1);
    border-color: rgba(255, 215, 0, 0.6);
    transform: translateY(-2px);
}

.action-btn:active {
    transform: translateY(0);
}

.action-btn .action-name {
    font-weight: bold;
    color: #ffd700;
    display: block;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.action-btn .action-desc {
    font-size: 0.9rem;
    color: #ccc;
}

/* Map View */
.galaxy-map-container {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.planet-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.planet-row {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.planet-list {
    list-style: none;
    display: grid;
    gap: 0.75rem;
}

.planet-item {
    display: flex;
    flex: 1;
    max-width: 280px;
}

.planet-item.empty {
    visibility: hidden;
}

.planet-button {
    width: 100%;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(255, 215, 0, 0.3);
    color: #e0e0e0;
    padding: 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    font-size: 1rem;
    font-weight: 600;
}

.planet-button:hover:not(:disabled) {
    background: rgba(255, 215, 0, 0.1);
    border-color: rgba(255, 215, 0, 0.6);
    transform: translateY(-2px);
}

.planet-button:active:not(:disabled) {
    transform: translateY(0);
}

.planet-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.1);
}

/* Planet status styling */
.current-planet .planet-button {
    background: rgba(255, 215, 0, 0.2);
    border-color: #ffd700;
    color: #ffd700;
    font-weight: bold;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
}

.adjacent-planet .planet-button {
    background: rgba(74, 144, 226, 0.1);
    border-color: rgba(74, 144, 226, 0.5);
    color: #4a90e2;
}

.distant-planet .planet-button {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.1);
    color: #888;
}

.selectable-planet .planet-button {
    background: rgba(34, 139, 34, 0.1);
    border-color: rgba(34, 139, 34, 0.5);
    color: #22bb22;
    box-shadow: 0 0 10px rgba(34, 139, 34, 0.2);
}

.selectable-planet .planet-button:hover:not(:disabled) {
    background: rgba(34, 139, 34, 0.2);
    border-color: rgba(34, 139, 34, 0.8);
    box-shadow: 0 0 15px rgba(34, 139, 34, 0.4);
}

.locked-planet .planet-button {
    background: rgba(139, 69, 19, 0.1);
    border-color: rgba(139, 69, 19, 0.3);
    color: rgba(139, 69, 19, 0.7);
    opacity: 0.6;
}

.map-info {
    text-align: center;
    color: #aaa;
    font-size: 0.9rem;
}

/* Turn result */
.turn-result {
    background: rgba(40, 167, 69, 0.1);
    border: 2px solid rgba(40, 167, 69, 0.3);
    border-radius: 8px;
    padding: 1.5rem;
    margin-top: 1.5rem;
    text-align: center;
    animation: slideIn 0.4s ease-out;
}

.turn-result.hidden {
    display: none;
}

.turn-result.damage-result {
    background: rgba(220, 53, 69, 0.1);
    border-color: rgba(220, 53, 69, 0.3);
}

.turn-result.success-result {
    background: rgba(40, 167, 69, 0.1);
    border-color: rgba(40, 167, 69, 0.3);
}

.result-text {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: #e0e0e0;
    line-height: 1.5;
}

/* Loading */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading.hidden {
    display: none;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 215, 0, 0.3);
    border-top: 4px solid #ffd700;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

/* Toast */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 1rem 2rem;
    border-radius: 8px;
    border: 2px solid #ffd700;
    z-index: 1001;
    animation: toastSlide 0.3s ease-out;
}

.toast.hidden {
    display: none;
}

/* Fight Dialog */
.fight-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 1.5rem 2rem;
    border-radius: 8px;
    border: 2px solid #ffd700;
    z-index: 1001;
    animation: toastSlide 0.3s ease-out;
    min-width: 300px;
    max-width: 400px;
}

.fight-dialog.hidden {
    display: none;
}

.fight-dialog-content h3 {
    color: #ffd700;
    margin-bottom: 1rem;
    font-size: 1.2rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
}

.fight-dialog-content p {
    margin-bottom: 1.5rem;
    text-align: center;
    color: #e0e0e0;
    line-height: 1.5;
}

.fight-dialog-buttons {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr 1fr;
}

.fight-dialog .fight-btn,
.fight-dialog .evade-btn {
    width: 100%;
    margin: 0;
}

.fight-dialog .evade-btn {
    background: rgba(255, 193, 7, 0.1);
    border-color: rgba(255, 193, 7, 0.3);
}

.fight-dialog .evade-btn:hover {
    background: rgba(255, 193, 7, 0.2);
    border-color: rgba(255, 193, 7, 0.6);
}

/* Help Button */
.help-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 215, 0, 0.2);
    border: 2px solid rgba(255, 215, 0, 0.5);
    color: #ffd700;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.help-btn:hover {
    background: rgba(255, 215, 0, 0.3);
    border-color: #ffd700;
    transform: scale(1.1);
}

.help-btn:active {
    transform: scale(0.95);
}

/* Help Dialog */
.help-dialog {
    position: fixed;
    top: 5%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.95);
    color: white;
    border-radius: 8px;
    border: 2px solid #ffd700;
    z-index: 1001;
    animation: toastSlide 0.3s ease-out;
    width: 90%;
    max-width: 600px;
    height: 85vh;
    max-height: 800px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.help-dialog.hidden {
    display: none;
}

.help-dialog-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.help-dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem 1rem;
    border-bottom: 1px solid rgba(255, 215, 0, 0.3);
    flex-shrink: 0;
}

.help-dialog-header h3 {
    color: #ffd700;
    font-size: 1.3rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

.close-btn {
    background: none;
    border: 2px solid rgba(255, 215, 0, 0.5);
    color: #ffd700;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.close-btn:hover {
    background: rgba(255, 215, 0, 0.2);
    border-color: #ffd700;
    transform: scale(1.1);
}

.close-btn:active {
    transform: scale(0.95);
}

.help-dialog-body {
    padding: 1.5rem 2rem 2rem;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    min-height: 0; /* Important: allows flex child to shrink below content size */
    line-height: 1.6;
    -webkit-overflow-scrolling: touch; /* Enable momentum scrolling on iOS */
    scroll-behavior: smooth; /* Smooth scrolling for keyboard navigation */
    outline: none; /* Remove default focus outline */
}

.help-dialog-body:focus {
    box-shadow: inset 0 0 0 2px rgba(255, 215, 0, 0.3);
}

/* Custom scrollbar for help dialog - WebKit browsers (Chrome, Safari, Edge) */
.help-dialog-body::-webkit-scrollbar {
    width: 8px;
}

.help-dialog-body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.help-dialog-body::-webkit-scrollbar-thumb {
    background: rgba(255, 215, 0, 0.6);
    border-radius: 4px;
    transition: background 0.2s ease;
}

.help-dialog-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 215, 0, 0.8);
}

/* Custom scrollbar for help dialog - Firefox */
.help-dialog-body {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 215, 0, 0.6) rgba(255, 255, 255, 0.1);
}

.help-dialog-body h4 {
    color: #ffd700;
    font-size: 1.2rem;
    margin: 1.5rem 0 0.75rem 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(255, 215, 0, 0.3);
    padding-bottom: 0.5rem;
}

.help-dialog-body h4:first-child {
    margin-top: 0;
}

.help-dialog-body h5 {
    color: #4a90e2;
    font-size: 1rem;
    margin: 1.25rem 0 0.5rem 0;
    font-weight: 600;
}

.help-dialog-body p {
    margin-bottom: 1rem;
    color: #e0e0e0;
}

.help-dialog-body ul {
    margin: 0.5rem 0 1rem 1.5rem;
    color: #e0e0e0;
}

.help-dialog-body li {
    margin-bottom: 0.5rem;
}

.help-dialog-body strong {
    color: #ffd700;
    font-weight: 600;
}

/* Turn Status */
.turn-status {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.turn-status h3 {
    color: #ffd700;
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-message {
    padding: 0.75rem;
    border-radius: 6px;
    font-weight: 500;
    text-align: center;
}

.status-message.can-act {
    background: rgba(40, 167, 69, 0.2);
    border: 1px solid rgba(40, 167, 69, 0.4);
    color: #28a745;
}

.status-message.cannot-act {
    background: rgba(255, 193, 7, 0.2);
    border: 1px solid rgba(255, 193, 7, 0.4);
    color: #ffc107;
}

/* Actions Disabled State */
.actions-disabled {
    text-align: center;
    padding: 2rem;
    background: rgba(255, 193, 7, 0.1);
    border: 2px dashed rgba(255, 193, 7, 0.3);
    border-radius: 8px;
    color: #ffc107;
}

.actions-disabled p {
    margin: 0.5rem 0;
    font-weight: 500;
}

.actions-disabled p:first-child {
    font-size: 1.1rem;
    color: #ffed4e;
}

/* Utilities */
.hidden {
    display: none;
}

.text-center {
    text-align: center;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes toastSlide {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Responsive design */
@media (max-width: 480px) {
    .game-main {
        padding: 0.5rem;
    }
    
    .game-header h1 {
        font-size: 1.25rem;
    }
    
    .help-btn {
        width: 28px;
        height: 28px;
        font-size: 1rem;
    }
    
    .player-status {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .view-header {
        flex-direction: column;
        gap: 0.5rem;
        align-items: stretch;
    }
    
    .nav-btn {
        width: 100%;
    }
    
    .planet-grid {
        gap: 0.25rem;
        max-width: 100%;
    }
    
    .planet-row {
        gap: 0.25rem;
    }
    
    .planet-item {
        max-width: 200px;
    }
    
    .planet-button {
        font-size: 0.8rem;
        padding: 0.5rem;
        line-height: 1.2;
    }
}

@media (max-height: 600px) {
    .game-header {
        padding: 0.5rem;
    }
    
    .game-header h1 {
        font-size: 1.25rem;
    }
    
    .inventory,
    .player-status {
        margin-bottom: 1rem;
    }
}

/* Win Condition Panel */
.win-condition-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(3px);
}

.win-condition-panel.hidden {
    display: none;
}

.win-condition-content {
    background: linear-gradient(135deg, rgba(0, 20, 40, 0.9), rgba(10, 30, 60, 0.9));
    color: white;
    padding: 3rem 2.5rem;
    border-radius: 12px;
    border: 3px solid #ffd700;
    text-align: center;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7), 0 0 20px rgba(255, 215, 0, 0.3);
    animation: winPanelSlide 0.5s ease-out;
}

.win-condition-content h2 {
    font-size: 2.5rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin: 0 0 1.5rem 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.win-condition-content h2.victory {
    color: #ffd700;
}

.win-condition-content h2.defeat {
    color: #ff6b6b;
}

.win-condition-message {
    margin: 2rem 0;
    font-size: 1.1rem;
    line-height: 1.6;
}

.win-condition-message p {
    margin: 1rem 0;
}

.win-condition-buttons {
    margin-top: 2.5rem;
}

.reset-btn {
    background: linear-gradient(135deg, #2c5530, #4a7c59);
    border: 2px solid #6b9b78;
}

.reset-btn:hover {
    background: linear-gradient(135deg, #4a7c59, #6b9b78);
    border-color: #8bb899;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

@keyframes winPanelSlide {
    0% {
        opacity: 0;
        transform: scale(0.8) translateY(-50px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@media (max-width: 768px) {
    .win-condition-content {
        padding: 2rem 1.5rem;
        margin: 1rem;
    }
    
    .win-condition-content h2 {
        font-size: 2rem;
    }
}