:root {
    /* Couleurs d'accent : chaque jeu redéfinit --accent, --accent-2,
       --accent-rgb, --win, --lose sous body[data-game="<id>"]. Le fond
       (--dark-bg, --light-bg, --card-bg) est commun à tous les jeux. */
    --accent: #667eea;
    --accent-2: #764ba2;
    --accent-rgb: 102, 126, 234;
    --win: #3a5a9e;
    --lose: #8b2635;
    --dark-bg: #1a1a2e;
    --light-bg: #16213e;
    --card-bg: #0f3460;
    --text-light: #e8e8e8;
    --text-dark: #0a0a0a;
    --danger: #c0392b;
    --border-radius: 12px;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--dark-bg) 0%, var(--light-bg) 100%);
    color: var(--text-light);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Screens */
.screen {
    display: none;
    min-height: 100vh;
    padding: 10px;
}

.screen.active {
    display: block;
}

#welcomeScreen.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* Typography */
.title {
    text-align: center;
    margin-bottom: 30px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.logo {
    font-size: 2rem;
    font-weight: bold;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
    background: linear-gradient(45deg, #ffd700, #ff8c00);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.subtitle {
    font-size: 0.9rem;
    color: var(--text-light);
    opacity: 0.8;
}

.title-small {
    font-size: 1.1rem;
    text-align: center;
    margin-bottom: 15px;
    color: #ffd700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.version-info {
    text-align: center;
    margin-top: 20px;
    font-size: 0.75rem;
    opacity: 0.6;
    color: var(--text-light);
}

.welcome-layout {
    display: flex;
    gap: 30px;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

.welcome-left {
    flex: 0 0 400px;
    display: flex;
}

.welcome-right {
    flex: 0 0 500px;
    display: flex;
}

.welcome-left .card {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin: 0;
    max-width: none;
    padding: 30px 25px;
}

.welcome-left .card h2 {
    margin-bottom: 20px;
}

.welcome-left .card input {
    margin-bottom: 15px;
}

.changelog {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 300px);
    min-height: 300px;
}

.changelog h3 {
    margin: 0 0 15px 0;
    font-size: 1rem;
    color: #ffd700;
    text-align: center;
    flex-shrink: 0;
}

.changelog-content {
    flex: 1;
    overflow-y: auto;
    padding-right: 10px;
    min-height: 0;
}

.changelog-item {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.changelog-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.changelog-version {
    font-size: 0.95rem;
    font-weight: bold;
    color: var(--accent);
    margin-bottom: 5px;
}

.changelog-date {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 10px;
}

.changelog-list {
    margin: 0;
    padding-left: 20px;
    list-style: none;
}

.changelog-list li {
    font-size: 0.8rem;
    line-height: 1.6;
    margin-bottom: 5px;
    position: relative;
    color: rgba(255, 255, 255, 0.85);
}

.changelog-list li::before {
    content: "•";
    position: absolute;
    left: -15px;
    color: var(--accent);
    font-weight: bold;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    margin: 0 auto;
}

.card h2 {
    margin-bottom: 15px;
    text-align: center;
    font-size: 1rem;
}

/* Buttons */
.btn {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, #3a7bd5 0%, #00d2ff 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(58, 123, 213, 0.4);
}

.btn-secondary {
    background: #444;
    color: white;
}

.btn-secondary:hover {
    background: #555;
}

.btn-large {
    width: 100%;
    padding: 12px;
    font-size: 0.95rem;
}

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

.btn-help {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #3498db;
    color: white;
    text-decoration: none;
    display: inline-block;
}

.btn-help:hover {
    background: #2980b9;
}

/* Input fields */
input[type="text"],
select {
    width: 100%;
    padding: 8px;
    margin-bottom: 15px;
    border: 2px solid transparent;
    border-radius: 8px;
    background: var(--light-bg);
    color: var(--text-light);
    font-size: 0.85rem;
    transition: border-color 0.3s;
}

input[type="text"]:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
}

/* User info */
.user-info {
    text-align: center;
    margin-bottom: 30px;
    font-size: 0.9rem;
}

/* Lobby */
.lobby-actions {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.lobby-actions .btn {
    flex: 0 0 auto;
}

.search-bar {
    flex: 1;
    min-width: 250px;
}

.search-bar input {
    margin-bottom: 0;
}

.room-list-container {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 20px;
}

.room-list-container h2 {
    margin-bottom: 20px;
}

.room-list {
    display: grid;
    gap: 15px;
}

.room-item {
    background: var(--light-bg);
    padding: 12px 16px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    transition: transform 0.2s;
    cursor: pointer;
}

.room-item:hover {
    transform: translateX(5px);
    background: #1e2f50;
}

.room-item-info {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    flex: 1;
    min-width: 0;
}

.room-code {
    color: #ffd700;
    font-weight: bold;
    font-size: 0.9rem;
}

.room-separator {
    opacity: 0.4;
    font-size: 0.7rem;
}

.room-host {
    font-weight: 600;
}

.room-players-count {
    font-weight: 600;
}

.room-players-list {
    opacity: 0.7;
    font-size: 0.75rem;
}

.room-item .btn {
    padding: 6px 12px;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.empty-message {
    text-align: center;
    opacity: 0.6;
    padding: 40px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    padding: 30px;
    border-radius: var(--border-radius);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h2 {
    margin-bottom: 20px;
    font-size: 1rem;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 0.85rem;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.modal-actions .btn {
    flex: 1;
}

/* Room Screen */
.room-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.room-code {
    color: #ffd700;
    font-weight: bold;
    font-size: 1rem;
    letter-spacing: 2px;
}

.room-info {
    background: var(--card-bg);
    padding: 12px 15px;
    border-radius: var(--border-radius);
    margin-bottom: 15px;
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.room-info p {
    margin: 0;
    font-size: 0.75rem;
}

.room-info .composition-info {
    display: block;
    background: transparent;
    padding: 0;
    border-radius: 0;
    font-size: 0.75rem;
    font-weight: 400;
    margin: 0;
    align-items: flex-start;
    gap: 0;
}

.players-waiting {
    background: var(--card-bg);
    padding: 15px;
    border-radius: var(--border-radius);
    margin-bottom: 15px;
}

.players-waiting h3 {
    margin-bottom: 10px;
    font-size: 0.85rem;
}

.players-waiting ul {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 8px;
}

.players-waiting li {
    padding: 6px 10px;
    background: var(--light-bg);
    border-radius: 6px;
    font-size: 0.8rem;
}

.player-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.player-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.btn-kick,
.btn-ban {
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    width: 20px;
    height: 20px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
}

.btn-ban {
    background: #8b2635;
}

.btn-kick:hover {
    background: #c0392b;
    transform: scale(1.1);
}

.btn-ban:hover {
    background: #6b1a28;
    transform: scale(1.1);
}

#startGameContainer {
    text-align: center;
    padding: 20px;
    background: var(--card-bg);
    border-radius: var(--border-radius);
}

.info-text {
    margin-top: 10px;
    opacity: 0.7;
    font-size: 0.75rem;
}

/* Room Screen Layout (same as Game Screen) */
.room-container {
    margin: 0 auto;
    display: flex;
    flex-direction: row;
    gap: 15px;
    height: calc(100vh - 20px);
    max-width: 1400px;
}

.room-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Game Screen */
.game-container {
    margin: 0 auto;
    display: flex;
    flex-direction: row;
    gap: 15px;
    height: calc(100vh - 20px);
}

.game-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    flex-wrap: wrap;
    gap: 10px;
}

.game-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

@keyframes alertSlideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.game-info {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.round-info,
.composition-info {
    background: var(--card-bg);
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Turn Indicator */
.turn-indicator {
    text-align: center;
    padding: 8px;
    background: var(--card-bg);
    border-radius: 6px;
    margin-bottom: 10px;
    font-size: 0.8rem;
    font-weight: 600;
}

.turn-indicator.your-turn {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

/* Game Board */
.game-board {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 10px;
    background: rgba(15, 52, 96, 0.3);
    border-radius: var(--border-radius);
    padding: 10px;
}

/* Players Grid */
.players-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
}

.player-card {
    background: var(--card-bg);
    padding: 8px;
    border-radius: var(--border-radius);
    text-align: center;
}

.player-card.current-turn {
    border: 3px solid #f39c12;
    box-shadow: 0 0 20px rgba(243, 156, 18, 0.3);
}

.player-card.is-you {
    border: 2px solid var(--accent);
}

.player-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
    gap: 8px;
}

.player-name {
    font-size: 0.9rem;
    font-weight: bold;
    text-align: left;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Your Hand */
@keyframes defusePulse {
    0%, 100% {
        background: linear-gradient(135deg, rgba(243, 156, 18, 0.3) 0%, rgba(230, 126, 34, 0.3) 100%);
        box-shadow: 0 0 10px rgba(243, 156, 18, 0.3);
    }
    50% {
        background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
        box-shadow: 0 0 20px rgba(243, 156, 18, 0.6);
    }
}

/* New Round Modal */
@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Game Over - Compact */
.game-over-content-compact {
    text-align: center;
    max-width: 600px;
}

.game-over-content-compact h2 {
    font-size: 1.1rem;
    margin-bottom: 15px;
}

.game-over-message {
    font-size: 0.95rem;
    margin: 12px 0;
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
}

.players-reveal-compact {
    margin: 20px 0;
}

.players-reveal-compact h3 {
    margin-bottom: 12px;
    font-size: 0.9rem;
}

.waiting-players-info {
    margin: 15px 0;
    padding: 12px;
    background: rgba(241, 196, 15, 0.2);
    border: 1px solid #f1c40f;
    border-radius: 8px;
    text-align: center;
}

.waiting-text {
    font-size: 0.85rem;
    font-weight: 600;
    color: #f39c12;
    margin: 0 0 8px 0;
}

.waiting-players-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}

.waiting-player-name {
    background: rgba(241, 196, 15, 0.3);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #f1c40f;
}

#backToLobbyBtn {
    margin: 15px auto 0;
    display: block;
}

/* Side Panel (Logs + Chat) */
.side-panel {
    width: 250px;
    display: none;
    flex-direction: column;
    gap: 10px;
    flex-shrink: 0;
    height: 100%;
}

.side-panel.active {
    display: flex;
}

#sidePanelContainer,
#gameSidePanelContainer {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Game Logs */
.game-logs {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: 0 4px 32px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.game-logs h4 {
    background: linear-gradient(135deg, #5a6c7d 0%, #4a5a6a 100%);
    padding: 8px 10px;
    margin: 0;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    font-weight: 600;
    font-size: 0.8rem;
    text-align: center;
}

.game-logs-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column-reverse;
    gap: 4px;
    min-height: 0;
}

.game-log-item {
    padding: 4px 6px;
    border-radius: 4px;
    background: var(--light-bg);
    font-size: 0.7rem;
    line-height: 1.3;
    animation: logSlide 0.2s ease-out;
    word-wrap: break-word;
}

.game-log-item.round-change {
    border-left: 3px solid #f39c12;
    font-weight: 600;
}

.game-log-item.player-join {
    border-left: 3px solid #2ecc71;
}

.game-log-item.player-leave {
    border-left: 3px solid #95a5a6;
}

.game-log-item.player-kick {
    border-left: 3px solid #e74c3c;
    font-weight: 600;
}

.game-log-item.player-ban {
    border-left: 3px solid #8b2635;
    font-weight: 600;
}

@keyframes logSlide {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Chat Widget */
.chat-widget {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: 0 4px 32px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.chat-header {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
    padding: 8px 10px;
    margin: 0;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    font-weight: 600;
    font-size: 0.8rem;
    text-align: center;
}

.chat-header h4 {
    margin: 0;
    font-size: 0.8rem;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-message {
    padding: 4px 6px;
    border-radius: 4px;
    background: var(--light-bg);
    word-wrap: break-word;
    animation: messageSlide 0.2s ease-out;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
    gap: 8px;
}

.chat-message-author {
    font-weight: 600;
    font-size: 0.7rem;
    color: var(--accent);
    flex-shrink: 0;
}

.chat-message-text {
    font-size: 0.75rem;
    line-height: 1.3;
}

.chat-message-time {
    font-size: 0.6rem;
    opacity: 0.5;
    flex-shrink: 0;
}

.chat-input-container {
    display: flex;
    gap: 4px;
    padding: 6px;
    background: var(--light-bg);
    border-radius: 0 0 var(--border-radius) var(--border-radius);
}

.chat-input-container input {
    flex: 1;
    padding: 5px 8px;
    border: 2px solid transparent;
    border-radius: 4px;
    background: var(--card-bg);
    color: var(--text-light);
    font-size: 0.75rem;
    margin: 0;
}

.chat-input-container input:focus {
    outline: none;
    border-color: var(--accent);
}

.chat-input-container .btn {
    padding: 5px 10px;
    font-size: 0.7rem;
    flex-shrink: 0;
}

/* Responsive - Large Screens */
@media (min-width: 1400px) {
    /* Increase player cards size */
    .players-grid {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
        gap: 15px;
    }

    .player-card {
        padding: 12px;
    }

    .player-name {
        font-size: 1.05rem;
    }

    /* Increase hand size */
    /* Larger announcement buttons */
    /* Larger game info */
    .round-info {
        padding: 8px 15px;
        font-size: 0.85rem;
    }

    .turn-indicator {
        padding: 12px;
        font-size: 0.95rem;
    }

}

@media (min-width: 1600px) {
    /* Even bigger for very large screens */
    .players-grid {
        grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
        gap: 20px;
    }

    .player-card {
        padding: 15px;
    }

    .player-name {
        font-size: 1.15rem;
    }

    .round-info {
        padding: 10px 18px;
        font-size: 0.9rem;
    }

    .turn-indicator {
        padding: 14px;
        font-size: 1rem;
    }

    .game-board {
        padding: 15px;
    }

}

@media (min-width: 1920px) {
    /* Maximum size for ultra-wide screens */
    .game-container {
        max-width: 1800px;
        margin: 0 auto;
    }

    .players-grid {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: 25px;
    }

    .player-card {
        padding: 18px;
    }

    .player-name {
        font-size: 1.25rem;
    }

    .round-info {
        padding: 12px 20px;
        font-size: 0.95rem;
    }

    .turn-indicator {
        padding: 16px;
        font-size: 1.1rem;
    }

    .game-board {
        padding: 20px;
    }

    .side-panel {
        width: 300px;
    }

    .game-logs h4,
.chat-header h4 {
        font-size: 0.9rem;
        padding: 10px 12px;
    }

    .game-log-item {
        font-size: 0.8rem;
        padding: 6px 8px;
    }

    .chat-message {
        padding: 6px 8px;
    }

    .chat-message-author {
        font-size: 0.8rem;
    }

    .chat-message-text {
        font-size: 0.85rem;
    }

}

/* Responsive - Small Screens */
@media (max-width: 768px) {
    /* General adjustments */
    body {
        font-size: 14px;
    }

    .screen {
        padding: 5px;
    }

    .container {
        padding: 0 5px;
    }

    /* Welcome screen - Stack vertically */
    .logo {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 0.9rem;
    }

    .welcome-layout {
        flex-direction: column;
        gap: 15px;
    }

    .welcome-left,
.welcome-right {
        flex: 1 1 auto;
        width: 100%;
        max-width: 100%;
    }

    .welcome-left .card {
        padding: 20px 15px;
    }

    .changelog {
        max-height: 300px;
        min-height: 200px;
        padding: 15px;
    }

    .changelog h3 {
        font-size: 0.9rem;
    }

    .changelog-list li {
        font-size: 0.75rem;
    }

    /* Lobby screen */
    .title-small {
        font-size: 1rem;
    }

    .lobby-actions {
        flex-direction: column;
        gap: 10px;
    }

    .lobby-actions .btn {
        width: 100%;
    }

    .search-bar {
        width: 100%;
        min-width: 100%;
    }

    /* Room list items - Stack vertically on mobile */
    .room-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 12px;
    }

    .room-item-info {
        width: 100%;
        flex-wrap: wrap;
        font-size: 0.75rem;
    }

    .room-code {
        font-size: 0.85rem;
    }

    .room-actions {
        width: 100%;
        flex-direction: row;
        gap: 8px;
    }

    .room-actions .btn {
        flex: 1;
        font-size: 0.7rem;
        padding: 8px 10px;
    }

    .status-badge {
        font-size: 0.7rem;
        padding: 3px 8px;
    }

    /* Room screen - Adjust header */
    .room-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .room-header h2 {
        font-size: 0.95rem;
    }

    .room-header > div {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .room-info {
        flex-direction: column;
        gap: 8px;
        padding: 10px;
    }

    .room-info p {
        font-size: 0.8rem;
    }

    .players-waiting {
        padding: 12px;
    }

    .players-waiting h3 {
        font-size: 0.85rem;
    }

    .players-waiting ul {
        grid-template-columns: 1fr;
    }

    /* Game screen - Major improvements */
    .game-container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
        gap: 8px;
        padding: 5px;
    }

    .game-main {
        flex: 0 1 auto;
        min-height: auto;
        display: flex;
        flex-direction: column;
        overflow-y: visible;
    }

    .game-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 8px;
        background: var(--card-bg);
        border-radius: 8px;
        margin-bottom: 8px;
    }

    .game-header-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .game-info {
        width: 100%;
        flex-wrap: wrap;
        gap: 6px;
    }

    .round-info {
        font-size: 0.7rem;
        padding: 5px 10px;
    }

    .turn-indicator {
        font-size: 0.75rem;
        padding: 8px;
        margin-bottom: 8px;
    }

    /* Players grid - Single column on mobile */
    .players-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .player-card {
        padding: 10px;
    }

    .player-name {
        font-size: 0.85rem;
    }

    /* Your hand - Role and cables side by side, announcements below */
    /* First row: role + cables side by side */
    /* Announcements below - spans both columns on row 2 */
    /* Game board - Better scrolling */
    .game-board {
        flex: 1 1 auto;
        overflow-y: auto;
        margin-bottom: 10px;
        max-height: 50vh;
    }

    /* Side panel - Stacked vertically on mobile */
    #gameSidePanelContainer {
        width: 100%;
        flex-shrink: 0;
    }

    .side-panel {
        width: 100%;
        height: auto;
        max-height: none;
        min-height: auto;
        flex-direction: column;
        gap: 10px;
        overflow: visible;
        display: flex !important;
    }

    .game-logs,
.chat-widget {
        flex: 0 0 auto;
        width: 100%;
        min-height: 200px;
        max-height: 250px;
        overflow: hidden;
    }

    .game-logs-content {
        overflow-y: auto;
        max-height: 140px;
    }

    .chat-messages {
        overflow-y: auto;
        max-height: 140px;
    }

    .game-logs h4,
.chat-header h4 {
        font-size: 0.75rem;
        padding: 6px 8px;
    }

    .game-logs-content,
.chat-messages {
        font-size: 0.7rem;
    }

    .game-log-item {
        font-size: 0.65rem;
        padding: 3px 5px;
    }

    .chat-message {
        padding: 4px 6px;
    }

    .chat-message-author {
        font-size: 0.65rem;
    }

    .chat-message-text {
        font-size: 0.7rem;
    }

    .chat-input-container input {
        font-size: 0.7rem;
        padding: 4px 6px;
    }

    .chat-input-container .btn {
        font-size: 0.65rem;
        padding: 4px 8px;
    }

    /* Modals - Better sizing and positioning */
    .modal {
        padding: 20px 10px;
        align-items: center;
        justify-content: center;
    }

    .modal-content {
        width: 90%;
        max-width: 400px;
        padding: 20px 15px;
        max-height: 80vh;
        overflow-y: auto;
        margin: auto;
    }

    .modal-content h2 {
        font-size: 1rem;
        margin-bottom: 15px;
    }

    .form-group {
        margin-bottom: 12px;
    }

    .form-group label {
        font-size: 0.85rem;
        margin-bottom: 6px;
    }

    input[type="text"],
select {
        font-size: 0.85rem;
        padding: 10px 8px;
    }

    .btn {
        font-size: 0.8rem;
        padding: 10px 16px;
    }

    .modal-actions {
        margin-top: 15px;
    }

    /* Round modal */
    /* Game over modal */
    .game-over-content-compact {
        max-width: 95%;
    }

    /* Spectator mode */
    .spectator-banner {
        font-size: 0.75rem;
        padding: 6px;
    }

    body.spectator-mode {
        padding-top: 30px;
    }

    /* Connection notifications */
    .connection-notification {
        font-size: 0.8rem;
        padding: 10px 15px;
        max-width: 90%;
    }

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

    /* Room container layout */
    .room-container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    .room-main {
        width: 100%;
    }

}

/* Responsive - Very Small Screens (smartphones in portrait) */
@media (max-width: 480px) {
    /* Further reduce sizes for very small screens */
    .logo {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 0.8rem;
    }

    .title-small {
        font-size: 0.9rem;
    }

    /* Make room items even more compact */
    .room-item {
        padding: 10px;
    }

    .room-item-info {
        font-size: 0.7rem;
    }

    .room-code {
        font-size: 0.8rem;
    }

    .room-players-list {
        display: none; /* Hide full player list on very small screens */
    }

    /* Game screen adjustments */
    .game-header {
        padding: 6px;
    }

    .round-info {
        font-size: 0.65rem;
        padding: 4px 8px;
    }

    .turn-indicator {
        font-size: 0.7rem;
        padding: 6px;
    }

    /* Reduce cable sizes even more */
    /* Compact announcements */
    /* Side panel adjustments */
    .side-panel {
        max-height: 250px;
    }

    .game-logs,
.chat-widget {
        min-height: 200px;
    }

    /* Defuse badge smaller */
    /* Announcements display */
}

/* Responsive - Tablet Portrait Mode */
@media (min-width: 481px) and (max-width: 768px) {
    /* Optimize for tablet portrait */
    .players-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .side-panel {
        max-height: 350px;
    }

    .game-logs,
.chat-widget {
        min-height: 280px;
    }

}

/* Responsive - Landscape Mode on Mobile */
@media (max-width: 768px) and (orientation: landscape) {
    /* Adjust for landscape orientation */
    .welcome-layout {
        flex-direction: row;
    }

    .welcome-left,
.welcome-right {
        flex: 1;
    }

    .changelog {
        max-height: calc(100vh - 200px);
    }

    .game-container {
        flex-direction: row;
        height: calc(100vh - 10px);
    }

    .game-main {
        flex: 1;
        overflow-y: auto;
    }

    .side-panel {
        width: 250px;
        max-height: 100%;
        flex-direction: column;
    }

}

/* Volume Slider */
.volume-slider {
    width: 100%;
    height: 6px;
    border-radius: 5px;
    background: linear-gradient(to right, var(--accent) 0%, var(--accent) 100%);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--text-light);
    cursor: pointer;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
    transition: all 0.15s ease;
}

.volume-slider::-webkit-slider-thumb:hover {
    background: #ffffff;
    transform: scale(1.2);
}

.volume-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--text-light);
    cursor: pointer;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
    border: none;
    transition: all 0.15s ease;
}

.volume-slider::-moz-range-thumb:hover {
    background: #ffffff;
    transform: scale(1.2);
}

/* Connection Notifications */
.connection-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    z-index: 10000;
    animation: slideDown 0.3s ease-out;
    font-weight: 600;
    font-size: 0.95rem;
    backdrop-filter: blur(10px);
}

@keyframes slideDown {
    from {
        transform: translate(-50%, -100%);
        opacity: 0;
    }
    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

.connection-notification.fade-out {
    animation: fadeOut 0.3s ease-out forwards;
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
        transform: translate(-50%, -20px);
    }
}

.connection-notification.reconnecting {
    background: linear-gradient(135deg, rgba(241, 196, 15, 0.95) 0%, rgba(243, 156, 18, 0.95) 100%);
    color: var(--text-dark);
    border: 2px solid #f39c12;
}

.connection-notification.reconnecting .notification-icon {
    animation: spin 2s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.connection-notification.success {
    background: linear-gradient(135deg, rgba(46, 204, 113, 0.95) 0%, rgba(39, 174, 96, 0.95) 100%);
    color: white;
    border: 2px solid #27ae60;
}

.connection-notification.warning {
    background: linear-gradient(135deg, rgba(231, 76, 60, 0.95) 0%, rgba(192, 57, 43, 0.95) 100%);
    color: white;
    border: 2px solid #c0392b;
}

.connection-notification.error {
    background: linear-gradient(135deg, rgba(192, 57, 43, 0.95) 0%, rgba(139, 38, 53, 0.95) 100%);
    color: white;
    border: 2px solid #8b2635;
}

.notification-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.notification-message {
    flex: 1;
}

/* Connection status styles for game logs */
.game-log-item.connection-lost {
    border-left: 3px solid #f39c12;
    background: rgba(241, 196, 15, 0.15);
    font-weight: 600;
}

.game-log-item.connection-restored {
    border-left: 3px solid #2ecc71;
    background: rgba(46, 204, 113, 0.15);
    font-weight: 600;
}

.game-log-item.player-disconnected {
    border-left: 3px solid #e67e22;
    background: rgba(230, 126, 34, 0.15);
    font-style: italic;
}

.game-log-item.player-reconnected {
    border-left: 3px solid #2ecc71;
    background: rgba(46, 204, 113, 0.15);
    font-weight: 600;
}

/* ============================================
   SPECTATOR MODE STYLES
   ============================================ */
/* Spectator banner */
.spectator-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
    color: white;
    padding: 10px;
    text-align: center;
    font-weight: bold;
    font-size: 14px;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* Adjust body when spectator mode is active */
body.spectator-mode {
    padding-top: 40px;
}

/* Status badges for rooms */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 600;
    margin-left: 8px;
}

.status-badge.waiting {
    background: rgba(52, 152, 219, 0.2);
    color: #3498db;
    border: 1px solid rgba(52, 152, 219, 0.4);
}

.status-badge.in-progress {
    background: rgba(46, 204, 113, 0.2);
    color: #2ecc71;
    border: 1px solid rgba(46, 204, 113, 0.4);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* Room item styles for in-progress games */
.room-item.in-progress {
    border-left: 3px solid #2ecc71;
    background: linear-gradient(90deg, rgba(46, 204, 113, 0.1) 0%, transparent 100%);
}

/* Room actions container */
.room-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Spectator button */
.btn-spectator {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
    color: white;
}

.btn-spectator:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(var(--accent-rgb), 0.4);
}

.btn-spectator:active {
    transform: translateY(0);
}

/* Spectator view for player cards */
.player-card.spectator-view {
    opacity: 0.95;
}

/* Game log items for spectator events */
.game-log-item.spectator,
.game-log-item.spectator-join,
.game-log-item.spectator-leave {
    border-left: 3px solid var(--accent);
    background: rgba(var(--accent-rgb), 0.15);
}

/* Disable interactions in spectator mode */
/* Hide certain UI elements in spectator mode */
/* Spectator info badge */
.spectator-info {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(var(--accent-rgb), 0.2);
    color: var(--accent);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.9em;
    font-weight: 600;
    margin-left: 10px;
}

/* Adjust game screen layout for spectator */
.spectator-mode .game-screen {
    padding-top: 50px;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .spectator-banner {
        font-size: 12px;
        padding: 8px;
    }

    body.spectator-mode {
        padding-top: 35px;
    }

    .room-actions {
        flex-direction: column;
        width: 100%;
    }

    .room-actions .btn {
        width: 100%;
    }

    .status-badge {
        font-size: 0.75em;
        padding: 3px 8px;
    }

}


/* ═══════════════════════════════════════════════════════════════════
   Socle multi-jeux : lobby, tables, éléments communs aux jeux
   ═══════════════════════════════════════════════════════════════════ */

body {
    transition: background 0.4s;
}

a.btn {
    text-decoration: none;
    display: inline-block;
}

.btn-danger {
    background: linear-gradient(135deg, #e74c3c 0%, var(--danger) 100%);
    color: white;
}

.btn-danger:hover {
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.5);
}

.btn-warning {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    color: white;
}

.btn-small {
    padding: 5px 10px;
    font-size: 0.7rem;
    text-transform: none;
    letter-spacing: 0;
}

.btn-link {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: inherit;
    padding: 0 4px;
    opacity: 0.8;
    text-decoration: underline dotted;
}

.btn-link:hover {
    opacity: 1;
}

.toggle {
    display: flex;
    gap: 8px;
    align-items: center;
    cursor: pointer;
}

.header-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Bandeau de mise à jour du serveur */
.drain-banner {
    position: sticky;
    top: 0;
    z-index: 1500;
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    color: #1a1a1a;
    font-weight: 600;
    font-size: 0.85rem;
    text-align: center;
    padding: 8px 12px;
}

/* Écran de démarrage */
#splashScreen.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    min-height: 100vh;
    animation: splashIn 0.4s ease-out;
}

.splash-logo {
    width: min(220px, 50vw);
    height: auto;
    filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.5));
    animation: splashPulse 1.6s ease-in-out infinite;
}

.splash-title {
    font-size: 2rem;
}

.splash-status {
    min-height: 1.2em;
    font-size: 0.85rem;
    opacity: 0.7;
}

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

@keyframes splashPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
}

/* Logo */
.app-logo {
    width: 150px;
    height: 150px;
    margin: 0 auto;
    filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.45));
}

.app-logo-small {
    width: 40px;
    height: 40px;
}

/* Accueil : formulaire du pseudo, puis la liste des jeux en dessous */
.welcome-left {
    flex-direction: column;
    gap: 15px;
}

.welcome-games {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 15px 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.welcome-games:empty {
    display: none;
}

.welcome-games h3 {
    font-size: 1rem;
    color: #ffd700;
    text-align: center;
}

.welcome-game {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.85rem;
}

.welcome-game-icon {
    font-size: 1.6rem;
    width: 36px;
    text-align: center;
    flex-shrink: 0;
}

.welcome-game-icon img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    vertical-align: middle;
}

.welcome-game-tagline {
    font-size: 0.75rem;
    opacity: 0.75;
}

/* Lobby */
.lobby-top {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.lobby-top .header-buttons {
    position: absolute;
    right: 0;
}

.user-info .btn-link {
    text-decoration: none;
}

#logoutBtn {
    font-size: 0.8rem;
    margin-left: 8px;
}

.games-catalog {
    margin-bottom: 20px;
}

.games-catalog h2,
.room-list-head h2 {
    font-size: 1rem;
    margin-bottom: 10px;
    color: var(--accent);
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 12px;
}

.game-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 12px 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.game-card-icon {
    font-size: 2rem;
    width: 48px;
    text-align: center;
    flex-shrink: 0;
}

.game-card-icon img {
    width: 44px;
    height: 44px;
    object-fit: contain;
}

.game-card-body {
    flex: 1;
    min-width: 0;
}

.game-card-name {
    font-weight: 700;
}

.game-card-tagline,
.game-card-meta {
    font-size: 0.75rem;
    opacity: 0.75;
}

.game-card-meta a {
    color: inherit;
}

.room-list-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.room-list-head h2 {
    margin-bottom: 0;
}

.room-list-head .search-bar {
    margin-left: auto;
}

.game-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.filter-chip {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-light);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 0.75rem;
    cursor: pointer;
}

.filter-chip.active {
    background: var(--accent);
    border-color: var(--accent);
}

.filter-chip:disabled {
    cursor: default;
}

.game-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

/* Table : jeu choisi et changement de jeu */
.table-game {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 10px 15px;
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.table-game-current {
    display: flex;
    align-items: center;
    gap: 12px;
}

.table-game-icon {
    font-size: 2rem;
}

.table-game-icon img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    vertical-align: middle;
}

.table-game-tagline {
    font-size: 0.75rem;
    opacity: 0.75;
}

.table-game-picker {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.table-game-label {
    font-size: 0.75rem;
    opacity: 0.8;
    margin-right: 4px;
}

.room-settings {
    background: var(--card-bg);
    padding: 12px 15px;
    border-radius: var(--border-radius);
    margin-bottom: 15px;
}

.room-settings h3 {
    font-size: 0.85rem;
    margin-bottom: 10px;
}

.room-settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
}

/* Les réglages du jeu s'insèrent dans la même grille */
.game-settings {
    display: contents;
}

.room-settings-grid label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.room-settings-grid select {
    margin: 0;
}

.players-waiting-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.players-waiting-head h3 {
    margin-bottom: 0;
}

.players-waiting li.player-bot {
    border: 1px dashed rgba(var(--accent-rgb), 0.6);
}

.players-waiting li.is-you {
    box-shadow: inset 3px 0 0 var(--accent);
}

.player-stats {
    opacity: 0.7;
    font-size: 0.85em;
}

.spectators-list {
    font-size: 0.8rem;
    opacity: 0.8;
    margin-top: 8px;
}

#takeSeatContainer {
    text-align: center;
    margin-top: 10px;
}

/* Partie */
.game-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.game-root {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.game-header-tools {
    display: inline-flex;
    gap: 8px;
}

.game-header-tools:empty {
    display: none;
}

/* Fin de partie : message et liste (contenu fourni par le jeu) */
.game-over-message.win {
    background: linear-gradient(135deg, var(--win) 0%, #2c4570 100%);
}

.game-over-message.lose {
    background: linear-gradient(135deg, var(--lose) 0%, #5a1a22 100%);
}

.game-over-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 10px 0;
}

.reveal-item {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.06);
}

.reveal-item.win { background: rgba(42, 157, 143, 0.35); }
.reveal-item.lose { background: rgba(192, 57, 43, 0.25); }

.changelog-modal {
    max-width: 600px;
}

.changelog-modal h3 {
    margin-bottom: 10px;
}

@media (max-width: 768px) {
    /* Journal et chat : seulement à une table (la règle mobile plus haut
       les force en display: flex !important) */
    .side-panel:not(.active) {
        display: none !important;
    }

    .lobby-top {
        justify-content: flex-start;
    }

    .app-logo {
        width: 110px;
        height: 110px;
    }

    .room-list-head .search-bar {
        margin-left: 0;
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    body {
        transition: none;
    }

    .splash-logo,
    #splashScreen.active {
        animation: none;
    }
}
