body {
    margin: 0;
    overflow: hidden;
    background: radial-gradient(circle farthest-corner at center, #4a5a6a 0%, #1c2833 100%);
    height: 100vh;
    font-family: Arial, sans-serif;
}

#scrabble-container {
    width: 100vw;
    height: 100vh;
    display: block;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

.ui-button {
    padding: 12px;
    font-size: 16px;
    font-weight: bold;
    color: #333;
    background-color: #eae0c8;
    border: 2px solid #6F4E37;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: background-color 0.2s, transform 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.ui-button:hover {
    background-color: #faf8ef;
}

.ui-button:focus {
    outline: none;
}

.info-display {
    pointer-events: none;
}

#top-right-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 10;
}

#bottom-ui-container {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    z-index: 10;
    align-items: center;
}

#validate-word-btn,
#exchange-btn,
#pass-btn,
#confirm-exchange-btn,
#cancel-exchange-btn {
    width: 120px;
}

#suggestion-btn {
    width: 120px;
    background-color: #add8e6;
}

.view-control-btn {
    width: 50px;
    height: 50px;
}

#turn-indicator {
    font-size: 18px;
    padding: 10px 15px;
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 8px;
}

#leaderboard-content tr.active {
    background-color: #f0e68c;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease-in-out;
    padding-top: min(1rem, 1vh);
}

.modal-overlay.active {
    opacity: 1;
}

.modal-panel {
    background-color: #eae0c8;
    padding: 25px;
    border-radius: 15px;
    border: 4px solid #6F4E37;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
    text-align: center;
    transform: scale(0.8);
    transition: transform 0.3s ease-in-out;
    max-width: 90%;
}

.modal-overlay.active .modal-panel {
    transform: scale(1);
    pointer-events: auto;
}

.modal-panel h3 {
    margin-top: 0;
    color: #333;
    font-size: 24px;
}

#joker-letters {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 10px;
}

.joker-letter-btn {
    width: 40px;
    height: 40px;
    background-color: #faf8ef;
    border: 2px solid #d2b48c;
    border-radius: 5px;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.joker-letter-btn:hover {
    background-color: #d2b48c;
    transform: scale(1.1);
}

#popup-message {
    margin: 0;
    font-size: 16px;
    font-weight: bold;
    color: white;
    text-align: left;
    line-height: 1.5;
}

#popup-message strong {
    color: #f0e68c;
}

#popup-panel {
    align-items: flex-start;
}

#popup-panel.popup-error {
    background-color: #b33939;
    border-color: #6e1a1a;
}

#popup-panel.popup-info {
    background-color: #3978b3;
    border-color: #1a4b6e;
}

#game-over-modal .modal-panel {
    padding: 40px;
    overflow-y: auto;
    height: calc(min(100%, 90vh) - 80px) !important;
}

#game-over-modal h2 {
    font-size: 36px;
    color: #0047ab;
    margin-top: 0;
    margin-bottom: 20px;
}

#game-over-modal p {
    font-size: 18px;
    margin: 10px 0;
}

#final-scores {
    margin-top: 20px;
    font-weight: bold;
}

.final-ranking-table {
    width: 100%;
    margin-top: 20px;
    border-collapse: collapse;
    text-align: left;
}

.final-ranking-table th {
    padding: 8px;
    border-bottom: 2px solid #6F4E37;
}

.final-ranking-table td {
    padding: 8px;
    border-bottom: 1px solid #d2b48c;
}

@media (max-width: 820px) {
    #top-right-controls {
        top: 75px;
    }

    .view-control-btn {
        width: 50px;
        height: 50px;
        font-size: 16px;
    }

    #bottom-ui-container {
        top: 0;
        left: 0;
        width: 100%;
        background-color: rgba(0, 0, 0, 0.2);
        padding: 5px;
        box-sizing: border-box;
        justify-content: center;
        align-items: center;
        gap: 5px;
        border-bottom: 2px solid #6F4E37;
    }

    #validate-word-btn,
    #exchange-btn,
    #pass-btn,
    #suggestion-btn,
    #confirm-exchange-btn,
    #cancel-exchange-btn {
        flex-grow: 1;
    }

}

#history-modal .modal-panel, #leaderboard-modal .modal-panel {
    max-width: 500px;
    max-height: 70vh;
    overflow-y: auto;
}

#history-content table, #leaderboard-content table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

#history-content th, #history-content td, #leaderboard-content th, #leaderboard-content td {
    border: 1px solid #6F4E37;
    padding: 8px;
    text-align: left;
}

#history-content th, #leaderboard-content th {
    background-color: #d2b48c;
    color: #333;
}

#close-history-btn, #close-leaderboard-btn {
    margin-top: 15px;
}

.player-color-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 8px;
}

#settings-modal .modal-panel {
    max-width: 400px;
}

.share-link-container {
    display: flex;
    margin: 20px 0;
}

#share-link-input {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px 0 0 5px;
}

#copy-link-btn {
    border-radius: 0 5px 5px 0;
}

#logout-btn {
    background-color: #e74c3c;
    color: white;
    width: 100%;
    margin-top: 10px;
}

.d-flex {
    gap: 0.5rem;
}
/* Styles for index.php */
.index-body {
    background: radial-gradient(circle farthest-corner at center, #4a5a6a 0%, #1c2833 100%);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem 1rem;
    overflow-y: auto;
}

.main-card {
    width: 100%;
    max-width: 1600px;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    padding: 30px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    color: #fff;
}

.main-card h1 {
    font-weight: bold;
    color: #eae0c8;
}

.main-card .card-header {
    background: none;
    border: none;
    padding: 0 0 20px 0;
    text-align: center;
}

.main-card .card-header h2 {
    font-size: 1.5rem;
    color: #fff;
}

.main-card .card-body {
    padding: 0;
}

.form-label {
    color: #eae0c8;
    font-weight: 500;
}

.form-control, .form-select {
    background-color: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    border-radius: 8px;
}

.form-control:focus, .form-select:focus {
    background-color: rgba(0, 0, 0, 0.5);
    border-color: #eae0c8;
    color: #fff;
    box-shadow: 0 0 0 0.25rem rgba(234, 224, 200, 0.25);
}

.form-control::placeholder {
    color: #aaa;
}

.form-check-input {
    background-color: rgba(0,0,0,0.3);
    border-color: rgba(255, 255, 255, 0.2);
}
.form-check-input:checked {
    background-color: #6F4E37;
    border-color: #6F4E37;
}
.form-check-input:focus {
    box-shadow: 0 0 0 0.25rem rgba(111, 78, 55, 0.25);
}

.btn-primary {
    background-color: #6F4E37;
    border-color: #6F4E37;
    font-weight: bold;
    padding: 12px;
    border-radius: 8px;
    transition: background-color 0.2s, border-color 0.2s;
}

.btn-primary:hover, .btn-primary:focus {
    background-color: #8a6d53;
    border-color: #8a6d53;
    box-shadow: 0 0 0 0.25rem rgba(111, 78, 55, 0.5);
}

#players-config .player-config-row {
    background-color: rgba(0,0,0,0.2);
    padding: 15px 10px;
    border-radius: 8px;
    margin-bottom: 10px !important;
}

.modal-content {
    background-color: #2c3e50;
    color: #fff;
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.modal-header {
    border-bottom: 1px solid #4a5a6a;
}

.modal-footer {
    border-top: 1px solid #4a5a6a;
}

#game-link-modal .btn-primary {
    background-color: #eae0c8;
    color: #333;
    border-color: #eae0c8;
}
#game-link-modal .btn-primary:hover {
    background-color: #fff;
    border-color: #fff;
}

#game-link-modal .btn-outline-secondary {
    color: #eae0c8;
    border-color: #eae0c8;
}
#game-link-modal .btn-outline-secondary:hover {
    background-color: #eae0c8;
    color: #333;
}

.btn-close-white {
    filter: invert(1) grayscale(100%) brightness(200%);
}

@media (max-width: 767px) {
    .index-body {
        align-items: flex-start;
    }
    .main-card {
        padding: 20px;
    }
    .player-config-row .col-sm-3 {
        margin-bottom: 10px;
    }
}

/* New styles for game over modal */
.final-ranking-table {
    margin-bottom: 20px;
}

.final-ranking-table th, .final-ranking-table td {
    white-space: nowrap; /* Prevent text wrapping in table cells */
    padding: 6px 4px; /* Reduced padding */
    font-size: 0.9em; /* Slightly smaller font */
}

.player-color-dot {
    width: 14px;
    height: 14px;
    margin-right: 5px;
    border: 1px solid #6F4E37;
}

.score-bonus {
    color: green;
    font-weight: bold;
}

.score-malus {
    color: red;
    font-weight: bold;
}

.remaining-letter {
    display: inline-block;
    background-color: #f0e68c; /* Light yellow background for letters */
    color: #333;
    border: 1px solid #6F4E37;
    border-radius: 3px;
    padding: 2px 4px;
    margin: 0 1px;
    font-family: 'Courier New', Courier, monospace; /* Monospace font for letters */
    font-size: 0.9em;
}

/* Responsive table headers */
@media (max-width: 600px) {
    .final-ranking-table th {
        font-size: 0.7em; /* Even smaller font for headers on small screens */
        padding: 4px 2px;
    }
    .final-ranking-table td {
        font-size: 0.8em;
        padding: 4px 2px;
    }
    /* Abbreviate headers if necessary, or hide less important ones */
    .final-ranking-table th:nth-child(3) { /* Score initial */
        content: 'Init. Score';
        font-size: 0;
    }
    .final-ranking-table th:nth-child(3)::before {
        content: 'Init. Score';
        font-size: 0.7em;
    }
    .final-ranking-table th:nth-child(4) { /* Lettres restantes */
        content: 'Rem. Letters';
        font-size: 0;
    }
    .final-ranking-table th:nth-child(4)::before {
        content: 'Rem. Letters';
        font-size: 0.7em;
    }
    .final-ranking-table th:nth-child(5) { /* Bonus/Malus */
        content: 'B/M';
        font-size: 0;
    }
    .final-ranking-table th:nth-child(5)::before {
        content: 'B/M';
        font-size: 0.7em;
    }
    .final-ranking-table th:nth-child(6) { /* Score final */
        content: 'Final Score';
        font-size: 0;
    }
    .final-ranking-table th:nth-child(6)::before {
        content: 'Final Score';
        font-size: 0.7em;
    }
}

/* Styling for highest scoring words section */
#highest-scoring-words {
    margin-top: 30px;
    padding: 15px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    border: 1px solid #d2b48c;
    color: #333;
}

#highest-scoring-words h4 {
    color: #0047ab;
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.2em;
}

#highest-scoring-words ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

#highest-scoring-words li {
    background-color: #faf8ef;
    margin-bottom: 8px;
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #e0d8c0;
    font-size: 1em;
    text-align: left; /* Align text to the left */
}

#highest-scoring-words li strong {
    color: #6F4E37;
}

.vr {
    color: rgba(255, 255, 255, 0.2);
}

@media (max-width: 991.98px) {
    .main-card .row > .col-lg-5 {
        border-bottom: 1px solid rgba(255, 255, 255, 0.2);
        padding-bottom: 2rem;
        margin-bottom: 2rem;
    }
}

/* Custom link styles for dark theme */
a {
    color: #8ab4f8; /* A light blue color */
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: #a1c2fa;
    text-decoration: underline;
}

/* More specific for main content links if needed */
.main-card a {
    color: #8ab4f8;
}

.main-card a:hover {
    color: #a1c2fa;
}