/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #0c1445, #1a2980, #26d0ce);
    background-size: 400% 400%;
    /*animation: gradientShift 8s ease infinite;*/
    color: #ffffff;
    min-height: 100vh;
    overflow-x: hidden;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.game-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    gap: 20px;
}

.main-content {
    flex: 1;
    min-width: 0;
}

/* Header Styles */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 20px 30px;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.game-title h1 {
    font-size: 3rem;
    font-weight: bold;
    text-shadow: 0 0 20px #26d0ce;
    background: linear-gradient(45deg, #26d0ce, #ffffff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    /*animation: glow 2s ease-in-out infinite alternate;*/
}

@keyframes glow {
    from { text-shadow: 0 0 20px #26d0ce; }
    to { text-shadow: 0 0 30px #26d0ce, 0 0 40px #26d0ce; }
}

.subtitle {
    font-style: italic;
    opacity: 0.8;
    margin-top: 5px;
}

.epoch-info {
    display: flex;
    gap: 30px;
    align-items: center;
}

.epoch-counter, .escape-threshold {
    text-align: center;
}

.turn-info {
    display: flex;
    gap: 20px;
    align-items: center;
}

.sets-left, .discards-left, .set-size {
    text-align: center;
}

.epoch-info .label {
    display: block;
    font-size: 0.9rem;
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.epoch-info .value {
    display: block;
    font-size: 2rem;
    font-weight: bold;
    color: #26d0ce;
    text-shadow: 0 0 10px #26d0ce;
}

/* Pulsing red effect for sets left */
.pulsing-red {
    animation: pulseRed 1s ease-in-out infinite alternate;
}

@keyframes pulseRed {
    0% { 
        color: #ff6b6b;
        text-shadow: 0 0 10px #ff6b6b;
    }
    100% { 
        color: #ff3030;
        text-shadow: 0 0 20px #ff3030, 0 0 30px #ff3030;
    }
}

/* Game over message */
.game-over-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: linear-gradient(145deg, #722020, #a82828);
    border: 3px solid #ff6b6b;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 10px 30px rgba(255, 107, 107, 0.5);
    animation: gameOverAppear 0.8s ease-in-out;
}

.game-over-message h2 {
    font-size: 3rem;
    color: #ffffff;
    text-shadow: 0 0 20px #ff6b6b;
    margin-bottom: 20px;
    animation: gameOverPulse 2s ease-in-out infinite;
}

.game-over-message p {
    font-size: 1.2rem;
    color: #ffffff;
    opacity: 0.9;
}

@keyframes gameOverAppear {
    0% { 
        opacity: 0; 
        transform: scale(0.8) rotateX(90deg);
    }
    100% { 
        opacity: 1; 
        transform: scale(1) rotateX(0deg);
    }
}

@keyframes gameOverPulse {
    0%, 100% { 
        text-shadow: 0 0 20px #ff6b6b;
    }
    50% { 
        text-shadow: 0 0 30px #ff6b6b, 0 0 40px #ff6b6b;
    }
}

/* Resource Sidebar */
.resource-sidebar {
    height: 72em;
    width: 200px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    /*height: fit-content;*/
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.resource-item {
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
}

.resource-item:hover {
    transform: translateX(5px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
}

.resource-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s;
}

.resource-item:hover::before {
    left: 100%;
}

.resource-icon {
    font-size: 2rem;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.5));
}

.resource-name {
    font-size: 0.8rem;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0;
}

.resource-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #26d0ce;
    margin: 0;
}

.resource-item.food .resource-value { color: #ff6b6b; }
.resource-item.water .resource-value { color: #4ecdc4; }
.resource-item.energy .resource-value { color: #ffe66d; }
.resource-item.population .resource-value { color: #a8e6cf; }
.resource-item.wood .resource-value { color: #cd853f; }

/* Game Actions */
.game-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.action-btn {
    padding: 15px 30px;
    border: none;
    border-radius: 25px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    position: relative;
    overflow: hidden;
}

.action-btn.primary {
    background: linear-gradient(45deg, #26d0ce, #1a2980);
    color: white;
    box-shadow: 0 5px 15px rgba(38, 208, 206, 0.4);
}

.action-btn.secondary {
    background: linear-gradient(45deg, #ff6b6b, #ee5a24);
    color: white;
    box-shadow: 0 5px 15px rgba(255, 107, 107, 0.4);
}

.action-btn.tertiary {
    background: linear-gradient(45deg, #ffa726, #ff8f00);
    color: white;
    box-shadow: 0 5px 15px rgba(255, 167, 38, 0.4);
}

.action-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.selection-counter {
    background: rgba(0, 0, 0, 0.3);
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: bold;
}

/* Play Area */
.play-area-container {
    margin-bottom: 30px;
}

.play-area {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    min-height: 150px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 15px;
    border: 2px solid rgba(38, 208, 206, 0.3);
    position: relative;
    flex-wrap: wrap;
}

.play-area-placeholder {
    color: rgba(255, 255, 255, 0.5);
    font-style: italic;
    text-align: center;
    font-size: 1.1rem;
}

.play-area .card {
    width: 140px;
    height: 168px;
    position: relative;
    transform: scale(0.8);
    overflow: visible;
}

.play-area .card::before {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    border: 2px solid #26d0ce;
    border-radius: 15px;
    /*animation: playAreaGlow 2s ease-in-out infinite alternate;*/
    z-index: -1;
}

@keyframes playAreaGlow {
    from { box-shadow: 0 0 5px #26d0ce; }
    to { box-shadow: 0 0 15px #26d0ce, 0 0 25px #26d0ce; }
}

.play-area .card .play-order {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 25px;
    height: 25px;
    background: linear-gradient(45deg, #ff6b6b, #ee5a24);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9rem;
    color: white;
    border: 2px solid white;
    z-index: 10;
}

/* Card Hand */
.hand-container {
    margin-bottom: 30px;
}

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

.deck-info {
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(0, 0, 0, 0.3);
    padding: 10px 15px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.deck-label {
    font-size: 0.9rem;
    opacity: 0.8;
    color: #ffffff;
}

.deck-size {
    font-size: 1.2rem;
    font-weight: bold;
    color: #26d0ce;
    text-shadow: 0 0 5px #26d0ce;
    min-width: 20px;
    text-align: center;
}

.hand-placeholder {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
    color: rgba(255, 255, 255, 0.5);
    font-style: italic;
    text-align: center;
    font-size: 1.1rem;
}

.section-title {
    font-size: 1.5rem;
    margin-bottom: 20px;
    text-align: center;
    color: #26d0ce;
    text-shadow: 0 0 10px #26d0ce;
}

.hand {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    min-height: 200px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 15px;
    border: 2px dashed rgba(255, 255, 255, 0.3);
}

.card {
    width: 180px;
    height: auto;
    background: linear-gradient(145deg, #1e3c72, #2a5298);
    border-radius: 15px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.card:hover {
    transform: translateY(-10px) scale(1.05);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.5);
}

.card.selected {
    border-color: #26d0ce;
    box-shadow: 0 0 20px #26d0ce, 0 15px 30px rgba(0, 0, 0, 0.5);
    transform: translateY(-5px);
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.card:hover::before {
    opacity: 1;
}

.card-header {
    text-align: center;
    margin-bottom: 15px;
}

.card-name {
    font-size: 1.1rem;
    font-weight: bold;
    color: #ffffff;
    margin-bottom: 5px;
}

.card-image {
    font-size: 2rem;
    margin-bottom: 10px;
}

.card-description {
    font-size: 0.8rem;
    opacity: 0.8;
    margin-bottom: 15px;
    line-height: 1.3;
}

.card-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.card-stat {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
}

.stat-label {
    opacity: 0.7;
}

.stat-value {
    font-weight: bold;
}

.stat-value.consumes { color: #ff6b6b; }
.stat-value.produces { color: #a8e6cf; }

.card-activations {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: #26d0ce;
    padding: 4px 8px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: bold;
    border: 1px solid #26d0ce;
    text-shadow: 0 0 5px #26d0ce;
    z-index: 10;
}

.card-activations.clickable {
    cursor: pointer;
    transition: all 0.2s ease;
}

.card-activations.clickable:hover {
    background: rgba(38, 208, 206, 0.2);
    border-color: #ffffff;
    color: #ffffff;
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(38, 208, 206, 0.5);
}

/* Compact card stats for play area */
.card-stats-compact {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: bold;
    margin-top: 10px;
}

.card-stats-compact .arrow {
    color: #26d0ce;
    font-size: 1.2rem;
    font-weight: bold;
}

/* Game Status */
.game-status {
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.status-message {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.loading-overlay.show {
    opacity: 1;
    visibility: visible;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid #26d0ce;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

.loading-text {
    font-size: 1.2rem;
    color: #26d0ce;
}

/* Error Message Styles */
.error-message {
    display: none;
    background: linear-gradient(145deg, #722020, #a82828);
    border: 2px solid #ff6b6b;
    border-radius: 10px;
    padding: 15px;
    margin: 15px 0;
    box-shadow: 0 5px 15px rgba(255, 107, 107, 0.4);
    animation: errorPulse 0.5s ease-in-out;
}

.error-message .error-icon {
    font-size: 1.5rem;
    display: inline-block;
    margin-right: 10px;
}

.error-message .error-text {
    font-weight: bold;
    color: #ffffff;
    display: inline-block;
    vertical-align: middle;
}

@keyframes errorPulse {
    0% { transform: scale(0.95); opacity: 0; }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); opacity: 1; }
}

/* Failed Card Highlighting */
.card.failed {
    border-color: #ff6b6b !important;
    box-shadow: 0 0 20px #ff6b6b, 0 15px 30px rgba(255, 107, 107, 0.5) !important;
    animation: failedCardShake 0.5s ease-in-out;
}

.card.failed::before {
    background: linear-gradient(45deg, transparent, rgba(255, 107, 107, 0.3), transparent) !important;
    opacity: 1 !important;
}

@keyframes failedCardShake {
    0%, 100% { transform: translateX(0) scale(0.8); }
    25% { transform: translateX(-5px) scale(0.8); }
    75% { transform: translateX(5px) scale(0.8); }
}

/* Resource Changes Display */
.resource-changes-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 15px;
    border: 2px solid #26d0ce;
    animation: resourceChangesAppear 0.5s ease-in-out;
}

.resource-changes-title {
    font-size: 1.5rem;
    font-weight: bold;
    color: #26d0ce;
    text-shadow: 0 0 10px #26d0ce;
    text-align: center;
}

.resource-changes-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
}

.resource-change-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    min-width: 200px;
    animation: resourceChangeItemAppear 0.3s ease-in-out;
}

.epoch-change-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(145deg, #1a2980, #26d0ce);
    padding: 15px;
    border-radius: 10px;
    border: 2px solid #26d0ce;
    min-width: 250px;
    animation: epochChangeAppear 0.5s ease-in-out;
    box-shadow: 0 5px 20px rgba(38, 208, 206, 0.4);
}

@keyframes epochChangeAppear {
    0% { 
        opacity: 0; 
        transform: translateY(-20px) scale(0.8);
        box-shadow: 0 0 0 rgba(38, 208, 206, 0);
    }
    50% {
        transform: translateY(-10px) scale(1.05);
        box-shadow: 0 10px 30px rgba(38, 208, 206, 0.6);
    }
    100% { 
        opacity: 1; 
        transform: translateY(0) scale(1);
        box-shadow: 0 5px 20px rgba(38, 208, 206, 0.4);
    }
}

.resource-change-icon {
    font-size: 2rem;
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.5));
}

.epoch-change-icon {
    font-size: 2.5rem;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.8));
    animation: epochIconPulse 2s ease-in-out infinite;
}

@keyframes epochIconPulse {
    0%, 100% { 
        transform: scale(1);
        filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.8));
    }
    50% { 
        transform: scale(1.1);
        filter: drop-shadow(0 0 15px rgba(255, 255, 255, 1));
    }
}

.epoch-change-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.epoch-change-name {
    font-size: 1.1rem;
    font-weight: bold;
    color: #ffffff;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

.epoch-change-values {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.epoch-change-delta {
    font-size: 1rem;
    font-weight: bold;
    text-align: center;
    color: #ffffff;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

.resource-change-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.resource-change-name {
    font-size: 1rem;
    font-weight: bold;
    color: #ffffff;
}

.resource-change-values {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.previous-value {
    color: rgba(255, 255, 255, 0.7);
}

.change-arrow {
    color: #26d0ce;
    font-weight: bold;
}

.current-value {
    color: #ffffff;
    font-weight: bold;
}

.resource-change-delta {
    font-size: 1.1rem;
    font-weight: bold;
    text-align: center;
}

.resource-change-delta.positive {
    color: #a8e6cf;
}

.resource-change-delta.negative {
    color: #ff6b6b;
}

.clear-changes-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 20px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    background: linear-gradient(45deg, #26d0ce, #1a2980);
    color: white;
    box-shadow: 0 5px 15px rgba(38, 208, 206, 0.4);
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.clear-changes-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(38, 208, 206, 0.6);
}

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

@keyframes resourceChangeItemAppear {
    0% { opacity: 0; transform: translateY(10px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .game-container {
        flex-direction: column;
    }
    
    .resource-sidebar {
        width: 100%;
        flex-direction: row;
        gap: 10px;
        overflow-x: auto;
        padding: 15px;
    }
    
    .resource-item {
        flex-shrink: 0;
        min-width: 120px;
    }
    
    .game-header {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }
    
    .game-title h1 {
        font-size: 2rem;
    }
    
    .hand-header {
        flex-direction: column;
        gap: 15px;
        align-items: center;
    }
    
    .deck-info {
        padding: 8px 12px;
        font-size: 0.9rem;
    }
    
    .deck-size {
        font-size: 1.1rem;
    }
    
    .hand {
        gap: 10px;
    }
    
    .card {
        width: 160px;
        height: 220px;
    }
    
    .game-actions {
        flex-direction: column;
    }
    
    .error-message {
        font-size: 0.9rem;
        padding: 12px;
    }
    
    .resource-changes-container {
        padding: 15px;
        gap: 15px;
    }
    
    .resource-changes-title {
        font-size: 1.2rem;
    }
    
    .resource-changes-grid {
        gap: 10px;
    }
    
    .resource-change-item {
        min-width: 180px;
        padding: 12px;
        font-size: 0.9rem;
    }
    
    .resource-change-icon {
        font-size: 1.5rem;
    }
    
    .clear-changes-btn {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
}

/* Resource icon tooltip styles */
.resource-icon-tooltip {
    display: inline-block;
    cursor: help;
    position: relative;
}