/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Old Standard TT', serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    color: #e8e8e8;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Game Container */
.game-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 5px;
    min-height: 100vh;
}

/* Header */
.game-header {
    text-align: center;
    margin-bottom: 8px;
    padding: 5px;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid #8b4513;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(139, 69, 19, 0.3);
}

.game-header h1 {
    font-family: 'Cinzel', serif;
    font-size: 1.4rem;
    font-weight: 700;
    color: #d4af37;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    margin-bottom: 5px;
}

.game-header h1 .subtitle {
    font-size: 0.8rem;
    font-weight: 400;
    color: #b8860b;
}

.game-info {
    display: flex;
    justify-content: center;
    gap: 15px;
    font-size: 0.85rem;
    font-weight: 600;
}

.vp-counter, .actions-counter {
    background: rgba(139, 69, 19, 0.2);
    padding: 3px 10px;
    border-radius: 5px;
    border: 1px solid #8b4513;
}

.best-score-counter {
    background: rgba(139, 69, 19, 0.2);
    padding: 3px 10px;
    border-radius: 5px;
    border: 1px solid #8b4513;
}

.most-monsters-counter {
    background: rgba(139, 69, 19, 0.2);
    padding: 3px 10px;
    border-radius: 5px;
    border: 1px solid #8b4513;
}

.how-to-play-btn {
    background: rgba(212, 175, 55, 0.2);
    color: #d4af37;
    border: 1px solid #d4af37;
    padding: 5px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-family: 'Old Standard TT', serif;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.how-to-play-btn:hover {
    background: rgba(212, 175, 55, 0.3);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.4);
    transform: translateY(-1px);
}

/* Party Status */
.party-status {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-top: 5px;
    flex-wrap: wrap;
}

/* Header Inventory */
.header-inventory {
    margin-top: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.header-inventory .resources {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.header-inventory .resources .resource-item {
    display: flex;
    align-items: center;
    gap: 3px;
    background: rgba(139, 69, 19, 0.1);
    padding: 3px 8px;
    border-radius: 3px;
    border: 1px solid #8b4513;
    font-size: 0.75rem;
    min-width: 80px;
}

.header-inventory .settlements {
    display: flex;
    justify-content: center;
}

.header-inventory .settlements .settlement-item {
    display: flex;
    align-items: center;
    gap: 3px;
    background: rgba(139, 69, 19, 0.1);
    padding: 3px 8px;
    border-radius: 3px;
    border: 1px solid #8b4513;
    font-size: 0.75rem;
    min-width: 120px;
}

.character-portrait {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid #8b4513;
    border-radius: 5px;
    padding: 3px 6px;
    text-align: center;
    min-width: 65px;
    transition: all 0.3s ease;
}

.character-portrait.alive {
    border-color: #27ae60;
    background: rgba(39, 174, 96, 0.1);
}

.character-portrait.dead {
    border-color: #e74c3c;
    background: rgba(231, 76, 60, 0.2);
    opacity: 0.6;
}

.portrait-name {
    font-weight: 600;
    margin-bottom: 2px;
    font-size: 0.65rem;
}

.portrait-status {
    font-size: 1rem;
}

/* Game Board */
.game-board {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto;
    gap: 5px;
    margin-bottom: 5px;
}

/* Resource Market */
.resource-market {
    grid-column: 1 / 3;
    background: rgba(0, 0, 0, 0.4);
    padding: 5px;
    border-radius: 8px;
    border: 2px solid #8b4513;
}

.resource-market h2 {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    color: #d4af37;
    margin-bottom: 5px;
    text-align: center;
}

.market-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
}

.resource-card {
    background: linear-gradient(145deg, #2c3e50, #34495e);
    border: 2px solid #8b4513;
    border-radius: 5px;
    padding: 5px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    font-size: 0.8rem;
}

.resource-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(212, 175, 55, 0.3);
    border-color: #d4af37;
}

.resource-card.selected {
    border-color: #d4af37;
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.5);
}

.resource-card .card-resources {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
}

.resource-icon {
    font-size: 1.5rem;
}

.resource-card .card-bonus {
    font-size: 0.9rem;
    color: #d4af37;
    font-weight: 600;
}

/* Action Area */
.action-area {
    background: rgba(0, 0, 0, 0.4);
    padding: 5px;
    border-radius: 8px;
    border: 2px solid #8b4513;
}

.action-area h2 {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    color: #d4af37;
    margin-bottom: 5px;
    text-align: center;
}

.actions-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
}

.action-btn {
    background: linear-gradient(145deg, #2c3e50, #34495e);
    border: 2px solid #8b4513;
    border-radius: 5px;
    padding: 5px;
    color: #e8e8e8;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.action-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(212, 175, 55, 0.3);
    border-color: #d4af37;
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.action-btn.character-dead-action {
    border-color: #e74c3c;
    opacity: 0.3;
}

.action-risk {
    font-size: 0.6rem;
    color: #e74c3c;
    font-weight: 600;
}

.action-icon {
    font-size: 1.2rem;
}

.action-name {
    font-weight: 600;
    font-size: 0.85rem;
}

.action-cost {
    font-size: 0.65rem;
    color: #bdc3c7;
}

.action-effect {
    font-size: 0.65rem;
    color: #d4af37;
    font-weight: 600;
}

/* Character Tracks */
.character-tracks {
    grid-column: 1 / 3;
    background: rgba(0, 0, 0, 0.4);
    padding: 5px;
    border-radius: 8px;
    border: 2px solid #8b4513;
}

.character-tracks h2 {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    color: #d4af37;
    margin-bottom: 5px;
    text-align: center;
}

.tracks-container {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
}

.character-track {
    background: rgba(139, 69, 19, 0.1);
    border: 1px solid #8b4513;
    border-radius: 5px;
    padding: 5px;
    text-align: center;
    transition: all 0.3s ease;
}

.character-track.character-dead {
    background: rgba(231, 76, 60, 0.2);
    border-color: #e74c3c;
    opacity: 0.6;
}

.character-info {
    margin-bottom: 3px;
}

.character-name {
    font-weight: 600;
    color: #d4af37;
    margin-bottom: 2px;
    font-size: 0.75rem;
}

.character-ability {
    font-size: 0.6rem;
    color: #bdc3c7;
    font-style: italic;
    transition: all 0.3s ease;
}

.character-ability.ability-active {
    color: #d4af37;
    font-weight: bold;
    text-shadow: 0 0 8px rgba(212, 175, 55, 0.6);
    background: rgba(212, 175, 55, 0.1);
    padding: 2px 4px;
    border-radius: 3px;
    border: 1px solid rgba(212, 175, 55, 0.3);
}

.track-levels {
    display: flex;
    justify-content: center;
    gap: 2px;
    margin: 5px 0;
}

.track-level {
    width: 20px;
    height: 20px;
    border: 1px solid #8b4513;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.7rem;
    background: rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.track-level.active {
    background: #d4af37;
    color: #1a1a2e;
    border-color: #d4af37;
}

.advance-track-btn {
    background: linear-gradient(145deg, #2c3e50, #34495e);
    border: 1px solid #8b4513;
    border-radius: 3px;
    padding: 3px 5px;
    color: #e8e8e8;
    cursor: pointer;
    font-size: 0.6rem;
    transition: all 0.3s ease;
}

.advance-track-btn:hover:not(:disabled) {
    background: linear-gradient(145deg, #34495e, #2c3e50);
    border-color: #d4af37;
}

.advance-track-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.advance-track-btn.affordable {
    color: #90EE90;
    font-weight: 700;
    text-shadow: 0 0 8px rgba(144, 238, 144, 0.6);
}

/* Player Inventory */
.player-inventory {
    background: rgba(0, 0, 0, 0.4);
    padding: 5px;
    border-radius: 8px;
    border: 2px solid #8b4513;
}

.player-inventory h2 {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    color: #d4af37;
    margin-bottom: 5px;
    text-align: center;
}

.resources {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 3px;
    margin-bottom: 5px;
}

.resource-item {
    display: flex;
    align-items: center;
    gap: 3px;
    background: rgba(139, 69, 19, 0.1);
    padding: 3px 5px;
    border-radius: 3px;
    border: 1px solid #8b4513;
    font-size: 0.75rem;
}

.resource-icon {
    font-size: 1.2rem;
    font-weight: bold;
    color: #d4af37;
    background: rgba(212, 175, 55, 0.2);
    border: 1px solid #d4af37;
    border-radius: 3px;
    padding: 2px 6px;
    margin-right: 8px;
}

.resource-name {
    font-weight: 600;
}

.resource-count {
    font-weight: 700;
    color: #d4af37;
    margin-left: auto;
}

.settlements {
    text-align: center;
}

.settlement-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: rgba(139, 69, 19, 0.1);
    padding: 3px 5px;
    border-radius: 3px;
    border: 1px solid #8b4513;
    font-size: 0.75rem;
}

.settlement-icon {
    font-size: 1.2rem;
}

.settlement-name {
    font-weight: 600;
}

.settlement-count {
    font-weight: 700;
    color: #d4af37;
}

/* Objectives */
.objectives {
    grid-column: 1 / 3;
    background: rgba(0, 0, 0, 0.4);
    padding: 5px;
    border-radius: 8px;
    border: 2px solid #8b4513;
}

.objectives h2 {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    color: #d4af37;
    margin-bottom: 5px;
    text-align: center;
}

.objectives-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
}

.objective-card {
    background: linear-gradient(145deg, #2c3e50, #34495e);
    border: 2px solid #8b4513;
    border-radius: 5px;
    padding: 5px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    font-size: 0.75rem;
}

.objective-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(212, 175, 55, 0.3);
    border-color: #d4af37;
}

.objective-card.completed {
    background: linear-gradient(145deg, #27ae60, #2ecc71);
    border-color: #27ae60;
    opacity: 0.7;
}

.objective-card .objective-text {
    font-weight: 600;
    margin-bottom: 8px;
}

.objective-card .objective-vp {
    font-size: 1.2rem;
    font-weight: 700;
    color: #d4af37;
}

/* Game Messages */
.game-messages {
    position: fixed;
    top: 20px;
    right: 20px;
    max-width: 300px;
    z-index: 1000;
}

/* Mobile adjustments for message box */
@media (max-width: 768px) {
    .game-messages {
        top: 10px; /* Position at very top of screen on mobile */
        right: 10px;
        left: 10px;
        max-width: none;
        z-index: 1001; /* Ensure it's above other content */
    }
    
    .message {
        font-size: 0.9rem; /* Slightly smaller text for mobile */
        padding: 12px; /* Slightly less padding for mobile */
        margin-bottom: 8px; /* Tighter spacing */
    }
}

.message {
    background: rgba(0, 0, 0, 0.95);
    border: 2px solid #8b4513;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    color: #e8e8e8;
    font-weight: 600;
    animation: slideIn 0.3s ease;
}

.message.success {
    border-color: #27ae60;
    background: rgba(39, 174, 96, 0.9);
}

.message.error {
    border-color: #e74c3c;
    background: rgba(231, 76, 60, 0.9);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.modal#tutorialModal {
    display: flex !important;
    align-items: center;
    justify-content: center;
}

.modal#tutorialModal.hidden {
    display: none !important;
}

.modal.show {
    display: flex !important;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: linear-gradient(145deg, #2c3e50, #34495e);
    border: 3px solid #d4af37;
    border-radius: 15px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    text-align: center;
    box-shadow: 0 0 30px rgba(212, 175, 55, 0.5);
    animation: scaleIn 0.3s ease;
}

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

@keyframes scaleIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-content h2 {
    font-family: 'Cinzel', serif;
    font-size: 2rem;
    color: #d4af37;
    margin-bottom: 20px;
}

.tutorial-content {
    text-align: left;
    margin-bottom: 20px;
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 10px;
}

.tutorial-content p {
    margin-bottom: 15px;
    line-height: 1.6;
}

.tutorial-content ul {
    margin-left: 20px;
    margin-bottom: 15px;
}

.tutorial-content li {
    margin-bottom: 8px;
    line-height: 1.5;
}

/* How to Play Modal Styles */
.how-to-play-content {
    max-width: 800px;
    width: 95%;
    position: relative;
}

.close-modal-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(139, 69, 19, 0.3);
    color: #d4af37;
    border: 1px solid #d4af37;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
}

.close-modal-btn:hover {
    background: rgba(139, 69, 19, 0.5);
    transform: rotate(90deg);
}

.instructions-content {
    text-align: left;
    max-height: 70vh;
    overflow-y: auto;
    padding-right: 10px;
}

.instructions-content section {
    margin-bottom: 25px;
}

.instructions-content h3 {
    font-family: 'Cinzel', serif;
    color: #d4af37;
    font-size: 1.3rem;
    margin-bottom: 10px;
    border-bottom: 2px solid #8b4513;
    padding-bottom: 5px;
}

.instructions-content h4 {
    font-family: 'Cinzel', serif;
    color: #b8860b;
    font-size: 1.1rem;
    margin-top: 15px;
    margin-bottom: 8px;
}

.instructions-content p {
    margin-bottom: 10px;
    line-height: 1.6;
}

.instructions-content ul {
    margin-left: 20px;
    margin-bottom: 15px;
}

.instructions-content li {
    margin-bottom: 8px;
    line-height: 1.5;
}

.action-description {
    background: rgba(0, 0, 0, 0.2);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
    border-left: 3px solid #8b4513;
}

.action-description p {
    margin-bottom: 5px;
}

.action-description p:last-child {
    margin-bottom: 0;
}

.final-score {
    margin-bottom: 20px;
}

.score-breakdown {
    background: rgba(0, 0, 0, 0.3);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 15px;
}

.score-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    padding: 5px 0;
    border-bottom: 1px solid rgba(139, 69, 19, 0.3);
}

.score-item.total {
    font-weight: 700;
    font-size: 1.2rem;
    color: #d4af37;
    border-bottom: 2px solid #d4af37;
    margin-top: 10px;
    padding-top: 15px;
}

.victory-message {
    font-size: 1.3rem;
    font-weight: 700;
    color: #d4af37;
    margin-top: 15px;
    padding: 15px;
    background: rgba(212, 175, 55, 0.1);
    border-radius: 8px;
    border: 1px solid #d4af37;
}

.death-log {
    background: rgba(231, 76, 60, 0.1);
    border: 2px solid #e74c3c;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    max-height: 200px;
    overflow-y: auto;
}

.death-log h3 {
    color: #e74c3c;
    font-size: 1.2rem;
    margin-bottom: 10px;
    text-align: center;
}

.death-log-item {
    background: rgba(0, 0, 0, 0.3);
    padding: 8px;
    margin-bottom: 8px;
    border-radius: 5px;
    border-left: 3px solid #e74c3c;
    font-size: 0.9rem;
    line-height: 1.4;
}

.death-log-item.character-death {
    border-left: 3px solid #e74c3c;
    color: #ff6b6b;
}

.death-log-item.creature-defeat {
    border-left: 3px solid #27ae60;
    color: #2ecc71;
}

.start-game-btn, .new-game-btn {
    background: linear-gradient(145deg, #27ae60, #2ecc71);
    border: 2px solid #27ae60;
    border-radius: 8px;
    padding: 15px 30px;
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.start-game-btn:hover, .new-game-btn:hover {
    background: linear-gradient(145deg, #2ecc71, #27ae60);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(39, 174, 96, 0.3);
}

/* Responsive Design */
@media (max-width: 768px) {
    .game-container {
        padding: 10px;
    }
    
    .game-header h1 {
        font-size: 2rem;
    }
    
    .game-info {
        flex-direction: column;
        gap: 10px;
    }
    
    .header-inventory {
        flex-direction: column;
        gap: 8px;
    }
    
    .header-inventory .resources {
        gap: 5px;
    }
    
    .header-inventory .resources .resource-item {
        min-width: 70px;
        font-size: 0.7rem;
    }
    
    .header-inventory .settlements .settlement-item {
        min-width: 100px;
        font-size: 0.7rem;
    }
    
    .game-board {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }
    
    .resource-market,
    .action-area,
    .character-tracks,
    .player-inventory,
    .objectives {
        grid-column: 1;
    }
    
    .market-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .actions-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .tracks-container {
        grid-template-columns: 1fr;
    }
    
    .resources {
        grid-template-columns: 1fr;
    }
    
    .objectives-container {
        grid-template-columns: 1fr;
    }
    
    /* Mobile message positioning handled in earlier media query */
}

@media (max-width: 480px) {
    .game-header h1 {
        font-size: 1.5rem;
    }
    
    .market-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        padding: 20px;
    }
    
    .modal-content h2 {
        font-size: 1.5rem;
    }
}
