/* ============================================
   ALPHABETMASTER - STYLES
   © 2024-2026 WebPoint - 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-glow: rgba(108, 92, 231, 0.4);
    --accent-cyan: #00cec9;
    --accent-pink: #fd79a8;
    --accent-green: #00b894;
    --accent-orange: #fdcb6e;
    --accent-red: #d63031;
    --accent-blue: #0984e3;
    --tile-size: 64px;
    --grid-gap: 5px;
    --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);
    --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.3);
}

* { 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;
    overflow: hidden;
}

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

.screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    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%);
    flex-direction: column;
}

.loading-container {
    text-align: center;
    animation: fadeInUp 1s 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, #6c5ce7, #a29bfe);
    border-radius: 10px;
    font-family: 'Orbitron', sans-serif;
    font-weight: 800;
    font-size: 1.5rem;
    color: #fff;
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.4);
    animation: tileFloat 2s ease-in-out infinite;
    animation-delay: calc(var(--i) * 0.12s);
}

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

.loading-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 2.5rem;
    font-weight: 900;
    background: linear-gradient(135deg, #6c5ce7, #00cec9);
    -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: 360px;
    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, #6c5ce7, #00cec9);
    border-radius: 3px;
    transition: width 0.3s ease;
}

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

.loading-count {
    font-size: 0.8rem;
    color: var(--accent-cyan);
    margin-top: 4px;
    font-family: 'Orbitron', sans-serif;
}

/* ============ 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);
}

.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: floatAround linear infinite;
    pointer-events: none;
}

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

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

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

.home-title span {
    background: linear-gradient(135deg, #6c5ce7, #00cec9);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.home-subtitle {
    font-size: 1.1rem;
    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: 50px;
    backdrop-filter: blur(10px);
}

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

.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:not(:disabled) {
    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:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.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);
}

.menu-btn.danger { border-color: var(--accent-red); }
.menu-btn.danger:hover {
    background: rgba(214, 48, 49, 0.15);
    border-color: var(--accent-red);
}

.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-version { margin-top: 4px; font-size: 0.7rem; color: var(--text-muted); }

/* ============ SCREEN CONTAINER (Profiles, Scores) ============ */

.screen-container {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 40px;
    max-width: 600px;
    width: 95%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.back-btn {
    background: none;
    border: none;
    color: var(--accent-purple);
    font-family: 'Poppins', sans-serif;
    font-size: 0.9rem;
    cursor: pointer;
    margin-bottom: 20px;
    transition: var(--transition);
}
.back-btn:hover { color: var(--accent-cyan); transform: translateX(-4px); }

.screen-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.5rem;
    margin-bottom: 24px;
}

/* ============ PROFILES ============ */

.profile-create {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
}

.profile-create input {
    flex: 1;
    padding: 12px 16px;
    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: 0.95rem;
    outline: none;
    transition: var(--transition);
}
.profile-create input:focus { border-color: var(--accent-purple); }

.btn-create-profile {
    padding: 12px 20px;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
    border: none;
    border-radius: var(--radius-sm);
    color: #fff;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}
.btn-create-profile:hover { transform: scale(1.05); box-shadow: 0 4px 20px var(--accent-purple-glow); }

.profile-list { display: flex; flex-direction: column; gap: 8px; }

.profile-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    cursor: pointer;
}
.profile-item:hover { background: var(--bg-card-hover); border-color: var(--accent-purple); }
.profile-item.active { border-color: var(--accent-cyan); background: rgba(0, 206, 201, 0.08); }

.profile-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
}

.profile-info { flex: 1; }
.profile-name { font-weight: 600; font-size: 0.95rem; }
.profile-stats { font-size: 0.75rem; color: var(--text-muted); }

.profile-actions { display: flex; gap: 6px; }
.profile-action-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--glass-border);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: var(--transition);
}
.profile-action-btn:hover { border-color: var(--accent-red); color: var(--accent-red); }
.profile-action-btn.play:hover { border-color: var(--accent-green); color: var(--accent-green); }

/* ============ SCORES TABLE ============ */

.scores-table-container { overflow-x: auto; }

.scores-table {
    width: 100%;
    border-collapse: collapse;
}
.scores-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--glass-border);
}
.scores-table td {
    padding: 12px 16px;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}
.scores-table tr:hover td { background: var(--bg-card-hover); }
.scores-table .rank-1 { color: #FFD700; font-weight: 700; }
.scores-table .rank-2 { color: #C0C0C0; font-weight: 600; }
.scores-table .rank-3 { color: #CD7F32; font-weight: 600; }
.scores-empty { text-align: center; color: var(--text-muted); padding: 40px; }

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

#screenGame {
    flex-direction: column;
    background: var(--bg-primary);
    overflow: hidden;
}

.game-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--glass-border);
    width: 100%;
    flex-shrink: 0;
}

.game-menu-btn {
    width: 42px;
    height: 42px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1.3rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}
.game-menu-btn:hover { background: var(--bg-card-hover); border-color: var(--accent-purple); }

.game-top-info { display: flex; align-items: center; gap: 12px; }

.player-badge {
    padding: 6px 14px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 500;
}
.level-badge {
    padding: 6px 14px;
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.2), rgba(0, 206, 201, 0.1));
    border: 1px solid var(--accent-purple);
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: 'Orbitron', sans-serif;
    color: var(--accent-cyan);
}

.inactivity-ring {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 3px solid var(--accent-green);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    transition: border-color 0.5s;
}
.inactivity-ring.warning { border-color: var(--accent-orange); color: var(--accent-orange); }
.inactivity-ring.danger { border-color: var(--accent-red); color: var(--accent-red); animation: pulseRing 0.5s ease infinite; }

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

/* ============ GAME LAYOUT ============ */

.game-layout {
    display: flex;
    flex: 1;
    gap: 16px;
    padding: 8px 16px;
    align-items: flex-start;
    justify-content: center;
    overflow: hidden;
}

.game-sidebar {
    width: 210px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.stat-card {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 10px 14px;
    backdrop-filter: blur(8px);
}

.stat-card .stat-icon { font-size: 1.4rem; }
.stat-card .stat-info { flex: 1; }
.stat-card .stat-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.stat-card .stat-value { font-family: 'Orbitron', sans-serif; font-size: 1.3rem; font-weight: 700; }

.score-card, .money-card, .words-card {
    display: flex;
    align-items: center;
    gap: 12px;
}

.score-card .stat-value { color: var(--accent-orange); }
.money-card .stat-value { color: var(--accent-green); }
.words-card .stat-value { color: var(--accent-cyan); }

.progress-bar-outer {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 4px;
    margin: 8px 0 6px;
    overflow: hidden;
}
.progress-bar-inner {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-purple), var(--accent-cyan));
    border-radius: 4px;
    transition: width 0.5s ease;
}
.progress-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: center;
}

.theme-selector { display: flex; gap: 8px; margin-top: 8px; }
.theme-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid transparent;
    background: none;
    cursor: pointer;
    padding: 3px;
    transition: var(--transition);
}
.theme-btn.active { border-color: #fff; }
.theme-btn:hover { transform: scale(1.15); }
.theme-dot { display: block; width: 100%; height: 100%; border-radius: 50%; }

/* ============ WORD SUGGESTION POPUP ============ */

.word-suggestion {
    position: absolute;
    top: 56px;
    left: 20px;
    background: rgba(0, 0, 0, 0.75);
    border: 1px solid rgba(253, 203, 110, 0.3);
    border-radius: 12px;
    padding: 10px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 20;
    backdrop-filter: blur(12px);
    opacity: 0;
    transform: translateX(-30px);
    transition: opacity 0.4s ease, transform 0.4s ease;
    pointer-events: none;
}

.word-suggestion.active {
    opacity: 1;
    transform: translateX(0);
}

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

.suggestion-label {
    font-size: 0.7rem;
    color: #a0a0b0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.suggestion-word {
    font-family: var(--level-font, 'Poppins'), sans-serif;
    font-weight: 800;
    font-size: 1rem;
    color: var(--accent-orange);
    letter-spacing: 2px;
    text-shadow: 0 0 8px rgba(253, 203, 110, 0.3);
}

/* ============ GAME CENTER ============ */

.game-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.word-display {
    text-align: center;
    min-height: 44px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.word-formed {
    font-family: var(--level-font, 'Poppins'), sans-serif;
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: 4px;
    min-height: 40px;
    color: var(--accent-cyan);
    text-shadow: 0 0 20px rgba(0, 206, 201, 0.3);
    transition: var(--transition);
}
.word-formed.invalid { color: var(--accent-red); text-shadow: 0 0 20px rgba(214, 48, 49, 0.3); }
.word-formed.valid { color: var(--accent-green); text-shadow: 0 0 20px rgba(0, 184, 148, 0.3); }

.auto-validate-bar-container {
    width: 180px;
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    overflow: hidden;
    margin: 4px auto 2px;
    opacity: 0;
    transition: opacity 0.3s;
}

.auto-validate-bar-container.active {
    opacity: 1;
}

.auto-validate-bar {
    height: 100%;
    width: 100%;
    border-radius: 2px;
}

.auto-validate-bar.valid {
    background: linear-gradient(90deg, var(--accent-green), var(--accent-cyan));
}

.auto-validate-bar.invalid {
    background: linear-gradient(90deg, var(--accent-red), var(--accent-orange));
}

.word-info {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 2px;
}


.game-grid-wrapper {
    position: relative;
}

/* ============ GRID ============ */

.game-grid {
    display: grid;
    grid-template-columns: repeat(8, var(--tile-size));
    grid-template-rows: repeat(8, var(--tile-size));
    gap: var(--grid-gap);
    padding: 12px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius);
    border: 1px solid var(--glass-border);
}

/* ============ TILES ============ */

.tile {
    width: var(--tile-size);
    height: var(--tile-size);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
    position: relative;
    user-select: none;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    overflow: hidden;
}

.tile:hover:not(.brick):not(.selected) {
    transform: scale(1.08);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    z-index: 2;
}

.tile.selected {
    transform: scale(0.92);
    box-shadow: 0 0 0 3px var(--accent-cyan), 0 0 25px rgba(0, 206, 201, 0.4);
    z-index: 3;
}

.tile.adjacent-hint {
    box-shadow: 0 0 0 2px rgba(108, 92, 231, 0.4), 0 3px 8px rgba(0, 0, 0, 0.3);
}

.tile-letter {
    font-family: var(--level-font, 'Poppins'), sans-serif;
    font-size: 1.25rem;
    font-weight: 800;
    line-height: 1;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.tile-points {
    font-size: 0.6rem;
    font-weight: 600;
    opacity: 0.7;
    margin-top: 2px;
}

.tile-order {
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: 0.55rem;
    font-weight: 700;
    color: var(--accent-cyan);
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Tile themes */
.tile.theme-classic { background: linear-gradient(145deg, #2196F3, #0D47A1); color: #fff; }
.tile.theme-gold { background: linear-gradient(145deg, #FFC107, #E65100); color: #fff; }
.tile.theme-fire { background: linear-gradient(145deg, #F44336, #B71C1C); color: #fff; }
.tile.theme-ice { background: linear-gradient(145deg, #E0F7FA, #81D4FA); color: #1a237e; }

/* Special tiles */
.tile.special-green {
    background: linear-gradient(145deg, #00E676, #00897B) !important;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3), 0 0 15px rgba(0, 230, 118, 0.3);
}
.tile.special-gold {
    background: linear-gradient(145deg, #FFD600, #FF8F00) !important;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3), 0 0 15px rgba(255, 214, 0, 0.3);
}
.tile.special-sapphire {
    background: linear-gradient(145deg, #448AFF, #1A237E) !important;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3), 0 0 15px rgba(68, 138, 255, 0.3);
}
.tile.special-diamond {
    background: linear-gradient(145deg, #E1BEE7, #7C4DFF) !important;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3), 0 0 20px rgba(124, 77, 255, 0.4);
    animation: shimmer 2s ease-in-out infinite;
}

.tile .special-badge {
    position: absolute;
    bottom: 2px;
    right: 3px;
    font-size: 0.55rem;
    font-weight: 700;
    background: rgba(0,0,0,0.3);
    padding: 1px 4px;
    border-radius: 3px;
}

/* Multiplier tiles */
.tile.multiplier-2 {
    background: linear-gradient(145deg, #FF9800, #E65100) !important;
    border: 2px solid #FFC107;
}
.tile.multiplier-3 {
    background: linear-gradient(145deg, #9C27B0, #4A148C) !important;
    border: 2px solid #CE93D8;
}
.tile.multiplier-4 {
    background: linear-gradient(145deg, #E91E63, #880E4F) !important;
    border: 2px solid #F48FB1;
}
.tile.multiplier-5 {
    background: linear-gradient(145deg, #00C853, #1B5E20) !important;
    border: 2px solid #69F0AE;
}

.tile.multiplier-2, .tile.multiplier-3, .tile.multiplier-4, .tile.multiplier-5 {
    animation: pulseTile 1.5s ease-in-out infinite;
}

.tile .multi-badge {
    position: absolute;
    top: 2px;
    right: 3px;
    font-size: 0.6rem;
    font-weight: 900;
    color: #FFD600;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

@keyframes pulseTile {
    0%, 100% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.06); filter: brightness(1.2); }
}

/* Fire tiles */
.tile.fire-tile {
    background: linear-gradient(145deg, #ff6b35, #d63031) !important;
    animation: burnTile 0.4s ease-in-out infinite alternate;
}

.tile .fire-emoji {
    position: absolute;
    top: -2px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.2rem;
    animation: flickerFire 0.3s ease-in-out infinite alternate;
    pointer-events: none;
}

.tile .fire-timer {
    position: absolute;
    top: 2px;
    right: 3px;
    font-size: 0.55rem;
    font-weight: 800;
    font-family: 'Orbitron', sans-serif;
}
.fire-timer.red { color: #ff1744; }
.fire-timer.orange { color: #ff9100; }
.fire-timer.yellow { color: #ffea00; }

@keyframes burnTile {
    from { box-shadow: 0 0 10px rgba(255, 107, 53, 0.5), inset 0 0 10px rgba(255, 0, 0, 0.2); }
    to { box-shadow: 0 0 25px rgba(255, 107, 53, 0.8), 0 0 50px rgba(214, 48, 49, 0.3), inset 0 0 15px rgba(255, 0, 0, 0.3); }
}

@keyframes flickerFire {
    from { transform: translateX(-50%) scale(1) rotate(-5deg); }
    to { transform: translateX(-50%) scale(1.15) rotate(5deg); }
}

/* Timed bonus tiles */
.tile.timed-bonus {
    background: linear-gradient(145deg, #00E5FF, #00B8D4) !important;
    border: 2px solid #18FFFF;
    animation: timedBonusPulse 1.2s ease-in-out infinite;
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.4), 0 3px 8px rgba(0, 0, 0, 0.3);
}

@keyframes timedBonusPulse {
    0%, 100% { box-shadow: 0 0 10px rgba(0, 229, 255, 0.3), 0 3px 8px rgba(0, 0, 0, 0.3); filter: brightness(1); }
    50% { box-shadow: 0 0 25px rgba(0, 229, 255, 0.6), 0 0 40px rgba(0, 229, 255, 0.2); filter: brightness(1.2); }
}

.tile .bonus-emoji {
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.85rem;
    pointer-events: none;
}

.tile .bonus-timer {
    position: absolute;
    top: 2px;
    right: 3px;
    font-size: 0.55rem;
    font-weight: 800;
    font-family: 'Orbitron', sans-serif;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.tile .bonus-value {
    position: absolute;
    bottom: 1px;
    right: 3px;
    font-size: 0.5rem;
    font-weight: 700;
    color: #FFD600;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Brick tiles */
.tile.brick {
    background: linear-gradient(145deg, #795548, #4E342E) !important;
    cursor: not-allowed;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.2);
}
.tile.brick::after {
    content: '';
    position: absolute;
    inset: 3px;
    border: 1px dashed rgba(255,255,255,0.15);
    border-radius: 4px;
}

/* Tile animations */
.tile.removing {
    animation: tileRemove 0.4s ease forwards;
}
@keyframes tileRemove {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2) rotate(10deg); opacity: 0.5; }
    100% { transform: scale(0) rotate(30deg); opacity: 0; }
}

.tile.appearing {
    animation: tileAppear 0.4s ease forwards;
}
@keyframes tileAppear {
    0% { transform: scale(0) translateY(-20px); opacity: 0; }
    60% { transform: scale(1.1) translateY(0); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

.tile.falling {
    animation: tileFall 0.3s ease forwards;
}
@keyframes tileFall {
    0% { transform: translateY(calc(var(--fall-distance) * -1)); }
    70% { transform: translateY(3px); }
    100% { transform: translateY(0); }
}

@keyframes shimmer {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.3); }
}

.tile.shake {
    animation: tileShake 0.3s ease;
}
@keyframes tileShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* ============ GRID HINT HIGHLIGHT ============ */

.tile.hint-highlight {
    animation: hintBlink 1s ease-in-out 3 !important;
    z-index: 5;
}

@keyframes hintBlink {
    0%, 100% {
        box-shadow: 0 0 0 3px rgba(253, 203, 110, 0.9), 0 0 20px rgba(253, 203, 110, 0.4);
        filter: brightness(1.3);
    }
    50% {
        box-shadow: 0 3px 8px rgba(0,0,0,0.3);
        filter: brightness(1);
    }
}

/* ============ GAME ACTIONS ============ */

.game-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.reset-btn {
    padding: 10px 32px;
    background: linear-gradient(135deg, rgba(214, 48, 49, 0.15), rgba(253, 121, 168, 0.1));
    border: 2px solid rgba(214, 48, 49, 0.4);
    border-radius: 50px;
    color: #ff7675;
    font-family: 'Poppins', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

.reset-icon {
    font-size: 1.2rem;
    display: inline-block;
    transition: transform 0.3s ease;
}

.reset-btn:hover {
    background: linear-gradient(135deg, rgba(214, 48, 49, 0.3), rgba(253, 121, 168, 0.2));
    border-color: rgba(214, 48, 49, 0.7);
    color: #fff;
    box-shadow: 0 0 20px rgba(214, 48, 49, 0.2);
    transform: scale(1.05);
}

.reset-btn:hover .reset-icon {
    transform: rotate(-360deg);
}

.reset-btn:active {
    transform: scale(0.95);
}

.game-message {
    min-height: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    text-align: center;
    transition: var(--transition);
}
.game-message.success { color: var(--accent-green); }
.game-message.error { color: var(--accent-red); }
.game-message.warning { color: var(--accent-orange); }

/* ============ WORD HISTORY ============ */

.word-history {
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-empty { color: var(--text-muted); font-size: 0.8rem; text-align: center; padding: 20px 0; }

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background: rgba(0,0,0,0.2);
    border-radius: 6px;
    font-size: 0.8rem;
    animation: slideInRight 0.3s ease;
}
.history-word { font-weight: 600; font-family: 'Orbitron', sans-serif; letter-spacing: 1px; }
.history-score { color: var(--accent-orange); font-weight: 600; }

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

/* ============ VIDEO REACTION ============ */

.video-card {
    padding: 0 !important;
    overflow: hidden;
    border-radius: var(--radius);
}

.video-container {
    position: relative;
    width: 100%;
    aspect-ratio: 4/3;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
}

.video-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.reaction-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px 12px;
    background: linear-gradient(transparent, rgba(0,0,0,0.85));
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

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

.reaction-message {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 0.8rem;
    text-align: center;
    color: #fff;
    text-shadow: 0 1px 6px rgba(0,0,0,0.5);
}

.reaction-message.mock { color: #ff7675; }
.reaction-message.neutral { color: var(--accent-cyan); }
.reaction-message.good { color: var(--accent-green); }
.reaction-message.great { color: var(--accent-orange); }
.reaction-message.epic { color: #ffd93d; text-shadow: 0 0 10px rgba(255, 217, 61, 0.5); }

/* ============ LEGEND ============ */

.legend-items { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 0.75rem; color: var(--text-secondary); }
.legend-dot {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    flex-shrink: 0;
}
.legend-dot.special-green { background: linear-gradient(135deg, #00E676, #00897B); }
.legend-dot.special-gold { background: linear-gradient(135deg, #FFD600, #FF8F00); }
.legend-dot.special-sapphire { background: linear-gradient(135deg, #448AFF, #1A237E); }
.legend-dot.special-diamond { background: linear-gradient(135deg, #E1BEE7, #7C4DFF); }
.legend-dot.fire { background: linear-gradient(135deg, #ff6b35, #d63031); }
.legend-dot.brick { background: linear-gradient(135deg, #795548, #4E342E); }
.legend-dot.multiplier { background: linear-gradient(135deg, #FF9800, #9C27B0); }

/* ============ GAME MENU OVERLAY ============ */

.game-menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}
.game-menu-overlay.active { opacity: 1; visibility: visible; }

.game-menu-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 380px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: var(--shadow);
    animation: modalAppear 0.3s ease;
}

.game-menu-panel h2 {
    font-family: 'Orbitron', sans-serif;
    text-align: center;
    margin-bottom: 12px;
}

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

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}
.modal-overlay.active { opacity: 1; visibility: visible; }

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 40px;
    max-width: 480px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow);
    animation: modalAppear 0.3s ease;
}

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

.modal h2 {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.5rem;
    margin-bottom: 16px;
}

.modal p {
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.modal .modal-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 20px 0;
}
.modal .modal-stat {
    background: var(--bg-card);
    padding: 12px;
    border-radius: var(--radius-sm);
}
.modal .modal-stat-label { font-size: 0.75rem; color: var(--text-muted); }
.modal .modal-stat-value { font-family: 'Orbitron', sans-serif; font-size: 1.1rem; font-weight: 700; margin-top: 4px; }

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
}

.modal-btn {
    padding: 12px 28px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Poppins', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.modal-btn.primary {
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
    color: #fff;
}
.modal-btn.primary:hover { transform: scale(1.05); }
.modal-btn.secondary {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
}

/* ============ NOTIFICATIONS ============ */

.notifications-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.notification {
    padding: 14px 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--shadow-sm);
    animation: notifIn 0.3s ease, notifOut 0.3s ease 2.7s forwards;
    backdrop-filter: blur(10px);
    pointer-events: auto;
}
.notification.success { border-color: var(--accent-green); color: var(--accent-green); }
.notification.error { border-color: var(--accent-red); color: var(--accent-red); }
.notification.warning { border-color: var(--accent-orange); color: var(--accent-orange); }
.notification.info { border-color: var(--accent-cyan); color: var(--accent-cyan); }

@keyframes notifIn { from { transform: translateX(100px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes notifOut { from { opacity: 1; } to { opacity: 0; transform: translateX(50px); } }

/* ============ SCORE POPUPS ============ */

#scorePopups {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.score-popup {
    position: absolute;
    font-family: 'Orbitron', sans-serif;
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--accent-orange);
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    animation: scoreFloat 1.5s ease-out forwards;
    pointer-events: none;
    white-space: nowrap;
}

@keyframes scoreFloat {
    0% { opacity: 1; transform: translateY(0) scale(0.5); }
    20% { transform: translateY(-10px) scale(1.2); }
    100% { opacity: 0; transform: translateY(-80px) scale(1); }
}

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

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

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

/* ============ SCROLLBAR ============ */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

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

@media (max-width: 1100px) {
    .game-sidebar { width: 180px; }
    :root { --tile-size: 56px; }
}

@media (max-width: 900px) {
    .game-layout { flex-direction: column; align-items: center; }
    .game-sidebar { width: 100%; max-width: 560px; flex-direction: row; flex-wrap: wrap; }
    .game-sidebar .stat-card { flex: 1; min-width: 140px; }
    .game-sidebar.right { order: 3; }
}

@media (max-width: 600px) {
    :root { --tile-size: 42px; --grid-gap: 3px; }
    .home-title { font-size: 2rem; }
    .loading-logo .logo-letter { width: 38px; height: 38px; font-size: 1rem; }
    .game-top-bar { padding: 8px 12px; }
}

/* ============ PARTICLE EFFECTS ============ */

.particle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    z-index: 50;
    will-change: transform, opacity;
    animation: particleFly var(--p-duration, 800ms) ease-out forwards;
    animation-delay: var(--p-delay, 0ms);
}

@keyframes particleFly {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    80% {
        opacity: 0.6;
    }
    100% {
        transform: translate(var(--px, 0), var(--py, 0)) scale(0);
        opacity: 0;
    }
}

.particle.spark {
    border-radius: 1px;
    animation: sparkFly var(--p-duration, 600ms) ease-out forwards;
    animation-delay: var(--p-delay, 0ms);
}

@keyframes sparkFly {
    0% {
        transform: translate(0, 0) scale(1) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translate(var(--px, 0), var(--py, 0)) scale(0) rotate(720deg);
        opacity: 0;
    }
}

.particle.star {
    border-radius: 0;
    background: none !important;
    font-size: var(--star-size, 12px);
    width: auto !important;
    height: auto !important;
    animation: starFly var(--p-duration, 1200ms) ease-out forwards;
    animation-delay: var(--p-delay, 0ms);
}
.particle.star::after {
    content: '✦';
    color: var(--star-color, #ffd93d);
    text-shadow: 0 0 6px var(--star-color, #ffd93d);
}

@keyframes starFly {
    0% {
        transform: translate(0, 0) scale(0.5) rotate(0deg);
        opacity: 1;
    }
    30% {
        transform: translate(calc(var(--px, 0) * 0.3), calc(var(--py, 0) * 0.3)) scale(1.5) rotate(180deg);
        opacity: 1;
    }
    100% {
        transform: translate(var(--px, 0), var(--py, 0)) scale(0) rotate(540deg);
        opacity: 0;
    }
}

/* ============ SHOCKWAVE ============ */

.shockwave {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    z-index: 49;
    transform: translate(-50%, -50%);
    animation: shockwaveGrow var(--sw-duration, 600ms) ease-out forwards;
}

@keyframes shockwaveGrow {
    0% {
        width: 10px;
        height: 10px;
        border: 3px solid var(--sw-color, rgba(255,255,255,0.6));
        opacity: 0.9;
    }
    100% {
        width: var(--sw-size, 200px);
        height: var(--sw-size, 200px);
        border: 1px solid var(--sw-color, rgba(255,255,255,0));
        opacity: 0;
    }
}

/* ============ SCREEN SHAKE ============ */

.shake-light {
    animation: screenShakeLight 0.35s ease !important;
}

.shake-heavy {
    animation: screenShakeHeavy 0.5s ease !important;
}

@keyframes screenShakeLight {
    0%, 100% { transform: translate(0); }
    10% { transform: translate(-3px, 2px); }
    30% { transform: translate(4px, -3px); }
    50% { transform: translate(-2px, 4px); }
    70% { transform: translate(3px, -2px); }
    90% { transform: translate(-1px, 1px); }
}

@keyframes screenShakeHeavy {
    0%, 100% { transform: translate(0); }
    5% { transform: translate(-6px, 4px) rotate(-0.5deg); }
    15% { transform: translate(8px, -6px) rotate(0.5deg); }
    25% { transform: translate(-5px, 7px) rotate(-0.3deg); }
    35% { transform: translate(7px, -4px) rotate(0.4deg); }
    45% { transform: translate(-8px, 3px) rotate(-0.5deg); }
    55% { transform: translate(5px, -7px) rotate(0.3deg); }
    65% { transform: translate(-4px, 5px) rotate(-0.2deg); }
    75% { transform: translate(6px, -3px) rotate(0.2deg); }
    85% { transform: translate(-3px, 4px); }
    95% { transform: translate(1px, -1px); }
}

/* ============ SCREEN FLASH ============ */

.screen-flash {
    position: fixed;
    inset: 0;
    z-index: 999;
    pointer-events: none;
    animation: flashBang 0.5s ease-out forwards;
}

@keyframes flashBang {
    0% { background: rgba(255, 255, 255, 0.7); }
    30% { background: rgba(255, 215, 0, 0.3); }
    100% { background: transparent; }
}

/* ============ BONUS TEXT POPUP ============ */

.bonus-text {
    position: absolute;
    pointer-events: none;
    z-index: 60;
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
    animation: bonusTextPop 1.8s ease-out forwards;
    white-space: nowrap;
    left: 50%;
    transform: translateX(-50%);
}

@keyframes bonusTextPop {
    0% { opacity: 0; transform: translateX(-50%) translateY(10px) scale(0.3); }
    15% { opacity: 1; transform: translateX(-50%) translateY(-10px) scale(1.3); }
    30% { transform: translateX(-50%) translateY(-15px) scale(1); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: translateX(-50%) translateY(-60px) scale(0.8); }
}

.bonus-text.tier-3 { font-size: 1.1rem; color: var(--accent-cyan); }
.bonus-text.tier-4 { font-size: 1.4rem; color: var(--accent-orange); }
.bonus-text.tier-5 { font-size: 1.8rem; color: #ff6b6b; text-shadow: 0 0 20px rgba(255, 107, 107, 0.6), 0 2px 12px rgba(0,0,0,0.6); }
