/* style.css - Main styles for the Civilization Card Roguelike Game */
body {
    margin: 0;
    font-family: 'Microsoft YaHei', 'Arial', sans-serif;
    background: #222;
    color: #fff;
    overflow-x: hidden;
}

/* Mobile detection and responsive layout */
.mobile-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.desktop-layout {
    display: flex;
    flex-direction: row;
    height: 100vh;
    width: 100vw;
}

#game-container {
    display: flex;
    flex-direction: row;
    height: 100vh;
    width: 100vw;
}
#left-panel, #right-panel {
    width: 22vw;
    min-width: 220px;
    background: rgba(30,30,40,0.95);
    padding: 20px;
    box-sizing: border-box;
    overflow-y: auto;
    display: block; /* Default display for desktop */
}

/* Mobile collapsible panels */
.mobile-summary-bar {
    display: none;
    background: rgba(30,30,40,0.95);
    padding: 10px 15px;
    border-bottom: 1px solid #444;
    cursor: pointer;
    user-select: none;
}

.mobile-summary-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9em;
}

.mobile-summary-toggle {
    font-size: 1.2em;
    transition: transform 0.3s ease;
}

.mobile-summary-toggle.expanded {
    transform: rotate(180deg);
}

.mobile-panel-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: rgba(30,30,40,0.95);
}

.mobile-panel-content.expanded {
    max-height: 300px;
    padding: 15px;
}
#center-panel {
    flex: 1;
    background: #333;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding: 20px;
    box-sizing: border-box;
    overflow-y: auto;
    min-width: 0; /* Prevent flex item from overflowing */
}

#center-panel h2 {
    text-align: center;
    margin-bottom: 10px;
}

#center-panel p {
    text-align: center;
    margin-bottom: 20px;
}

/* Ensure event cards use full width on desktop */
#event-cards {
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    gap: 20px;
    margin: 20px 0;
    width: 100%;
    max-width: none;
}

/* Desktop specific styles */
@media (min-width: 901px) {
    #left-panel, #right-panel {
        display: block !important; /* Force show on desktop */
    }
    
    .mobile-summary-bar {
        display: none !important; /* Hide mobile bars on desktop */
    }
    
    .mobile-panel-content {
        display: none !important; /* Hide mobile content on desktop */
    }
}
/* Event cards styling with responsive improvements */
.event-card {
    background: #444;
    border-radius: 12px;
    box-shadow: 0 2px 8px #0006;
    padding: 18px 16px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 2px solid transparent;
    font-size: 1.1em;
    flex: 1; /* Take equal space */
    min-width: 200px;
    max-width: 300px;
}

.event-card.selected {
    border-color: #ffd700;
    background: #555;
    transform: scale(1.05);
}

/* Action options styling */
#action-options {
    display: flex;
    flex-direction: row;
    gap: 16px;
    margin: 18px 0;
    justify-content: center;
    flex-wrap: wrap;
}
.action-btn {
    background: #2e8b57;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 0.95em;
    cursor: pointer;
    transition: background 0.2s;
    text-align: left;
    line-height: 1.3;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    margin-bottom: 8px;
    flex: 1;
    min-width: 180px;
    max-width: 250px;
}
.action-btn.selected {
    background: #ffd700;
    color: #222;
}
.action-btn:hover {
    background: #3aa76d;
}
.action-btn.selected:hover {
    background: #ffed4a;
}
.action-btn.unaffordable {
    background: #666;
    cursor: not-allowed;
    opacity: 0.6;
}
.action-btn.unaffordable:hover {
    background: #666;
}
.action-desc {
    font-size: 0.85em;
    margin: 4px 0;
    color: #ddd;
}
.action-costs {
    font-size: 0.8em;
    color: #ff9999;
    margin: 2px 0;
}
.action-effects {
    font-size: 0.8em;
    color: #99ff99;
    margin: 2px 0;
}
.action-investment {
    font-size: 0.8em;
    color: #f39c12;
    margin: 2px 0;
    background: rgba(243, 156, 18, 0.1);
    padding: 4px 6px;
    border-radius: 4px;
    border-left: 2px solid #f39c12;
}
button {
    background: #1e90ff;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 18px;
    font-size: 1em;
    margin: 10px auto;
    cursor: pointer;
    transition: background 0.2s;
    display: block;
    max-width: 300px;
}

button:disabled {
    background: #888;
    cursor: not-allowed;
}
/* Resource display styles */
.resource-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px;
    margin: 2px 0;
    border-radius: 4px;
    transition: background-color 0.3s;
}
.resource-item.critical {
    background-color: rgba(244, 67, 54, 0.2);
    border-left: 3px solid #f44336;
}
.resource-item.warning {
    background-color: rgba(255, 152, 0, 0.2);
    border-left: 3px solid #ff9800;
}
.resource-item.good {
    background-color: rgba(76, 175, 80, 0.2);
    border-left: 3px solid #4caf50;
}
.resource-name {
    font-weight: bold;
}
.resource-value {
    font-size: 1.1em;
    font-weight: bold;
}

/* Stage display styles */
.stage-name {
    font-size: 1.2em;
    font-weight: bold;
    margin-bottom: 8px;
    text-align: center;
}
.stage-progress {
    margin-top: 8px;
}
.progress-bar {
    width: 100%;
    height: 8px;
    background-color: #333;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 4px;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4caf50, #8bc34a);
    transition: width 0.5s ease;
}
.next-stage {
    font-size: 0.8em;
    color: #ccc;
    text-align: center;
}
.final-stage {
    color: #ffd700;
    text-align: center;
    font-weight: bold;
}

/* Event log styles */
.log-entry {
    padding: 4px 0;
    border-bottom: 1px solid #333;
    line-height: 1.4;
}
.log-entry.latest {
    color: #ffd700;
    font-weight: bold;
}

/* Event card effects display */
.effects {
    font-size: 0.85em;
    color: #ccc;
    margin-top: 6px;
    padding: 4px 6px;
    background-color: rgba(0,0,0,0.3);
    border-radius: 4px;
}

/* Game over screen styles */
.game-over-screen {
    text-align: center;
    padding: 20px;
    max-width: 500px;
    margin: 0 auto;
}
.final-stats, .legacy-info {
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
    padding: 16px;
    margin: 16px 0;
    text-align: left;
}
.stat-item, .legacy-item {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px solid #333;
}
.stat-item:last-child, .legacy-item:last-child {
    border-bottom: none;
}
.restart-button {
    background: #4caf50;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-size: 1.1em;
    cursor: pointer;
    margin-top: 20px;
    transition: background 0.3s;
}
.restart-button:hover {
    background: #45a049;
}

/* Start location selection styles */
#start-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 16px;
    margin: 20px 0;
    max-width: 800px;
    width: 100%;
}
.start-location-card {
    background: rgba(255,255,255,0.1);
    border: 2px solid transparent;
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.3s;
}
.start-location-card:hover {
    background: rgba(255,255,255,0.15);
    border-color: #1e90ff;
}
.start-location-card.selected {
    border-color: #ffd700;
    background: rgba(255,215,0,0.1);
}
.start-location-card h3 {
    margin: 0 0 8px 0;
    color: #ffd700;
}
.start-desc {
    font-size: 0.85em;
    color: #ccc;
    margin: 0 0 8px 0;
    font-style: italic;
}
.start-resources {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
    font-size: 0.9em;
}
.start-resource {
    padding: 2px 0;
}
.legacy-display {
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
    padding: 12px;
    margin: 16px 0;
    font-size: 0.9em;
}
.legacy-display h3 {
    margin: 0 0 8px 0;
    color: #ffd700;
}

/* Help screen styles */
.help-screen {
    text-align: left;
    padding: 20px;
    max-width: 700px;
    margin: 0 auto;
    max-height: 90vh;
    overflow-y: auto;
}
.help-screen h2 {
    text-align: center;
    margin-bottom: 20px;
    color: #ffd700;
    font-size: 1.5em;
}
.help-section {
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
    padding: 16px;
    margin: 12px 0;
}
.help-section h3 {
    margin: 0 0 12px 0;
    color: #ffd700;
    font-size: 1.2em;
}
.help-section p, .help-section ol {
    margin: 8px 0;
    line-height: 1.5;
}
.help-section ol {
    padding-left: 20px;
}

/* New detailed help styles */
.help-expandable {
    margin-top: 8px;
    padding: 6px 12px;
    background: rgba(255, 215, 0, 0.1);
    border-radius: 4px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.help-expandable:hover {
    background: rgba(255, 215, 0, 0.2);
}

.expand-text {
    color: #ffd700;
    font-size: 0.9em;
    font-weight: bold;
}

.help-details {
    margin-top: 10px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    border-left: 3px solid #ffd700;
}

.resource-guide, .stage-guide, .action-guide, .strategy-guide, .legacy-guide, .warning-guide {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

.resource-guide div, .stage-guide div, .action-guide div, .strategy-guide div, .legacy-guide div, .warning-guide div {
    background: rgba(255,255,255,0.1);
    padding: 8px 12px;
    border-radius: 4px;
    border-left: 3px solid #4caf50;
    font-size: 0.95em;
}

.resource-guide div {
    border-left-color: #2196f3;
}

.stage-guide div {
    border-left-color: #ff9800;
}

.action-guide div {
    border-left-color: #9c27b0;
}

.strategy-guide div {
    border-left-color: #f44336;
}

.legacy-guide div {
    border-left-color: #ffd700;
}

.warning-guide div {
    border-left-color: #f44336;
    background: rgba(244, 67, 54, 0.1);
}

.resource-guide div strong, .stage-guide div strong, .action-guide div strong, 
.strategy-guide div strong, .legacy-guide div strong, .warning-guide div strong {
    color: #ffd700;
}

/* Mobile responsive for help */
@media (max-width: 900px) {
    .help-screen {
        padding: 15px;
        max-width: 100%;
    }
    
    .help-section {
        padding: 12px;
    }
    
    .help-expandable {
        padding: 5px 10px;
    }
    
    .expand-text {
        font-size: 0.85em;
    }
    
    .help-details {
        padding: 8px;
    }
    
    .resource-guide div, .stage-guide div, .action-guide div, .strategy-guide div, .legacy-guide div, .warning-guide div {
        padding: 6px 10px;
        font-size: 0.9em;
    }
}

#event-log {
    font-size: 0.98em;
    line-height: 1.6;
    max-height: 80vh;
    overflow-y: auto;
}
/* Civilization stage backgrounds */
body.stage-tribe { background: linear-gradient(120deg, #4e342e 60%, #607d8b 100%); }
body.stage-agriculture { background: linear-gradient(120deg, #8bc34a 60%, #cddc39 100%); }
body.stage-city { background: linear-gradient(120deg, #ffb300 60%, #ff7043 100%); }
body.stage-empire { background: linear-gradient(120deg, #b71c1c 60%, #fbc02d 100%); }
body.stage-industrial { background: linear-gradient(120deg, #607d8b 60%, #90caf9 100%); }
body.stage-info { background: linear-gradient(120deg, #00bcd4 60%, #8e24aa 100%); }
body.stage-stellar { background: linear-gradient(120deg, #212121 60%, #00e676 100%); }
/* Desktop layout - show side panels */
@media (min-width: 901px) {
    #left-panel, #right-panel {
        display: block !important; /* Force show on desktop */
        width: 22vw;
        min-width: 220px;
        background: rgba(30,30,40,0.95);
        padding: 20px;
        box-sizing: border-box;
        overflow-y: auto;
    }
    
    .mobile-summary-bar {
        display: none !important; /* Hide mobile bars on desktop */
    }
    
    .mobile-panel-content {
        display: none !important; /* Hide mobile content on desktop */
    }
    
    #center-panel {
        align-items: stretch; /* Full width content on desktop */
        padding: 30px 40px; /* More padding on desktop */
    }
    
    #event-cards {
        justify-content: space-around; /* Better distribution on desktop */
        gap: 30px;
    }
    
    .event-card {
        flex: 1;
        max-width: 280px;
        min-width: 200px;
    }
    
    #action-options {
        justify-content: center;
        gap: 20px;
        flex-wrap: wrap;
    }
    
    .action-btn {
        flex: 1;
        max-width: 240px;
        min-width: 180px;
    }
}

/* Mobile layout */
@media (max-width: 900px) {
    #game-container {
        flex-direction: column;
    }
    
    #left-panel, #right-panel {
        display: none !important; /* Hide desktop panels on mobile */
    }
    
    .mobile-summary-bar {
        display: block !important;
    }
    
    .mobile-panel-content {
        display: block !important;
    }
    
    #center-panel {
        flex: 1;
        padding: 10px;
        order: 3; /* Center panel goes last for main content focus */
        align-items: center; /* Center content on mobile */
    }
    
    .mobile-resource-summary {
        order: 1;
    }
    
    .mobile-log-summary {
        order: 2;
    }
    
    #event-cards {
        flex-direction: column;
        gap: 12px;
    }
    
    .event-card {
        margin: 0;
        font-size: 1em;
        max-width: none;
    }
    
    #action-options {
        flex-direction: column;
        gap: 10px;
    }
    
    .action-btn {
        margin: 5px 0;
        padding: 12px;
        font-size: 1em;
        max-width: none;
    }
    
    #start-options {
        display: flex;
        flex-direction: column;
        gap: 15px;
        grid-template-columns: none;
        grid-template-rows: none;
    }
    
    .start-location-card {
        margin: 0;
    }
}

/* Stage requirements display styles */
.stage-requirements {
    background: rgba(52, 73, 94, 0.1);
    padding: 10px;
    border-radius: 6px;
    border-left: 4px solid #3498db;
    margin-top: 10px;
}

.next-stage {
    font-weight: bold;
    margin-bottom: 8px;
    color: #34495e;
}

.req-list {
    font-size: 0.9em;
    line-height: 1.4;
    color: #2c3e50;
}

.req-list span {
    margin-right: 10px;
}

/* Turn Summary Styles */
.turn-summary {
    text-align: center;
    padding: 20px;
    max-width: 600px;
    margin: 0 auto;
}

.action-taken {
    background: rgba(40, 60, 80, 0.8);
    border-radius: 10px;
    padding: 20px;
    margin: 20px 0;
}

.action-summary {
    margin: 10px 0;
}

.action-summary strong {
    color: #4fc3f7;
    font-size: 1.2em;
}

.resource-changes {
    background: rgba(50, 70, 50, 0.8);
    border-radius: 10px;
    padding: 20px;
    margin: 20px 0;
}

.resource-changes ul {
    list-style: none;
    padding: 0;
    margin: 10px 0;
}

.resource-changes li {
    padding: 5px 0;
    font-size: 1.1em;
}

.resource-cost {
    color: #ff6b6b;
}

.resource-gain {
    color: #51cf66;
}

.turn-summary-actions {
    margin: 30px 0 20px 0;
}

.next-turn-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 8px;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s ease;
}

.next-turn-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

/* Civilization Advancement Notification */
.civilization-advancement {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.5s ease-in;
}

.advancement-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 40px 60px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    animation: slideIn 0.7s ease-out;
    max-width: 80%;
}

.advancement-title {
    font-size: 2.5em;
    font-weight: bold;
    color: #fff;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.advancement-stage {
    font-size: 3em;
    font-weight: bold;
    color: #ffd700;
    margin: 20px 0;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.7);
    animation: glow 2s ease-in-out infinite alternate;
}

.advancement-description {
    font-size: 1.3em;
    color: #e8eaf6;
    margin: 20px 0;
    line-height: 1.4;
}

.advancement-button {
    background: linear-gradient(135deg, #ffd700 0%, #ffb300 100%);
    color: #333;
    border: none;
    padding: 15px 30px;
    border-radius: 10px;
    font-size: 1.2em;
    font-weight: bold;
    cursor: pointer;
    margin-top: 30px;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(255, 215, 0, 0.3);
}

.advancement-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 215, 0, 0.5);
}

/* Stellar Challenge Styles */
.stellar-challenge {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border: 2px solid #ffd700;
    border-radius: 15px;
    padding: 20px;
    margin: 20px 0;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

.stellar-challenge h3 {
    color: #ffd700;
    margin: 0 0 15px 0;
    text-align: center;
    font-size: 1.4em;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.victory-requirements {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
    margin: 15px 0;
}

.victory-requirements div {
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: 8px;
    padding: 8px 12px;
    text-align: center;
    font-weight: bold;
    color: #ffd700;
    font-size: 0.9em;
}

.stellar-challenge p {
    text-align: center;
    color: #ccc;
    margin: 15px 0 5px 0;
    line-height: 1.4;
}

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

@keyframes slideIn {
    from { 
        opacity: 0;
        transform: translateY(-50px) scale(0.8);
    }
    to { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes glow {
    from { 
        text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.7), 0 0 20px rgba(255, 215, 0, 0.3);
    }
    to { 
        text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.7), 0 0 30px rgba(255, 215, 0, 0.6);
    }
}

/* Mobile responsive for advancement notification */
@media (max-width: 900px) {
    .advancement-content {
        padding: 30px 40px;
        margin: 20px;
    }
    
    .advancement-title {
        font-size: 2em;
    }
    
    .advancement-stage {
        font-size: 2.2em;
    }
    
    .advancement-description {
        font-size: 1.1em;
    }
    
    .stellar-challenge {
        padding: 15px;
        margin: 15px 0;
    }
    
    .stellar-challenge h3 {
        font-size: 1.2em;
    }
    
    .victory-requirements {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 8px;
    }
    
    .victory-requirements div {
        padding: 6px 8px;
        font-size: 0.8em;
    }
}

/* Pre-game state styles */
.no-game {
    text-align: center;
    color: #7f8c8d;
    font-style: italic;
    padding: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    margin: 10px 0;
}

/* Continue game interface */
.continue-game {
    text-align: center;
    padding: 40px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    margin: 20px;
    border: 2px solid #3498db;
}

.continue-game h2 {
    color: #3498db;
    margin-bottom: 20px;
    font-size: 2em;
}

.game-status {
    margin: 30px 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.status-item {
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #3498db;
    font-size: 1.1em;
    font-weight: bold;
}

.secondary-button {
    background: rgba(108, 117, 125, 0.8);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    margin: 10px;
    transition: all 0.3s ease;
}

.secondary-button:hover {
    background: rgba(108, 117, 125, 1);
    transform: translateY(-2px);
}

/* Mobile responsive for continue game */
@media (max-width: 900px) {
    .continue-game {
        margin: 10px;
        padding: 20px;
    }
    
    .continue-game h2 {
        font-size: 1.5em;
    }
    
    .game-status {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .status-item {
        padding: 10px;
        font-size: 1em;
    }
}

/* Investment tracking styles */
.investments-section {
    margin-top: 20px;
    padding: 15px;
    background: rgba(52, 152, 219, 0.1);
    border-radius: 8px;
    border-left: 4px solid #3498db;
}

.investments-section h3 {
    margin: 0 0 15px 0;
    color: #3498db;
    font-size: 1.1em;
}

.investments-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.investment-item {
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 6px;
    border-left: 3px solid #f39c12;
}

.investment-name {
    font-weight: bold;
    color: #f39c12;
    margin-bottom: 5px;
    font-size: 0.9em;
}

.investment-details {
    font-size: 0.8em;
    color: #bdc3c7;
}

.investment-time {
    color: #e74c3c;
    font-weight: bold;
    margin-bottom: 2px;
}

.investment-returns {
    color: #27ae60;
}

/* Mobile responsive for investments */
@media (max-width: 900px) {
    .investments-section {
        margin-top: 10px;
        padding: 10px;
    }
    
    .investments-section h3 {
        font-size: 1em;
        margin-bottom: 10px;
    }
    
    .investment-item {
        padding: 8px;
    }
    
    .investment-name {
        font-size: 0.85em;
    }
    
    .investment-details {
        font-size: 0.75em;
    }
}
