/**
 * IACTA - The Die is Cast
 * Game Styles
 * 
 * Copyright (c) 2025 b1231.xyz
 * Free to use, modify, and distribute with attribution
 */

:root {
    --primary-color: #862d2d;      /* Roman red */
    --secondary-color: #c5a572;    /* Roman gold */
    --border-color: #8b7355;       /* Bronze */
    --text-color: #2C3E50;         /* Dark slate */
    --background-color: #f4e9d9;   /* Parchment */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Times New Roman', serif;
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    padding: 5px;
    min-height: 100vh;
    font-size: 14px;
}

h1, h2, h3, h4 {
    font-family: 'Trajan Pro', 'Times New Roman', serif;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.game-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 5px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 5px;
}

header {
    grid-column: 1 / -1;
    text-align: center;
    margin-bottom: 2px;
}

header .subtitle {
    font-family: 'Trajan Pro', 'Times New Roman', serif;
    color: var(--secondary-color);
    font-size: 1em;
    font-style: italic;
    margin: 2px 0;
    letter-spacing: 0.1em;
    text-transform: none;
}

h1 {
    font-size: 2em;
    letter-spacing: 0.15em;
    margin: 0;
    color: var(--primary-color);
    text-align: center;
    font-weight: 800;
}

h2 {
    font-size: 1.1em;
    margin-bottom: 4px;
}

.header-info {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 5px;
}

.turn-counter, .high-score {
    font-size: 1em;
    font-weight: bold;
    color: var(--secondary-color);
    background: rgba(255, 255, 255, 0.8);
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.game-board {
    grid-column: 1;
    display: grid;
    grid-template-rows: auto auto auto;
    gap: 5px;
}

.resources-dice-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    align-items: start;
}

.resources-section {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: auto repeat(2, 1fr);
    gap: 3px;
    padding: 4px;
    background: #fff;
    border-radius: 6px;
    border: 2px solid var(--border-color);
}

.resources-section h2 {
    grid-column: 1 / -1;
    margin: 0 0 4px 0;
}

.resource {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 6px;
    border-radius: 4px;
    background: linear-gradient(135deg, #f8f8f8 0%, #e8e8e8 100%);
    border: 1px solid #ddd;
    min-width: 0;
}

.resource label {
    font-size: 0.65em;
    font-weight: 600;
    color: var(--text-color);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin: 0;
    white-space: nowrap;
    flex-shrink: 0;
}


.value {
    font-size: 1.4em;
    font-weight: bold;
    color: var(--primary-color);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
    white-space: nowrap;
    flex-shrink: 0;
}

.dice-section {
    padding: 3px;
    background: #fff;
    border-radius: 6px;
    border: 2px solid var(--border-color);
}

.dice-container {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    margin: 3px 0;
    min-height: 40px;
    overflow-x: auto;
    align-items: center; /* Center align all items vertically */
}

.dice-section button {
    width: 100%;
    margin-top: 8px;
    padding: 6px 12px;
    font-size: 0.8em;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Trajan Pro', 'Times New Roman', serif;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    transition: all 0.2s ease;
}

.dice-section button:hover {
    background: var(--secondary-color);
    transform: translateY(-1px);
}

.die {
    width: 32px;
    height: 32px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.1em;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.die.selected {
    border-color: var(--primary-color);
    background: var(--secondary-color);
    color: #fff;
    transform: scale(1.1);
}

.die:hover:not(.used) {
    border-color: var(--primary-color);
    transform: scale(1.05);
}

.die.used {
    opacity: 0.5;
}

.actions-section {
    padding: 3px;
    background: #fff;
    border-radius: 6px;
    border: 2px solid var(--border-color);
}

.action-spaces {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, auto);
    gap: 3px;
}

.action-space {
    padding: 4px;
    border-radius: 3px;
    background: #f8f8f8;
    border: 1px solid var(--border-color);
}

.action-space h3 {
    margin: 0 0 2px 0;
    font-size: 0.8em;
}

.action-space p {
    margin: 0 0 2px 0;
    font-size: 0.7em;
}

.action-effect {
    font-size: 0.7em;
    margin: 2px 0 0 0;
}

.dice-slots {
    min-height: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    align-items: center;
    margin-top: 2px;
}


.events-section {
    padding: 3px;
    background: #fff;
    border-radius: 6px;
    border: 2px solid var(--border-color);
}

.events-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
}

.events-section h2 {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 5px;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.event-card {
    border: 2px solid var(--secondary-color);
    border-radius: 6px;
    padding: 8px;
    background-color: #fff;
}

.event-card h3 {
    color: var(--primary-color);
    margin-bottom: 4px;
}

.event-card p {
    color: var(--text-color);
    font-size: 0.85em;
    line-height: 1.3;
}

.action-button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.2s;
}

.action-button:hover {
    background-color: #a00000;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    max-height: 90vh;
    overflow-y: auto;
    max-width: 90vw;
}

.tutorial-content {
    max-width: 500px;
}

.tutorial-steps {
    text-align: left;
    margin: 15px 0;
}

.tutorial-steps h3 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

.tutorial-steps ol {
    padding-left: 20px;
}

.tutorial-steps li {
    margin-bottom: 10px;
}

.tutorial-steps ul {
    padding-left: 15px;
    margin: 5px 0;
}

.tutorial-steps ul li {
    margin-bottom: 3px;
}

#start-game {
    font-size: 1.1em;
    padding: 12px 24px;
    margin-top: 15px;
}

.feedback-message {
    grid-column: 1 / -1;
    padding: 5px;
    margin-bottom: 5px;
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
    color: #856404;
    border-radius: 3px;
    text-align: center;
    transition: opacity 0.3s;
    font-size: 0.9em;
}

.feedback-message.hidden {
    display: none;
}

@media (max-width: 768px) {
    body {
        padding: 3px;
        font-size: 12px;
    }

    .game-container {
        grid-template-columns: 1fr;
        padding: 3px;
        gap: 3px;
    }

    h1 {
        font-size: 1.6em;
    }

    .subtitle {
        font-size: 0.9em;
    }

    .resources-dice-row {
        grid-template-columns: 1fr;
        gap: 3px;
    }

    .resources-section {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: auto repeat(2, 1fr);
        gap: 3px;
        padding: 4px;
    }

    .action-spaces {
        grid-template-columns: repeat(2, 1fr);
    }

    .die {
        width: 28px;
        height: 28px;
        font-size: 0.9em;
    }

    .reroll-button {
        width: 28px;
        height: 28px;
        font-size: 0.9em;
        padding: 0;
        margin: 0;
        min-width: 28px;
        max-width: 28px;
    }

    .dice-section button {
        font-size: 0.9em;
        padding: 8px 16px;
    }

    .action-space {
        padding: 3px;
    }

    .action-space h3 {
        font-size: 0.7em;
    }

    .action-space p {
        font-size: 0.6em;
    }


    .modal-content {
        padding: 15px;
        margin: 10px;
    }


}

@media (max-width: 480px) {
    body {
        font-size: 12px;
        padding: 2px;
    }

    .game-container {
        padding: 2px;
        gap: 2px;
    }

    .resources-dice-row {
        grid-template-columns: 1fr;
        gap: 2px;
    }

    h1 {
        font-size: 1.3em;
    }

    .subtitle {
        font-size: 0.9em;
    }

    .turn-counter {
        font-size: 0.9em;
    }

    .die {
        width: 18px;
        height: 18px;
        font-size: 0.7em;
    }

    .reroll-button {
        width: 18px;
        height: 18px;
        font-size: 0.7em;
        padding: 0;
        margin: 0;
        min-width: 18px;
        max-width: 18px;
    }

    .dice-section button {
        font-size: 0.7em;
        padding: 3px 8px;
        margin: 2px 0;
    }

    .resource {
        padding: 6px 8px;
    }

    .resource label {
        font-size: 0.6em;
    }

    .value {
        font-size: 1.2em;
    }

    .action-space {
        padding: 3px;
    }

    .action-space h3 {
        font-size: 0.6em;
        margin-bottom: 2px;
    }

    .action-space p {
        font-size: 0.5em;
        margin-bottom: 2px;
    }

    .action-effect {
        font-size: 0.5em;
        margin: 2px 0;
    }



    .modal-content {
        padding: 10px;
        margin: 5px;
    }


    .popup-content {
        padding: 8px 15px;
        font-size: 0.7em;
    }
}

@media (max-width: 360px) {
    body {
        font-size: 11px;
    }

    .die {
        width: 24px;
        height: 24px;
        font-size: 0.8em;
    }

    .reroll-button {
        width: 24px;
        height: 24px;
        font-size: 0.8em;
        padding: 0;
        margin: 0;
        min-width: 24px;
        max-width: 24px;
    }

    .dice-section button {
        font-size: 0.6em;
        padding: 2px 6px;
    }

    .action-space {
        padding: 2px;
    }

    .action-space h3 {
        font-size: 0.55em;
    }

    .action-space p {
        font-size: 0.45em;
    }

    .resource label {
        font-size: 0.55em;
    }

    .value {
        font-size: 1.0em;
    }

}


.popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    animation: popupFadeIn 0.3s ease-out;
}

.popup-content {
    background-color: #ff4444;
    color: white;
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    text-align: center;
    font-size: 1.1em;
    font-weight: bold;
}

@keyframes popupFadeIn {
    0% {
        opacity: 0;
        transform: translate(-50%, -40%);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

@keyframes popupFadeOut {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -60%);
    }
}

.popup.hidden {
    display: none;
}

.popup.fadeout {
    animation: popupFadeOut 0.3s ease-in forwards;
}

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

/* Old objective card styles removed - now using objective-space */

/* Remove the old cycling text */
.events-section h2::after {
    content: " ←←←";
    color: var(--secondary-color);
    font-size: 1.2em;
    margin-left: 10px;
    letter-spacing: 4px;
    animation: arrowPulse 2s infinite;
    display: inline-block;
}

@keyframes arrowPulse {
    0% { 
        opacity: 0.2;
        transform: translateX(0);
    }
    50% { 
        opacity: 1;
        transform: translateX(-10px);
    }
    100% { 
        opacity: 0.2;
        transform: translateX(0);
    }
}

/* Old objective card button styles removed - now using dice placement */

/* Add some visual grouping */
.action-space[data-action="recruit"],
.action-space[data-action="conscript"] {
    border-left: 4px solid #e74c3c;  /* Military-related actions */
}

.action-space[data-action="bribe"],
.action-space[data-action="negotiate"] {
    border-left: 4px solid #3498db;  /* Political-related actions */
}

.action-space[data-action="gather"],
.action-space[data-action="march"] {
    border-left: 4px solid #2ecc71;  /* Supply/Glory-related actions */
}

.resource-tracks .resource label {
    font-family: 'Trajan Pro', 'Times New Roman', serif;
    color: var(--primary-color);
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.9em;
    letter-spacing: 0.05em;
}

button {
    background: var(--primary-color);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Trajan Pro', 'Times New Roman', serif;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    transition: all 0.2s ease;
}

button:hover {
    background: var(--secondary-color);
}

button:disabled,
button.disabled {
    background: #ccc;
    color: #666;
    cursor: not-allowed;
    opacity: 0.6;
}

button:disabled:hover,
button.disabled:hover {
    background: #ccc;
    transform: none;
}

/* Reroll button styled as a die */
.reroll-button {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    background: var(--secondary-color);
    color: var(--text-color);
    font-weight: bold;
    font-size: 1.1em;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0; /* Prevent shrinking */
    padding: 0; /* Remove default button padding */
    margin: 0; /* Remove default button margin */
    box-sizing: border-box; /* Include border in width calculation */
    min-width: 32px; /* Ensure minimum width */
    max-width: 32px; /* Ensure maximum width */
}

.reroll-button:hover:not(.disabled) {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.reroll-button.disabled {
    background: #ccc;
    color: #666;
    cursor: not-allowed;
    opacity: 0.6;
}

.reroll-button.disabled:hover {
    background: #ccc;
    transform: none;
    box-shadow: none;
}

/* Objectives Section */
.objectives-section {
    margin-top: 20px;
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    border: 2px solid var(--border-color);
}

.objectives-section h2 {
    color: var(--primary-color);
    margin-bottom: 15px;
    text-align: center;
    font-size: 1.4em;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}

.objective-spaces {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.objective-space {
    background: #fff;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    position: relative;
}

.objective-space:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.objective-space h3 {
    color: var(--primary-color);
    margin: 0 0 8px 0;
    font-size: 1.1em;
    font-weight: bold;
}

.objective-space p {
    margin: 0 0 10px 0;
    font-size: 0.9em;
    color: var(--text-color);
    line-height: 1.4;
}

.objective-space .dice-slots {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 10px;
    min-height: 30px;
    border: 1px dashed #ccc;
    border-radius: 4px;
    padding: 5px;
    background: #f8f9fa;
}

.objective-space .dice-slot {
    width: 25px;
    height: 25px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8em;
    font-weight: bold;
    color: var(--primary-color);
}

.objective-space .dice-slot.occupied {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Visual grouping for different objective types */
.objective-space[data-action="military_dominance"],
.objective-space[data-action="armed_supply_lines"] {
    border-left: 4px solid #e74c3c;  /* Military-related objectives */
}

.objective-space[data-action="political_influence"],
.objective-space[data-action="military_political_alliance"],
.objective-space[data-action="political_supply_chain"] {
    border-left: 4px solid #3498db;  /* Political-related objectives */
}

.objective-space[data-action="supply_chain"],
.objective-space[data-action="resource_empire"] {
    border-left: 4px solid #2ecc71;  /* Supply-related objectives */
}

/* Mobile-specific font size adjustments */
@media (max-width: 768px) {
    /* Header and main titles */
    h1 {
        font-size: 2.5em;
    }
    
    h2 {
        font-size: 1.4em;
    }
    
    .subtitle {
        font-size: 1.1em;
    }
    
    /* Resource values */
    .value {
        font-size: 1.8em;
    }
    
    .resource label {
        font-size: 0.8em;
    }
    
    /* Action spaces */
    .action-space h3 {
        font-size: 1em;
    }
    
    .action-space p {
        font-size: 0.8em;
    }
    
    .action-effect {
        font-size: 0.8em;
    }
    
    /* Objective spaces */
    .objective-space h3 {
        font-size: 1.3em;
    }
    
    .objective-space p {
        font-size: 1em;
    }
    
    /* Dice */
    .die {
        font-size: 1.3em;
    }
    
    /* Buttons */
    button {
        font-size: 1em;
        padding: 12px 24px;
    }
    
    
    /* Event card */
    .event-card h3 {
        font-size: 1.2em;
    }
    
    .event-card p {
        font-size: 1em;
    }
    
    /* Feedback message */
    .feedback-message {
        font-size: 1.1em;
    }
    
    /* Turn counter */
    .turn-counter {
        font-size: 1.1em;
    }
}

/* Footer */
.game-footer {
    text-align: center;
    padding: 15px 10px;
    margin-top: 20px;
    background: linear-gradient(135deg, var(--background-color) 0%, #e8dcc8 100%);
    border-top: 2px solid var(--border-color);
    font-size: 0.85em;
    color: var(--text-color);
}

.game-footer p {
    margin: 0;
    font-family: 'Times New Roman', serif;
}

.game-footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: bold;
    transition: color 0.2s ease;
}

.game-footer a:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

@media (max-width: 768px) {
    .game-footer {
        font-size: 0.75em;
        padding: 10px 5px;
    }
}