/* ═══════════════════════════════════════════════════════════
   SacàMots — Stylesheet principal
   Design moderne, responsive, optimisé pour le Scrabble
   ═══════════════════════════════════════════════════════════ */

/* ── Variables ── */
:root {
    --color-primary: #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-primary-light: #dbeafe;
    --color-accent: #f59e0b;
    --color-accent-dark: #d97706;
    --color-success: #16a34a;
    --color-success-light: #dcfce7;
    --color-warning: #ea580c;
    --color-danger: #dc2626;
    --color-danger-light: #fee2e2;

    --color-bg: #f8fafc;
    --color-bg-card: #ffffff;
    --color-bg-dark: #0f172a;
    --color-text: #1e293b;
    --color-text-light: #64748b;
    --color-text-muted: #94a3b8;
    --color-border: #e2e8f0;
    --color-border-light: #f1f5f9;

    /* Plateau Scrabble */
    --board-bg: #1a6b3c;
    --board-border: #145530;
    --cell-bg: #d4c89a;
    --cell-border: #c4b88a;
    --cell-center: #f472b6;
    --cell-mot-x2: #f9a8d4;
    --cell-mot-x3: #ef4444;
    --cell-lettre-x2: #60a5fa;
    --cell-lettre-x3: #2563eb;
    --tile-bg: #fef3c7;
    --tile-bg-hover: #fde68a;
    --tile-border: #d97706;
    --tile-text: #1e293b;
    --tile-joker: #a78bfa;

    --radius: 8px;
    --radius-lg: 12px;
    --radius-sm: 4px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    --transition: 0.2s ease;
}

/* ── Reset ── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ── */
.header {
    background: var(--color-bg-dark);
    color: #fff;
    padding: 0 1rem;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
}

.logo-icon { font-size: 1.5rem; }
.logo-text { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em; }
.logo-accent { color: var(--color-accent); }
.logo.logo-min {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--color-accent), var(--color-accent-dark));
    box-shadow: 0 8px 20px rgba(245, 158, 11, 0.35);
}

.music-controls {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.btn-musique,
.btn-musique-arrow {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: background 0.2s, transform 0.2s;
    line-height: 1;
    color: #fff;
}

.btn-musique-arrow {
    font-size: 1.8rem;
}

.btn-musique:hover,
.btn-musique-arrow:hover {
    background: rgba(255,255,255,0.12);
    transform: translateY(-1px);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.home-view .header {
    display: none;
}

.nav-pseudo {
    font-weight: 600;
    color: var(--color-accent);
}

.btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.btn-logout .logout-icon {
    display: none;
}

@media (max-width: 640px) {
    .btn-logout .logout-text { display: none; }
    .btn-logout .logout-icon { display: inline; font-size: 1.1rem; }
}

/* ── Boutons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1.25rem;
    border: 2px solid transparent;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.4;
}

.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); text-decoration: none; }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }

.btn-success { background: var(--color-success); color: #fff; }
.btn-success:hover { background: #15803d; }

.btn-warning { background: var(--color-warning); color: #fff; }
.btn-warning:hover { background: #c2410c; }

.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

.btn-outline { background: transparent; color: #fff; border-color: rgba(255,255,255,0.3); }
.btn-outline:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.5); }

.btn-ghost { background: transparent; color: rgba(255,255,255,0.7); }
.btn-ghost:hover { color: #fff; background: rgba(255,255,255,0.1); }

.btn-sm { padding: 0.25rem 0.75rem; font-size: 0.8rem; }
.btn-lg { padding: 0.75rem 2rem; font-size: 1rem; }
.btn-block { width: 100%; }

/* Boutons dans un contexte clair */
.page .btn-outline { color: var(--color-text); border-color: var(--color-border); }
.page .btn-outline:hover { background: var(--color-border-light); border-color: var(--color-text-light); }
.page .btn-ghost { color: var(--color-text-light); }
.page .btn-ghost:hover { color: var(--color-text); background: var(--color-border-light); }

/* ── Formulaires ── */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
    color: var(--color-text);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 2px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.9375rem;
    transition: border-color var(--transition);
    background: #fff;
    color: var(--color-text);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.form-error {
    background: var(--color-danger-light);
    color: var(--color-danger);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

/* ── Main Content ── */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
    background: radial-gradient(circle at top, rgba(37,99,235,0.35), transparent 45%),
        radial-gradient(circle at 20% 20%, rgba(245,158,11,0.35), transparent 40%),
        var(--color-bg);
    min-height: calc(100vh - 56px);
}

/* ── Page Accueil ── */
.text-accent { color: var(--color-accent); }

/* Annuler les contraintes du main-content pour l'accueil plein écran */
.page-accueil {
    margin: -1.5rem -1rem;
    padding: 0;
    max-width: none;
}

/* Hero plein écran avec plateau en arrière-plan */
.hero-landing {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Grille de plateau en fond (pure CSS) */
.hero-board-bg {
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(
            0deg,
            var(--board-border) 0px, var(--board-border) 1px,
            transparent 1px, transparent 40px
        ),
        repeating-linear-gradient(
            90deg,
            var(--board-border) 0px, var(--board-border) 1px,
            transparent 1px, transparent 40px
        );
    background-color: var(--board-bg);
    filter: blur(3px);
    transform: scale(1.05);
}

/* ── Splash Screen ── */
.splash-screen {
    position: relative;
    min-height: calc(100vh - 56px);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: var(--color-bg-dark);
}

.splash-content {
    text-align: center;
    z-index: 2;
    animation: splashFadeIn 0.8s ease-out;
}

.splash-title {
    font-size: 3.5rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 0.5rem;
}

.splash-sub {
    font-size: 1.2rem;
    color: var(--color-text-muted);
    margin-bottom: 2rem;
}

.splash-btn {
    animation: splashPulse 2s ease-in-out infinite;
}

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

@keyframes splashPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); }
    50% { transform: scale(1.05); box-shadow: 0 0 20px 5px rgba(245, 158, 11, 0.3); }
}

/* Pluie de jetons en arrière-plan */
.jetons-pluie {
    position: absolute;
    inset: 0;
    z-index: 1;
    overflow: hidden;
    pointer-events: none;
}

.jeton-tombant {
    position: absolute;
    top: -50px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.2em;
    height: 2.2em;
    background: linear-gradient(145deg, #f5e6c8, #dfc89a);
    border-radius: 4px;
    font-weight: 700;
    color: #3e2723;
    box-shadow: 1px 2px 4px rgba(0,0,0,0.2);
    animation: jetonTombe linear forwards;
    font-family: 'Georgia', serif;
}

.jeton-tombant .jt-val {
    position: absolute;
    bottom: 2px;
    right: 3px;
    font-size: 0.5em;
    font-weight: 600;
    color: #795548;
}

@keyframes jetonTombe {
    0% {
        transform: translateY(0) rotate(0deg);
    }
    100% {
        transform: translateY(calc(100vh + 60px)) rotate(360deg);
    }
}

/* Overlay sombre semi-transparent */
.hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        135deg,
        rgba(15, 23, 42, 0.85) 0%,
        rgba(15, 23, 42, 0.7) 40%,
        rgba(15, 23, 42, 0.85) 100%
    );
}

/* Contenu centré */
.hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 2rem;
}

.hero-rotating-tile {
    width: clamp(90px, 15vw, 140px);
    height: clamp(90px, 15vw, 140px);
    margin: 0 auto 1rem;
    perspective: 900px;
}

.hero-rotating-tile .tile-3d {
    width: 100%;
    height: 100%;
    border-radius: 16px;
    border: 3px solid rgba(60,50,40,0.35);
    background: linear-gradient(135deg, #f9e7c2, #d7ba8a);
    box-shadow:
        0 20px 40px rgba(15,23,42,0.45),
        inset 0 4px 8px rgba(255,255,255,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #3b2f27;
    font-family: 'Georgia', serif;
    font-size: clamp(2.5rem, 5vw, 3.5rem);
    font-weight: 700;
    position: relative;
    transform-style: preserve-3d;
    animation: tileSpin 4s linear infinite;
}

.hero-rotating-tile .tile-3d::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 16px;
    background: rgba(255,255,255,0.15);
    transform: translateZ(6px);
}

.hero-rotating-tile .tile-letter {
    position: relative;
    z-index: 2;
    text-transform: uppercase;
    line-height: 1;
}

.hero-rotating-tile .tile-value {
    position: absolute;
    bottom: 10px;
    right: 12px;
    font-size: clamp(0.8rem, 2vw, 1rem);
    font-weight: 600;
    z-index: 2;
}

@keyframes tileSpin {
    0% { transform: rotateY(0deg); }
    50% { transform: rotateY(180deg); }
    100% { transform: rotateY(360deg); }
}

.hero-title-big {
    font-size: 4.5rem;
    font-weight: 900;
    letter-spacing: -0.04em;
    color: #fff;
    margin-bottom: 0.75rem;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.hero-title-big .text-accent {
    color: var(--color-accent);
}

.hero-tagline {
    font-size: 1.5rem;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.hero-sub {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 2.5rem;
}

.btn-jouer {
    font-size: 1.5rem;
    padding: 1rem 3.5rem;
    background: linear-gradient(135deg, var(--color-accent), var(--color-accent-dark));
    color: #fff;
    border: none;
    border-radius: 50px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 8px 30px rgba(245, 158, 11, 0.4);
    transition: all 0.25s ease;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.btn-jouer:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 12px 40px rgba(245, 158, 11, 0.5);
}

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

/* Barre de fonctionnalités */
.features-bar {
    display: flex;
    justify-content: center;
    gap: 2rem;
    padding: 1.25rem 1rem;
    background: var(--color-bg-dark);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    flex-wrap: wrap;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
    font-weight: 500;
}

.feature-item span {
    font-size: 1.2rem;
}

/* ── Modale Choix Jouer ── */
.choix-jouer {
    text-align: center;
}

.choix-jouer h2 {
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
    color: var(--color-bg-dark);
}

.choix-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.choix-carte {
    background: var(--color-bg);
    padding: 1.5rem 1rem;
    border-radius: var(--radius-lg);
    cursor: pointer;
    border: 2px solid var(--color-border);
    transition: all 0.2s ease;
}

.choix-carte:hover {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
    transform: translateY(-2px);
}

.choix-icone {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 0.75rem;
}

.choix-carte h3 {
    font-size: 1rem;
    margin-bottom: 0.25rem;
    color: var(--color-bg-dark);
}

.choix-carte p {
    font-size: 0.8rem;
    color: var(--color-text-light);
}

.choix-footer {
    font-size: 0.85rem;
    color: var(--color-text-light);
}

/* ── Formulaire invité ── */
.form-invite {
    text-align: center;
}

.form-invite h2 {
    margin-bottom: 1.5rem;
    color: var(--color-bg-dark);
}

.pseudo-input {
    position: relative;
    display: flex;
    align-items: center;
}

.pseudo-input input {
    padding-right: 3rem;
}

.pseudo-random-btn {
    position: absolute;
    right: 0.4rem;
    border: none;
    background: var(--color-border-light);
    color: var(--color-text);
    border-radius: 8px;
    width: 2.25rem;
    height: 2.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: background var(--transition), transform var(--transition);
}

.pseudo-random-btn:hover {
    background: var(--color-border);
    transform: translateY(-1px);
}

/* ── Auth form (connexion/inscription en modale) ── */
.auth-form {
    background: var(--color-bg-card);
    padding: 2rem;
    border-radius: var(--radius-lg);
}

.auth-form h2 {
    margin-bottom: 1.5rem;
    text-align: center;
}

.auth-switch {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.875rem;
    color: var(--color-text-light);
}

/* ── Bandeau reprise de partie ── */
.bandeau-reprise {
    background: linear-gradient(135deg, var(--color-primary-light), #ede9fe);
    border: 2px solid var(--color-primary);
    border-radius: var(--radius-lg);
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    animation: bandeauEntree 0.4s ease;
}

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

.bandeau-reprise-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.bandeau-reprise-info strong {
    font-size: 1.05rem;
    color: var(--color-bg-dark);
}

.bandeau-reprise-info span {
    font-size: 0.85rem;
    color: var(--color-text-light);
}

.bandeau-reprise-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-danger-text {
    color: var(--color-danger) !important;
    border-color: var(--color-danger) !important;
}

.btn-danger-text:hover {
    background: var(--color-danger-light) !important;
}

/* ── Lobby ── */
.page-lobby {
    min-height: calc(100vh - 56px);
    padding-bottom: 3rem;
}

.lobby-hero {
    display: flex;
    gap: 2rem;
    align-items: stretch;
    flex-wrap: wrap;
    margin-bottom: 2rem;
}


.lobby-hero-text {
    flex: 1 1 420px;
    background: var(--color-bg-card);
    border-radius: var(--radius-lg);
    padding: 2rem 2.5rem;
    color: var(--color-text);
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(15,23,42,0.08);
}

.lobby-hero-text .eyebrow {
    letter-spacing: 0.3em;
    text-transform: uppercase;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.lobby-hero-text h2 {
    font-size: clamp(2.2rem, 3vw, 2.8rem);
    margin: 0.4rem 0;
}

.lobby-hero-text .subtitle {
    color: var(--color-text-light);
    margin-bottom: 1.5rem;
}

.lobby-ctas {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}


.rooms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
}

.room-card-v2 {
    background: rgba(15, 23, 42, 0.9);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    color: #fff;
    border: 1px solid rgba(37,99,235,0.4);
    box-shadow: 0 12px 30px rgba(15,23,42,0.4);
    transform: translateY(0);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.room-card-v2:hover {
    transform: translateY(-6px);
    box-shadow: 0 18px 40px rgba(15,23,42,0.55);
}

.room-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.35rem;
}

.room-card-chip {
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0.2rem 0.75rem;
    border-radius: 999px;
}
.chip-private { background: rgba(236,72,153,0.2); color: #f472b6; }
.chip-public { background: rgba(34,197,94,0.2); color: #4ade80; }

.room-card-meta {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.65);
    margin-bottom: 0.75rem;
}

.room-card-stats {
    display: flex;
    gap: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.room-card-v2 .btn {
    width: 100%;
}

.loading,
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--color-text-muted);
    font-style: italic;
}

/* ── Room (salle d'attente) ── */
.page-room {
    min-height: calc(100vh - 56px);
    background: radial-gradient(circle at 80% 20%, rgba(14,165,233,0.2), transparent 45%),
        radial-gradient(circle at 10% 10%, rgba(31,41,55,0.25), transparent 50%),
        var(--color-bg);
    padding-bottom: 3rem;
}

.room-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.room-code {
    background: var(--color-accent);
    color: #fff;
    font-weight: 700;
    font-family: monospace;
    font-size: 1.1rem;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
}

.room-content {
    display: grid;
    gap: 1.5rem;
}

.room-content > .room-config {
    align-self: flex-start;
}

@media (min-width: 992px) {
    .room-content {
        grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
        align-items: flex-start;
        grid-auto-flow: dense;
    }

    .room-content > .room-players {
        grid-column: 1;
        grid-row: 1;
    }

    .room-content > .room-config {
        grid-column: 2;
        grid-row: 1;
    }

    .room-content > .room-chat {
        grid-column: 1 / -1;
    }
}

.room-players {
    background: var(--color-bg-card);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    color: var(--color-text);
}

.card-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

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

.player-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-radius: var(--radius);
    background: var(--color-bg);
    border: 1px solid var(--color-border-light);
}

.player-card.owner { border-color: rgba(245,158,11,0.6); }
.player-card.ready { border-color: rgba(16,185,129,0.6); }
.player-card.bot { border-style: dashed; }
.player-card.empty { opacity: 0.45; }

.player-avatar {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: var(--color-border-light);
    color: var(--color-text);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.player-card.bot .player-avatar { background: rgba(34,197,94,0.2); }
.player-card.empty .player-avatar { border: 1px dashed var(--color-border-light); background: transparent; }

.player-info { flex: 1; }
.player-info .player-name { font-weight: 700; display: block; color: var(--color-bg-dark); }
.player-info .player-role { font-size: 0.85rem; color: var(--color-text-light); }

.player-status-chip {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.8rem;
    border-radius: 999px;
    background: rgba(15,23,42,0.08);
}
.player-status-chip.ready { background: rgba(16,185,129,0.2); color: #34d399; }
.player-status-chip.owner { background: rgba(245,158,11,0.2); color: #fbbf24; }

.room-status-chip {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    background: rgba(255,255,255,0.14);
}
.room-status-chip.waiting { color: #fbbf24; }
.room-status-chip.playing { color: #60a5fa; }

.room-config-card {
    background: var(--color-bg-card);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-lg);
}

.room-config-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1.25rem;
}
.room-config-list li {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--color-border-light);
}
.room-config-list li span { color: var(--color-text-muted); }
.room-config-list li strong { font-weight: 700; }

.room-progress {
    width: 100%;
    height: 10px;
    background: var(--color-border-light);
    border-radius: 999px;
    overflow: hidden;
}
.room-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #0ea5e9, #a855f7, #f97316);
}
.room-progress-text {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.room-chat {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: 0 15px 40px rgba(15,23,42,0.15);
    padding: 1.25rem;
    color: var(--color-text);
    border: 1px solid rgba(15,23,42,0.08);
}

.room-countdown {
    background: rgba(56,189,248,0.15);
    color: #bae6fd;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.chat-messages {
    background: #f8fafc;
    border-radius: var(--radius);
    color: var(--color-text);
}

.room-footer {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1.5rem;
}

.room-footer .btn {
    flex: 1;
    max-width: 220px;
}

/* ── Chat ── */
.game-chat {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.game-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.game-chat-header h3 {
    margin: 0;
    font-size: 0.95rem;
}

.btn-toggle-chat {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 0.2rem 0.5rem;
    font-size: 0.7rem;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-toggle-chat:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

.btn-toggle-chat.chat-off {
    color: var(--color-danger);
    border-color: var(--color-danger);
}

.chat-disabled-notice {
    padding: 1rem;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.8rem;
    font-style: italic;
}

.chat-messages {
    flex: 1;
    min-height: 120px;
    max-height: 250px;
    overflow-y: auto;
    padding: 0.75rem;
    background: #f8fafc;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    border: 1px solid rgba(15,23,42,0.08);
}

.chat-msg {
    color: var(--color-text);
}

.chat-msg {
    margin-bottom: 0.375rem;
    line-height: 1.4;
}

.chat-msg-author {
    font-weight: 700;
    color: var(--color-primary);
}

.chat-msg-system {
    color: var(--color-text-muted);
    font-style: italic;
}

.chat-form {
    display: flex;
    gap: 0.375rem;
}

.chat-form input {
    flex: 1;
    min-width: 0;
    padding: 0.4rem 0.6rem;
    border: 2px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.8rem;
}

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

.chat-form .btn-sm {
    flex-shrink: 0;
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
}

.btn-emoji-toggle {
    flex-shrink: 0;
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 0.25rem 0.4rem;
    font-size: 0.95rem;
    cursor: pointer;
    line-height: 1;
    transition: all var(--transition);
}

.btn-emoji-toggle:hover {
    background: var(--color-bg);
    border-color: var(--color-primary);
}

.chat-smileys-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
    padding: 0.4rem;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    margin-top: 0.375rem;
}

.smiley-btn {
    background: none;
    border: none;
    font-size: 1.15rem;
    cursor: pointer;
    padding: 0.2rem;
    border-radius: var(--radius-sm);
    line-height: 1;
    transition: transform 0.15s, background 0.15s;
}

.smiley-btn:hover {
    background: var(--color-bg-card);
    transform: scale(1.2);
}

.chat-rules {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    font-size: 0.65rem;
    color: var(--color-text-muted);
    line-height: 1.4;
    border-left: 2px solid var(--color-border);
}

/* ── Game Layout ── */
.game-layout {
    display: grid;
    grid-template-columns: 220px 1fr 240px;
    gap: 1rem;
    min-height: calc(100vh - 120px);
}

.game-sidebar {
    background: var(--color-bg-card);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
    overflow-y: auto;
}

.game-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

/* ── Scores ── */
.game-scores .score-card {
    padding: 0.625rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    background: var(--color-bg);
    transition: all var(--transition);
}

.score-card.active {
    background: var(--color-primary-light);
    border-left: 3px solid var(--color-primary);
}

.score-card .player-name {
    font-size: 0.85rem;
    font-weight: 700;
}

.score-card .player-score {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--color-primary);
}

.score-card .player-rack-count {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.game-bag-count {
    text-align: center;
    padding: 0.75rem;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    margin: 0.75rem 0;
}

.game-history h3 {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.history-list {
    max-height: 300px;
    overflow-y: auto;
    font-size: 0.8rem;
}

.history-item {
    padding: 0.375rem 0;
    border-bottom: 1px solid var(--color-border-light);
}

.history-item:last-child { border-bottom: none; }

.history-item .h-player { font-weight: 600; }
.history-item .h-score { color: var(--color-primary); font-weight: 700; }
.history-item .h-words { color: var(--color-text-light); font-size: 0.75rem; }

/* ── Barre de statut ── */
.turn-info {
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.turn-info::before {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-danger);
    flex-shrink: 0;
}

.turn-info.mon-tour {
    color: var(--color-primary);
    font-weight: 700;
    font-size: 1.05rem;
    animation: pulseTour 1.5s ease-in-out infinite;
}

.turn-info.mon-tour::before {
    background: var(--color-success);
    box-shadow: 0 0 6px var(--color-success);
}

@keyframes pulseTour {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.85; transform: scale(1.05); }
}

.game-status-bar {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    background: var(--color-bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    font-weight: 600;
}

.game-status-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-toggle-son {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.2rem;
    line-height: 1;
    opacity: 0.7;
    transition: opacity var(--transition);
}

.btn-toggle-son:hover {
    opacity: 1;
}

.game-timer {
    font-family: monospace;
    font-size: 1.1rem;
    color: var(--color-warning);
}

.game-timer.urgent {
    color: var(--color-danger);
    animation: blink 0.5s infinite;
}

@keyframes blink {
    50% { opacity: 0.3; }
}

/* ── Plateau 15×15 ── */
.game-board-wrapper {
    background: var(--board-bg);
    border: 3px solid var(--board-border);
    border-radius: var(--radius);
    padding: 4px;
    box-shadow: var(--shadow-lg);
    width: fit-content;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(15, 1fr);
    grid-template-rows: repeat(15, 1fr);
    gap: 2px;
    --board-size: min(calc(100vh - 260px), calc(100vw - 520px), 700px);
    width: var(--board-size);
    height: var(--board-size);
}

.board-cell {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--cell-bg);
    border-radius: 2px;
    font-size: clamp(0.5rem, 1.8vw, 0.85rem);
    font-weight: 700;
    position: relative;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.board-cell:hover:not(.has-tile) { background: #e8deb0; }

.board-cell.center { background: var(--cell-center); }
.board-cell.center::after { content: '★'; color: #fff; font-size: clamp(0.6rem, 2vw, 1rem); }

.board-cell.mot-x2 { background: var(--cell-mot-x2); }
.board-cell.mot-x2:not(.has-tile)::after { content: 'M×2'; color: #fff; font-size: clamp(0.35rem, 1vw, 0.55rem); }

.board-cell.mot-x3 { background: var(--cell-mot-x3); }
.board-cell.mot-x3:not(.has-tile)::after { content: 'M×3'; color: #fff; font-size: clamp(0.35rem, 1vw, 0.55rem); }

.board-cell.lettre-x2 { background: var(--cell-lettre-x2); }
.board-cell.lettre-x2:not(.has-tile)::after { content: 'L×2'; color: #fff; font-size: clamp(0.35rem, 1vw, 0.55rem); }

.board-cell.lettre-x3 { background: var(--cell-lettre-x3); }
.board-cell.lettre-x3:not(.has-tile)::after { content: 'L×3'; color: #fff; font-size: clamp(0.35rem, 1vw, 0.55rem); }

.board-cell.has-tile {
    background: var(--tile-bg);
    border: 2px solid var(--tile-border);
    box-shadow: 1px 1px 2px rgba(0,0,0,0.2);
    cursor: default;
}

.board-cell.has-tile.joker-tile {
    border-color: var(--tile-joker);
}

.board-cell.has-tile .tile-letter {
    font-size: clamp(0.55rem, 2vw, 0.95rem);
    font-weight: 800;
    color: var(--tile-text);
    line-height: 1;
}

.board-cell.has-tile .tile-value {
    position: absolute;
    bottom: 1px;
    right: 2px;
    font-size: clamp(0.3rem, 0.8vw, 0.55rem);
    font-weight: 600;
    color: var(--color-text-light);
}

.board-cell.temp-tile {
    background: var(--tile-bg-hover);
    border: 2px solid var(--color-accent);
    box-shadow: 0 0 6px rgba(245, 158, 11, 0.5);
    animation: placedPulse 0.3s ease;
}

.board-cell.last-played {
    border: 2px solid var(--color-primary);
    box-shadow: 0 0 8px rgba(37, 99, 235, 0.5);
    animation: lastPlayGlow 2s ease-in-out 3;
}

@keyframes lastPlayGlow {
    0%, 100% { box-shadow: 0 0 4px rgba(37, 99, 235, 0.3); }
    50% { box-shadow: 0 0 12px rgba(37, 99, 235, 0.7); }
}

@keyframes placedPulse {
    0% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.board-cell.drop-target {
    background: rgba(37, 99, 235, 0.2);
    outline: 2px dashed var(--color-primary);
}

/* ── Chevalet ── */
.game-rack-wrapper {
    width: 100%;
    max-width: 600px;
}

.game-rack {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 0.75rem;
    background: #8B5E3C;
    border-radius: var(--radius);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3), var(--shadow-md);
    min-height: 60px;
}

.rack-tile {
    width: clamp(40px, 8vw, 56px);
    height: clamp(40px, 8vw, 56px);
    background: var(--tile-bg);
    border: 2px solid var(--tile-border);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: clamp(1rem, 3vw, 1.5rem);
    color: var(--tile-text);
    cursor: grab;
    user-select: none;
    transition: all 0.15s ease;
    box-shadow: 1px 2px 3px rgba(0,0,0,0.25);
    position: relative;
}

.rack-tile:hover { transform: translateY(-4px); box-shadow: 2px 4px 6px rgba(0,0,0,0.3); }
.rack-tile:active { cursor: grabbing; transform: scale(0.95); }

.rack-tile.joker { border-color: var(--tile-joker); background: #ede9fe; }

.rack-tile.selected {
    outline: 3px solid var(--color-primary);
    transform: translateY(-6px);
    box-shadow: 0 6px 12px rgba(37, 99, 235, 0.3);
}

.rack-tile.exchange-selected {
    outline: 3px solid var(--color-danger);
    opacity: 0.6;
}

.rack-tile .tile-value-rack {
    font-size: 0.55rem;
    font-weight: 600;
    color: var(--color-text-light);
    position: absolute;
    bottom: 2px;
    right: 3px;
}

.rack-tile.dragging {
    opacity: 0.4;
}

.rack-tile.rack-drop-target {
    outline: 3px dashed var(--color-accent);
    background: var(--tile-bg-hover);
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 6px 16px rgba(245, 158, 11, 0.35);
}

.rack-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

.score-preview {
    display: none;
    background: var(--color-primary);
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius);
    animation: popIn 0.2s ease-out;
}

@keyframes popIn {
    0% { transform: scale(0.7); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.touch-ghost {
    position: fixed;
    z-index: 3000;
    pointer-events: none;
    opacity: 0.85;
    transform: scale(1.15);
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

/* ── Modale ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.modal-content {
    background: var(--color-bg-card);
    border-radius: var(--radius-lg);
    padding: 2rem;
    max-width: 480px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    position: relative;
}

.modal-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--color-text-muted);
    line-height: 1;
}

.modal-close:hover { color: var(--color-text); }

/* ── Toast notifications ── */
.toast-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
    max-width: 400px;
    text-align: center;
    pointer-events: auto;
}

.toast-success { background: var(--color-success); }
.toast-error { background: var(--color-danger); }
.toast-info { background: var(--color-primary); }
.toast-warning { background: var(--color-warning); }

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

.toast.hiding {
    animation: toastOut 0.3s ease forwards;
}

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

/* ── Zone publicitaire ── */
.ad-zone {
    text-align: center;
    padding: 0.5rem;
    background: var(--color-border-light);
    border-radius: var(--radius-sm);
    min-height: 60px;
}

.ad-banner-top, .ad-banner-bottom {
    max-width: 1400px;
    margin: 0 auto;
}

/* ── Game Over ── */
.game-over-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    backdrop-filter: blur(4px);
}

.game-over-card {
    background: var(--color-bg-card);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    text-align: center;
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

.game-over-card h2 { font-size: 1.75rem; margin-bottom: 1rem; }
.game-over-card .winner-name { color: var(--color-accent); font-weight: 800; font-size: 1.5rem; }

.final-scores {
    margin: 1.5rem 0;
}

.final-scores table {
    width: 100%;
    border-collapse: collapse;
}

.final-scores th, .final-scores td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border-light);
}

.final-scores th { font-size: 0.8rem; color: var(--color-text-muted); text-transform: uppercase; }
.final-scores td { font-weight: 600; }

/* ── Responsive ── */
@media (max-width: 1024px) {
    .game-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
    }

    .game-sidebar-left {
        display: flex;
        gap: 1rem;
        flex-wrap: wrap;
        order: 1;
    }

    .game-sidebar-left .game-history { display: none; }

    .game-center { order: 2; }
    .game-sidebar-right { order: 3; }

    .game-board { --board-size: min(90vw, 585px); width: var(--board-size); height: var(--board-size); }
}

@media (max-width: 768px) {
    .room-content { grid-template-columns: 1fr; }
    .hero-title-big { font-size: 2.5rem; }
    .hero-tagline { font-size: 1.1rem; }
    .hero-sub { font-size: 0.85rem; }
    .btn-jouer { font-size: 1.2rem; padding: 0.875rem 2.5rem; }
    .choix-options { grid-template-columns: 1fr; }
    .features-bar { gap: 1rem; }
    .lobby-header { flex-direction: column; align-items: flex-start; }
    .game-sidebar-right { display: none; }
}

@media (max-width: 480px) {
    .header { padding: 0 0.5rem; }
    .main-content { padding: 1rem 0.5rem; }
    .game-board { --board-size: 95vw; width: var(--board-size); height: var(--board-size); }
    .rack-tile { width: 38px; height: 38px; font-size: 0.9rem; }
    .rack-actions { gap: 0.25rem; flex-wrap: nowrap; }
    .rack-actions .btn { padding: 0.375rem 0.5rem; font-size: 0.75rem; white-space: nowrap; }
    .game-status-bar { padding: 0.35rem 0.5rem; font-size: 0.8rem; }
    .score-preview { font-size: 0.75rem; padding: 0.25rem 0.5rem; }
}

@media (max-width: 640px) {
    .page-lobby { padding-bottom: 2rem; }
    .lobby-hero {
        flex-direction: column;
        gap: 1rem;
        margin-bottom: 1.25rem;
    }
    .lobby-hero-text {
        flex: 1 1 auto;
        width: 100%;
    }
    .lobby-hero-text { padding: 1.5rem; }
    .lobby-ctas {
        flex-direction: column;
        gap: 0.75rem;
    }
    .lobby-ctas .btn {
        width: 100%;
        justify-content: center;
    }
    .rooms-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    .room-card-v2 { padding: 1.25rem; }
    .room-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.35rem;
    }
    .room-card-stats {
        flex-direction: column;
        gap: 0.35rem;
    }
}
