/**
 * styles.css - Стили для Game Hub Mini App
 * 
 * Игровой хаб с двумя играми:
 * - Лабиринт
 * - Match3 (3 в ряд)
 */

/* ============================================
   === CSS VARIABLES & THEMES ===
   ============================================ */

:root {
    /* Sizing */
    --header-height: 60px;
    --footer-height: 68px;
    --border-radius: 16px;
    --border-radius-sm: 10px;
    --border-radius-xs: 6px;
    
    /* Transitions */
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
}

/* === NEON THEME (Default) === */
[data-theme="neon"] {
    --primary: #00f5ff;
    --primary-dark: #00c4cc;
    --primary-light: #7fffff;
    --primary-rgb: 0, 245, 255;
    
    --accent: #ff00aa;
    --accent-light: #ff66cc;
    --accent-rgb: 255, 0, 170;
    
    --secondary: #a855f7;
    --secondary-rgb: 168, 85, 247;
    
    --success: #00ff88;
    --success-rgb: 0, 255, 136;
    
    --warning: #ffaa00;
    --warning-rgb: 255, 170, 0;
    
    --bg-deep: #0a0a12;
    --bg-dark: #0f0f1a;
    --bg-card: #161625;
    --bg-elevated: #1e1e32;
    --bg-overlay: rgba(10, 10, 18, 0.95);
    
    --text-primary: #ffffff;
    --text-secondary: #a0a0b8;
    --text-muted: #606078;
    
    --border-color: rgba(0, 245, 255, 0.2);
    --border-glow: rgba(0, 245, 255, 0.5);
    
    --wall-primary: #1a2744;
    --wall-secondary: #0d1525;
    --wall-highlight: #2a3d5c;
    
    --path-color: #0a0f18;
    --player-color: var(--primary);
    --exit-color: var(--success);
}

/* Telegram theme integration */
body.telegram-theme {
    --bg-deep: var(--tg-theme-bg-color, var(--bg-deep));
    --text-primary: var(--tg-theme-text-color, var(--text-primary));
    --text-secondary: var(--tg-theme-hint-color, var(--text-secondary));
    --primary: var(--tg-theme-button-color, var(--primary));
}

/* ============================================
   === RESET & BASE ===
   ============================================ */

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

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-deep) !important;
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background var(--transition-slow), color var(--transition-slow);
}

/* Force dark background */
html, body, .app-container, .game-area, .background-effects, .screen {
    background-color: var(--bg-deep) !important;
}

/* Force white text everywhere */
.overlay-content,
.overlay-content *,
.win-content,
.win-content *,
.leaderboard-content,
.leaderboard-content * {
    color: #ffffff !important;
}

.stat-label {
    color: #888899 !important;
}

/* ============================================
   === BACKGROUND EFFECTS ===
   ============================================ */

.background-effects {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
    background: var(--bg-deep);
}

.grid-overlay {
    position: absolute;
    inset: 0;
    background-image: 
        linear-gradient(rgba(var(--primary-rgb), 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(var(--primary-rgb), 0.03) 1px, transparent 1px);
    background-size: 40px 40px;
    animation: gridMove 20s linear infinite;
}

@keyframes gridMove {
    0% { transform: translate(0, 0); }
    100% { transform: translate(40px, 40px); }
}

.glow-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
    animation: orbFloat 15s ease-in-out infinite;
}

.glow-orb-1 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(var(--primary-rgb), 0.6), transparent 70%);
    top: -100px;
    left: -100px;
    animation-delay: 0s;
}

.glow-orb-2 {
    width: 250px;
    height: 250px;
    background: radial-gradient(circle, rgba(var(--accent-rgb), 0.5), transparent 70%);
    bottom: -50px;
    right: -50px;
    animation-delay: -5s;
}

.glow-orb-3 {
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(var(--secondary-rgb), 0.4), transparent 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -10s;
}

@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(30px, -30px) scale(1.1); }
    50% { transform: translate(-20px, 20px) scale(0.9); }
    75% { transform: translate(20px, 30px) scale(1.05); }
}

.particles {
    position: absolute;
    inset: 0;
}

/* ============================================
   === APP CONTAINER & SCREENS ===
   ============================================ */

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-width: 100%;
    overflow: hidden;
    position: relative;
    z-index: 1;
    background: var(--bg-deep);
}

.screen {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: absolute;
    inset: 0;
    z-index: 1;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.screen.hidden {
    display: none;
    opacity: 0;
    pointer-events: none;
}

/* ============================================
   === MAIN MENU ===
   ============================================ */

.menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    /* Учитываем верхнюю панель Telegram (~56px) + safe-area */
    padding-top: calc(60px + env(safe-area-inset-top, 0px));
    flex-shrink: 0;
    gap: 12px;
}

.menu-header .header-left {
    flex: 1;
    min-width: 0;
}

.menu-header .user-name {
    max-width: 120px;
}

.menu-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    overflow-y: auto;
}

.menu-logo {
    position: relative;
    text-align: center;
    margin-bottom: 32px;
}

.hub-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 32px;
    font-weight: 900;
    color: #ffffff;
    letter-spacing: 3px;
    text-shadow: 
        0 0 10px rgba(var(--primary-rgb), 0.8),
        0 0 20px rgba(var(--primary-rgb), 0.5),
        0 0 40px rgba(var(--primary-rgb), 0.3);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.hub-subtitle {
    font-family: 'Space Grotesk', sans-serif;
    color: #d0d0e8;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* Games List */
.games-list {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.game-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.game-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.1), transparent);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.game-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
    box-shadow: 0 8px 30px rgba(var(--primary-rgb), 0.2);
}

.game-card:hover::before {
    opacity: 1;
}

.game-card:active {
    transform: translateY(0);
}

.game-card-icon {
    font-size: 48px;
    flex-shrink: 0;
    filter: drop-shadow(0 0 10px rgba(var(--primary-rgb), 0.3));
}

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

.game-card-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 4px;
}

.game-card-desc {
    font-size: 13px;
    color: #c8c8dc;
    margin-bottom: 8px;
    line-height: 1.4;
}

.game-card-stats {
    display: flex;
    gap: 12px;
}

.game-card-stats .stat {
    font-size: 12px;
    color: var(--primary);
    font-weight: 600;
}

.game-card-arrow {
    font-size: 28px;
    color: var(--text-secondary);
    font-weight: 300;
    transition: transform var(--transition-fast), color var(--transition-fast);
}

.game-card:hover .game-card-arrow {
    transform: translateX(4px);
    color: var(--primary);
}

/* ============================================
   === GAME HEADER ===
   ============================================ */

.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: var(--header-height);
    padding: 8px 12px;
    /* Учитываем верхнюю панель Telegram (~56px) + safe-area */
    padding-top: calc(60px + env(safe-area-inset-top, 0px));
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    z-index: 600;
    position: relative;
    transition: opacity 0.3s ease, transform 0.3s ease;
    gap: 8px;
}

.header-left,
.header-right {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-right {
    justify-content: flex-end;
}

.header-center {
    flex: 2;
    display: flex;
    justify-content: center;
}

/* Back Button */
.btn-back {
    font-size: 24px !important;
    font-weight: 300;
    padding: 0;
    width: 36px;
    height: 36px;
}

/* User Avatar */
.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    border: 2px solid var(--primary);
    box-shadow: 0 0 10px rgba(var(--primary-rgb), 0.3);
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-avatar-sm {
    width: 28px;
    height: 28px;
    border-width: 1px;
}

.user-avatar-sm .avatar-letter {
    font-size: 11px;
}

.avatar-letter {
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: var(--bg-deep);
}

.user-name {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 13px;
    font-weight: 700;
    color: var(--primary);
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 1;
    text-shadow: 0 0 10px rgba(var(--primary-rgb), 0.3);
}

/* Timer */
.timer-container {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    padding: 10px 20px;
    border-radius: 25px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm), 0 0 20px rgba(var(--primary-rgb), 0.1);
}

.timer-glow {
    position: absolute;
    inset: -2px;
    border-radius: 27px;
    background: linear-gradient(90deg, 
        rgba(var(--primary-rgb), 0.3),
        rgba(var(--accent-rgb), 0.3),
        rgba(var(--primary-rgb), 0.3)
    );
    background-size: 200% 100%;
    animation: timerGlow 3s linear infinite;
    opacity: 0;
    transition: opacity var(--transition-normal);
    z-index: -1;
}

.game-header.playing .timer-glow {
    opacity: 1;
}

@keyframes timerGlow {
    0% { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}

.timer-icon {
    font-size: 16px;
    animation: timerPulse 1s ease-in-out infinite;
}

@keyframes timerPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.timer {
    font-family: 'JetBrains Mono', monospace;
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    min-width: 95px;
    text-align: center;
    text-shadow: 0 0 10px rgba(var(--primary-rgb), 0.5);
}

/* Match3 Timer (countdown style) */
.match3-timer .timer {
    min-width: 55px;
}

.match3-timer.warning .timer {
    color: var(--warning);
    animation: warningPulse 0.5s ease-in-out infinite;
}

.match3-timer.danger .timer {
    color: #ff4444;
    animation: warningPulse 0.3s ease-in-out infinite;
}

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

/* Score Container */
.score-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.score-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.score-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 20px;
    font-weight: 900;
    color: var(--warning);
    text-shadow: 0 0 10px rgba(var(--warning-rgb), 0.5);
}

/* Combo Container */
.combo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 12px;
    background: linear-gradient(135deg, var(--accent), var(--warning));
    border-radius: 20px;
    animation: comboPulse 0.5s ease-in-out;
}

.combo-container.hidden {
    display: none;
}

.combo-text {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--bg-deep);
}

.combo-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 16px;
    font-weight: 900;
    color: var(--bg-deep);
}

@keyframes comboPulse {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

/* Level Badge */
.level-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    padding: 8px 14px;
    border-radius: 20px;
    box-shadow: 0 0 15px rgba(var(--primary-rgb), 0.3);
}

.level-text {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--bg-deep);
    opacity: 0.8;
}

.level-number {
    font-family: 'Orbitron', sans-serif;
    font-size: 16px;
    font-weight: 900;
    color: var(--bg-deep);
}

/* ============================================
   === GAME AREA ===
   ============================================ */

.game-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    padding: 16px;
    background: var(--bg-deep);
}

.canvas-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

/* Canvas Frame */
.canvas-frame {
    position: relative;
    padding: 4px;
    background: linear-gradient(135deg, 
        rgba(var(--primary-rgb), 0.3),
        rgba(var(--accent-rgb), 0.2),
        rgba(var(--primary-rgb), 0.3)
    );
    border-radius: calc(var(--border-radius) + 4px);
    box-shadow: 
        var(--shadow-lg),
        0 0 30px rgba(var(--primary-rgb), 0.2),
        inset 0 0 20px rgba(var(--primary-rgb), 0.1);
}

.match3-frame {
    background: linear-gradient(135deg, 
        rgba(var(--warning-rgb), 0.3),
        rgba(var(--accent-rgb), 0.2),
        rgba(var(--warning-rgb), 0.3)
    );
    box-shadow: 
        var(--shadow-lg),
        0 0 30px rgba(var(--warning-rgb), 0.2),
        inset 0 0 20px rgba(var(--warning-rgb), 0.1);
}

.frame-corner {
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid var(--primary);
    z-index: 2;
}

.match3-frame .frame-corner {
    border-color: var(--warning);
}

.frame-corner-tl {
    top: -2px;
    left: -2px;
    border-right: none;
    border-bottom: none;
    border-radius: 8px 0 0 0;
}

.frame-corner-tr {
    top: -2px;
    right: -2px;
    border-left: none;
    border-bottom: none;
    border-radius: 0 8px 0 0;
}

.frame-corner-bl {
    bottom: -2px;
    left: -2px;
    border-right: none;
    border-top: none;
    border-radius: 0 0 0 8px;
}

.frame-corner-br {
    bottom: -2px;
    right: -2px;
    border-left: none;
    border-top: none;
    border-radius: 0 0 8px 0;
}

#labyrinthCanvas,
#match3Canvas {
    display: block;
    border-radius: var(--border-radius);
    touch-action: none;
}

#labyrinthCanvas {
    image-rendering: pixelated;
}

/* ============================================
   === OVERLAYS ===
   ============================================ */

.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-deep) !important;
    z-index: 100;
    animation: fadeIn 0.3s ease;
    padding: 16px;
    overflow-y: auto;
}

.overlay.hidden {
    display: none;
}

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

.overlay-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 24px 16px;
    max-width: 340px;
    width: calc(100% - 32px);
    text-align: center;
    box-shadow: var(--shadow-lg), 0 0 40px rgba(var(--primary-rgb), 0.1);
    animation: slideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: visible;
    max-height: 85vh;
    overflow-y: auto;
}

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

/* Staggered animations for children */
.overlay-content > * {
    animation: fadeSlideIn 0.4s ease backwards;
}

.overlay-content > *:nth-child(1) { animation-delay: 0.1s; }
.overlay-content > *:nth-child(2) { animation-delay: 0.15s; }
.overlay-content > *:nth-child(3) { animation-delay: 0.2s; }
.overlay-content > *:nth-child(4) { animation-delay: 0.25s; }
.overlay-content > *:nth-child(5) { animation-delay: 0.3s; }
.overlay-content > *:nth-child(6) { animation-delay: 0.35s; }

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

/* === Start Overlay === */
.start-content {
    background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-elevated) 100%);
}

.logo-container {
    position: relative;
    margin-bottom: 28px;
}

.logo-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 60px;
    background: radial-gradient(ellipse, rgba(var(--primary-rgb), 0.3), transparent 70%);
    filter: blur(20px);
    animation: logoGlow 3s ease-in-out infinite;
}

@keyframes logoGlow {
    0%, 100% { opacity: 0.5; transform: translate(-50%, -50%) scale(1); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
}

.game-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 28px;
    font-weight: 900;
    color: #ffffff;
    letter-spacing: 3px;
    text-shadow: 
        0 0 10px rgba(var(--primary-rgb), 0.8),
        0 0 20px rgba(var(--primary-rgb), 0.5),
        0 0 40px rgba(var(--primary-rgb), 0.3);
    margin-bottom: 8px;
    position: relative;
}

.title-icon {
    color: var(--primary);
    font-size: 24px;
    animation: iconRotate 4s linear infinite;
    display: inline-block;
}

@keyframes iconRotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.game-subtitle {
    font-family: 'Space Grotesk', sans-serif;
    color: #b0b0c8;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Level Selector */
.level-selector {
    margin-bottom: 24px;
}

.selector-label {
    display: block;
    font-family: 'Space Grotesk', sans-serif;
    color: #9090a8;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 14px;
}

.level-buttons {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    justify-content: center;
    align-items: center;
}

.level-btn {
    width: 40px;
    height: 40px;
    border: 2px solid var(--primary);
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-radius: var(--border-radius-xs);
    font-family: 'Orbitron', sans-serif;
    font-size: 16px;
    font-weight: 900;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
    text-shadow: 0 0 10px rgba(var(--primary-rgb), 0.5);
}

.level-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.2), transparent);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.level-btn:hover {
    border-color: var(--primary);
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(var(--primary-rgb), 0.4);
    background: var(--bg-card);
}

.level-btn:hover::before {
    opacity: 1;
}

.level-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #ffffff !important;
    border-color: transparent;
    box-shadow: 0 0 25px rgba(var(--primary-rgb), 0.6);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8) !important;
}

.level-btn.locked {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Navigation buttons for infinite levels */
.level-btn.level-nav {
    width: 36px;
    background: var(--bg-dark);
    border-color: var(--border-color);
    font-size: 20px;
    font-weight: 400;
    color: var(--text-secondary);
}

.level-btn.level-nav:hover {
    background: var(--bg-elevated);
    border-color: var(--primary);
    color: var(--primary);
}

/* Match3 Rules */
.match3-rules {
    margin-bottom: 24px;
}

.rule-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    margin-bottom: 8px;
    background: var(--bg-dark);
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
}

.rule-icon {
    font-size: 20px;
}

.rule-text {
    font-size: 13px;
    color: var(--text-secondary);
    text-align: left;
}

/* Controls Info */
.controls-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.control-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.control-icon {
    font-size: 18px;
}

.control-text {
    font-size: 13px;
    color: #a0a0b8;
    font-weight: 600;
}

.control-divider {
    color: #707088;
    font-size: 12px;
    font-style: italic;
}

/* === Win Overlay === */
.win-content {
    background: linear-gradient(180deg, var(--bg-card) 0%, rgba(var(--success-rgb), 0.1) 100%);
}

.win-effects {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.win-icon {
    font-size: 56px;
    margin-bottom: 12px;
    animation: winBounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    filter: drop-shadow(0 0 20px rgba(var(--success-rgb), 0.5));
}

@keyframes winBounce {
    0% { transform: scale(0) rotate(-10deg); }
    50% { transform: scale(1.2) rotate(5deg); }
    100% { transform: scale(1) rotate(0deg); }
}

.win-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 26px;
    font-weight: 900;
    color: var(--success);
    letter-spacing: 3px;
    margin-bottom: 16px;
    text-shadow: 0 0 20px rgba(var(--success-rgb), 0.5);
}

.win-stats {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.stat-item {
    text-align: center;
    padding: 8px 10px;
    background: var(--bg-dark);
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
    min-width: 75px;
    flex: 0 1 auto;
}

.stat-item.stat-large {
    min-width: 100px;
    padding: 10px 14px;
}

.stat-icon {
    display: block;
    font-size: 20px;
    margin-bottom: 4px;
}

.stat-label {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.stat-value {
    display: block;
    font-family: 'JetBrains Mono', monospace;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-large .stat-value {
    font-size: 22px;
}

.win-record {
    margin-bottom: 12px;
}

.record-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--accent), var(--warning));
    color: var(--bg-deep);
    padding: 10px 20px;
    border-radius: 25px;
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 1px;
    animation: recordPulse 1.5s ease-in-out infinite;
    box-shadow: 0 0 30px rgba(var(--accent-rgb), 0.5);
}

.record-icon {
    font-size: 18px;
    animation: iconFlash 0.5s ease-in-out infinite;
}

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

@keyframes iconFlash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.win-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.win-buttons .btn {
    width: 100%;
    padding: 12px 16px;
    font-size: 13px;
}

/* === Leaderboard Overlay === */
.leaderboard-content {
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    padding: 24px;
}

.leaderboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-shrink: 0;
}

.leaderboard-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.leaderboard-title .title-icon {
    animation: none;
}

.btn-close {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    background: var(--bg-dark);
    color: var(--text-secondary);
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-close:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-color: var(--primary);
}

/* Leaderboard Tabs */
.leaderboard-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-shrink: 0;
}

.tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    font-family: 'Space Grotesk', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.tab-btn.active {
    background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.2), rgba(var(--accent-rgb), 0.1));
    border-color: var(--primary);
    color: var(--text-primary);
}

.tab-icon {
    font-size: 16px;
}

.tab-text {
    white-space: nowrap;
}

.leaderboard-list {
    flex: 1;
    overflow-y: auto;
    margin: 0 -24px;
    padding: 0 24px;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    background: var(--bg-dark);
    border: 1px solid transparent;
    border-radius: var(--border-radius-sm);
    margin-bottom: 8px;
    transition: all var(--transition-fast);
}

.leaderboard-item:hover {
    background: var(--bg-elevated);
    border-color: var(--border-color);
}

.leaderboard-item.current-user {
    background: rgba(var(--primary-rgb), 0.15);
    border-color: var(--primary);
}

.leaderboard-item.top-3 {
    background: linear-gradient(90deg, rgba(var(--accent-rgb), 0.15) 0%, var(--bg-dark) 100%);
}

.leader-rank {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 14px;
    margin-right: 14px;
    border-radius: 50%;
    background: var(--bg-card);
    flex-shrink: 0;
    color: #ffffff !important;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.leader-rank.gold { 
    background: linear-gradient(135deg, #FFD700, #FFA500); 
    color: #ffffff !important;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8) !important;
}

.leader-rank.silver { 
    background: linear-gradient(135deg, #E8E8E8, #A0A0A0); 
    color: #ffffff !important; 
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8) !important;
}

.leader-rank.bronze { 
    background: linear-gradient(135deg, #CD7F32, #8B4513); 
    color: #ffffff !important; 
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8) !important;
}

.leader-info {
    flex: 1;
    min-width: 0;
}

.leader-name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.leader-stats {
    display: flex;
    gap: 12px;
    font-size: 11px;
    color: var(--text-muted);
}

.leaderboard-user {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.user-rank {
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
}

.user-rank span {
    color: var(--primary);
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
}

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px;
    color: var(--text-muted);
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ============================================
   === CONTROL PANEL ===
   ============================================ */

.control-panel {
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: 14px 16px;
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
    flex-shrink: 0;
    z-index: 600;
    position: relative;
}

.control-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    max-width: 100%;
}

.control-row-center {
    justify-content: center;
    gap: 20px;
}

.control-toggles {
    display: flex;
    flex-shrink: 1;
    min-width: 0;
    gap: 16px;
}

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

.toggle-label input[type="checkbox"] {
    display: none;
}

.toggle-switch {
    width: 44px;
    height: 24px;
    background: var(--bg-dark);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    position: relative;
    transition: all var(--transition-fast);
}

.toggle-switch::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    background: var(--text-muted);
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: all var(--transition-fast);
}

.toggle-label input:checked + .toggle-switch {
    background: rgba(var(--primary-rgb), 0.2);
    border-color: var(--primary);
}

.toggle-label input:checked + .toggle-switch::after {
    background: var(--primary);
    left: 22px;
    box-shadow: 0 0 10px rgba(var(--primary-rgb), 0.5);
}

.toggle-text {
    font-size: 12px;
    color: #ffffff !important;
    font-weight: 600;
}

/* ============================================
   === BUTTONS ===
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border: none;
    border-radius: var(--border-radius-sm);
    font-family: 'Space Grotesk', sans-serif;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    position: relative;
    overflow: hidden;
    color: #ffffff !important;
}

.btn * {
    color: #ffffff !important;
}

.btn:active {
    transform: scale(0.98);
}

.btn-content {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    z-index: 1;
}

.btn-text {
    color: inherit;
}

/* Primary Button */
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #ffffff !important;
    font-weight: 800;
    box-shadow: var(--shadow-sm);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8) !important;
}

.btn-primary * {
    color: #ffffff !important;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(var(--primary-rgb), 0.4);
}

.btn-glow {
    animation: buttonGlow 2s ease-in-out infinite;
}

@keyframes buttonGlow {
    0%, 100% { 
        box-shadow: 
            0 4px 15px rgba(var(--primary-rgb), 0.3),
            0 0 30px rgba(var(--primary-rgb), 0.1);
    }
    50% { 
        box-shadow: 
            0 4px 20px rgba(var(--primary-rgb), 0.5),
            0 0 50px rgba(var(--primary-rgb), 0.2);
    }
}

.btn-shine {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: btnShine 3s infinite;
}

@keyframes btnShine {
    0% { left: -100%; }
    20%, 100% { left: 100%; }
}

/* Secondary Button */
.btn-secondary {
    background: var(--bg-elevated);
    color: #ffffff !important;
    border: 1px solid var(--border-color);
}

.btn-secondary * {
    color: #ffffff !important;
}

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

/* Outline Button */
.btn-outline {
    background: transparent;
    color: #ffffff !important;
    border: 2px solid var(--primary);
}

.btn-outline * {
    color: #ffffff !important;
}

.btn-outline:hover {
    background: rgba(var(--primary-rgb), 0.2);
    color: #ffffff !important;
}

/* Large Button */
.btn-large {
    padding: 18px 36px;
    font-size: 16px;
    border-radius: var(--border-radius);
    letter-spacing: 1px;
}

/* Icon Button */
.btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    font-size: 20px;
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    flex-shrink: 0;
}

.btn-icon:hover {
    background: var(--bg-elevated);
    color: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(var(--primary-rgb), 0.2);
}

.btn-shuffle {
    background: linear-gradient(135deg, var(--accent), var(--secondary));
    border-color: var(--accent);
    color: #fff;
}

.btn-shuffle:hover {
    background: linear-gradient(135deg, var(--secondary), var(--accent));
    box-shadow: 0 0 20px rgba(var(--accent-rgb), 0.4);
}

/* ============================================
   === SUDOKU SPECIFIC STYLES ===
   ============================================ */

.sudoku-area {
    flex-direction: column;
    gap: 16px;
    padding: 12px;
}

.sudoku-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

/* Sudoku Grid - 9x9 */
.sudoku-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    gap: 1px;
    background: var(--border-color);
    border: 3px solid var(--primary);
    border-radius: var(--border-radius-sm);
    box-shadow: 
        var(--shadow-lg),
        0 0 30px rgba(var(--primary-rgb), 0.2),
        inset 0 0 20px rgba(var(--primary-rgb), 0.1);
    aspect-ratio: 1;
    width: 100%;
    max-width: min(85vw, 400px);
}

/* Sudoku Cell */
.sudoku-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    font-family: 'JetBrains Mono', monospace;
    font-size: clamp(18px, 5vw, 28px);
    font-weight: 700;
    color: #ffffff !important;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* 3x3 Block Borders */
.sudoku-cell:nth-child(3n) {
    border-right: 2px solid var(--primary);
}

.sudoku-cell:nth-child(9n) {
    border-right: none;
}

.sudoku-cell:nth-child(n+19):nth-child(-n+27),
.sudoku-cell:nth-child(n+46):nth-child(-n+54) {
    border-bottom: 2px solid var(--primary);
}

/* Cell States */
.sudoku-cell.fixed {
    color: #a0a0b8 !important;
    background: var(--bg-dark);
    cursor: default;
}

.sudoku-cell.selected {
    background: rgba(var(--primary-rgb), 0.3);
    box-shadow: inset 0 0 0 2px var(--primary);
}

.sudoku-cell.highlighted {
    background: rgba(var(--primary-rgb), 0.1);
}

.sudoku-cell.same-number {
    background: rgba(var(--accent-rgb), 0.15);
}

.sudoku-cell.error {
    color: #ff4444;
    animation: cellError 0.3s ease;
}

.sudoku-cell.error::after {
    content: '';
    position: absolute;
    inset: 2px;
    border: 2px solid #ff4444;
    border-radius: 4px;
    animation: errorPulse 0.5s ease infinite;
}

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

@keyframes errorPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.sudoku-cell.correct {
    color: var(--success);
}

.sudoku-cell.hint-used {
    color: var(--warning);
}

/* Notes (small numbers in cell) */
.sudoku-cell .notes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    position: absolute;
    inset: 2px;
    font-size: clamp(8px, 1.8vw, 10px);
    color: var(--text-muted);
    pointer-events: none;
}

.sudoku-cell .notes span {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Sudoku Input Panel */
.sudoku-input-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: 400px;
}

.number-buttons {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 6px;
    width: 100%;
}

.number-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-xs);
    font-family: 'JetBrains Mono', monospace;
    font-size: clamp(18px, 5vw, 24px);
    font-weight: 700;
    color: #ffffff !important;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.number-btn:hover {
    border-color: var(--primary);
    background: var(--bg-elevated);
    transform: translateY(-2px);
}

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

.number-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-color: transparent;
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    box-shadow: 0 0 20px rgba(var(--primary-rgb), 0.4);
}

.number-btn.completed {
    opacity: 0.3;
    pointer-events: none;
}

.action-buttons {
    display: flex;
    gap: 12px;
}

.btn-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.btn-action.active {
    background: rgba(var(--primary-rgb), 0.2);
    border-color: var(--primary);
    color: var(--primary);
}

/* Difficulty Badge */
.difficulty-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, var(--secondary), var(--accent));
    padding: 8px 14px;
    border-radius: 20px;
    box-shadow: 0 0 15px rgba(var(--secondary-rgb), 0.3);
}

.mines-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, var(--secondary), var(--accent));
    padding: 6px 12px;
    border-radius: 16px;
    box-shadow: 0 0 10px rgba(var(--secondary-rgb), 0.3);
}

.mines-text {
    font-size: 13px;
    font-weight: 600;
    color: #ffffff !important;
}

.minesweeper-info {
    margin-bottom: 20px;
}

.info-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(var(--primary-rgb), 0.15);
    padding: 10px 16px;
    border-radius: 12px;
    border: 1px solid rgba(var(--primary-rgb), 0.3);
}

.info-icon {
    font-size: 18px;
}

.info-text {
    font-size: 14px;
    color: var(--primary);
    font-weight: 500;
}

.difficulty-text {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Hint Button */
.btn-hint {
    font-size: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-hint:hover {
    border-color: var(--warning);
    box-shadow: 0 0 15px rgba(var(--warning-rgb), 0.3);
}

.btn-sm {
    padding: 8px 12px;
    font-size: 14px;
}

/* Difficulty Selector */
.difficulty-selector {
    margin-bottom: 20px;
}

.difficulty-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.difficulty-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px;
    background: var(--bg-dark);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.difficulty-btn.active {
    background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.2), rgba(var(--accent-rgb), 0.1));
    border-color: var(--primary);
}

.diff-name {
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 4px;
}

.diff-desc {
    font-size: 11px;
    color: #b0b0c8;
}

/* Mode Selector */
.mode-selector {
    margin-bottom: 24px;
}

.mode-buttons {
    display: flex;
    gap: 10px;
}

.mode-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-dark);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.mode-btn.active {
    background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.2), rgba(var(--accent-rgb), 0.1));
    border-color: var(--primary);
}

.mode-icon {
    font-size: 18px;
}

.mode-name {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
}

/* Sudoku Timer hidden state for relaxed mode */
.sudoku-timer.hidden-timer {
    opacity: 0.3;
}

/* ============================================
   === MINESWEEPER SPECIFIC STYLES ===
   ============================================ */

.minesweeper-area {
    flex-direction: column;
    gap: 16px;
    padding: 12px;
    overflow: auto;
}

.minesweeper-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

#minesweeperCanvas {
    display: block;
    border-radius: var(--border-radius-sm);
    border: 3px solid var(--warning);
    box-shadow: 
        var(--shadow-lg),
        0 0 30px rgba(var(--warning-rgb), 0.2);
    touch-action: none;
}

/* Mines Counter */
.mines-counter {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    padding: 8px 14px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

.mines-icon {
    font-size: 18px;
}

.mines-count {
    font-family: 'JetBrains Mono', monospace;
    font-size: 18px;
    font-weight: 700;
    color: var(--warning);
    min-width: 24px;
    text-align: center;
}

/* Minesweeper Difficulty Badge */
.minesweeper-difficulty {
    background: linear-gradient(135deg, var(--warning), #ff6b35);
}

/* Minesweeper Rules */
.minesweeper-rules {
    margin-bottom: 20px;
}

.minesweeper-diff-btns {
    grid-template-columns: 1fr;
    gap: 8px;
}

/* Lose overlay specific */
.lose-content {
    background: linear-gradient(180deg, var(--bg-card) 0%, rgba(255, 68, 68, 0.1) 100%);
}

.lose-title {
    color: #ff4444 !important;
    text-shadow: 0 0 20px rgba(255, 68, 68, 0.5);
}

.lose-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

/* ============================================
   === MATCH3 SPECIFIC STYLES ===
   ============================================ */

.match3-area {
    /* Match3 specific adjustments */
}

/* Score popup animation */
.score-popup {
    position: absolute;
    font-family: 'Orbitron', sans-serif;
    font-size: 18px;
    font-weight: 900;
    color: var(--warning);
    text-shadow: 0 0 10px rgba(var(--warning-rgb), 0.8);
    pointer-events: none;
    animation: scorePopup 1s ease-out forwards;
    z-index: 1000;
}

@keyframes scorePopup {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateY(-60px) scale(1.5);
        opacity: 0;
    }
}

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

@media (max-width: 400px) {
    .hub-title {
        font-size: 26px;
    }
    
    .game-title {
        font-size: 24px;
        letter-spacing: 2px;
    }
    
    .title-icon {
        font-size: 18px;
    }
    
    .timer {
        font-size: 16px;
        min-width: 85px;
    }
    
    .timer-container {
        padding: 8px 14px;
    }
    
    .level-badge {
        padding: 6px 10px;
    }
    
    .level-number {
        font-size: 14px;
    }
    
    .btn-icon {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    
    .control-toggles {
        gap: 10px;
    }
    
    .toggle-switch {
        width: 36px;
        height: 20px;
    }
    
    .toggle-switch::after {
        width: 12px;
        height: 12px;
    }
    
    .toggle-label input:checked + .toggle-switch::after {
        left: 18px;
    }
    
    .toggle-text {
        font-size: 10px;
    }
    
    .win-stats {
        gap: 10px;
    }
    
    .stat-item {
        min-width: 75px;
        padding: 10px 12px;
    }
    
    .stat-value {
        font-size: 16px;
    }
    
    .overlay-content {
        padding: 24px 16px;
    }
    
    .game-card {
        padding: 16px;
    }
    
    .game-card-icon {
        font-size: 40px;
    }
    
    .game-card-title {
        font-size: 16px;
    }
    
    .game-card-desc {
        font-size: 12px;
    }
}

@media (max-width: 360px) {
    .user-name {
        display: none;
    }
    
    .controls-info {
        flex-direction: column;
        gap: 8px;
    }
    
    .control-divider {
        display: none;
    }
    
    .tab-text {
        display: none;
    }
    
    .tab-btn {
        padding: 12px;
    }
}

@media (min-height: 700px) {
    .controls-info {
        margin-top: 32px;
    }
}

/* ============================================
   === UTILITY CLASSES ===
   ============================================ */

.hidden {
    display: none !important;
}

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

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

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

.shake {
    animation: shake 0.4s ease;
}

/* Confetti animation for win */
@keyframes confettiFall {
    0% {
        transform: translateY(-100%) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

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

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}
