/* ============================================
   MOTRIX - Trouve le mot caché
   © 2024-2026 PRESTATIC (SARL) - SOUILAH AKIM
   ============================================ */

:root {
    --bg-primary: #0a0a1a;
    --bg-secondary: #12122a;
    --bg-tertiary: #1a1a3a;
    --bg-card: rgba(255, 255, 255, 0.04);
    --bg-card-hover: rgba(255, 255, 255, 0.08);
    --glass: rgba(255, 255, 255, 0.06);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: #b0b0c0;
    --text-muted: #606070;
    --accent-purple: #6c5ce7;
    --accent-purple-light: #a29bfe;
    --accent-purple-glow: rgba(108, 92, 231, 0.4);
    --accent-cyan: #00cec9;
    --accent-cyan-glow: rgba(0, 206, 201, 0.4);
    --accent-green: #00b894;
    --accent-pink: #fd79a8;
    --accent-orange: #fdcb6e;
    --accent-red: #d63031;
    --tile-size: clamp(52px, 13vw, 64px);
    --tile-gap: clamp(5px, 1.2vw, 7px);
    --radius: 14px;
    --radius-sm: 8px;
    --radius-lg: 20px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

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

body {
    font-family: 'Poppins', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* ============ SCREENS ============ */

.screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s ease;
    z-index: 1;
}

.screen.active {
    opacity: 1;
    visibility: visible;
    z-index: 10;
}

/* ============ LOADING SCREEN ============ */

#screenLoading {
    background: radial-gradient(ellipse at center, #1a1a4a 0%, var(--bg-primary) 70%);
}

.loading-container {
    text-align: center;
    animation: fadeInUp 0.8s ease;
}

.loading-logo {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 30px;
}

.logo-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-purple-light));
    border-radius: 10px;
    font-family: 'Orbitron', sans-serif;
    font-weight: 800;
    font-size: 1.5rem;
    color: #fff;
    box-shadow: 0 4px 15px var(--accent-purple-glow);
    animation: tileFloat 2s ease-in-out infinite;
    animation-delay: calc(var(--i) * 0.12s);
}

.loading-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 2.5rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.loading-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 40px;
}

.loading-bar-container {
    width: 320px;
    max-width: 80vw;
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    margin: 0 auto 16px;
    overflow: hidden;
}

.loading-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-purple), var(--accent-cyan));
    border-radius: 3px;
    transition: width 0.3s ease;
}

.loading-text {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ============ HOME SCREEN ============ */

#screenHome {
    background: radial-gradient(ellipse at 30% 20%, rgba(108, 92, 231, 0.15) 0%, transparent 50%),
                radial-gradient(ellipse at 70% 80%, rgba(0, 206, 201, 0.1) 0%, transparent 50%),
                var(--bg-primary);
    overflow-y: auto;
}

.floating-letters {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

.floating-tile {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    opacity: 0.06;
    animation: floatUp linear infinite;
    pointer-events: none;
}

.home-container {
    position: relative;
    z-index: 1;
    text-align: center;
    max-width: 480px;
    width: 100%;
    padding: 40px 20px;
}

.home-title {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(2.4rem, 8vw, 3.2rem);
    font-weight: 900;
    color: #fff;
    margin-bottom: 6px;
    text-shadow: 0 0 40px rgba(108, 92, 231, 0.3);
}

.home-title span {
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.home-subtitle {
    font-size: 1.05rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.home-stats-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 20px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 50px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 44px;
    backdrop-filter: blur(10px);
}

.home-menu {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 44px;
}

.menu-btn {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    padding: 18px 24px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    backdrop-filter: blur(10px);
}

.menu-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-purple);
    transform: translateX(8px);
    box-shadow: 0 0 30px rgba(108, 92, 231, 0.15);
}

.menu-btn.primary {
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.2), rgba(0, 206, 201, 0.1));
    border-color: var(--accent-purple);
}

.menu-btn.primary:hover {
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.35), rgba(0, 206, 201, 0.2));
    box-shadow: 0 0 40px rgba(108, 92, 231, 0.25);
}

.btn-icon { font-size: 1.4rem; }
.btn-label { flex: 1; }
.btn-arrow { color: var(--text-muted); font-size: 1.2rem; transition: var(--transition); }
.menu-btn:hover .btn-arrow { color: var(--accent-purple); transform: translateX(4px); }

.home-footer {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.home-footer strong { color: var(--accent-purple); }

.home-legal {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 8px 0 4px;
}

.home-legal a {
    color: #8888a0;
    text-decoration: none;
    font-size: 0.7rem;
    transition: color 0.3s;
}
.home-legal a:hover { color: var(--accent-purple); }

.home-cookie-btn {
    background: none;
    border: none;
    color: #8888a0;
    font-size: 0.7rem;
    font-family: 'Poppins', sans-serif;
    cursor: pointer;
    transition: color 0.3s;
    padding: 0;
}
.home-cookie-btn:hover { color: var(--accent-purple); }

.home-version {
    margin-top: 4px;
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ============ GAME SCREEN ============ */

#screenGame {
    background: radial-gradient(ellipse at 50% 0%, rgba(108, 92, 231, 0.08) 0%, transparent 60%),
                var(--bg-primary);
    flex-direction: column;
    justify-content: flex-start;
}

.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    flex-shrink: 0;
}

.back-to-hub {
    position: absolute;
    top: 20px;
    left: 24px;
    z-index: 5;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    background: rgba(108, 92, 231, 0.12);
    border: 1px solid rgba(108, 92, 231, 0.3);
    border-radius: 50px;
    color: var(--accent-purple-light);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s;
    backdrop-filter: blur(10px);
}
.back-to-hub:hover {
    background: rgba(108, 92, 231, 0.25);
    border-color: rgba(108, 92, 231, 0.6);
    color: #fff;
    transform: translateX(-4px);
}

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

.game-back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}
.game-back-btn:hover {
    background: var(--bg-card-hover);
    color: var(--accent-purple);
    border-color: var(--accent-purple);
}

.game-hub-link {
    padding: 6px 14px;
    background: rgba(108, 92, 231, 0.12);
    border: 1px solid rgba(108, 92, 231, 0.25);
    border-radius: 50px;
    color: var(--accent-purple-light);
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 500;
    transition: all 0.3s;
}
.game-hub-link:hover {
    background: rgba(108, 92, 231, 0.25);
    border-color: rgba(108, 92, 231, 0.5);
    color: #fff;
}

.game-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.3rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

.game-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}
.game-action-btn:hover {
    background: var(--bg-card-hover);
    color: var(--accent-cyan);
    border-color: var(--accent-cyan);
}

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

.game-mode-badge {
    padding: 6px 16px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--accent-cyan);
    backdrop-filter: blur(8px);
    letter-spacing: 0.5px;
}

.game-player-badge {
    padding: 6px 16px;
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.15), rgba(0, 206, 201, 0.08));
    border: 1px solid rgba(108, 92, 231, 0.3);
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-purple-light);
    letter-spacing: 0.3px;
}

.game-player-badge:empty {
    display: none;
}

.game-replay-btn {
    padding: 6px 18px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 50px;
    font-family: 'Poppins', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-orange);
    cursor: pointer;
    transition: var(--transition);
    letter-spacing: 0.3px;
}

.game-replay-btn:hover {
    background: rgba(253, 203, 110, 0.12);
    border-color: var(--accent-orange);
    transform: scale(1.05);
}

/* ============ GAME MAIN (board + leaderboard) ============ */

.game-main {
    flex: 1;
    display: flex;
    align-items: stretch;
    justify-content: center;
    width: 100%;
    min-height: 0;
    gap: 16px;
    padding: 0 16px;
}

/* ============ GAME BOARD ============ */

.game-board-area {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    min-height: 0;
}

.game-board {
    display: grid;
    grid-template-rows: repeat(6, var(--tile-size));
    grid-template-columns: repeat(5, var(--tile-size));
    gap: var(--tile-gap);
}

.tile {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--tile-size);
    height: var(--tile-size);
    border: 2px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(1.4rem, 4vw, 1.8rem);
    font-weight: 800;
    color: var(--text-primary);
    text-transform: uppercase;
    transition: border-color 0.15s ease;
    perspective: 600px;
}

.tile-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border-radius: calc(var(--radius-sm) - 2px);
    background: transparent;
    transition: background 0s;
    transform-style: preserve-3d;
}

.tile.filled {
    border-color: rgba(108, 92, 231, 0.5);
    animation: popIn 0.08s ease;
}

.tile.reveal .tile-inner {
    animation: flipTile 0.5s ease forwards;
}

.tile.correct .tile-inner {
    background: linear-gradient(135deg, #00cec9, #00b894);
    box-shadow: 0 0 18px var(--accent-cyan-glow), inset 0 1px 0 rgba(255,255,255,0.15);
}

.tile.present .tile-inner {
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    box-shadow: 0 0 18px var(--accent-purple-glow), inset 0 1px 0 rgba(255,255,255,0.15);
}

.tile.absent .tile-inner {
    background: #1e1e2e;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}

.tile.correct,
.tile.present,
.tile.absent {
    border-color: transparent;
}

.tile.win-bounce {
    animation: winBounce 0.6s ease;
}

/* ============ LEADERBOARD ============ */

.game-leaderboard {
    width: 200px;
    flex-shrink: 0;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 14px;
    display: flex;
    flex-direction: column;
    align-self: center;
    backdrop-filter: blur(10px);
    max-height: 380px;
}

.lb-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--glass-border);
}

.lb-icon { font-size: 1.1rem; }

.lb-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.lb-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    overflow-y: auto;
}

.lb-empty {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    padding: 16px 0;
}

.lb-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    transition: var(--transition);
}

.lb-row:nth-child(1) { background: rgba(255, 215, 0, 0.08); }
.lb-row:nth-child(2) { background: rgba(192, 192, 192, 0.06); }
.lb-row:nth-child(3) { background: rgba(205, 127, 50, 0.06); }

.lb-row.lb-me-row {
    border: 1px solid rgba(108, 92, 231, 0.3);
    background: rgba(108, 92, 231, 0.08);
}

.lb-rank {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.75rem;
    font-weight: 800;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.lb-row:nth-child(1) .lb-rank { color: #ffd700; }
.lb-row:nth-child(2) .lb-rank { color: #c0c0c0; }
.lb-row:nth-child(3) .lb-rank { color: #cd7f32; }

.lb-name {
    flex: 1;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lb-score {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--accent-cyan);
    flex-shrink: 0;
}

.lb-score.odd-score {
    color: var(--accent-pink);
}

.lb-me {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--glass-border);
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
}

.lb-me:empty {
    display: none;
}

.lb-me strong {
    color: var(--accent-purple-light);
    font-weight: 700;
}

.lb-mobile-toggle {
    display: none;
    position: fixed;
    bottom: max(16px, env(safe-area-inset-bottom));
    right: 16px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    z-index: 100;
    box-shadow: 0 4px 20px var(--accent-purple-glow);
    transition: var(--transition);
}

.lb-mobile-toggle:active {
    transform: scale(0.9);
}

/* Mobile leaderboard overlay */
.game-leaderboard.lb-mobile-open {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 85%;
    max-width: 320px;
    max-height: 70vh;
    z-index: 200;
    background: var(--bg-secondary);
    box-shadow: var(--shadow);
    animation: fadeInUp 0.3s ease;
}

.lb-mobile-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 150;
}

/* ============ KEYBOARD ============ */

.game-keyboard {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 6px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    width: 100%;
    max-width: 540px;
    margin: 0 auto;
}

.keyboard-row {
    display: flex;
    gap: 5px;
    width: 100%;
    justify-content: center;
}

.key {
    display: flex;
    align-items: center;
    justify-content: center;
    height: clamp(50px, 8vh, 58px);
    min-width: clamp(28px, 7.5vw, 44px);
    flex: 1;
    max-width: 44px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'Poppins', sans-serif;
    font-size: clamp(0.85rem, 2.5vw, 1rem);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s, border-color 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.key:active {
    transform: scale(0.92);
}

.key:hover {
    background: rgba(255, 255, 255, 0.16);
}

.key.wide {
    flex: 1.5;
    max-width: 68px;
    font-size: clamp(0.65rem, 2vw, 0.8rem);
    font-weight: 700;
    letter-spacing: 0.5px;
}

.key.correct {
    background: linear-gradient(135deg, #00cec9, #00b894);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 0 12px var(--accent-cyan-glow);
}

.key.present {
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 0 12px var(--accent-purple-glow);
}

.key.absent {
    background: #16161e;
    border-color: rgba(255, 255, 255, 0.03);
    color: rgba(255, 255, 255, 0.35);
}

/* ============ TOAST ============ */

.toast-container {
    position: fixed;
    top: 10%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 14px 28px;
    background: rgba(255, 255, 255, 0.95);
    color: #0a0a1a;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 700;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    animation: toastIn 0.25s ease;
    pointer-events: auto;
}

.toast.fade-out {
    animation: toastOut 0.3s ease forwards;
}

/* ============ MODAL ============ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    padding: 20px;
}

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

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 420px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
    transform: translateY(20px) scale(0.96);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal {
    transform: translateY(0) scale(1);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.modal-close:hover {
    background: var(--bg-card-hover);
    color: #fff;
}

.modal h2 {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 20px;
    text-align: center;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.modal h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 16px 0 8px;
}

.modal p, .modal li {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Pseudo input in modal */
.pseudo-input {
    width: 100%;
    padding: 14px 18px;
    background: var(--bg-tertiary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
    font-weight: 500;
    outline: none;
    transition: var(--transition);
    text-align: center;
    margin-bottom: 16px;
}

.pseudo-input:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 20px var(--accent-purple-glow);
}

.pseudo-input::placeholder {
    color: var(--text-muted);
}

/* How to play examples */
.example-row {
    display: flex;
    gap: 5px;
    margin: 10px 0;
}

.example-tile {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Orbitron', sans-serif;
    font-weight: 800;
    font-size: 1rem;
    border-radius: 6px;
    color: #fff;
}

.example-tile.ex-correct {
    background: linear-gradient(135deg, #00cec9, #00b894);
    box-shadow: 0 0 10px var(--accent-cyan-glow);
}
.example-tile.ex-present {
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    box-shadow: 0 0 10px var(--accent-purple-glow);
}
.example-tile.ex-absent {
    background: #1e1e2e;
}
.example-tile.ex-empty {
    background: transparent;
    border: 2px solid rgba(255,255,255,0.1);
}

.example-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 4px 0 12px;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.distribution-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.dist-label {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    width: 16px;
    text-align: right;
    color: var(--text-secondary);
}

.dist-bar-container {
    flex: 1;
    height: 24px;
    background: rgba(255,255,255,0.04);
    border-radius: 4px;
    overflow: hidden;
}

.dist-bar {
    height: 100%;
    min-width: 24px;
    background: linear-gradient(90deg, var(--accent-purple), var(--accent-cyan));
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.dist-bar.highlight {
    background: linear-gradient(90deg, #00cec9, #00b894);
}

/* Share / action buttons in modal */
.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.modal-btn {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Poppins', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.modal-btn.btn-primary {
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
    color: #fff;
}
.modal-btn.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--accent-purple-glow);
}

.modal-btn.btn-secondary {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
}
.modal-btn.btn-secondary:hover {
    background: var(--bg-card-hover);
}

/* ============ CONFETTI ============ */

#confettiCanvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 8000;
    pointer-events: none;
}

/* ============ ANIMATIONS ============ */

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

@keyframes tileFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes floatUp {
    0% { transform: translateY(110vh) rotate(0deg); }
    100% { transform: translateY(-120px) rotate(360deg); }
}

@keyframes popIn {
    0% { transform: scale(1); }
    50% { transform: scale(1.12); }
    100% { transform: scale(1); }
}

@keyframes flipTile {
    0% { transform: rotateX(0deg); }
    50% { transform: rotateX(-90deg); }
    100% { transform: rotateX(0deg); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 50%, 90% { transform: translateX(-5px); }
    30%, 70% { transform: translateX(5px); }
}

@keyframes winBounce {
    0%, 100% { transform: translateY(0); }
    30% { transform: translateY(-25px); }
    50% { transform: translateY(4px); }
    70% { transform: translateY(-10px); }
    85% { transform: translateY(2px); }
}

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

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

@keyframes glowPulse {
    0%, 100% { box-shadow: 0 0 15px var(--accent-cyan-glow); }
    50% { box-shadow: 0 0 30px var(--accent-cyan-glow), 0 0 50px rgba(0, 206, 201, 0.15); }
}

.row-shake .tile {
    animation: shake 0.5s ease;
}

/* ============ RESPONSIVE ============ */

@media (max-height: 700px) {
    :root {
        --tile-size: clamp(44px, 10vw, 54px);
        --tile-gap: 4px;
    }
    .game-header { padding: 8px 12px; }
    .game-mode-badge { margin-top: 4px; padding: 4px 12px; font-size: 0.7rem; }
    .game-keyboard { gap: 4px; padding: 6px 4px; }
    .key { height: clamp(42px, 7vh, 52px); }
}

@media (max-height: 580px) {
    :root {
        --tile-size: clamp(38px, 8vw, 46px);
    }
    .game-mode-badge { display: none; }
}

@media (max-width: 768px) {
    .game-leaderboard { display: none; }
    .lb-mobile-toggle { display: flex; align-items: center; justify-content: center; }
    .game-leaderboard.lb-mobile-open { display: flex; }
    .game-main { padding: 0 8px; }
}

@media (max-width: 480px) {
    .back-to-hub { top: 12px; left: 12px; padding: 8px 16px; font-size: 0.8rem; }
    .game-hub-link { font-size: 0.65rem; padding: 5px 10px; }
}

@media (max-width: 380px) {
    .key { min-width: 24px; font-size: 0.8rem; border-radius: 6px; }
    .key.wide { font-size: 0.6rem; }
    .keyboard-row { gap: 3px; }
    .game-keyboard { padding: 8px 3px; gap: 4px; }
    .game-hub-link { display: none; }
}

@media (min-width: 600px) {
    .key:hover:not(.correct):not(.present):not(.absent) {
        background: rgba(255, 255, 255, 0.18);
        border-color: rgba(108, 92, 231, 0.3);
    }
}

/* Scrollbar for modals */
.modal::-webkit-scrollbar { width: 6px; }
.modal::-webkit-scrollbar-track { background: transparent; }
.modal::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
