body {
    font-family: sans-serif;
    background-color: #f0f0f0;
    color: #333;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    min-height: 100vh;
    margin: 0;
}

#game-container {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 1200px;
    position: relative; /* Needed for positioning the language switcher */
}

/* --- Language Switcher --- */
#language-switcher {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 10;
}

#language-btn {
    background-color: #f0f0f0;
    color: #333;
    border: 1px solid #ccc;
    padding: 2px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 30px;
}

#language-btn span {
    font-size: 1.6em;
    line-height: 1;
}

#language-btn:hover {
    background-color: #e0e0e0;
}

#language-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background-color: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.15);
    min-width: 150px;
}

#language-dropdown a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    color: #333;
    text-decoration: none;
}

#language-dropdown a:hover {
    background-color: #f0f0f0;
}

#language-dropdown a span {
    font-size: 1.2em;
}

h1, h2 {
    text-align: center;
    color: #1a237e;
}

/* --- Setup Screen --- */
#setup-screen {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 400px;
    margin: 0 auto;
}

.setup-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

#player-names {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.player-name-input {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    flex-grow: 1;
}

.player-name-row {
    display: flex;
    align-items: center;
    gap: 5px;
}

.reorder-btn {
    padding: 5px 8px;
    font-size: 18px;
    line-height: 1;
    background-color: #5c6bc0;
}
.reorder-btn:hover {
    background-color: #3949ab;
}


button {
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    background-color: #3949ab;
    color: white;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s;
}

button:hover {
    background-color: #1a237e;
}

button:disabled {
    background-color: #9fa8da;
    cursor: not-allowed;
}


/* --- Game Screen --- */
.hidden {
    display: none !important;
}

#game-info {
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.2em;
}

#dice-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
}

.die-image {
    width: 80px;
    height: 80px;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 10px;
    transition: all 0.2s;
}

.die-image.locked {
    border: 3px solid #ff4081;
    box-shadow: 0 0 10px #ff4081;
}

#scoreboard-container {
    margin-top: 20px;
    overflow: auto;
    max-height: 70vh; /* Or any suitable height */
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.9em;
}

th, td {
    border: 1px solid #ccc;
    padding: 8px;
    text-align: center;
}

th {
    background-color: #e8eaf6;
}

.sticky-header {
    position: sticky;
    top: 0;
    z-index: 2;
    /* The background is inherited from `th` but let's be explicit */
    background-color: #e8eaf6;
}

.player-header.sticky-header {
    background-color: #c5cae9;
}

.sticky-col {
    position: sticky;
    left: 0;
    z-index: 1;
    /* Most sticky column cells are white */
    background-color: #fff;
}

/* The top-left corner cell needs to be on top of everything */
thead .sticky-col.sticky-header {
    z-index: 3;
    background-color: #e8eaf6;
}

/* Other sticky column cells need their specific backgrounds to override the default */
#scoreboard .total-score .sticky-col {
    background-color: #c5cae9;
}

#scoreboard .highlight-row > .sticky-col {
    background-color: #f0f0f0;
}

.category-name {
    text-align: left;
    font-weight: bold;
}

.player-header {
    background-color: #c5cae9;
    transition: background-color 0.3s;
}

.player-column-divider {
    border-right: 2px solid #555;
}

.category-column-divider {
    border-left: 2px solid #555;
    border-right: 2px solid #555;
}

.highlight-row > td, .highlight-row > th {
    background-color: #f0f0f0;
}

.hidden-row {
    display: none;
}

.active-player-col {
    background-color: #9fa8da !important;
}

.last-scored {
    background-color: #fff9c4; /* A light yellow */
}

.next-required-cell {
    box-shadow: 0 0 10px 3px #42a5f5; /* A blue glow */
    border: 2px solid #42a5f5;
}

.score-cell {
    cursor: pointer;
    min-width: 50px;
}

.score-cell:hover {
    background-color: #e0e0e0;
}
.score-cell.filled {
    cursor: not-allowed;
    color: #555;
    font-weight: bold;
}

.section-header {
    background-color: #9fa8da;
    font-weight: bold;
    text-align: left;
}

.total-score {
    font-weight: bold;
    background-color: #c5cae9;
}

#new-game-btn {
    margin-top: 20px;
    background-color: #c62828;
}
#new-game-btn:hover {
    background-color: #8e0000;
}

#simulation-log {
    margin-top: 20px;
    padding: 15px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background-color: #f9f9f9;
    max-height: 300px;
    overflow-y: auto;
}

#simulation-log h3 {
    margin-top: 0;
    text-align: center;
}

#log-content p {
    margin: 5px 0;
    padding: 3px;
    border-bottom: 1px solid #eee;
    font-size: 0.9em;
}

@media (max-width: 768px) {
    body {
        padding: 5px;
    }
    #game-container {
        padding: 10px;
    }
    .die-image {
        width: 50px;
        height: 50px;
    }
    table {
        font-size: 0.8em;
    }
    th, td {
        padding: 4px;
    }
    button {
        padding: 8px 12px;
        font-size: 14px;
    }
    h1 {
        font-size: 1.5em;
    }
}

/* --- Cache Status --- */
#cache-status {
    text-align: center;
    padding: 10px;
    margin-top: 20px;
    color: #888; /* Gray text color */
    font-size: 0.9em;
}

#cache-status p {
    margin: 0;
}

/* --- iOS Install Prompt --- */
#ios-install-prompt {
    position: fixed;
    bottom: 50px; /* Adjust to be above the cache status bar */
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 400px;
    background-color: #5c6bc0;
    color: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    z-index: 101;
    text-align: center;
}

#ios-install-prompt.hidden {
    display: none;
}

#ios-install-prompt p {
    margin: 0 0 10px 0;
}

#ios-install-prompt button {
    background-color: #fff;
    color: #3949ab;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
}

/* --- Rules Modal --- */
.title-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    position: relative;
}

#rules-btn {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    padding: 0 5px;
    color: #5c6bc0;
}

#rules-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

#rules-modal-content {
    background: #fff;
    padding: 20px 30px;
    border-radius: 8px;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

#rules-close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 2em;
    color: #888;
    cursor: pointer;
}

.rules-section h3 {
    margin-top: 20px;
    color: #1a237e;
}
.rules-section h4 {
    margin-top: 15px;
    color: #3949ab;
}
.rules-section p, .rules-section li {
    line-height: 1.6;
}
