        @font-face {
            font-family: 'Press Start 2P';
            src: url('../Press_Start_2P/PressStart2P-Regular.ttf') format('truetype');
            font-display: swap;
        }

        :root {
            /* Colors */
            --color-bg-primary: #1a1a2e;
            --color-bg-secondary: #16213e;
            --color-accent-yellow: #ffe14d;
            --color-accent-cyan: #00ffff;
            --color-accent-green: #00ff64;
            --color-accent-green-dark: #00cc2c;
            --color-accent-blue: #0d6bff;
            --color-accent-blue-dark: #0a47cc;
            --color-accent-magenta: #ff00ff;
            --color-accent-red: #ff0055;
            --color-warning-orange: #ffaa00;
            --color-danger-red: #ff0000;
            --color-text-primary: #ffffff;
            --color-text-secondary: rgba(255, 255, 255, 0.85);
            --color-text-muted: rgba(255, 255, 255, 0.6);

            /* Spacing */
            --spacing-xs: 4px;
            --spacing-sm: 8px;
            --spacing-md: 12px;
            --spacing-lg: 16px;
            --spacing-xl: 24px;
            --spacing-2xl: 32px;

            /* Border Radius */
            --radius-sm: 8px;
            --radius-md: 12px;
            --radius-lg: 14px;
            --radius-xl: 18px;

            /* Transitions */
            --transition-fast: 0.2s;
            --transition-normal: 0.3s;
            --transition-slow: 0.5s;

            /* Shadows */
            --shadow-sm: 0 4px 10px rgba(0, 0, 0, 0.35);
            --shadow-md: 0 12px 24px rgba(0, 0, 0, 0.35);
            --shadow-lg: 0 18px 36px rgba(0, 0, 0, 0.45);

            /* Z-index layers */
            --z-penalty: 90;
            --z-message: 100;
            --z-mobile-combo: 200;
            --z-world-select: 998;
            --z-level-select: 999;
            --z-welcome: 1000;

            /* Font family */
            --font-primary: 'Press Start 2P', 'Courier New', monospace;

            /* Telegram Safe Area Insets */
            /* These fallback to 0px when not in Telegram environment */
            /* Updated dynamically by TelegramService.updateSafeAreaCSS() */
            --tg-safe-area-inset-top: 0px;
            --tg-safe-area-inset-bottom: 0px;
            --tg-safe-area-inset-left: 0px;
            --tg-safe-area-inset-right: 0px;
            --tg-content-safe-area-inset-top: 0px;
            --tg-content-safe-area-inset-bottom: 0px;
            --tg-content-safe-area-inset-left: 0px;
            --tg-content-safe-area-inset-right: 0px;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            -webkit-tap-highlight-color: transparent;
            -webkit-user-select: none; /* Désactive la sélection */
            -moz-user-select: none;
            -ms-user-select: none;
            -webkit-touch-callout: none; /* Supprime le menu contextuel */
            user-select: none;
        }

        /* Prevent horizontal overflow on all screens */
        div[id$="Screen"] {
            max-width: 100%;
            overflow-x: hidden;
        }

        /* Telegram Safe Area Management - Applied to all BaseScreen instances */
        /* This ensures all screens respect Telegram's header/footer UI elements */
        .telegram-safe-screen {
            padding-top: max(
                calc(env(safe-area-inset-top, 0px) + 20px),
                calc(var(--tg-content-safe-area-inset-top, 0px) + 20px)
            );
            padding-bottom: max(
                calc(env(safe-area-inset-bottom, 0px) + 20px),
                calc(var(--tg-content-safe-area-inset-bottom, 0px) + 20px)
            );
        }

        /* Mobile: Increase padding to avoid Telegram header overlap */
        @media (max-width: 600px) {
            .telegram-safe-screen {
                padding-top: max(
                    calc(env(safe-area-inset-top, 0px) + 60px),
                    calc(var(--tg-content-safe-area-inset-top, 0px) + 60px),
                    60px
                );
                padding-bottom: max(
                    calc(env(safe-area-inset-bottom, 0px) + 12px),
                    calc(var(--tg-content-safe-area-inset-bottom, 0px) + 12px),
                    12px
                );
            }
        }

        html {
            overflow: hidden;
            overflow-x: hidden;
            height: 100%;
            overscroll-behavior: none;
            max-width: 100%;
        }

        body {
            background: #1a1a2e;
            font-family: 'Press Start 2P', 'Courier New', monospace;
            overflow: hidden;
            overflow-x: hidden;
            touch-action: none;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            min-height: 100vh;
            min-height: 100dvh;
            height: 100vh;
            height: 100dvh;
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            position: fixed;
            width: 100%;
            max-width: 100%;
            left: 0;
            top: 0;
        }

        #gameContainer {
            display: flex;
            flex-direction: column;
            align-items: center;
            width: 100%;
            max-width: 600px;
            height: 100vh;
            height: 100dvh;
            /* Use max() to take the larger of iOS safe area or Telegram content safe area */
            padding-top: max(
                calc(env(safe-area-inset-top, 0px) + 10px),
                calc(var(--tg-content-safe-area-inset-top, 0px) + 10px)
            );
            padding-left: 10px;
            padding-right: 10px;
            padding-bottom: max(
                calc(env(safe-area-inset-bottom, 0px) + 10px),
                calc(var(--tg-content-safe-area-inset-bottom, 0px) + 10px)
            );
            justify-content: flex-start;
            box-sizing: border-box;
            touch-action: pan-y;
            background: #0a0a0f;
            position: relative;
            z-index: 1;
        }

        /* Mobile override: increase top padding to avoid Telegram header overlap */
        @media (max-width: 600px) {
            #gameContainer {
                padding-top: max(
                    calc(env(safe-area-inset-top, 0px) + 60px),
                    calc(var(--tg-content-safe-area-inset-top, 0px) + 60px),
                    60px
                );
            }
        }

        #gameCanvas {
            display: block;
            -ms-interpolation-mode: nearest-neighbor;
            image-rendering: -moz-crisp-edges;
            image-rendering: -webkit-crisp-edges;
            image-rendering: -o-crisp-edges;
            image-rendering: pixelated;
            image-rendering: crisp-edges;
            cursor: crosshair;
            border: 2px solid rgba(255, 255, 255, 0.2);
            box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
            touch-action: manipulation;
            transition: opacity 0.3s;
        }

        #gameCanvas.hidden {
            opacity: 0;
            pointer-events: none;
        }

        #imageLabel {
            color: white;
            font-family: 'Press Start 2P', 'Courier New', monospace;
            font-size: 14px;
            text-align: center;
            margin-top: 8px;
            letter-spacing: 1px;
            text-shadow: 2px 2px 0 rgba(0,0,0,0.9);
            transition: opacity 0.3s;
        }

        #imageLabel.hidden {
            opacity: 0;
        }

        @media (max-width: 600px) {
            #imageLabel {
                font-size: 11px;
                margin-top: 6px;
            }
        }

        #ui {
            width: 100%;
            max-width: 520px;
            pointer-events: none;
            color: white;
            text-shadow: 2px 2px 0 rgba(0,0,0,0.9);
        }

        @media (max-width: 600px) {
            #ui {
                max-width: 100%;
                padding: 0;
                width: 100%;
            }
        }

        #topBar {
            display: flex;
            flex-direction: column;
            gap: 8px;
            padding: 14px 16px;
            font-size: 13px;
            font-weight: bold;
            background: linear-gradient(135deg, rgba(0, 0, 0, 0.6), rgba(24, 24, 48, 0.8));
            border-radius: 14px;
            margin-bottom: 12px;
            letter-spacing: 1px;
            border: 2px solid rgba(255, 255, 255, 0.1);
            box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35), inset 0 0 20px rgba(0, 0, 0, 0.4);
            width: 100%;
            box-sizing: border-box;
            transition: opacity 0.3s;
        }

        #topBar.hidden {
            opacity: 0;
            pointer-events: none;
        }

        #leftSection {
            display: grid;
            grid-template-columns: repeat(2, auto);
            column-gap: 20px;
            row-gap: 6px;
            align-items: center;
        }

        #leftSection .stat-pair {
            display: flex;
            align-items: baseline;
            gap: 6px;
        }

        #leftSection .label {
            color: rgba(255, 255, 255, 0.6);
            font-size: 0.9em;
        }

        #leftSection .label::after {
            content: ':';
            margin-left: 2px;
        }

        #leftSection .value {
            color: #ffe14d;
        }

        #leftSection .value.timer {
            color: #00ff99;
        }

        .topBar-row {
            display: grid;
            grid-template-columns: 1fr auto;
            gap: 18px;
            align-items: center;
        }

        #rightSection {
            display: flex;
            flex-direction: column;
            gap: 6px;
            align-items: flex-end;
        }

        #rightSection > div {
            min-height: 20px;
            display: flex;
            align-items: center;
        }

        /* Skin Info Bar (second row) */
        #skinInfoBar {
            padding-top: 8px;
            border-top: 1px solid rgba(255, 255, 255, 0.1);
            display: flex;
            align-items: center;
            gap: 12px;
            width: 100%;
            grid-column: 1 / -1; /* Force full width if parent is grid */
        }

        .skin-display {
            display: flex;
            align-items: center;
            flex-shrink: 0;
        }

        .skin-sprite-hud {
            width: 24px;
            height: 24px;
            image-rendering: pixelated;
            image-rendering: crisp-edges;
        }

        .skin-icon-hud {
            font-size: 20px;
            line-height: 1;
        }

        /* Progress Bar */
        .progress-bar-container {
            flex: 1;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .progress-bar-bg {
            flex: 1;
            height: 20px;
            background: rgba(0, 0, 0, 0.5);
            border: 2px solid rgba(255, 255, 255, 0.2);
            border-radius: 10px;
            overflow: hidden;
            position: relative;
        }

        .progress-bar-fill {
            height: 100%;
            background: linear-gradient(90deg,
                var(--color-accent-cyan) 0%,
                var(--color-accent-green) 100%);
            width: 0%;
            transition: width 0.3s ease;
            box-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
        }

        .progress-text {
            font-family: 'Press Start 2P', monospace;
            font-size: 10px;
            color: var(--color-text-primary);
            min-width: 40px;
            text-align: right;
        }

        #timer {
            transition: color 0.3s;
            transform-origin: left center;
        }

        #timer.warning {
            color: #ffaa00 !important;
            animation: pulse 0.5s infinite;
        }

        #timer.warning .value {
            color: #ffaa00 !important;
        }

        #timer.danger {
            color: #ff0000 !important;
            animation: pulse 0.3s infinite;
        }

        #timer.danger .value {
            color: #ff0000 !important;
        }

        @media (max-width: 600px) {
            #topBar {
                font-size: 10px;
                padding: 8px;
                gap: 6px;
                grid-template-columns: 1fr auto;
                margin-bottom: 8px;
                border-radius: 8px;
                border-width: 1px;
                letter-spacing: 0;
                display: grid !important;
            }

            #leftSection {
                display: grid !important;
                grid-template-columns: repeat(2, 1fr);
                column-gap: 8px;
                row-gap: 6px;
            }

            #leftSection .stat-pair {
                gap: 4px;
                white-space: nowrap;
                display: flex !important;
                align-items: baseline;
            }

            #leftSection .label {
                font-size: 0.85em;
            }

            #leftSection .value {
                font-size: 1.1em;
            }

            #rightSection {
                display: flex !important;
                align-items: center;
                justify-content: flex-end;
            }

            #timer {
                font-size: 11px;
            }

            #timer .value {
                font-size: 1.2em;
            }
        }


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

        #centerMessage {
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            font-size: clamp(22px, 4vw, 28px);
            font-weight: bold;
            text-align: center;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.3s;
            z-index: 100;
            display: flex;
            flex-direction: column;
            gap: 12px;
            align-items: center;
            justify-content: center;
            max-width: 540px;
            width: 90%;
            padding: 28px 32px;
            color: white;
            background: linear-gradient(160deg, rgba(14, 14, 30, 0.92), rgba(26, 26, 50, 0.88));
            border-radius: 18px;
            border: 2px solid rgba(255, 255, 255, 0.12);
            box-shadow: 0 18px 36px rgba(0, 0, 0, 0.45), inset 0 0 30px rgba(0, 0, 0, 0.5);
        }

        #messageText {
            color: white;
            letter-spacing: 2px;
            line-height: 1.25;
            word-wrap: break-word;
            overflow-wrap: break-word;
            white-space: normal;
            width: 100%;
        }

        .message-title {
            font-size: clamp(26px, 4.5vw, 34px);
            letter-spacing: 4px;
            text-transform: uppercase;
            margin-bottom: 8px;
            color: #ffe14d;
            text-shadow: 3px 3px 0 rgba(0,0,0,0.6), 0 0 18px rgba(255, 225, 77, 0.45);
        }

        .message-body {
            font-size: clamp(16px, 3.5vw, 22px);
            line-height: 1.4;
            color: rgba(255, 255, 255, 0.92);
            margin: 0;
        }

        #centerMessage.show {
            opacity: 1;
        }

        #centerMessage.show #restartBtn,
        #centerMessage.show #nextLevelBtn,
        #centerMessage.show #levelSelectBtn,
        #centerMessage.show #shareScoreBtn {
            pointer-events: all;
        }

        #centerMessage.game-complete {
            align-items: stretch;
            padding: 24px 16px 20px;
            top: 50%;
            max-height: 90vh;
            overflow-y: auto;
        }

        #messageText.game-complete {
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

        .gc-subtitle {
            font-size: clamp(14px, 3.5vw, 20px);
            color: rgba(255, 255, 255, 0.75);
            letter-spacing: 1px;
        }

        .gc-grid {
            display: flex;
            justify-content: flex-start;
            gap: 12px;
            background: rgba(0, 0, 0, 0.25);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 10px;
            padding: 12px;
        }

        .gc-col {
            display: flex;
            flex-direction: column;
            gap: 10px;
            min-width: 140px;
        }

        .gc-row {
            display: grid;
            grid-template-columns: auto auto 1fr;
            align-items: center;
            gap: 6px;
            font-size: clamp(12px, 2.8vw, 16px);
        }

        .gc-row .gc-level {
            color: rgba(255, 255, 255, 0.8);
        }

        .gc-row .gc-stars {
            color: #ffe14d;
            letter-spacing: 2px;
            font-size: 0.9em;
            justify-self: center;
        }

        .gc-row .gc-score {
            text-align: right;
            color: rgba(255, 255, 255, 0.85);
            justify-self: end;
        }

        .gc-summary {
            display: grid;
            /* Issue #81: Prevent overflow on very small screens */
            grid-template-columns: repeat(auto-fit, minmax(min(150px, 45%), 1fr));
            gap: 12px;
            font-size: clamp(14px, 3vw, 18px);
        }

        .gc-summary-item {
            display: flex;
            flex-direction: column;
            gap: 4px;
            background: rgba(0, 0, 0, 0.2);
            border-radius: 10px;
            padding: 12px;
            border: 1px solid rgba(255, 255, 255, 0.08);
        }

        .gc-summary-item .label {
            color: rgba(255, 255, 255, 0.6);
            font-size: 0.9em;
            text-transform: uppercase;
        }

        .gc-summary-item .value {
            color: #ffe14d;
            letter-spacing: 2px;
        }

        .gc-badge {
            display: inline-block;
            background: #ff007a;
            color: white;
            font-size: 12px;
            padding: 2px 8px;
            border-radius: 999px;
            margin-left: 8px;
            letter-spacing: 1px;
        }

        /* Validation Badge */
        #validationBadge {
            display: none;
            font-size: clamp(11px, 2.5vw, 14px);
            padding: 6px 12px;
            border-radius: 20px;
            letter-spacing: 1px;
            font-weight: bold;
            text-transform: uppercase;
            margin-top: 8px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        }

        #validationBadge.validated {
            display: inline-block;
            background: linear-gradient(135deg, #00ff64, #00cc2c);
            color: #06110a;
            border: 2px solid #00ff64;
        }

        #validationBadge.rejected {
            display: inline-block;
            background: linear-gradient(135deg, #ff0055, #cc0044);
            color: white;
            border: 2px solid #ff0055;
        }

        @media (max-width: 600px) {
            #centerMessage.game-complete {
                padding: 22px 14px 26px;
            }
            #messageText.game-complete {
                gap: 12px;
            }
            .gc-grid {
                flex-direction: column;
                align-items: center;
                padding: 12px;
                gap: 12px;
            }
            .gc-col {
                min-width: 0;
                width: 100%;
            }
            .gc-summary {
                gap: 10px;
            }
            .gc-summary-item {
                padding: 10px;
            }
        }

        @media (max-width: 600px) {
            #centerMessage {
                top: 50%;
                padding: 20px 16px;
                max-width: 100%;
                width: 100%;
            }
            .message-title {
                margin-bottom: 10px;
                font-size: clamp(18px, 5.5vw, 26px);
                letter-spacing: 1px;
                word-break: break-word;
            }
            .message-body {
                font-size: clamp(14px, 3.5vw, 18px);
            }
        }

        /* Action Buttons Grid Container */
        #actionButtons {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(min(200px, 45%), 1fr));
            gap: 16px;
            max-width: 500px;
            margin: 16px auto 0;
            width: 100%;
        }

        #restartBtn, #nextLevelBtn, #levelSelectBtn, #shareScoreBtn {
            /* Style mode-card */
            background: rgba(15, 20, 40, 0.6);
            border: 3px solid rgba(255, 255, 255, 0.18);
            border-radius: 14px;
            padding: 16px 20px;
            font-size: 18px;
            min-height: 60px;
            margin-top: 0;
            color: white;
            font-family: 'Press Start 2P', 'Courier New', monospace;
            cursor: pointer;
            transition: all 0.3s;
            pointer-events: none;
            box-shadow: 0 0 12px rgba(0, 0, 0, 0.2);
            text-transform: uppercase;
            letter-spacing: 2px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        #nextLevelBtn {
            background: linear-gradient(135deg, #00ff64, #00cc2c);
            border-color: #00ff64;
            color: #06110a;
            box-shadow: 0 12px 26px rgba(0, 255, 120, 0.4), inset 0 -5px 0 rgba(0, 0, 0, 0.25);
        }

        #levelSelectBtn {
            background: linear-gradient(135deg, #0d6bff, #0a47cc);
            border-color: rgba(13, 107, 255, 0.6);
            color: #e0f1ff;
            box-shadow: 0 12px 26px rgba(13, 107, 255, 0.35), inset 0 -5px 0 rgba(0, 0, 60, 0.35);
        }

        #shareScoreBtn {
            background: linear-gradient(135deg, #00d4ff, #0099cc);
            border-color: #00d4ff;
            color: #fff;
            box-shadow: 0 12px 26px rgba(0, 212, 255, 0.4), inset 0 -5px 0 rgba(0, 0, 0, 0.25);
        }

        #restartBtn:hover, #nextLevelBtn:hover, #levelSelectBtn:hover, #shareScoreBtn:hover {
            transform: translateY(-4px);
            box-shadow: 0 10px 22px rgba(0, 0, 0, 0.35);
        }

        #nextLevelBtn:hover {
            background: linear-gradient(135deg, #00ff64, #00bb22);
            border-color: rgba(0, 255, 120, 0.8);
            box-shadow: 0 10px 22px rgba(0, 255, 120, 0.35);
        }

        #levelSelectBtn:hover {
            border-color: rgba(13, 107, 255, 0.8);
            box-shadow: 0 10px 22px rgba(13, 107, 255, 0.35);
        }

        #shareScoreBtn:hover {
            border-color: rgba(0, 212, 255, 0.8);
            box-shadow: 0 10px 22px rgba(0, 212, 255, 0.35);
        }

        #restartBtn:active, #nextLevelBtn:active, #levelSelectBtn:active, #shareScoreBtn:active {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        }

        #restartBtn:focus-visible, #nextLevelBtn:focus-visible, #levelSelectBtn:focus-visible, #shareScoreBtn:focus-visible {
            outline: 3px solid #00ffff;
            outline-offset: 2px;
        }

        #centerMessage.game-complete #starsContainer {
            margin: 0;
            min-height: 0;
        }

        @media (max-width: 600px) {
            #actionButtons {
                grid-template-columns: 1fr;
                gap: 12px;
                margin-top: 12px;
                max-width: 100%;
            }

            #restartBtn, #nextLevelBtn, #levelSelectBtn, #shareScoreBtn {
                font-size: 16px;
                padding: 14px 20px;
                min-height: 54px;
                letter-spacing: 1.5px;
            }
        }

        #bottomBar {
            position: fixed;
            bottom: 24px;
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            gap: 10px;
            justify-content: flex-start;
            pointer-events: all;
            z-index: 1000;
        }

        /* Combo Boost Container */
        #comboBoostContainer {
            display: flex;
            gap: 12px;
            align-items: center;
            padding: 8px 12px;
            background: rgba(15, 20, 40, 0.7);
            border: 3px solid rgba(255, 255, 255, 0.15);
            border-radius: 8px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
            pointer-events: all;
        }

        /* Combo Counter */
        #comboCounter {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 4px;
            min-width: 60px;
        }

        .combo-label {
            font-family: 'Press Start 2P', monospace;
            font-size: 8px;
            color: rgba(255, 255, 255, 0.6);
            letter-spacing: 1px;
        }

        .combo-value {
            font-family: 'Press Start 2P', monospace;
            font-size: 18px;
            color: var(--color-accent-cyan);
            text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
            font-weight: bold;
        }

        /* Token Slots Container */
        #tokenSlotsContainer {
            display: flex;
            gap: 8px;
            align-items: center;
            pointer-events: all;
        }

        /* Token Slot (Fixed slots - 3 slots always visible) */
        .token-slot {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            width: 54px;
            height: 54px;
            border: 3px solid rgba(255, 255, 255, 0.2);
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.3s ease;
            touch-action: manipulation;
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
            background: rgba(0, 0, 0, 0.3);
            pointer-events: all;
            position: relative;
        }

        /* Token count badge (×2, ×3) */
        .token-count {
            position: absolute;
            top: -8px;
            right: -8px;
            background: rgba(255, 0, 0, 0.9);
            color: white;
            font-family: 'Press Start 2P', monospace;
            font-size: 10px;
            padding: 2px 6px;
            border-radius: 10px;
            border: 2px solid white;
            box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
            z-index: 10;
            display: none; /* Hidden by default, shown via JS when count > 1 */
        }

        /* Token icon inside slot */
        .token-slot .token-icon {
            font-size: 18px;
            opacity: 0.3;
            transition: opacity 0.3s ease;
        }

        /* Token label (shows required combo) */
        .token-slot .token-label {
            font-family: 'Press Start 2P', monospace;
            font-size: 8px;
            color: rgba(255, 255, 255, 0.4);
            margin-top: 2px;
        }

        /* Slot states - SMALL (5 clics) - Cyan */
        .token-slot[data-token-type="small"].available {
            border-color: #00ffff;
            background: rgba(0, 255, 255, 0.15);
        }

        .token-slot[data-token-type="small"].available .token-icon {
            opacity: 1;
            color: #00ffff;
        }

        .token-slot[data-token-type="small"].available .token-label {
            color: #00ffff;
        }

        .token-slot[data-token-type="small"].available:hover {
            background: rgba(0, 255, 255, 0.3);
            transform: scale(1.05);
            box-shadow: 0 6px 15px rgba(0, 255, 255, 0.5);
        }

        /* Slot states - MEDIUM (10 clics) - Green */
        .token-slot[data-token-type="medium"].available {
            border-color: #00ff00;
            background: rgba(0, 255, 0, 0.15);
        }

        .token-slot[data-token-type="medium"].available .token-icon {
            opacity: 1;
            color: #00ff00;
        }

        .token-slot[data-token-type="medium"].available .token-label {
            color: #00ff00;
        }

        .token-slot[data-token-type="medium"].available:hover {
            background: rgba(0, 255, 0, 0.3);
            transform: scale(1.05);
            box-shadow: 0 6px 15px rgba(0, 255, 0, 0.5);
        }

        /* Slot states - LARGE (15 clics) - Orange */
        .token-slot[data-token-type="large"].available {
            border-color: #ff9900;
            background: rgba(255, 153, 0, 0.15);
        }

        .token-slot[data-token-type="large"].available .token-icon {
            opacity: 1;
            color: #ff9900;
        }

        .token-slot[data-token-type="large"].available .token-label {
            color: #ff9900;
        }

        .token-slot[data-token-type="large"].available:hover {
            background: rgba(255, 153, 0, 0.3);
            transform: scale(1.05);
            box-shadow: 0 6px 15px rgba(255, 153, 0, 0.5);
        }

        /* Armed state (token is ready to blast) */
        .token-slot.armed {
            background: rgba(255, 255, 0, 0.4);
            border-color: #ffff00;
            animation: pulse-armed 0.8s ease-in-out infinite;
        }

        .token-slot.armed .token-icon {
            color: #ffff00;
        }

        .token-slot.armed .token-label {
            color: #ffff00;
        }

        /* Disabled state (can't be clicked) */
        .token-slot:not(.available) {
            cursor: not-allowed;
            opacity: 0.6;
        }

        /* Blast Button (OLD - will be removed) */
        .blast-btn {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 4px;
            padding: 12px 20px;
            font-family: 'Press Start 2P', monospace;
            font-size: 10px;
            border: 3px solid;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.3s ease;
            touch-action: manipulation;
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
            min-width: 80px;
        }

        /* Blast button states */
        .blast-btn[disabled] {
            background: rgba(102, 102, 102, 0.3);
            border-color: #666666;
            color: #666666;
            cursor: not-allowed;
            opacity: 0.5;
        }

        .blast-btn.low-combo {
            background: rgba(0, 255, 255, 0.2);
            border-color: #00ffff;
            color: #00ffff;
        }

        .blast-btn.low-combo:hover {
            background: rgba(0, 255, 255, 0.3);
            transform: translateY(-2px);
            box-shadow: 0 6px 15px rgba(0, 255, 255, 0.4);
        }

        .blast-btn.medium-combo {
            background: rgba(0, 255, 0, 0.2);
            border-color: #00ff00;
            color: #00ff00;
        }

        .blast-btn.medium-combo:hover {
            background: rgba(0, 255, 0, 0.3);
            transform: translateY(-2px);
            box-shadow: 0 6px 15px rgba(0, 255, 0, 0.4);
        }

        .blast-btn.high-combo {
            background: rgba(255, 153, 0, 0.2);
            border-color: #ff9900;
            color: #ff9900;
        }

        .blast-btn.high-combo:hover {
            background: rgba(255, 153, 0, 0.3);
            transform: translateY(-2px);
            box-shadow: 0 6px 15px rgba(255, 153, 0, 0.4);
        }

        .blast-btn.mega-combo {
            background: rgba(255, 0, 0, 0.2);
            border-color: #ff0000;
            color: #ff0000;
            animation: pulse-mega 1s infinite;
        }

        .blast-btn.mega-combo:hover {
            background: rgba(255, 0, 0, 0.3);
            transform: translateY(-2px);
            box-shadow: 0 6px 15px rgba(255, 0, 0, 0.4);
        }

        .blast-btn.armed {
            background: rgba(255, 255, 0, 0.3);
            border-color: #ffff00;
            color: #ffff00;
            animation: pulse-armed 0.5s infinite;
        }

        .blast-btn.armed:hover {
            background: rgba(255, 255, 0, 0.4);
            transform: scale(1.05);
            box-shadow: 0 6px 20px rgba(255, 255, 0, 0.6);
        }

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

        .blast-label {
            font-size: 8px;
            letter-spacing: 1px;
        }

        @keyframes pulse-mega {
            0%, 100% {
                box-shadow: 0 4px 10px rgba(255, 0, 0, 0.4);
            }
            50% {
                box-shadow: 0 4px 20px rgba(255, 0, 0, 0.8);
            }
        }

        @keyframes pulse-armed {
            0%, 100% {
                box-shadow: 0 4px 10px rgba(255, 255, 0, 0.4);
                transform: scale(1);
            }
            50% {
                box-shadow: 0 4px 25px rgba(255, 255, 0, 0.9);
                transform: scale(1.03);
            }
        }

        .debug-btn {
            pointer-events: all;
            background: rgba(20, 20, 40, 0.85);
            border: 2px solid rgba(255, 255, 255, 0.2);
            color: rgba(255, 255, 255, 0.75);
            padding: 8px 14px;
            font-family: 'Press Start 2P', 'Courier New', monospace;
            font-size: 10px;
            cursor: pointer;
            transition: all 0.2s;
            border-radius: 6px;
            touch-action: manipulation;
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
        }

        .debug-btn:hover {
            background: rgba(40, 40, 70, 0.9);
            transform: translateY(-2px);
        }

        .debug-btn:active {
            transform: translateY(1px);
        }

        .debug-btn:focus-visible {
            outline: 2px solid #00ffff;
            outline-offset: 2px;
        }

        #skipBtn {
            background: rgba(255, 165, 0, 0.2);
            border-color: rgba(255, 165, 0, 0.5);
            color: #ffb54d;
        }

        #skipBtn:hover {
            background: rgba(255, 165, 0, 0.3);
        }

        #floatingTexts {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            pointer-events: none;
            z-index: 9999; /* Above all other elements to ensure visibility */
        }

        .floatingText {
            position: absolute;
            font-weight: bold;
            font-size: 24px;
            animation: floatUp 1s ease-out forwards;
            white-space: nowrap;
            /* Removed left: 50% !important to respect JS positioning */
            transform: translateX(-50%); /* Center text horizontally from its position */
        }

        @keyframes floatUp {
            0% {
                opacity: 1;
                transform: translateX(-50%) translateY(0);
            }
            100% {
                opacity: 0;
                transform: translateX(-50%) translateY(-50px);
            }
        }

        /* Penalty Message */
        #penaltyMessage {
            position: fixed;
            top: 44%;
            left: 50%;
            transform: translate(-50%, -50%);
            font-size: 28px;
            font-weight: bold;
            text-align: center;
            color: #ff0000;
            background: rgba(0, 0, 0, 0.8);
            padding: 20px 30px;
            border: 3px solid #ff0000;
            border-radius: 8px;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.2s;
            z-index: 90;
            white-space: pre-line;
            text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
        }

        #penaltyMessage.show {
            opacity: 1;
        }

        @media (max-width: 600px) {
            #penaltyMessage {
                font-size: 20px;
                padding: 15px 20px;
            }
        }

        /* Stars Container */
        #starsContainer {
            display: flex;
            gap: 15px;
            justify-content: flex-start;
            margin: 20px 0;
            min-height: 60px;
        }

        .star {
            font-size: 48px;
            opacity: 0;
            transform: scale(0);
            animation: starPop 0.5s ease-out forwards;
            filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.8));
        }

        .star:nth-child(1) {
            animation-delay: 0s;
        }

        .star:nth-child(2) {
            animation-delay: 0.2s;
        }

        .star:nth-child(3) {
            animation-delay: 0.4s;
        }

        @keyframes starPop {
            0% {
                opacity: 0;
                transform: scale(0) rotate(0deg);
            }
            50% {
                transform: scale(1.3) rotate(180deg);
            }
            100% {
                opacity: 1;
                transform: scale(1) rotate(360deg);
            }
        }

        @media (max-width: 600px) {
            .star {
                font-size: 36px;
            }
            #starsContainer {
                gap: 10px;
                min-height: 50px;
            }
        }

        /* Welcome Screen Styles */
        /* Global background canvas - visible across all screens */
        #globalBackgroundCanvas {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 0;
            pointer-events: none;
        }

        #welcomeScreen {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(135deg, rgba(26, 26, 46, 0.6) 0%, rgba(22, 33, 62, 0.6) 100%);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            z-index: 1000;
            overflow: hidden;
            /* padding-top and padding-bottom managed by .telegram-safe-screen (BaseScreen) */
            padding-left: 10px;
            padding-right: 10px;
        }

        #welcomeContent {
            width: 92%;
            max-width: 420px;
            max-height: 100%;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            text-align: center;
            color: white;
            font-family: 'Press Start 2P', 'Courier New', monospace;
            overflow: hidden;
            position: relative;
            z-index: 1;
        }

        #welcomeContent h1 {
            font-size: clamp(24px, 6vw, 32px);
            font-family: 'Press Start 2P', 'Courier New', monospace;
            margin-top: 4px;
            margin-bottom: 12px;
            color: #ffdd00;
            text-shadow: 3px 3px 0 rgba(0,0,0,0.5);
            letter-spacing: 4px;
            flex-shrink: 0;
        }

        #rulesSlider {
            position: relative;
            width: 100%;
            margin-bottom: 32px;
            margin-top: 8px;
            flex-shrink: 1;
            min-height: 0;
            overflow: hidden;
        }

        .rule-slide {
            display: none;
            opacity: 0;
            transition: opacity 0.3s ease;
            width: 100%;
            padding: 16px;
            background: linear-gradient(135deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.03));
            border-radius: 14px;
            border: 2px solid rgba(255, 255, 255, 0.15);
            min-height: 240px;
            flex-direction: column;
            justify-content: flex-start;
        }

        .rule-slide.active {
            display: flex;
            opacity: 1;
        }

        .rule-slide h2 {
            font-size: clamp(18px, 4.5vw, 24px);
            margin-bottom: 16px;
            color: #00ffff;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            line-height: 1.2;
            text-align: center;
        }

        .rule-slide h2 .emoji {
            font-size: 1.5em;
            display: inline-block;
            line-height: 1;
        }

        .rule-slide p {
            font-size: clamp(11px, 2.8vw, 14px);
            line-height: 1.6;
            margin: 5px 0;
            color: rgba(255, 255, 255, 0.95);
            text-align: left;
            padding-left: 8px;
        }

        .rule-slide p strong {
            color: #ffe14d;
            font-weight: bold;
        }

        .rule-slide p.warning {
            color: #ff8844;
            font-weight: bold;
        }

        #slideIndicators {
            display: flex;
            justify-content: flex-start;
            gap: 8px;
            margin-bottom: 10px;
            flex-shrink: 0;
        }

        .indicator {
            width: 12px;
            height: 12px;
            border-radius: 50%;
            background: rgba(255, 255, 255, 0.3);
            cursor: pointer;
            transition: all 0.3s;
        }

        .indicator.active {
            background: #ffdd00;
            transform: scale(1.3);
        }

        .indicator:focus-visible {
            outline: 2px solid #00ffff;
            outline-offset: 2px;
        }

        #startGameBtn {
            font-size: clamp(18px, 4.5vw, 26px);
            padding: 12px 40px;
            background: linear-gradient(135deg, #00ff00, #00cc00);
            border: 3px solid #00ff00;
            color: #000;
            font-family: 'Press Start 2P', 'Courier New', monospace;
            font-weight: bold;
            cursor: pointer;
            border-radius: 8px;
            box-shadow: 0 6px 20px rgba(0, 255, 0, 0.4);
            text-transform: uppercase;
            letter-spacing: 2px;
            transition: all 0.3s;
            margin-bottom: 8px;
            flex-shrink: 0;
        }

        #startGameBtn:hover {
            transform: scale(1.05);
            box-shadow: 0 8px 30px rgba(0, 255, 0, 0.6);
        }

        #startGameBtn:active {
            transform: scale(0.95);
        }

        #startGameBtn:focus-visible {
            outline: 3px solid #00ffff;
            outline-offset: 4px;
        }

        .version-badge {
            margin-top: 16px;
            font-size: 10px;
            font-family: 'Courier New', monospace;
            color: rgba(255, 255, 255, 0.4);
            text-align: center;
            user-select: text;
            -webkit-user-select: text;
            padding: 4px 8px;
            border-radius: 4px;
            background: rgba(0, 0, 0, 0.2);
        }

        .version-badge:hover {
            color: rgba(255, 255, 255, 0.6);
            background: rgba(0, 0, 0, 0.3);
        }

        @media (max-width: 600px) {
            #welcomeScreen {
                /* padding-top and padding-bottom managed by .telegram-safe-screen (BaseScreen) */
                padding-left: 12px;
                padding-right: 12px;
            }

            #welcomeContent {
                max-width: 360px;
                width: 100%;
            }

            #welcomeContent h1 {
                font-size: 22px;
                margin-top: 0;
                margin-bottom: 8px;
            }

            #rulesSlider {
                margin-top: 6px;
                margin-bottom: 24px;
            }

            .rule-slide {
                padding: 14px;
                min-height: 220px;
            }

            .rule-slide h2 {
                font-size: 16px;
                margin-bottom: 12px;
                gap: 8px;
            }

            .rule-slide p {
                font-size: 10px;
                margin: 4px 0;
                padding-left: 6px;
            }

            #slideIndicators {
                margin-bottom: 8px;
                gap: 6px;
            }

            .indicator {
                width: 10px;
                height: 10px;
            }

            #startGameBtn {
                font-size: 16px;
                padding: 10px 28px;
                margin-bottom: 4px;
            }
        }

        /* Level Select Screen Styles */
        #levelSelectScreen {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(135deg, rgba(26, 26, 46, 0.6) 0%, rgba(22, 33, 62, 0.6) 100%);
            display: none;
            align-items: center;
            justify-content: center;
            z-index: 999;
            overflow: hidden;
            /* padding-top and padding-bottom managed by .telegram-safe-screen (BaseScreen) */
            padding-left: 10px;
            padding-right: 10px;
        }

        #levelSelectContent {
            width: 92%;
            max-width: 600px;
            max-height: 100%;
            display: flex;
            flex-direction: column;
            align-items: center;
            text-align: center;
            color: white;
            font-family: 'Press Start 2P', 'Courier New', monospace;
            position: relative;
            overflow: hidden;
        }

        #levelSelectBackBtn {
            align-self: flex-start;
            margin-bottom: 32px;
            padding: 12px 24px;
            font-size: 14px;
            font-family: 'Press Start 2P', 'Courier New', monospace;
            background: linear-gradient(135deg, rgba(20, 30, 50, 0.85), rgba(15, 20, 40, 0.9));
            border: 2px solid rgba(0, 255, 255, 0.4);
            border-radius: 12px;
            color: #00ffff;
            letter-spacing: 2px;
            text-transform: uppercase;
            cursor: pointer;
            transition: all 0.25s ease;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), inset 0 0 20px rgba(0, 255, 255, 0.05);
        }

        #levelSelectBackBtn:hover {
            transform: translateY(-3px) scale(1.02);
            background: linear-gradient(135deg, rgba(25, 35, 60, 0.9), rgba(20, 25, 50, 0.95));
            border-color: rgba(0, 255, 255, 0.7);
            box-shadow: 0 8px 20px rgba(0, 255, 255, 0.25), inset 0 0 25px rgba(0, 255, 255, 0.1);
            color: #00ffff;
            text-shadow: 0 0 10px rgba(0, 255, 255, 0.6);
        }

        #levelSelectBackBtn:active {
            transform: translateY(0px) scale(0.98);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), inset 0 0 15px rgba(0, 255, 255, 0.08);
        }

        #levelSelectBackBtn:focus-visible {
            outline: 3px solid #00ffff;
            outline-offset: 4px;
        }

        #levelSelectContent h1 {
            font-size: clamp(28px, 6vw, 40px);
            margin-bottom: 16px;
            color: #ffe14d;
            text-shadow: 3px 3px 0 rgba(0,0,0,0.6), 0 0 20px rgba(255, 225, 77, 0.5);
            letter-spacing: 3px;
            flex-shrink: 0;
        }

        #levelsGrid {
            display: grid;
            width: 100%;
            grid-template-columns: repeat(5, minmax(0, 1fr));
            gap: 18px;
            margin-bottom: 16px;
            flex-shrink: 1;
            min-height: 0;
            overflow: hidden;
        }

        .level-card {
            background: rgba(15, 20, 40, 0.6);
            border: 3px solid rgba(255, 255, 255, 0.18);
            border-radius: 14px;
            padding: 16px 12px;
            cursor: pointer;
            transition: all 0.3s;
            position: relative;
            box-shadow: 0 0 12px rgba(0, 0, 0, 0.2);
        }

        .level-card.unlocked {
            border-color: rgba(0, 255, 120, 0.45);
        }

        .level-card.unlocked:hover {
            background: rgba(30, 40, 70, 0.8);
            border-color: rgba(0, 255, 120, 0.8);
            transform: translateY(-4px);
            box-shadow: 0 10px 22px rgba(0, 255, 120, 0.35);
        }

        .level-card.locked {
            opacity: 0.6;
            cursor: not-allowed;
            background: rgba(10, 10, 20, 0.6);
            border-color: rgba(120, 120, 150, 0.3);
        }

        .level-card.locked::after {
            content: 'LOCKED';
            display: block;
            margin-top: 12px;
            font-size: 12px;
            color: rgba(200, 200, 200, 0.7);
            letter-spacing: 2px;
        }

        .level-card.selected {
            background: rgba(0, 255, 120, 0.25);
            border-color: #00ff78;
            box-shadow: 0 0 24px rgba(0, 255, 120, 0.6);
            transform: translateY(-6px);
        }

        .level-card:focus-visible {
            outline: 3px solid #00ffff;
            outline-offset: 2px;
        }

        .level-number {
            font-size: 22px;
            font-weight: bold;
            margin-bottom: 10px;
            color: #ffe14d;
            letter-spacing: 1px;
        }

        .level-stars {
            font-size: 20px;
            margin-bottom: 5px;
            min-height: 24px;
        }

        .level-score {
            font-size: 13px;
            color: rgba(255, 255, 255, 0.8);
            letter-spacing: 1px;
        }

        .level-score.best {
            color: #ffe14d;
        }

        .level-lock {
            font-size: 32px;
            color: rgba(200, 200, 200, 0.5);
        }

        #levelSelectStats {
            background: linear-gradient(135deg, rgba(0, 0, 0, 0.45), rgba(20, 20, 40, 0.7));
            border-radius: 16px;
            border: 2px solid rgba(255, 255, 255, 0.1);
            box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.6);
            padding: 16px;
            margin-bottom: 16px;
            display: grid;
            width: 100%;
            /* Issue #81: Prevent overflow on very small screens */
            grid-template-columns: repeat(auto-fit, minmax(min(180px, 45%), 1fr));
            gap: 12px;
            flex-shrink: 0;
        }

        .stat-item {
            font-size: 16px;
            letter-spacing: 1px;
        }

        .stat-label {
            color: rgba(255, 255, 255, 0.75);
            font-size: 13px;
            text-transform: uppercase;
            margin-bottom: 8px;
        }

        .stat-value {
            color: #ffe14d;
            font-size: 26px;
            font-weight: bold;
        }

        #levelSelectPlayBtn {
            font-size: clamp(18px, 4vw, 24px);
            padding: 14px 50px;
            background: linear-gradient(135deg, #00ff64, #00cc2c);
            border: 4px solid #00ff64;
            color: #06110a;
            font-family: 'Press Start 2P', 'Courier New', monospace;
            font-weight: bold;
            cursor: pointer;
            border-radius: 12px;
            box-shadow: 0 12px 30px rgba(0, 255, 120, 0.4), inset 0 -6px 0 rgba(0, 0, 0, 0.25);
            text-transform: uppercase;
            letter-spacing: 3px;
            transition: transform 0.2s ease, box-shadow 0.2s ease;
            display: none;
            flex-shrink: 0;
        }

        #levelSelectPlayBtn.show {
            display: inline-block;
        }

        #levelSelectPlayBtn:hover {
            transform: translateY(-4px) scale(1.03);
            box-shadow: 0 16px 36px rgba(0, 255, 120, 0.55), inset 0 -6px 0 rgba(0, 0, 0, 0.3);
        }

        #levelSelectPlayBtn:active {
            transform: translateY(2px) scale(0.98);
            box-shadow: 0 8px 18px rgba(0, 255, 120, 0.4), inset 0 -2px 0 rgba(0, 0, 0, 0.35);
        }

        #levelSelectPlayBtn:focus-visible {
            outline: 3px solid #00ffff;
            outline-offset: 4px;
        }

        @keyframes shake {
            0%, 100% { transform: translateX(0); }
            25% { transform: translateX(-10px); }
            75% { transform: translateX(10px); }
        }

        @media (max-width: 600px) {
            #levelSelectScreen {
                /* padding-top and padding-bottom managed by .telegram-safe-screen (BaseScreen) */
            padding-left: 12px;
            padding-right: 12px;
            }

            #levelSelectContent {
                width: 100%;
                max-width: 100%;
            }

            #levelSelectBackBtn {
                font-size: 13px;
                padding: 8px 12px;
                margin-bottom: 20px;
            }

            #levelSelectContent h1 {
                font-size: 20px;
                margin-bottom: 8px;
            }

            #levelSelectStats {
                grid-template-columns: 1fr;
                gap: 6px;
                padding: 8px;
                margin-bottom: 8px;
            }

            .stat-item {
                font-size: 12px;
            }

            .stat-label {
                font-size: 10px;
                margin-bottom: 3px;
            }

            .stat-value {
                font-size: 16px;
            }

            #levelsGrid {
                grid-template-columns: repeat(2, 1fr);
                gap: 5px 8px;
                margin-bottom: 8px;
                padding: 0;
            }

            .level-card {
                padding: 4px 2px;
                border-width: 1px;
                border-radius: 5px;
                min-height: 0;
            }

            .level-number {
                font-size: 12px;
                margin-bottom: 2px;
                line-height: 1.1;
            }

            .level-stars {
                font-size: 10px;
                min-height: 11px;
                margin-bottom: 2px;
                line-height: 1.1;
            }

            .level-score {
                font-size: 8px;
                margin: 0;
                line-height: 1.1;
            }

            .level-lock {
                font-size: 16px;
                margin: 1px 0;
                line-height: 1;
            }

            .level-card.locked::after {
                content: '';
                display: none;
            }

            #levelSelectPlayBtn {
                font-size: 16px;
                padding: 10px 30px;
            }
        }

        /* Mode Select Screen Styles */
        #modeSelectScreen {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(135deg, rgba(26, 26, 46, 0.6) 0%, rgba(22, 33, 62, 0.6) 100%);
            display: none;
            align-items: center;
            justify-content: center;
            z-index: 997;
            overflow: hidden;
            /* padding-top and padding-bottom managed by .telegram-safe-screen (BaseScreen) */
            padding-left: 10px;
            padding-right: 10px;
        }

        #modeSelectContent {
            width: 90%;
            max-width: 600px;
            max-height: 100%;
            display: flex;
            flex-direction: column;
            text-align: center;
            color: white;
            font-family: 'Press Start 2P', 'Courier New', monospace;
            overflow: hidden;
        }

        #modeSelectContent h1 {
            font-size: clamp(28px, 6vw, 40px);
            margin-bottom: 16px;
            color: #ffe14d;
            text-shadow: 3px 3px 0 rgba(0,0,0,0.6), 0 0 20px rgba(255, 225, 77, 0.5);
            letter-spacing: 3px;
            flex-shrink: 0;
        }

        #modeSelectContent h2 {
            font-size: clamp(18px, 4vw, 24px);
            margin-bottom: 24px;
            color: rgba(255, 255, 255, 0.85);
            letter-spacing: 2px;
            flex-shrink: 0;
        }

        #modesGrid {
            display: grid;
            /* Issue #81: Prevent overflow on very small screens */
            grid-template-columns: repeat(auto-fit, minmax(min(240px, 45%), 1fr));
            gap: 20px;
            margin-bottom: 16px;
            flex-shrink: 1;
            min-height: 0;
            overflow-y: auto;
            padding: 4px;
        }

        .mode-card {
            background: rgba(15, 20, 40, 0.6);
            border: 3px solid rgba(255, 255, 255, 0.18);
            border-radius: 14px;
            padding: 24px 20px;
            cursor: pointer;
            transition: all 0.3s;
            position: relative;
            box-shadow: 0 0 12px rgba(0, 0, 0, 0.2);
            display: flex;
            flex-direction: column;
            gap: 12px;
            min-height: 110px;
            justify-content: center;
        }

        .mode-card.unlocked {
            border-color: rgba(0, 255, 120, 0.45);
        }

        .mode-card.unlocked:hover {
            background: rgba(30, 40, 70, 0.8);
            border-color: rgba(0, 255, 120, 0.8);
            transform: translateY(-4px);
            box-shadow: 0 10px 22px rgba(0, 255, 120, 0.35);
        }

        .mode-card.locked {
            opacity: 0.5;
            cursor: not-allowed;
            gap: 4px;
            background: rgba(10, 10, 20, 0.6);
            border-color: rgba(120, 120, 150, 0.3);
        }

        .mode-card:focus-visible {
            outline: 3px solid #00ffff;
            outline-offset: 2px;
        }

        .mode-name {
            font-size: 26px;
            font-weight: bold;
            color: #ffe14d;
            letter-spacing: 2px;
        }

        .mode-description {
            font-size: 14px;
            color: rgba(255, 255, 255, 0.8);
            letter-spacing: 1px;
        }

        .mode-lock {
            font-size: 16px;
            color: rgba(200, 200, 200, 0.5);
            margin: 0;
            text-align: center;
        }

        .mode-card.shake {
            animation: shake 0.5s;
        }

        /* Leaderboard Button in Mode Select */
        .leaderboard-btn {
            width: 100%;
            max-width: 400px;
            margin: 24px auto 0;
            padding: 20px 24px;
            background: linear-gradient(135deg, rgba(255, 215, 0, 0.15) 0%, rgba(255, 193, 7, 0.1) 100%);
            border: 3px solid rgba(255, 215, 0, 0.6);
            border-radius: 16px;
            cursor: pointer;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            font-family: 'Press Start 2P', 'Courier New', monospace;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 16px;
            box-shadow: 0 4px 12px rgba(255, 215, 0, 0.2),
                        inset 0 1px 0 rgba(255, 255, 255, 0.1);
            position: relative;
            overflow: hidden;
        }

        .leaderboard-btn::before {
            content: '';
            position: absolute;
            top: 0;
            left: -100%;
            width: 100%;
            height: 100%;
            background: linear-gradient(90deg, transparent, rgba(255, 215, 0, 0.2), transparent);
            transition: left 0.5s;
        }

        .leaderboard-btn:hover::before {
            left: 100%;
        }

        .leaderboard-btn:hover {
            transform: translateY(-4px);
            border-color: rgba(255, 215, 0, 0.9);
            box-shadow: 0 8px 20px rgba(255, 215, 0, 0.4),
                        inset 0 1px 0 rgba(255, 255, 255, 0.2),
                        0 0 20px rgba(255, 215, 0, 0.3);
            background: linear-gradient(135deg, rgba(255, 215, 0, 0.25) 0%, rgba(255, 193, 7, 0.15) 100%);
        }

        .leaderboard-btn:active {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(255, 215, 0, 0.3),
                        inset 0 1px 0 rgba(255, 255, 255, 0.1);
        }

        .leaderboard-icon {
            font-size: 32px;
            filter: drop-shadow(0 2px 4px rgba(255, 215, 0, 0.5));
            animation: trophy-pulse 2s ease-in-out infinite;
        }

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

        .leaderboard-text {
            font-size: clamp(14px, 3vw, 18px);
            font-weight: bold;
            color: #ffd700;
            text-shadow: 0 2px 8px rgba(255, 215, 0, 0.5),
                         0 0 20px rgba(255, 215, 0, 0.3);
            letter-spacing: 2px;
        }

        @media (max-width: 600px) {
            #modeSelectScreen {
                /* padding-top and padding-bottom managed by .telegram-safe-screen (BaseScreen) */
            padding-left: 12px;
            padding-right: 12px;
            }

            #modeSelectContent {
                width: 100%;
                max-width: 100%;
            }

            #modeSelectContent h1 {
                font-size: 20px;
                margin-bottom: 8px;
            }

            #modeSelectContent h2 {
                font-size: 14px;
                margin-bottom: 16px;
            }

            #modesGrid {
                grid-template-columns: 1fr;
                gap: 12px;
                margin-bottom: 12px;
            }

            .mode-card {
                padding: 16px 14px;
                gap: 8px;
            }

            .mode-card.locked {
                gap: 4px;
            }

            .mode-name {
                font-size: 20px;
            }

            .mode-description {
                font-size: 11px;
            }

            .mode-lock {
                font-size: 16px;
                margin: 0;
            }

            .leaderboard-btn {
                margin: 16px auto 0;
                padding: 16px 20px;
                gap: 12px;
                max-width: 100%;
            }

            .leaderboard-icon {
                font-size: 24px;
            }

            .leaderboard-text {
                font-size: 12px;
                letter-spacing: 1px;
            }
        }

        /* World Select Screen Styles */
        #worldSelectScreen {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(135deg, rgba(26, 26, 46, 0.6) 0%, rgba(22, 33, 62, 0.6) 100%);
            display: none;
            align-items: center;
            justify-content: center;
            z-index: 998;
            overflow: hidden;
            overscroll-behavior: none;
            touch-action: none;
            /* padding-top and padding-bottom managed by .telegram-safe-screen (BaseScreen) */
            padding-left: 10px;
            padding-right: 10px;
        }

        #worldSelectContent {
            width: 90%;
            max-width: 600px;
            max-height: 100%;
            display: flex;
            flex-direction: column;
            text-align: center;
            color: white;
            font-family: 'Press Start 2P', 'Courier New', monospace;
            overflow: hidden;
            touch-action: pan-y;
            box-sizing: border-box;
        }

        #worldSelectBackBtn {
            align-self: flex-start;
            margin-bottom: 32px;
            padding: 12px 24px;
            font-size: 14px;
            font-family: 'Press Start 2P', 'Courier New', monospace;
            background: linear-gradient(135deg, rgba(20, 30, 50, 0.85), rgba(15, 20, 40, 0.9));
            border: 2px solid rgba(0, 255, 255, 0.4);
            border-radius: 12px;
            color: #00ffff;
            letter-spacing: 2px;
            text-transform: uppercase;
            cursor: pointer;
            transition: all 0.25s ease;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), inset 0 0 20px rgba(0, 255, 255, 0.05);
        }

        #worldSelectBackBtn:hover {
            transform: translateY(-3px) scale(1.02);
            background: linear-gradient(135deg, rgba(25, 35, 60, 0.9), rgba(20, 25, 50, 0.95));
            border-color: rgba(0, 255, 255, 0.7);
            box-shadow: 0 8px 20px rgba(0, 255, 255, 0.25), inset 0 0 25px rgba(0, 255, 255, 0.1);
            color: #00ffff;
            text-shadow: 0 0 10px rgba(0, 255, 255, 0.6);
        }

        #worldSelectBackBtn:active {
            transform: translateY(0px) scale(0.98);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), inset 0 0 15px rgba(0, 255, 255, 0.08);
        }

        #worldSelectBackBtn:focus-visible {
            outline: 3px solid #00ffff;
            outline-offset: 4px;
        }

        #worldSelectContent h1 {
            font-size: clamp(28px, 6vw, 40px);
            margin-bottom: 16px;
            color: #ffe14d;
            text-shadow: 3px 3px 0 rgba(0,0,0,0.6), 0 0 20px rgba(255, 225, 77, 0.5);
            letter-spacing: 3px;
            flex-shrink: 0;
        }

        #worldSelectContent h2 {
            font-size: clamp(18px, 4vw, 24px);
            margin-bottom: 24px;
            color: rgba(255, 255, 255, 0.85);
            letter-spacing: 2px;
            flex-shrink: 0;
        }

        #worldsGrid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
            gap: 20px;
            margin-bottom: 16px;
            flex-shrink: 1;
            min-height: 0;
            overflow-y: auto;
            overflow-x: hidden;
            overscroll-behavior-y: contain;
            -webkit-overflow-scrolling: touch;
            padding: 4px;
            width: 100%;
            box-sizing: border-box;
        }

        .world-card {
            background: rgba(15, 20, 40, 0.6);
            border: 3px solid rgba(255, 255, 255, 0.18);
            border-radius: 14px;
            padding: 24px 20px;
            cursor: pointer;
            transition: all 0.3s;
            position: relative;
            box-shadow: 0 0 12px rgba(0, 0, 0, 0.2);
            display: flex;
            flex-direction: column;
            gap: 12px;
            box-sizing: border-box;
            min-width: 0;
        }

        .world-card.unlocked {
            border-color: rgba(0, 255, 120, 0.45);
        }

        .world-card.unlocked:hover {
            background: rgba(30, 40, 70, 0.8);
            border-color: rgba(0, 255, 120, 0.8);
            transform: translateY(-4px);
            box-shadow: 0 10px 22px rgba(0, 255, 120, 0.35);
        }

        .world-card.locked {
            opacity: 0.5;
            cursor: not-allowed;
            background: rgba(10, 10, 20, 0.6);
            border-color: rgba(120, 120, 150, 0.3);
        }

        .world-card:focus-visible {
            outline: 3px solid #00ffff;
            outline-offset: 2px;
        }

        .world-number {
            font-size: 26px;
            font-weight: bold;
            color: #ffe14d;
            letter-spacing: 2px;
        }

        .world-name {
            font-size: 18px;
            color: #00ffff;
            letter-spacing: 1px;
            margin-bottom: 8px;
        }

        .world-progress {
            font-size: 14px;
            color: rgba(255, 255, 255, 0.8);
        }

        .world-stars {
            font-size: 20px;
            margin-top: 4px;
        }

        .world-lock {
            font-size: 48px;
            color: rgba(200, 200, 200, 0.5);
            margin: 20px 0;
        }

        .world-lock-text {
            font-size: 14px;
            color: rgba(200, 200, 200, 0.7);
            letter-spacing: 1px;
        }

        /* Pause Button - Border color changes to show current target color */
        .pause-btn {
            pointer-events: all;
            background: rgba(30, 30, 50, 0.85);
            border: 3px solid rgba(255, 255, 255, 0.3);
            color: #ffffff;
            font-size: 20px;
            width: 44px;
            height: 44px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            border-radius: 8px;
            transition: all 0.2s ease, border-color 0.2s ease;
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
            touch-action: manipulation;
            user-select: none;
        }

        .pause-btn:hover {
            background: rgba(50, 50, 80, 0.95);
            border-color: rgba(255, 255, 255, 0.5);
            transform: translateY(-2px);
            box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
        }

        .pause-btn:active {
            transform: translateY(0px);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
        }

        .pause-btn:focus-visible {
            outline: 3px solid #00ffff;
            outline-offset: 2px;
        }

        /* Pause Overlay */
        #pauseOverlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.85);
            backdrop-filter: blur(8px);
            display: none;
            align-items: center;
            justify-content: center;
            z-index: 150;
            opacity: 0;
            transition: opacity 0.3s ease;
        }

        #pauseOverlay.show {
            display: flex;
            opacity: 1;
        }

        #pauseContent {
            background: linear-gradient(160deg, rgba(14, 14, 30, 0.95), rgba(26, 26, 50, 0.92));
            border: 3px solid rgba(255, 255, 255, 0.2);
            border-radius: 20px;
            padding: 40px 48px;
            display: flex;
            flex-direction: column;
            gap: 20px;
            align-items: center;
            box-shadow: 0 24px 48px rgba(0, 0, 0, 0.6), inset 0 0 40px rgba(0, 0, 0, 0.5);
            min-width: 320px;
        }

        .pause-title {
            font-family: 'Press Start 2P', 'Courier New', monospace;
            font-size: clamp(28px, 6vw, 40px);
            color: #ffe14d;
            text-shadow: 3px 3px 0 rgba(0,0,0,0.6), 0 0 20px rgba(255, 225, 77, 0.5);
            letter-spacing: 4px;
            margin-bottom: 10px;
        }

        .pause-option-btn {
            font-family: 'Press Start 2P', 'Courier New', monospace;
            font-size: clamp(16px, 3.5vw, 20px);
            padding: 16px 40px;
            background: linear-gradient(135deg, #00ff64, #00cc2c);
            border: 3px solid #00ff64;
            color: #06110a;
            font-weight: bold;
            cursor: pointer;
            border-radius: 12px;
            box-shadow: 0 8px 20px rgba(0, 255, 120, 0.4), inset 0 -4px 0 rgba(0, 0, 0, 0.25);
            text-transform: uppercase;
            letter-spacing: 2px;
            transition: all 0.2s ease;
            width: 100%;
            touch-action: manipulation;
        }

        .pause-option-btn:hover {
            transform: translateY(-3px);
            box-shadow: 0 12px 28px rgba(0, 255, 120, 0.5), inset 0 -4px 0 rgba(0, 0, 0, 0.3);
        }

        .pause-option-btn:active {
            transform: translateY(1px);
            box-shadow: 0 4px 12px rgba(0, 255, 120, 0.4), inset 0 -2px 0 rgba(0, 0, 0, 0.35);
        }

        .pause-option-btn:focus-visible {
            outline: 3px solid #00ffff;
            outline-offset: 4px;
        }

        .pause-option-btn.quit {
            background: linear-gradient(135deg, rgba(40, 40, 70, 0.95), rgba(30, 30, 50, 0.9));
            border-color: rgba(255, 255, 255, 0.3);
            color: rgba(255, 255, 255, 0.9);
            box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4), inset 0 -4px 0 rgba(0, 0, 0, 0.35);
        }

        .pause-option-btn.quit:hover {
            background: linear-gradient(135deg, rgba(60, 60, 100, 0.95), rgba(50, 50, 80, 0.9));
            border-color: rgba(255, 255, 255, 0.5);
            box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5), inset 0 -4px 0 rgba(0, 0, 0, 0.4);
        }

        @media (max-width: 600px) {
            .pause-btn {
                font-size: 18px;
                width: 40px;
                height: 40px;
                margin-left: 4px;
            }

            #pauseContent {
                padding: 32px 28px;
                min-width: 100%;
                max-width: 100%;
            }

            .pause-title {
                font-size: 24px;
                letter-spacing: 2px;
                margin-bottom: 6px;
            }

            .pause-option-btn {
                font-size: 14px;
                padding: 14px 32px;
                letter-spacing: 1px;
            }
        }

        /* Reduced Motion Support */
        @media (prefers-reduced-motion: reduce) {
            *,
            *::before,
            *::after {
                animation-duration: 0.01ms !important;
                animation-iteration-count: 1 !important;
                transition-duration: 0.01ms !important;
                scroll-behavior: auto !important;
            }

            .star {
                animation: none !important;
                opacity: 1 !important;
                transform: scale(1) !important;
            }

            .floatingText {
                animation: none !important;
            }
        }

        @media (max-width: 600px) {
            #worldSelectScreen {
                /* padding-top and padding-bottom managed by .telegram-safe-screen (BaseScreen) */
            padding-left: 12px;
            padding-right: 12px;
            }

            #worldSelectContent {
                width: 100%;
                max-width: 100%;
            }

            #worldSelectBackBtn {
                font-size: 13px;
                padding: 8px 12px;
                margin-bottom: 20px;
            }

            #worldSelectContent h1 {
                font-size: 20px;
                margin-bottom: 8px;
            }

            #worldSelectContent h2 {
                font-size: 14px;
                margin-bottom: 16px;
            }

            #worldsGrid {
                grid-template-columns: 1fr;
                gap: 12px;
                margin-bottom: 12px;
            }

            .world-card {
                padding: 16px 14px;
                gap: 8px;
            }

            .world-number {
                font-size: 20px;
            }

            .world-name {
                font-size: 14px;
                margin-bottom: 4px;
            }

            .world-progress {
                font-size: 11px;
            }

            .world-stars {
                font-size: 16px;
            }

            .world-lock {
                font-size: 36px;
                margin: 12px 0;
            }

            .world-lock-text {
                font-size: 11px;
            }
        }

        /* Image Gallery Screen Styles */
        #imageGalleryScreen {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(135deg, rgba(26, 26, 46, 0.6) 0%, rgba(22, 33, 62, 0.6) 100%);
            display: none;
            align-items: center;
            justify-content: center;
            z-index: 996;
            overflow: hidden;
            /* padding-top and padding-bottom managed by .telegram-safe-screen (BaseScreen) */
            padding-left: 10px;
            padding-right: 10px;
        }

        #imageGalleryContent {
            width: 90%;
            max-width: 900px;
            max-height: 100%;
            display: flex;
            flex-direction: column;
            text-align: center;
            color: white;
            font-family: 'Press Start 2P', 'Courier New', monospace;
            overflow: hidden;
        }

        .gallery-back-btn {
            align-self: flex-start;
            margin-bottom: 20px;
            padding: 10px 20px;
            font-size: 13px;
            font-family: 'Press Start 2P', 'Courier New', monospace;
            background: linear-gradient(135deg, rgba(20, 30, 50, 0.85), rgba(15, 20, 40, 0.9));
            border: 2px solid rgba(0, 255, 255, 0.4);
            border-radius: 10px;
            color: #00ffff;
            letter-spacing: 1px;
            text-transform: uppercase;
            cursor: pointer;
            transition: all 0.25s ease;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        }

        .gallery-back-btn:hover {
            transform: translateY(-2px);
            background: linear-gradient(135deg, rgba(25, 35, 60, 0.9), rgba(20, 25, 50, 0.95));
            border-color: rgba(0, 255, 255, 0.7);
            box-shadow: 0 6px 16px rgba(0, 255, 255, 0.25);
        }

        .gallery-back-btn:active {
            transform: translateY(0px);
        }

        .gallery-back-btn:focus-visible {
            outline: 3px solid #00ffff;
            outline-offset: 3px;
        }

        #imageGalleryContent h1 {
            font-size: clamp(24px, 5vw, 34px);
            margin-bottom: 8px;
            color: #ffe14d;
            text-shadow: 3px 3px 0 rgba(0,0,0,0.6), 0 0 20px rgba(255, 225, 77, 0.5);
            letter-spacing: 3px;
            flex-shrink: 0;
        }

        .gallery-subtitle {
            font-size: clamp(11px, 2.5vw, 14px);
            margin-bottom: 16px;
            color: rgba(255, 255, 255, 0.7);
            letter-spacing: 1px;
            flex-shrink: 0;
        }

        /* Search Bar Container - Mobile-First Vertical Layout */
        #imageGallerySearch {
            display: flex;
            flex-direction: column;
            gap: 12px;
            width: 100%;
            max-width: 600px;
            margin: 20px auto 16px auto;
            padding: 0 16px;
            flex-shrink: 0;
            box-sizing: border-box;
        }

        /* Search Input - Full Width */
        #imageSearch {
            width: 100%;
            padding: 12px 16px;
            font-family: 'Press Start 2P', 'Courier New', monospace;
            font-size: clamp(10px, 2.5vw, 14px);
            background: rgba(255, 255, 255, 0.05);
            border: 2px solid rgba(255, 255, 255, 0.2);
            border-radius: 8px;
            color: #fff;
            transition: all 0.2s ease;
            box-sizing: border-box;
            letter-spacing: 1px;
        }

        #imageSearch:focus {
            outline: none;
            border-color: #00ffff;
            box-shadow: 0 0 12px rgba(0, 255, 255, 0.3);
        }

        #imageSearch::placeholder {
            color: rgba(255, 255, 255, 0.4);
        }

        /* Buttons - Full Width on Mobile */
        #randomImageBtn,
        #connectWalletBtn {
            width: 100%;
            padding: 12px 16px;
            font-family: 'Press Start 2P', 'Courier New', monospace;
            font-size: clamp(10px, 2.5vw, 12px);
            border: 2px solid rgba(255, 255, 255, 0.2);
            border-radius: 8px;
            color: #fff;
            cursor: pointer;
            transition: all 0.2s ease;
            text-transform: uppercase;
            letter-spacing: 1px;
            box-sizing: border-box;
            /* Prevent text overflow on mobile */
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        #randomImageBtn {
            background: linear-gradient(135deg, #ff00ff, #cc00cc);
            border-color: #ff00ff;
            box-shadow: 0 4px 12px rgba(255, 0, 255, 0.3);
        }

        #randomImageBtn:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 16px rgba(255, 0, 255, 0.4);
        }

        #randomImageBtn:active {
            transform: translateY(0px);
        }

        #randomImageBtn:focus-visible {
            outline: 3px solid #00ffff;
            outline-offset: 3px;
        }

        #connectWalletBtn {
            background: linear-gradient(135deg, #00ff88, #00cc66);
            border-color: #00ff88;
            box-shadow: 0 4px 12px rgba(0, 255, 136, 0.3);
        }

        #connectWalletBtn:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 16px rgba(0, 255, 136, 0.4);
            background: linear-gradient(135deg, #00ffaa, #00dd77);
        }

        #connectWalletBtn:active {
            transform: translateY(0px);
        }

        #connectWalletBtn:focus-visible {
            outline: 3px solid #00ffff;
            outline-offset: 3px;
        }

        #imageGrid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
            grid-auto-rows: minmax(min-content, auto);
            gap: 12px;
            padding: 16px;
            background: rgba(0, 0, 0, 0.3);
            border: 2px solid rgba(255, 255, 255, 0.1);
            border-radius: 12px;
            overflow-y: auto;
            max-height: 400px;
            margin-bottom: 16px;
            flex-shrink: 1;
            min-height: 0;
        }

        #imageGrid.loading {
            opacity: 0.5;
            pointer-events: none;
        }

        .image-card {
            background: rgba(15, 20, 40, 0.8);
            border: 2px solid rgba(255, 255, 255, 0.2);
            border-radius: 8px;
            padding: 8px;
            cursor: pointer;
            transition: all 0.2s ease;
            display: flex;
            flex-direction: column;
            gap: 6px;
            align-items: center;
        }

        .image-card:hover {
            border-color: rgba(0, 255, 255, 0.6);
            background: rgba(25, 35, 60, 0.9);
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(0, 255, 255, 0.3);
        }

        .image-card.selected {
            border-color: #00ff64;
            background: rgba(0, 255, 100, 0.2);
            box-shadow: 0 0 16px rgba(0, 255, 100, 0.5);
            transform: scale(1.05);
        }

        .image-card.selected:hover {
            border-color: #00ff64;
        }

        .image-card img {
            width: 100%;
            height: auto;
            aspect-ratio: 1;
            object-fit: contain;
            image-rendering: pixelated;
            border-radius: 4px;
        }

        .image-label {
            font-size: 9px;
            color: rgba(255, 255, 255, 0.7);
            letter-spacing: 0.5px;
        }

        #imageGalleryPagination {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 16px;
            margin-bottom: 16px;
            flex-shrink: 0;
        }

        #prevPageBtn,
        #nextPageBtn {
            padding: 10px 16px;
            font-family: 'Press Start 2P', 'Courier New', monospace;
            font-size: 14px;
            background: rgba(15, 20, 40, 0.8);
            border: 2px solid rgba(255, 255, 255, 0.3);
            border-radius: 8px;
            color: white;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        #prevPageBtn:hover:not(:disabled),
        #nextPageBtn:hover:not(:disabled) {
            background: rgba(30, 40, 70, 0.9);
            border-color: #00ffff;
            transform: translateY(-2px);
        }

        #prevPageBtn:disabled,
        #nextPageBtn:disabled {
            opacity: 0.3;
            cursor: not-allowed;
        }

        #prevPageBtn:focus-visible,
        #nextPageBtn:focus-visible {
            outline: 3px solid #00ffff;
            outline-offset: 3px;
        }

        #pageInfo {
            font-size: 12px;
            color: rgba(255, 255, 255, 0.85);
            letter-spacing: 1px;
            min-width: 140px;
        }

        #imagePreview {
            background: rgba(0, 0, 0, 0.3);
            border: 2px solid rgba(255, 255, 255, 0.15);
            border-radius: 12px;
            padding: 16px;
            margin-bottom: 16px;
            min-height: 120px;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
        }

        .preview-placeholder {
            font-size: 12px;
            color: rgba(255, 255, 255, 0.5);
            letter-spacing: 1px;
        }

        .preview-content {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 12px;
        }

        .preview-content img {
            width: auto;
            height: 80px;
            image-rendering: pixelated;
            border-radius: 8px;
            border: 2px solid rgba(255, 255, 255, 0.3);
        }

        .preview-label {
            font-size: 13px;
            color: #ffe14d;
            letter-spacing: 1px;
        }

        #validateImageBtn {
            padding: 14px 50px;
            font-family: 'Press Start 2P', 'Courier New', monospace;
            font-size: clamp(16px, 3.5vw, 22px);
            background: linear-gradient(135deg, #00ff64, #00cc2c);
            border: 3px solid #00ff64;
            border-radius: 10px;
            color: #06110a;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.2s ease;
            box-shadow: 0 8px 20px rgba(0, 255, 100, 0.4);
            text-transform: uppercase;
            letter-spacing: 2px;
            flex-shrink: 0;
        }

        #validateImageBtn:hover:not(:disabled) {
            transform: translateY(-3px);
            box-shadow: 0 12px 28px rgba(0, 255, 100, 0.5);
        }

        #validateImageBtn:active:not(:disabled) {
            transform: translateY(1px);
        }

        #validateImageBtn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
            box-shadow: none;
        }

        #validateImageBtn:focus-visible {
            outline: 3px solid #00ffff;
            outline-offset: 4px;
        }

        @media (max-width: 600px) {
            #imageGalleryScreen {
                /* padding-top and padding-bottom managed by .telegram-safe-screen (BaseScreen) */
            padding-left: 12px;
            padding-right: 12px;
            }

            #imageGalleryContent {
                width: 100%;
                max-width: 100%;
            }

            .gallery-back-btn {
                font-size: 11px;
                padding: 8px 14px;
                margin-bottom: 14px;
            }

            #imageGalleryContent h1 {
                font-size: 20px;
                margin-bottom: 6px;
            }

            .gallery-subtitle {
                font-size: 10px;
                margin-bottom: 12px;
            }

            /* Removed old search bar overrides - now using mobile-first CSS at line 2174 */

            #imageGrid {
                grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
                gap: 8px;
                padding: 12px;
                max-height: 300px;
                margin-bottom: 12px;
            }

            .image-card {
                padding: 6px;
                gap: 4px;
            }

            .image-label {
                font-size: 8px;
            }

            #imageGalleryPagination {
                gap: 12px;
                margin-bottom: 12px;
            }

            #prevPageBtn,
            #nextPageBtn {
                padding: 8px 12px;
                font-size: 12px;
            }

            #pageInfo {
                font-size: 10px;
                min-width: 110px;
            }

            #imagePreview {
                padding: 12px;
                min-height: 100px;
                margin-bottom: 12px;
            }

            .preview-content img {
                height: 60px;
            }

            .preview-label {
                font-size: 11px;
            }

            #validateImageBtn {
                padding: 12px 36px;
                font-size: 14px;
            }
        }

        /* Create Duel Screen Styles */
        #createDuelScreen {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(135deg, rgba(26, 26, 46, 0.6) 0%, rgba(22, 33, 62, 0.6) 100%);
            display: none;
            align-items: center;
            justify-content: center;
            z-index: 995;
            overflow: hidden;
            /* padding-top and padding-bottom managed by .telegram-safe-screen (BaseScreen) */
            padding-left: 10px;
            padding-right: 10px;
        }

        #createDuelContent {
            width: 90%;
            max-width: 900px;
            max-height: 100%;
            display: flex;
            flex-direction: column;
            text-align: center;
            color: white;
            font-family: 'Press Start 2P', 'Courier New', monospace;
            overflow-y: auto;
            padding-right: 8px;
        }

        #createDuelContent h1 {
            font-size: clamp(24px, 5vw, 34px);
            margin-bottom: 8px;
            color: #ffe14d;
            text-shadow: 3px 3px 0 rgba(0,0,0,0.6), 0 0 20px rgba(255, 225, 77, 0.5);
            letter-spacing: 3px;
            flex-shrink: 0;
        }

        .duel-section {
            background: rgba(0, 0, 0, 0.3);
            border: 2px solid rgba(255, 255, 255, 0.15);
            border-radius: 12px;
            padding: 16px;
            margin-bottom: 16px;
            flex-shrink: 0;
        }

        .section-title {
            font-size: clamp(14px, 3vw, 18px);
            color: #00ffff;
            margin-bottom: 12px;
            letter-spacing: 1px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
        }

        .section-title .duel-image-compact {
            flex-direction: row;
            gap: 6px;
            align-items: center;
        }

        .section-title .duel-image-preview img {
            height: 40px;
            width: 40px;
            max-width: 200px;
            max-height: 200px;
            object-fit: contain;
        }

        .section-title .duel-image-number {
            font-size: 10px;
            margin: 0;
        }

        .leaderboard-title-text {
            flex: 1;
            text-align: left;
        }

        .section-title.success {
            color: #00ff64;
        }

        .refresh-leaderboard-btn {
            font-size: 16px;
            padding: 6px 10px;
            background: transparent;
            border: none;
            cursor: pointer;
            transition: all 0.2s ease;
            line-height: 1;
        }

        .refresh-leaderboard-btn:hover {
            transform: rotate(180deg);
        }

        .refresh-leaderboard-btn:active {
            transform: rotate(360deg);
        }

        .current-player-name {
            font-size: clamp(12px, 2.5vw, 14px);
            color: #ffe14d;
            letter-spacing: 0.5px;
            font-weight: bold;
            padding: 6px 10px;
            background: rgba(0, 0, 0, 0.3);
            border-radius: 6px;
            border: 2px solid rgba(255, 225, 77, 0.3);
            flex: 1;
            min-width: 0; /* Allow text truncation if needed */
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .current-player-name.is-creator {
            color: #ff0055;
            border-color: rgba(255, 0, 85, 0.5);
            background: rgba(255, 0, 85, 0.1);
        }

        /* Player Participation Info */
        .player-participation-info {
            margin-top: 8px;
        }

        .participation-result {
            background: rgba(0, 255, 100, 0.1);
            border: 2px solid rgba(0, 255, 100, 0.3);
            border-radius: 8px;
            padding: 10px 12px;
        }

        .participation-subtitle {
            font-size: 10px;
            color: #cccccc;
            margin: 0;
            text-align: center;
            line-height: 1.4;
        }

        /* Creator Notice */
        .creator-notice {
            background: rgba(255, 193, 7, 0.1) !important;
            border-color: rgba(255, 193, 7, 0.3) !important;
        }

        /* Time Badge (compact) */
        .duel-time-badge {
            font-family: 'Press Start 2P', monospace;
            font-size: 11px;
            color: #00ff64;
            background: rgba(0, 255, 100, 0.15);
            border: 2px solid rgba(0, 255, 100, 0.4);
            border-radius: 8px;
            padding: 6px 12px;
            letter-spacing: 1px;
            font-weight: bold;
            text-shadow: 0 0 10px rgba(0, 255, 100, 0.5);
            white-space: nowrap;
            display: inline-flex;
            align-items: center;
            gap: 6px;
        }

        .duel-time-badge::before {
            content: '⏱️';
            font-size: 12px;
        }

        .duel-time-badge.expired {
            color: #ff0055;
            background: rgba(255, 0, 85, 0.15);
            border-color: rgba(255, 0, 85, 0.4);
            text-shadow: 0 0 10px rgba(255, 0, 85, 0.5);
        }

        .duel-time-badge.expired::before {
            content: '⏰';
        }

        /* Leaderboard Table */
        .leaderboard-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 12px;
            color: white;
        }

        .leaderboard-table thead th {
            padding: 10px 8px;
            background: rgba(0, 255, 255, 0.15);
            border: 1px solid rgba(0, 255, 255, 0.3);
            color: #00ffff;
            text-align: center;
            letter-spacing: 1px;
            font-size: 11px;
        }

        .leaderboard-table tbody td {
            padding: 10px 8px;
            border: 1px solid rgba(255, 255, 255, 0.1);
            text-align: center;
            color: rgba(255, 255, 255, 0.95);
            background: rgba(0, 0, 0, 0.2);
        }

        .leaderboard-table tbody tr:hover {
            background: rgba(0, 255, 255, 0.1);
        }

        .leaderboard-table tbody tr.rank-1 td {
            background: rgba(255, 215, 0, 0.15);
            border-color: rgba(255, 215, 0, 0.3);
        }

        .leaderboard-table tbody tr.rank-2 td {
            background: rgba(192, 192, 192, 0.15);
            border-color: rgba(192, 192, 192, 0.3);
        }

        .leaderboard-table tbody tr.rank-3 td {
            background: rgba(205, 127, 50, 0.15);
            border-color: rgba(205, 127, 50, 0.3);
        }

        .leaderboard-table .rank {
            font-size: 16px;
            font-weight: bold;
        }

        .leaderboard-table .player {
            color: #ffe14d;
            font-weight: bold;
            letter-spacing: 0.5px;
        }

        .leaderboard-table .score {
            color: #00ff64;
            font-weight: bold;
        }

        .leaderboard-table .time {
            color: rgba(255, 255, 255, 0.8);
            font-size: 11px;
        }

        .leaderboard-table .stars {
            font-size: 14px;
        }

        /* Leaderboard Pagination */
        .leaderboard-pagination {
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 16px;
            margin-top: 16px;
        }

        .leaderboard-pagination .pagination-btn {
            font-family: 'Press Start 2P', monospace;
            font-size: 10px;
            padding: 8px 14px;
            background: linear-gradient(135deg, rgba(0, 255, 255, 0.2), rgba(0, 200, 255, 0.2));
            border: 2px solid rgba(0, 255, 255, 0.5);
            border-radius: 8px;
            color: #00ffff;
            cursor: pointer;
            transition: all 0.2s ease;
            text-transform: uppercase;
        }

        .leaderboard-pagination .pagination-btn:hover:not(:disabled) {
            background: linear-gradient(135deg, rgba(0, 255, 255, 0.3), rgba(0, 200, 255, 0.3));
            border-color: #00ffff;
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(0, 255, 255, 0.4);
        }

        .leaderboard-pagination .pagination-btn:active:not(:disabled) {
            transform: translateY(0);
        }

        .leaderboard-pagination .pagination-btn:disabled {
            opacity: 0.3;
            cursor: not-allowed;
        }

        .leaderboard-pagination .page-indicator {
            font-family: 'Press Start 2P', monospace;
            font-size: 10px;
            color: rgba(255, 255, 255, 0.8);
            letter-spacing: 0.5px;
        }

        @media (max-width: 600px) {
            .duel-time-badge {
                font-size: 9px;
                padding: 5px 10px;
                justify-content: center;
            }

            .current-player-name {
                font-size: 11px;
                padding: 5px 8px;
            }

            #startDuelBtn {
                font-size: 13px;
                padding: 12px 24px;
                min-height: 48px;
            }

            .leaderboard-table {
                font-size: 10px;
            }

            .leaderboard-table thead th {
                padding: 6px 4px;
                font-size: 9px;
            }

            .leaderboard-table tbody td {
                padding: 6px 4px;
            }

            .leaderboard-table .rank {
                font-size: 14px;
            }

            .leaderboard-table .stars {
                font-size: 12px;
            }

            .leaderboard-pagination {
                gap: 12px;
                margin-top: 12px;
            }

            .leaderboard-pagination .pagination-btn {
                font-size: 8px;
                padding: 6px 10px;
            }

            .leaderboard-pagination .page-indicator {
                font-size: 8px;
            }
        }

        /* Duel Image Compact - Used in section title */
        .duel-image-compact {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 4px;
        }

        /* Hide image preview in Image Gallery screen (redundant with green border) */
        #imagePreview {
            display: none;
        }

        .duel-image-preview {
            background: transparent;
            border: none;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 0;
        }

        .duel-image-preview img {
            height: 60px;
            width: 60px;
            image-rendering: pixelated;
            object-fit: contain;
        }

        .duel-image-number {
            font-size: 12px;
            color: #ffe14d;
            letter-spacing: 1px;
            font-weight: bold;
            text-align: center;
            text-shadow: 0 0 8px rgba(255, 225, 77, 0.5);
        }

        .duration-options {
            display: flex;
            gap: 8px;
            justify-content: space-between;
        }

        .duration-option {
            flex: 1;
            padding: 12px 8px;
            font-family: 'Press Start 2P', 'Courier New', monospace;
            font-size: clamp(10px, 2.5vw, 14px);
            background: rgba(15, 20, 40, 0.8);
            border: 2px solid rgba(255, 255, 255, 0.3);
            border-radius: 8px;
            color: white;
            cursor: pointer;
            transition: all 0.2s ease;
            white-space: nowrap;
        }

        .duration-option:hover {
            background: rgba(30, 40, 70, 0.9);
            border-color: #00ffff;
            transform: translateY(-2px);
        }

        .duration-option.selected {
            background: rgba(0, 255, 255, 0.2);
            border-color: #00ffff;
            color: #00ffff;
            box-shadow: 0 0 12px rgba(0, 255, 255, 0.4);
        }

        /* Max Participants Selection */
        .max-participants-options {
            display: flex;
            gap: 8px;
            justify-content: space-between;
        }

        .max-participants-option {
            flex: 1;
            padding: 12px 8px;
            font-family: 'Press Start 2P', 'Courier New', monospace;
            font-size: clamp(10px, 2.5vw, 14px);
            background: rgba(15, 20, 40, 0.8);
            border: 2px solid rgba(255, 255, 255, 0.3);
            border-radius: 8px;
            color: white;
            cursor: pointer;
            transition: all 0.2s ease;
            white-space: nowrap;
        }

        .max-participants-option:hover {
            background: rgba(30, 40, 70, 0.9);
            border-color: #ff00ff;
            transform: translateY(-2px);
        }

        .max-participants-option.selected {
            background: rgba(255, 0, 255, 0.2);
            border-color: #ff00ff;
            color: #ff00ff;
            box-shadow: 0 0 12px rgba(255, 0, 255, 0.4);
        }

        /* Participants Count Indicator */
        .participants-count {
            font-family: 'Press Start 2P', 'Courier New', monospace;
            font-size: clamp(10px, 2.2vw, 13px);
            color: #00ffcc;
            text-align: center;
            padding: 8px 12px;
            margin: 8px 0;
            background: rgba(0, 255, 204, 0.1);
            border: 2px solid rgba(0, 255, 204, 0.3);
            border-radius: 8px;
            transition: all 0.3s ease;
        }

        .participants-count.warning {
            color: #ff6b00;
            background: rgba(255, 107, 0, 0.15);
            border-color: #ff6b00;
            animation: pulse-warning 2s infinite;
        }

        @keyframes pulse-warning {
            0%, 100% {
                box-shadow: 0 0 0 rgba(255, 107, 0, 0.4);
            }
            50% {
                box-shadow: 0 0 12px rgba(255, 107, 0, 0.6);
            }
        }

        /* Expiry Warning */
        .expiry-warning {
            font-family: 'Press Start 2P', 'Courier New', monospace;
            font-size: clamp(10px, 2.2vw, 13px);
            text-align: center;
            padding: 12px 16px;
            margin: 12px 0;
            border-radius: 8px;
            transition: all 0.3s ease;
            line-height: 1.6;
        }

        .expiry-warning.warning {
            color: #ffaa00;
            background: rgba(255, 170, 0, 0.15);
            border: 2px solid #ffaa00;
            animation: pulse-expiry-warning 2s infinite;
        }

        .expiry-warning.urgent {
            color: #ff4444;
            background: rgba(255, 68, 68, 0.15);
            border: 2px solid #ff4444;
            animation: pulse-expiry-urgent 1.5s infinite;
        }

        @keyframes pulse-expiry-warning {
            0%, 100% {
                box-shadow: 0 0 0 rgba(255, 170, 0, 0.4);
            }
            50% {
                box-shadow: 0 0 16px rgba(255, 170, 0, 0.6);
            }
        }

        @keyframes pulse-expiry-urgent {
            0%, 100% {
                box-shadow: 0 0 0 rgba(255, 68, 68, 0.4);
            }
            50% {
                box-shadow: 0 0 20px rgba(255, 68, 68, 0.7);
            }
        }

        .duel-actions {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 12px;
            margin-bottom: 16px;
        }

        .action-btn {
            padding: 14px 20px;
            font-family: 'Press Start 2P', 'Courier New', monospace;
            font-size: clamp(13px, 2.8vw, 16px);
            font-weight: bold;
            cursor: pointer;
            border-radius: 10px;
            transition: all 0.2s ease;
            text-transform: uppercase;
            letter-spacing: 1px;
            border: 3px solid;
        }

        .test-btn {
            background: linear-gradient(135deg, #0d6bff, #0a47cc);
            border-color: rgba(13, 107, 255, 0.6);
            color: #e0f1ff;
            box-shadow: 0 8px 20px rgba(13, 107, 255, 0.35);
        }

        .test-btn:hover:not(:disabled) {
            transform: translateY(-3px);
            box-shadow: 0 12px 28px rgba(13, 107, 255, 0.45);
        }

        .create-btn {
            background: linear-gradient(135deg, #00ff64, #00cc2c);
            border-color: #00ff64;
            color: #06110a;
            box-shadow: 0 8px 20px rgba(0, 255, 100, 0.4);
        }

        .create-btn:hover:not(:disabled) {
            transform: translateY(-3px);
            box-shadow: 0 12px 28px rgba(0, 255, 100, 0.5);
        }

        /* START CHALLENGE button - centered with bright green like START GAME */
        #startDuelBtn {
            /* Slightly smaller than START GAME to fit better in compact layout */
            font-size: clamp(14px, 3.5vw, 20px);
            padding: 10px 30px;
            background: linear-gradient(135deg, #00ff00, #00cc00); /* Pure green like START GAME */
            border: 3px solid #00ff00;
            color: #000;
            font-family: 'Press Start 2P', 'Courier New', monospace;
            font-weight: bold;
            cursor: pointer;
            border-radius: 8px;
            box-shadow: 0 6px 20px rgba(0, 255, 0, 0.4);
            text-transform: uppercase;
            letter-spacing: 2px;
            transition: all 0.3s;
            margin: 0 auto 8px auto; /* Centered horizontally */
            flex-shrink: 0;
            display: block; /* Required for margin auto to work */
            touch-action: manipulation;
        }

        #startDuelBtn:hover:not(:disabled) {
            transform: scale(1.05);
            box-shadow: 0 8px 30px rgba(0, 255, 0, 0.6);
        }

        #startDuelBtn:active:not(:disabled) {
            transform: scale(0.95);
        }

        #startDuelBtn:focus-visible {
            outline: 3px solid #00ffff;
            outline-offset: 4px;
        }

        #startDuelBtn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
            transform: none;
        }

        .action-btn:active:not(:disabled) {
            transform: translateY(1px);
        }

        .action-btn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
            box-shadow: none;
        }

        /* Share Section Success */
        .share-section-success {
            background: rgba(0, 255, 100, 0.05);
            border-color: rgba(0, 255, 100, 0.3);
        }

        /* Duel Created Inline Layout */
        .duel-created-inline {
            display: flex;
            align-items: stretch;
            justify-content: center;
            gap: 8px;
            margin: 12px 0;
            flex-wrap: wrap;
        }

        .share-url-input-inline {
            flex: 1;
            min-width: 200px;
            padding: 10px 12px;
            font-family: 'Press Start 2P', 'Courier New', monospace;
            font-size: 9px;
            background: rgba(15, 20, 40, 0.8);
            border: 2px solid rgba(255, 255, 255, 0.3);
            border-radius: 6px;
            color: white;
            letter-spacing: 0.3px;
            -webkit-user-select: all;
            -moz-user-select: all;
            user-select: all;
        }

        .share-url-input-inline:focus {
            outline: none;
            border-color: #00ff64;
            box-shadow: 0 0 8px rgba(0, 255, 100, 0.3);
        }

        .btn-copy-inline {
            padding: 8px 12px;
            font-size: 16px;
            background: rgba(255, 225, 77, 0.15);
            border: 2px solid rgba(255, 225, 77, 0.4);
            border-radius: 6px;
            cursor: pointer;
            transition: all 0.2s ease;
            line-height: 1;
        }

        .btn-copy-inline:hover {
            background: rgba(255, 225, 77, 0.25);
            border-color: #ffe14d;
            transform: scale(1.05);
        }

        .btn-copy-inline.copied {
            background: rgba(0, 255, 100, 0.2);
            border-color: #00ff64;
        }

        .btn-play-inline {
            padding: 10px 18px;
            font-family: 'Press Start 2P', 'Courier New', monospace;
            font-size: 11px;
            font-weight: bold;
            background: linear-gradient(135deg, #00ff00, #00cc00);
            border: 2px solid #00ff00;
            border-radius: 6px;
            color: white;
            cursor: pointer;
            transition: all 0.2s ease;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            white-space: nowrap;
        }

        .btn-play-inline:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(0, 255, 0, 0.4);
        }

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

        @media (max-width: 600px) {
            #createDuelScreen {
                /* padding-top and padding-bottom managed by .telegram-safe-screen (BaseScreen) */
            padding-left: 12px;
            padding-right: 12px;
            }

            #createDuelContent {
                width: 100%;
                max-width: 100%;
            }

            #createDuelContent h1 {
                font-size: 20px;
                margin-bottom: 6px;
            }

            .duel-section {
                padding: 12px;
                margin-bottom: 12px;
            }

            .section-title {
                font-size: 10px;
                margin-bottom: 8px;
            }

            /* Force smaller font for CREATE DUEL titles on mobile */
            #createDuelScreen .section-title {
                font-size: 10px !important;
            }

            .section-title .duel-image-preview img {
                height: 30px;
                width: 30px;
            }

            .section-title .duel-image-number {
                font-size: 8px;
            }

            .section-title .duel-image-compact {
                gap: 4px;
            }

            /* DUEL INFO - Optimize leaderboard title section on mobile */
            #duelInfoScreen .section-title {
                gap: 4px;
                font-size: 9px;
            }

            #duelInfoScreen .leaderboard-title-text {
                font-size: 9px;
            }

            #duelInfoScreen .refresh-leaderboard-btn {
                font-size: 14px;
                padding: 8px 10px;
                min-width: 44px;
                min-height: 44px;
                display: inline-flex;
                align-items: center;
                justify-content: center;
            }

            #duelInfoScreen .section-title .duel-image-preview img {
                height: 24px;
                width: 24px;
            }

            .duration-options {
                gap: 6px;
            }

            .duration-option {
                padding: 10px 6px;
                font-size: clamp(9px, 2vw, 11px);
            }

            .max-participants-options {
                gap: 6px;
            }

            .max-participants-option {
                padding: 10px 6px;
                font-size: clamp(9px, 2vw, 11px);
            }

            .duel-actions {
                grid-template-columns: 1fr;
                gap: 10px;
            }

            .action-btn {
                padding: 12px 16px;
                font-size: 12px;
            }

            .share-instructions {
                font-size: 10px;
                margin-bottom: 10px;
            }

            .share-url-container {
                flex-direction: column;
                gap: 8px;
            }

            .share-url-input {
                padding: 10px;
                font-size: 9px;
            }

            .duel-created-inline {
                gap: 6px;
                margin: 10px 0;
                flex-wrap: wrap;
            }

            .share-url-input-inline {
                min-width: 150px;
                padding: 8px 10px;
                font-size: 8px;
            }

            .btn-copy-inline {
                padding: 7px 10px;
                font-size: 14px;
            }

            .btn-play-inline {
                padding: 9px 14px;
                font-size: 10px;
            }
        }

        /* Duel Menu Screen Styles */
        #duelMenuScreen {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(135deg, rgba(26, 26, 46, 0.6) 0%, rgba(22, 33, 62, 0.6) 100%);
            display: none;
            align-items: center;
            justify-content: center;
            z-index: 995;
            overflow: hidden;
            /* padding-top and padding-bottom managed by .telegram-safe-screen (BaseScreen) */
            padding-left: 10px;
            padding-right: 10px;
        }

        #duelMenuContent {
            width: 90%;
            max-width: 900px;
            max-height: 100%;
            display: flex;
            flex-direction: column;
            text-align: center;
            color: white;
            font-family: 'Press Start 2P', 'Courier New', monospace;
            overflow-y: auto;
        }

        #duelMenuContent h1 {
            font-size: clamp(24px, 5vw, 34px);
            margin-bottom: 8px;
            color: #ffe14d;
            text-shadow: 3px 3px 0 rgba(0,0,0,0.6), 0 0 20px rgba(255, 225, 77, 0.5);
            letter-spacing: 3px;
            flex-shrink: 0;
        }

        .duel-menu-options {
            display: flex;
            flex-direction: column;
            gap: 16px;
            margin-top: 8px;
        }

        .duel-menu-item {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 12px;
        }

        .duel-menu-item .section-title {
            margin-bottom: 0;
        }

        .duel-menu-item .duel-menu-desc {
            font-size: 12px;
            color: rgba(255, 255, 255, 0.8);
            letter-spacing: 0.5px;
            margin-bottom: 8px;
        }

        .duel-menu-item .action-btn {
            width: 100%;
            max-width: 300px;
        }

        @media (max-width: 600px) {
            #duelMenuScreen {
                /* padding-top and padding-bottom managed by .telegram-safe-screen (BaseScreen) */
            padding-left: 12px;
            padding-right: 12px;
            }

            #duelMenuContent {
                width: 100%;
                max-width: 100%;
            }

            #duelMenuContent h1 {
                font-size: 20px;
                margin-bottom: 6px;
            }

            .duel-menu-options {
                gap: 12px;
            }

            .duel-menu-item .duel-menu-desc {
                font-size: 10px;
                margin-bottom: 10px;
            }
        }

/* ===================================
   Duel Info Screen
   =================================== */

#duelInfoContent {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    position: relative;
}

/* ===================================
   My Duels Screen
   =================================== */

#myDuelsScreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(15, 20, 40, 0.6) 0%, rgba(26, 32, 64, 0.6) 100%);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 996;
    overflow: hidden;
    padding-left: 10px;
    padding-right: 10px;
    /* padding-top and padding-bottom managed by .telegram-safe-screen (BaseScreen) */
}

#myDuelsContent {
    width: 90%;
    max-width: 900px;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow: hidden;
}

#myDuelsContent h1 {
    font-size: clamp(24px, 5vw, 34px);
    margin-bottom: 8px;
    color: #ffe14d;
    text-shadow: 3px 3px 0 rgba(0,0,0,0.6), 0 0 20px rgba(255, 225, 77, 0.5);
    letter-spacing: 3px;
    flex-shrink: 0;
}

/* Tab Navigation */
.tabs-container {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-shrink: 0;
}

.tab-button {
    flex: 1;
    padding: 12px 20px;
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 11px;
    background: rgba(15, 20, 40, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    position: relative;
}

.tab-button:hover {
    background: rgba(30, 40, 70, 0.7);
    border-color: rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.9);
    transform: translateY(-2px);
}

.tab-button.active {
    background: rgba(30, 40, 70, 0.9);
    border-bottom: 4px solid #00ffff;
    color: #00ffff;
    box-shadow: 0 0 12px rgba(0, 255, 255, 0.3);
}

.tab-button.active:hover {
    transform: translateY(0);
}

.tab-button .count-badge {
    color: rgba(255, 255, 255, 0.5);
    font-size: 10px;
    margin-left: 4px;
}

.tab-button.active .count-badge {
    color: rgba(0, 255, 255, 0.8);
}

/* Tab Content */
.tab-content {
    display: none;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.tab-content.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

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

.duels-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 200px;
    max-width: 100%;
}

/* Utility classes for duel stats */
.rank-total {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
}

.stars-small {
    font-size: 10px;
    margin-left: 4px;
}

/* Pagination Controls */
.duels-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 16px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.pagination-btn {
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 10px;
    padding: 10px 16px;
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.2), rgba(0, 200, 255, 0.2));
    border: 2px solid rgba(0, 255, 255, 0.5);
    border-radius: 8px;
    color: #00ffff;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.pagination-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.3), rgba(0, 200, 255, 0.3));
    border-color: rgba(0, 255, 255, 0.8);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 255, 255, 0.3);
}

.pagination-btn:active:not(:disabled) {
    transform: translateY(0);
}

.pagination-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    border-color: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.2);
}

.page-info {
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 11px;
    color: #ffe14d;
    letter-spacing: 1px;
    min-width: 80px;
    text-align: center;
}

/* Count Badge */
.count-badge {
    font-size: 12px;
    color: rgba(0, 255, 255, 0.8);
    font-weight: normal;
}

@media (max-width: 600px) {
    #myDuelsScreen {
        /* padding-top and padding-bottom managed by .telegram-safe-screen (BaseScreen) */
        padding-left: 0;
        padding-right: 0;
    }

    #myDuelsContent {
        width: 100%;
        max-width: 100%;
        padding: 0 16px; /* Add horizontal padding to prevent cutoff */
    }

    #myDuelsContent h1 {
        font-size: 20px;
        margin-bottom: 6px;
    }

    .tabs-container {
        gap: 6px;
        margin-bottom: 12px;
    }

    .tab-button {
        padding: 10px 6px;
        font-size: 8px;
        letter-spacing: 0px;
        /* Prevent text overflow */
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .tab-button .count-badge {
        font-size: 7px;
        margin-left: 2px;
    }

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

    .page-info {
        font-size: 9px;
        min-width: 60px;
    }

    .duels-pagination {
        gap: 12px;
        padding: 8px;
        margin-top: 12px;
    }

    .count-badge {
        font-size: 10px;
    }
}

/* ===================================
   My Duels Screen - Duel Cards
   =================================== */

.duel-card {
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    transition: all 0.3s ease;
}

.duel-card:hover {
    border-color: rgba(0, 255, 255, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 255, 255, 0.2);
}

.duel-card.expired {
    opacity: 0.6;
    border-color: rgba(255, 255, 255, 0.1);
}

/* Compact Duel Card Layout */
.duel-card-compact {
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
}

.duel-card-compact:hover {
    border-color: rgba(0, 255, 255, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 255, 255, 0.2);
}

.duel-card-compact.expired {
    opacity: 0.6;
    border-color: rgba(255, 255, 255, 0.1);
}

.duel-card-compact .duel-card-image {
    width: 25px;
    height: 25px;
    object-fit: contain;
    image-rendering: pixelated;
    background: transparent;
    border: none;
    padding: 0;
}

.duel-card-header {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
}

.duel-card-image {
    width: 80px;
    height: 80px;
    object-fit: contain;
    image-rendering: pixelated;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 8px;
}

.duel-card-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.view-duel-btn {
    padding: 8px 16px;
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 11px;
    background: rgba(0, 255, 255, 0.2);
    border: 2px solid #00ffff;
    border-radius: 8px;
    color: #00ffff;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
}

.view-duel-btn:hover {
    background: rgba(0, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 0 12px rgba(0, 255, 255, 0.4);
}

.copy-link-btn-small {
    padding: 8px 12px;
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 10px;
    background: rgba(255, 225, 77, 0.1);
    border: 2px solid rgba(255, 225, 77, 0.5);
    border-radius: 8px;
    color: #ffe14d;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
}

.copy-link-btn-small:hover {
    background: rgba(255, 225, 77, 0.2);
    border-color: #ffe14d;
    transform: translateY(-2px);
    box-shadow: 0 0 12px rgba(255, 225, 77, 0.3);
}

.copy-link-btn-small.copied {
    background: rgba(0, 255, 100, 0.2);
    border-color: #00ff64;
    color: #00ff64;
}

.copy-link-btn-small:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    border-color: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.4);
}

.delete-duel-btn {
    padding: 8px 12px;
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 10px;
    background: rgba(255, 0, 85, 0.15);
    border: 2px solid rgba(255, 0, 85, 0.5);
    border-radius: 8px;
    color: #ff0055;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
}

.delete-duel-btn:hover {
    background: rgba(255, 0, 85, 0.25);
    border-color: #ff0055;
    transform: translateY(-2px);
    box-shadow: 0 0 12px rgba(255, 0, 85, 0.4);
}

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

@media (max-width: 480px) {
    .duel-card-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .duel-card-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .duel-card-actions {
        width: 100%;
        justify-content: stretch;
    }

    .view-duel-btn,
    .copy-link-btn-small,
    .delete-duel-btn {
        flex: 1;
        font-size: 8px;
        padding: 6px 8px;
    }
}

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

#leaderboardScreen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    height: 100%;
    padding-left: 20px;
    padding-right: 20px;
    overflow-y: auto;
    /* padding-top and padding-bottom managed by .telegram-safe-screen (BaseScreen) */
}

#leaderboardContent {
    width: 100%;
    max-width: 800px;
    position: relative;
}

.leaderboard-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 24px;
    position: relative;
}

.leaderboard-header h1 {
    margin: 0;
    font-size: clamp(24px, 6vw, 36px);
    color: #00ffff;
    text-shadow: 0 0 12px rgba(0, 255, 255, 0.6);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.refresh-btn {
    background: rgba(0, 255, 255, 0.1);
    border: 2px solid rgba(0, 255, 255, 0.3);
    color: #00ffff;
    font-family: 'Press Start 2P', monospace;
    font-size: 20px;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.3s;
}

.refresh-btn:hover {
    background: rgba(0, 255, 255, 0.2);
    border-color: #00ffff;
    transform: scale(1.05);
}

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

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

/* Tabs */
.leaderboard-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 8px;
    flex-wrap: wrap;
}

.leaderboard-tab {
    background: rgba(15, 20, 40, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.6);
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(10px, 2.5vw, 14px);
    padding: 10px 16px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.3s;
    flex: 1;
    min-width: 100px;
}

.leaderboard-tab:hover {
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(15, 20, 40, 0.8);
}

.leaderboard-tab.active {
    background: linear-gradient(135deg, #00ffff, #00cccc);
    border-color: #00ffff;
    color: #000;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
}

/* Panel */
.leaderboard-panel {
    background: rgba(15, 20, 40, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 20px;
    min-height: 400px;
}

.leaderboard-loading {
    text-align: center;
    padding: 40px;
    color: #00ffff;
    font-size: 16px;
}

/* Leaderboard List */

/* Player Rank Card - Single line format with rank */
.player-rank-card {
    background: rgba(0, 255, 255, 0.05);
    border: none;
    border-radius: 0;
    padding: 10px 0;
    margin-bottom: 16px;
    box-shadow: none;
}

.player-rank-card.rank-1 {
    background: rgba(255, 215, 0, 0.05);
}

.player-rank-card.rank-2 {
    background: rgba(192, 192, 192, 0.05);
}

.player-rank-card.rank-3 {
    background: rgba(205, 127, 50, 0.05);
}

.player-rank-header {
    text-align: left;
    margin-bottom: 6px;
}

.player-rank-label {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(9px, 2vw, 10px);
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.player-rank-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.player-rank-position {
    font-size: 24px;
    min-width: 40px;
    text-align: center;
}

.player-rank-position .rank-number {
    font-family: 'Press Start 2P', monospace;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
}

.player-rank-name {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(12px, 3vw, 14px);
    color: #fff;
    font-weight: bold;
    flex: 1;
}

.player-rank-score {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(14px, 3.5vw, 16px);
    color: #00ffff;
    font-weight: bold;
    text-align: right;
    white-space: nowrap;
}

/* Leaderboard table container */
.leaderboard-table-container {
    width: 100%;
    overflow-x: auto;
}

/* Leaderboard table */
.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
}

/* Table header - compact */
.leaderboard-table thead th {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(9px, 2vw, 10px);
    color: rgba(255, 255, 255, 0.8);
    text-align: left;
    padding: 10px 12px;
    text-transform: uppercase;
    border-bottom: none;
    background: transparent;
    line-height: 1.2;
}

.leaderboard-table thead th.col-rank {
    width: 100px;
    text-align: center;
}

.leaderboard-table thead th.col-score {
    text-align: right;
    width: 150px;
}

/* Table rows - compact styling without borders */
.leaderboard-row {
    border-bottom: none;
    transition: background 0.2s;
}

.leaderboard-row:hover {
    background: rgba(255, 255, 255, 0.08);
}

.leaderboard-row td {
    padding: 6px 12px;
    line-height: 1.2;
}

/* Rank column */
.col-rank {
    text-align: center;
    font-size: 20px;
}

.medal {
    font-size: 22px;
    display: inline-block;
    line-height: 1;
}

.rank-number {
    font-family: 'Press Start 2P', monospace;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1;
}

/* Player column */
.col-player {
    padding-left: 12px;
}

.player-name {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(11px, 2.8vw, 14px);
    color: #fff;
    font-weight: bold;
    margin-bottom: 2px;
    line-height: 1.2;
}

/* Score column */
.col-score {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(12px, 3vw, 15px);
    color: #00ffff;
    font-weight: bold;
    text-align: right;
    line-height: 1.2;
}

/* Empty state */
.leaderboard-empty {
    text-align: center;
    padding: 60px 20px;
    color: rgba(255, 255, 255, 0.6);
}

.leaderboard-empty p:first-child {
    font-size: 48px;
    margin-bottom: 16px;
}

.leaderboard-empty p:nth-child(2) {
    font-family: 'Press Start 2P', monospace;
    font-size: 18px;
    color: #fff;
    margin-bottom: 8px;
}

.empty-hint {
    font-size: 14px;
    font-style: italic;
}

/* Error state */
.leaderboard-error {
    text-align: center;
    padding: 40px 20px;
    color: #ff4444;
}

.leaderboard-error p:first-child {
    font-family: 'Press Start 2P', monospace;
    font-size: 18px;
    margin-bottom: 12px;
}

.error-message {
    font-family: 'Courier New', monospace;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 20px;
}

.leaderboard-error .action-btn {
    margin-top: 16px;
}

/* Mobile responsive */
@media (max-width: 600px) {
    #leaderboardScreen {
        padding-left: 12px;
        padding-right: 12px;
        /* padding-top and padding-bottom managed by .telegram-safe-screen (BaseScreen) */
    }

    .leaderboard-header h1 {
        font-size: 20px;
    }

    .refresh-btn {
        font-size: 16px;
        padding: 6px 10px;
    }

    .leaderboard-tabs {
        gap: 4px;
    }

    .leaderboard-tab {
        font-size: 8px;
        padding: 8px 6px;
        min-width: 0;
        /* Prevent text overflow */
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .leaderboard-panel {
        padding: 12px;
        min-height: 300px;
    }

    /* Player rank card mobile */
    .player-rank-card {
        padding: 12px;
        margin-bottom: 16px;
    }

    .player-rank-label {
        font-size: 9px;
        letter-spacing: 1px;
    }

    .player-rank-content {
        gap: 12px;
    }

    .player-rank-position {
        font-size: 28px;
        min-width: 50px;
    }

    .player-rank-position .rank-number {
        font-size: 16px;
    }

    .player-rank-name {
        font-size: 14px;
    }

    .player-rank-score {
        font-size: 16px;
        min-width: 90px;
    }

    /* Table mobile styles */
    .leaderboard-table thead th {
        font-size: 9px;
        padding: 8px 10px;
    }

    .leaderboard-table thead th.col-rank {
        width: 60px;
    }

    .leaderboard-table thead th.col-score {
        width: 100px;
    }

    .leaderboard-row td {
        padding: 10px 12px;
    }

    .col-rank {
        font-size: 20px;
    }

    .medal {
        font-size: 24px;
    }

    .rank-number {
        font-size: 12px;
    }

    .col-player {
        padding-left: 12px;
    }

    .player-name {
        font-size: 12px;
    }

    .col-score {
        font-size: 14px;
    }
}

/* ============================================================================
 * NOTIFICATION SYSTEM (Issue #56)
 * ============================================================================
 * Toast-style notifications to replace alert() dialogs
 * Non-blocking, auto-dismiss, supports multiple types
 */

/* Container */
.notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 400px;
    pointer-events: none;
}

/* Individual notification */
.notification {
    background: rgba(30, 30, 30, 0.95);
    border-radius: 12px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
    border-left: 4px solid #666;
    padding: 16px;
    min-width: 300px;
    max-width: 400px;
    pointer-events: all;
    transform: translateX(450px);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    opacity: 0;
}

/* Notification states */
.notification-enter {
    transform: translateX(450px);
    opacity: 0;
}

.notification-visible {
    transform: translateX(0);
    opacity: 1;
}

.notification-exit {
    transform: translateX(450px);
    opacity: 0;
}

/* Notification types */
.notification-info {
    border-left-color: #3498db;
}

.notification-success {
    border-left-color: #2ecc71;
}

.notification-warning {
    border-left-color: #f39c12;
}

.notification-error {
    border-left-color: #e74c3c;
}

/* Content */
.notification-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.notification-icon {
    font-size: 24px;
    flex-shrink: 0;
    line-height: 1;
}

.notification-message {
    flex: 1;
    color: #ffffff;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.notification-close {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    transition: color 0.2s ease;
}

.notification-close:hover {
    color: rgba(255, 255, 255, 1);
}

/* Mobile responsiveness */
@media (max-width: 600px) {
    .notification-container {
        left: 10px;
        right: 10px;
        top: 10px;
        max-width: none;
    }

    .notification {
        min-width: 0;
        max-width: none;
    }

    .notification-message {
        font-size: 13px;
    }
}

/* ============================================================================
 * MOBILE TOUCH TARGET ACCESSIBILITY (Issue #59)
 * ============================================================================
 * Ensure all interactive elements have min 44x44px touch targets (WCAG 2.1)
 */

/* Global minimum touch target size for all buttons on mobile */
@media (max-width: 768px) {
    button,
    .btn,
    .tab-button,
    .pagination-btn,
    [role="button"],
    a[class*="btn"],
    input[type="button"],
    input[type="submit"] {
        min-width: 44px;
        min-height: 44px;
        /* Add padding to ensure content is properly spaced */
        padding: 8px 12px;
    }

    /* Delete buttons - ensure adequate size */
    button[aria-label*="delete"],
    button[aria-label*="Delete"] {
        min-width: 44px;
        min-height: 44px;
        padding: 10px;
    }

    /* Close buttons (like in notifications) */
    .notification-close,
    button[aria-label*="Close"],
    button[aria-label*="close"] {
        min-width: 44px;
        min-height: 44px;
        padding: 10px;
    }

    /* Inline buttons (copy, play) */
    .btn-copy-inline,
    .btn-play-inline {
        min-width: 44px;
        min-height: 44px;
        padding: 10px 14px;
    }
}

/* =========================================
   BUTTON TOUCH FEEDBACK (Issue #58)
   ========================================= */

/* General button active states for visual feedback */
button:active:not(:disabled),
.btn:active:not(:disabled),
[role="button"]:active:not(:disabled) {
    transform: scale(0.95);
    opacity: 0.85;
    transition: transform 0.1s ease-out, opacity 0.1s ease-out;
}

/* Primary buttons (Start, Create, etc.) */
#createDuelBtn:active,
#startDuelBtn:active {
    transform: scale(0.97);
    filter: brightness(0.9);
}

/* Navigation buttons (Back, Cancel) */
.gallery-back-btn:active {
    transform: translateX(-2px) scale(0.97);
    opacity: 0.8;
}

/* Tab buttons */
.tab-button:active {
    transform: translateY(2px);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Pagination buttons */
.pagination-btn:active,
#prevLeaderboardPage:active,
#nextLeaderboardPage:active {
    transform: scale(0.92);
    background: rgba(255, 255, 255, 0.05);
}

/* Icon buttons (Copy, Delete, Refresh) */
.copy-link-btn-small:active,
.delete-duel-btn:active,
.refresh-leaderboard-btn:active,
#copyDuelLinkBtn:active,
#refreshLeaderboardBtn:active,
#copyLinkBtn:active {
    transform: scale(0.85) rotate(5deg);
    opacity: 0.7;
}

/* Duration and max participants option buttons */
.duration-option:active,
.max-participants-option:active {
    transform: scale(0.95);
    box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.4);
}

/* View/Play duel buttons */
.view-duel-btn:active,
.btn-play-inline:active {
    transform: scale(0.96);
    box-shadow: 0 2px 8px rgba(0, 255, 100, 0.4);
}

/* Notification close button */
.notification-close:active {
    transform: scale(0.9) rotate(90deg);
    opacity: 0.6;
    transition: transform 0.2s ease-out, opacity 0.1s ease-out;
}

/* Disabled buttons - no feedback */
button:disabled,
.btn:disabled,
[role="button"]:disabled,
button[disabled],
.btn[disabled],
[role="button"][disabled] {
    transform: none !important;
    opacity: 0.5 !important;
    cursor: not-allowed !important;
}

/* Touch-specific enhancements for mobile */
@media (hover: none) and (pointer: coarse) {
    /* Slightly stronger feedback on touch devices */
    button:active:not(:disabled),
    .btn:active:not(:disabled),
    [role="button"]:active:not(:disabled) {
        transform: scale(0.93);
        opacity: 0.8;
    }

    /* Add subtle background pulse on touch */
    button:active:not(:disabled)::before,
    .btn:active:not(:disabled)::before {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 100%;
        height: 100%;
        background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, transparent 70%);
        transform: translate(-50%, -50%);
        pointer-events: none;
        animation: touchPulse 0.3s ease-out;
    }
}

@keyframes touchPulse {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
}

/* ========================================
   MOBILE & RESPONSIVE IMPROVEMENTS
   Issues #74, #75, #76
   ======================================== */

/* Issue #76: Fluid Typography with clamp()
   Scales smoothly across device sizes */
:root {
    /* Base typography scales */
    --font-xs: clamp(10px, 2vw, 12px);
    --font-sm: clamp(12px, 2.5vw, 14px);
    --font-base: clamp(14px, 3vw, 16px);
    --font-md: clamp(16px, 3.5vw, 18px);
    --font-lg: clamp(18px, 4vw, 22px);
    --font-xl: clamp(22px, 5vw, 28px);
    --font-2xl: clamp(28px, 6vw, 36px);
    --font-3xl: clamp(36px, 8vw, 48px);
}

/* Apply fluid typography to key elements */
body {
    font-size: var(--font-base);
}

h1 {
    font-size: var(--font-3xl);
}

.message-title {
    font-size: var(--font-xl);  /* clamp(22px, 5vw, 28px) - prevents overflow on mobile */
}

h2, .section-title {
    font-size: var(--font-2xl);
}

h3 {
    font-size: var(--font-xl);
}

button, .btn {
    font-size: var(--font-md);
}

p, .message-body {
    font-size: var(--font-base);
}

small, .subtitle {
    font-size: var(--font-sm);
}

/* Issue #74: Tablet Breakpoints (Small Tablets - Portrait)
   Optimized for tablets 601-768px */
@media (min-width: 601px) and (max-width: 768px) {
    /* Tablet-specific spacing */
    .screen-container {
        padding: 30px 40px;
    }

    /* Duel cards - 2 columns on small tablets */
    .duels-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }

    /* Buttons spacing */
    .action-btn,
    .btn {
        padding: 14px 24px;
        min-height: 48px;
    }

    /* Leaderboard entries */
    .leaderboard-entry {
        padding: 14px;
        font-size: var(--font-md);
    }

    /* Modal dialogs */
    #centerMessage {
        max-width: 500px;
        padding: 30px;
    }
}

/* Issue #74: Tablet Breakpoints (Large Tablets - Landscape)
   Optimized for tablets 769-1024px */
@media (min-width: 769px) and (max-width: 1024px) {
    /* Buttons */
    .action-btn,
    .btn {
        padding: 16px 28px;
        min-height: 52px;
    }

    /* Modal dialogs */
    #centerMessage {
        max-width: 600px;
        padding: 40px;
    }
}

/* Issue #75: Orientation Handling (Landscape Phones)
   Optimized for phones in landscape mode */
@media (max-width: 900px) and (orientation: landscape) {
    /* Compact header */
    #topBar {
        height: 40px;
        padding: 8px 12px;
    }

    #topBar h1 {
        font-size: var(--font-xl);
    }

    /* Canvas takes available space */
    #gameCanvas {
        flex: 1;
        max-height: calc(100vh - 80px);
    }

    /* Compact modals */
    #centerMessage {
        max-height: 80vh;
        overflow-y: auto;
        padding: 20px;
    }

    /* .message-title already set to --font-xl globally, no override needed */

    /* Compact buttons */
    .action-btn,
    .btn {
        padding: 10px 20px;
        min-height: 44px;
    }

    /* Reduce gap in button groups */
    .button-group {
        gap: 10px;
    }

    /* Leaderboard compact view */
    .leaderboard-entry {
        padding: 10px;
        font-size: var(--font-sm);
    }
}

/* Landscape tablets - optimize horizontal space */
@media (min-width: 601px) and (max-width: 1024px) and (orientation: landscape) {
    /* Wider modals */
    #centerMessage {
        max-width: 700px;
    }

}

/* Portrait mode optimizations */
@media (orientation: portrait) {

    /* Full-width canvas */
    #gameCanvas {
        width: 100%;
        max-width: 100%;
    }

    /* MY DUELS - Optimize table for mobile without horizontal scroll */
    .duels-table {
        min-width: 0;
        font-size: 10px;
    }

    .duels-table th {
        padding: 6px 3px;
        font-size: 8px;
        letter-spacing: 0;
    }

    .duels-table td {
        padding: 6px 3px;
        font-size: 10px;
    }

    .view-duel-btn {
        font-size: 8px !important;
        padding: 3px 4px !important;
    }
}

/* ==========================================================================
   DUEL INFO SCREEN - MOBILE-FIRST RESPONSIVE DESIGN
   ========================================================================== */

/* Participation Result Card - Mobile-Optimized */
.participation-result-card {
    background: linear-gradient(135deg, rgba(0, 255, 127, 0.1), rgba(0, 191, 255, 0.1));
    border: 2px solid var(--accent, #00ff7f);
    border-radius: 12px;
    padding: 20px;
    margin: 20px 0;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 255, 127, 0.2);
}

.participation-result-card.creator-notice {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.1), rgba(255, 140, 0, 0.1));
    border-color: #ffd700;
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.2);
}

.participation-header {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(10px, 2.5vw, 14px);
    color: var(--accent, #00ff7f);
    letter-spacing: 1px;
    margin-bottom: 16px;
    text-transform: uppercase;
}

.participation-result-card.creator-notice .participation-header {
    color: #ffd700;
}

.participation-score {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(32px, 10vw, 48px);
    color: #fff;
    font-weight: bold;
    margin: 12px 0;
    text-shadow: 0 0 10px var(--accent, #00ff7f), 0 0 20px var(--accent, #00ff7f);
}

.participation-rank {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(12px, 3.5vw, 18px);
    color: #fff;
    margin: 8px 0;
}

.participation-meta {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(10px, 2.8vw, 14px);
    color: rgba(255, 255, 255, 0.7);
    margin-top: 12px;
}

.participation-subtitle {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(9px, 2.2vw, 12px);
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.6;
    margin-top: 12px;
}

/* Leaderboard List - 2-Column Mobile Layout */
.leaderboard-list {
    width: 100%;
    margin: 0 auto;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.leaderboard-item:hover,
.leaderboard-item:active {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    transform: scale(1.02);
}

/* Top 3 special styling */
.leaderboard-item.top-rank-1 {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.15), rgba(255, 215, 0, 0.05));
    border-color: #ffd700;
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.3);
}

.leaderboard-item.top-rank-2 {
    background: linear-gradient(135deg, rgba(192, 192, 192, 0.15), rgba(192, 192, 192, 0.05));
    border-color: #c0c0c0;
    box-shadow: 0 2px 8px rgba(192, 192, 192, 0.3);
}

.leaderboard-item.top-rank-3 {
    background: linear-gradient(135deg, rgba(205, 127, 50, 0.15), rgba(205, 127, 50, 0.05));
    border-color: #cd7f32;
    box-shadow: 0 2px 8px rgba(205, 127, 50, 0.3);
}

/* Left Column: Rank + Player */
.leaderboard-item-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0; /* Allow text truncation */
}

.leaderboard-item-rank {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(14px, 4vw, 20px);
    color: #fff;
    flex-shrink: 0;
    min-width: 32px;
    text-align: center;
}

.leaderboard-item-player {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(10px, 2.8vw, 14px);
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Right Column: Score + Meta */
.leaderboard-item-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.leaderboard-item-score {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(16px, 4.5vw, 22px);
    color: var(--accent, #00ff7f);
    font-weight: bold;
}

.leaderboard-item-meta {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(8px, 2vw, 10px);
    color: rgba(255, 255, 255, 0.6);
    white-space: nowrap;
}

/* Desktop Optimization (600px+) */
@media (min-width: 600px) {
    .participation-result-card {
        max-width: 500px;
        margin: 20px auto;
    }

    .leaderboard-list {
        max-width: 600px;
    }

    .leaderboard-item {
        padding: 16px 20px;
    }

    .leaderboard-item-left {
        gap: 16px;
    }

    .leaderboard-item-rank {
        min-width: 40px;
    }
}

/* ==========================================================================
   LEADERBOARD TABLE - RESPONSIVE LAYOUT WITH NAME/SCORE TRUNCATION
   ========================================================================== */

/* Player Rank Card (shown above table) */
.player-rank-card {
    background: linear-gradient(135deg, rgba(0, 255, 127, 0.15), rgba(0, 191, 255, 0.1));
    border: 2px solid var(--accent, #00ff7f);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(0, 255, 127, 0.2);
}

.player-rank-header {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(9px, 2.2vw, 11px);
    color: var(--accent, #00ff7f);
    letter-spacing: 1px;
    margin-bottom: 12px;
    text-transform: uppercase;
    text-align: center;
}

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

.player-rank-position {
    flex-shrink: 0;
    font-size: clamp(24px, 6vw, 32px);
    min-width: 60px;
    text-align: center;
}

.player-rank-name {
    flex: 1;
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(12px, 3.2vw, 16px);
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.player-rank-score {
    flex-shrink: 0;
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(14px, 3.8vw, 20px);
    color: var(--accent, #00ff7f);
    font-weight: bold;
    text-align: right;
    min-width: 80px;
}

/* Top 3 ranks special styling */
.player-rank-card.rank-1 {
    border-color: #ffd700;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.15), rgba(255, 215, 0, 0.05));
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.3);
}

.player-rank-card.rank-1 .player-rank-header {
    color: #ffd700;
}

.player-rank-card.rank-2 {
    border-color: #c0c0c0;
    background: linear-gradient(135deg, rgba(192, 192, 192, 0.15), rgba(192, 192, 192, 0.05));
    box-shadow: 0 4px 12px rgba(192, 192, 192, 0.3);
}

.player-rank-card.rank-2 .player-rank-header {
    color: #c0c0c0;
}

.player-rank-card.rank-3 {
    border-color: #cd7f32;
    background: linear-gradient(135deg, rgba(205, 127, 50, 0.15), rgba(205, 127, 50, 0.05));
    box-shadow: 0 4px 12px rgba(205, 127, 50, 0.3);
}

.player-rank-card.rank-3 .player-rank-header {
    color: #cd7f32;
}

/* Leaderboard Table Container */
.leaderboard-table-container {
    width: 100%;
    overflow-x: auto;
    margin: 0 auto;
    -webkit-overflow-scrolling: touch;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Press Start 2P', monospace;
}

/* Table Header */
.leaderboard-table thead th {
    padding: 12px 8px;
    font-size: clamp(9px, 2.2vw, 12px);
    color: rgba(255, 255, 255, 0.7);
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
}

.leaderboard-table thead .col-rank {
    width: 60px;
    text-align: center;
}

.leaderboard-table thead .col-player {
    flex: 1;
    min-width: 0;
}

.leaderboard-table thead .col-score {
    width: 100px;
    text-align: right;
}

/* Table Rows */
.leaderboard-row {
    transition: all 0.2s ease;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.leaderboard-row:hover,
.leaderboard-row:active {
    background: rgba(255, 255, 255, 0.08);
}

.leaderboard-row td {
    padding: 14px 8px;
    font-size: clamp(10px, 2.8vw, 14px);
    color: #fff;
}

/* Rank Column */
.leaderboard-row .col-rank {
    text-align: center;
    font-weight: bold;
    width: 60px;
}

.leaderboard-row .medal {
    font-size: clamp(18px, 5vw, 24px);
}

.leaderboard-row .rank-number {
    color: rgba(255, 255, 255, 0.6);
}

/* Player Name Column - Truncation with ellipsis */
.leaderboard-row .col-player {
    flex: 1;
    min-width: 0;
}

.leaderboard-row .player-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
    max-width: 100%;
}

/* Score Column - Auto width with abbreviations */
.leaderboard-row .col-score {
    text-align: right;
    font-weight: bold;
    color: var(--accent, #00ff7f);
    width: 100px;
    white-space: nowrap;
}

/* Large score styling (>= 1M) */
.leaderboard-row.large-score .col-score {
    font-size: clamp(9px, 2.5vw, 12px);
}

/* Top 3 ranks special styling */
.leaderboard-row.rank-1 {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.12), rgba(255, 215, 0, 0.03));
    border-color: #ffd700;
}

.leaderboard-row.rank-1 .col-rank {
    color: #ffd700;
}

.leaderboard-row.rank-2 {
    background: linear-gradient(135deg, rgba(192, 192, 192, 0.12), rgba(192, 192, 192, 0.03));
    border-color: #c0c0c0;
}

.leaderboard-row.rank-2 .col-rank {
    color: #c0c0c0;
}

.leaderboard-row.rank-3 {
    background: linear-gradient(135deg, rgba(205, 127, 50, 0.12), rgba(205, 127, 50, 0.03));
    border-color: #cd7f32;
}

.leaderboard-row.rank-3 .col-rank {
    color: #cd7f32;
}

/* Empty Leaderboard State */
.leaderboard-empty {
    text-align: center;
    padding: 40px 20px;
    color: rgba(255, 255, 255, 0.5);
    font-family: 'Press Start 2P', monospace;
}

.leaderboard-empty p {
    margin: 12px 0;
    font-size: clamp(12px, 3.5vw, 18px);
}

.leaderboard-empty .empty-hint {
    font-size: clamp(10px, 2.5vw, 12px);
    color: rgba(255, 255, 255, 0.4);
    line-height: 1.6;
}

/* Mobile Optimization (<600px) */
@media (max-width: 600px) {
    .leaderboard-table thead .col-rank {
        width: 50px;
    }

    .leaderboard-table thead .col-score {
        width: 80px;
    }

    .leaderboard-row td {
        padding: 12px 6px;
    }

    .leaderboard-row .col-rank {
        width: 50px;
    }

    .leaderboard-row .col-score {
        width: 80px;
        font-size: clamp(9px, 2.5vw, 12px);
    }

    .player-rank-score {
        min-width: 70px;
    }
}

/* Desktop Optimization (>= 768px) */
@media (min-width: 768px) {
    .leaderboard-table-container {
        max-width: 700px;
    }

    .leaderboard-table thead .col-rank {
        width: 80px;
    }

    .leaderboard-table thead .col-score {
        width: 130px;
    }

    .leaderboard-row .col-rank {
        width: 80px;
    }

    .leaderboard-row .col-score {
        width: 130px;
    }

    .player-rank-card {
        max-width: 600px;
        margin-left: auto;
        margin-right: auto;
    }
}

/* ==========================================================================
   MY DUELS SCREEN - MOBILE-FIRST CARD LAYOUT
   ========================================================================== */

/* Duels Card List Container */
.duels-card-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    margin: 0 auto;
}

/* Individual Duel Card */
.duel-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 16px;
    transition: all 0.2s ease;
}

.duel-card:hover,
.duel-card:active {
    transform: scale(1.01);
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow: 0 4px 12px rgba(0, 255, 127, 0.15);
}

/* Expired state */
.duel-card.expired {
    opacity: 0.6;
    background: linear-gradient(135deg, rgba(128, 128, 128, 0.08), rgba(128, 128, 128, 0.03));
    border-color: rgba(128, 128, 128, 0.3);
}

/* Top rank styling for joined duels */
.duel-card.top-rank-1 {
    border-color: #ffd700;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.12), rgba(255, 215, 0, 0.05));
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.25);
}

.duel-card.top-rank-2 {
    border-color: #c0c0c0;
    background: linear-gradient(135deg, rgba(192, 192, 192, 0.12), rgba(192, 192, 192, 0.05));
    box-shadow: 0 2px 8px rgba(192, 192, 192, 0.25);
}

.duel-card.top-rank-3 {
    border-color: #cd7f32;
    background: linear-gradient(135deg, rgba(205, 127, 50, 0.12), rgba(205, 127, 50, 0.05));
    box-shadow: 0 2px 8px rgba(205, 127, 50, 0.25);
}

/* Card Header (Image + Stats) */
.duel-card-header {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
}

/* Card Image Section */
.duel-card-image {
    position: relative;
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.duel-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.duel-card-image-id {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(7px, 1.8vw, 9px);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Card Stats Section */
.duel-card-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.duel-card-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.duel-card-stat .stat-label {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(7px, 1.8vw, 9px);
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.duel-card-stat .stat-value {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(10px, 2.8vw, 14px);
    color: #fff;
    font-weight: bold;
}

.duel-card-stat .stat-value.rank-display {
    color: var(--accent, #00ff7f);
}

.rank-total {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.85em;
}

.expired {
    color: #ff6b6b !important;
}

/* Card Actions */
.duel-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.duel-card-btn {
    flex: 1;
    min-width: 0;
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(8px, 2vw, 10px);
    padding: 10px 12px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.duel-card-btn:hover,
.duel-card-btn:active {
    transform: scale(1.05);
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.1);
}

.duel-card-btn.primary {
    background: linear-gradient(135deg, var(--accent, #00ff7f), #00bf7f);
    border-color: var(--accent, #00ff7f);
    color: #000;
    font-weight: bold;
}

.duel-card-btn.primary:hover,
.duel-card-btn.primary:active {
    box-shadow: 0 0 12px rgba(0, 255, 127, 0.4);
}

.duel-card-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
}

/* Desktop Optimization (600px+) */
@media (min-width: 600px) {
    .duels-card-list {
        max-width: 700px;
    }

    .duel-card {
        padding: 20px;
    }

    .duel-card-header {
        gap: 20px;
    }

    .duel-card-image {
        width: 100px;
        height: 100px;
    }

    .duel-card-actions {
        gap: 12px;
    }

    .duel-card-btn {
        padding: 12px 16px;
    }
}

/* REMOVED: Duplicate CSS for #imageGallerySearch - now using consolidated mobile-first CSS at line ~2174 */

/* ========================================
   RESPONSIVE LEADERBOARD MODE SELECTOR
   ======================================== */

/* Mobile: Dropdown (< 768px) */
.leaderboard-selector-mobile {
    display: block;
    width: 100%;
    margin: 20px 0;
}

.leaderboard-mode-select {
    width: 100%;
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(10px, 3vw, 14px);
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.2s ease;
}

.leaderboard-mode-select:hover,
.leaderboard-mode-select:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--accent, #00ff7f);
    outline: none;
}

/* Hide mobile dropdown on desktop */
@media (min-width: 768px) {
    .leaderboard-selector-mobile {
        display: none;
    }
}

/* Desktop: Tabs (>= 768px) */
.leaderboard-tabs-desktop {
    display: none;
}

@media (min-width: 768px) {
    .leaderboard-tabs-desktop {
        display: flex;
        gap: 8px;
        margin: 20px 0;
        flex-wrap: wrap;
        justify-content: center;
    }

    .leaderboard-tab {
        flex: 1;
        min-width: 100px;
        max-width: 150px;
        font-family: 'Press Start 2P', monospace;
        font-size: clamp(8px, 1.5vw, 12px);
        padding: 12px 16px;
        background: rgba(255, 255, 255, 0.05);
        border: 2px solid rgba(255, 255, 255, 0.2);
        border-radius: 8px;
        color: rgba(255, 255, 255, 0.6);
        cursor: pointer;
        text-transform: uppercase;
        transition: all 0.2s ease;
        white-space: nowrap;
    }

    .leaderboard-tab:hover {
        background: rgba(255, 255, 255, 0.1);
        border-color: rgba(255, 255, 255, 0.4);
        color: #fff;
        transform: scale(1.02);
    }

    .leaderboard-tab.active {
        background: linear-gradient(135deg, var(--accent, #00ff7f), #00bf7f);
        border-color: var(--accent, #00ff7f);
        color: #000;
        font-weight: bold;
    }

    .leaderboard-tab:active {
        transform: scale(0.98);
    }
}

/* Accessibility: Visually hidden label */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* ============================================================================
   DUEL COMPLETED SCREEN
   ============================================================================ */

#duelCompletedScreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-message);
    /* Use safe-area aware padding to avoid Telegram header/notches */
    padding: max(
        calc(env(safe-area-inset-top, 0px) + var(--spacing-lg)),
        calc(var(--tg-content-safe-area-inset-top, 0px) + var(--spacing-lg)),
        var(--spacing-lg)
    ) var(--spacing-lg) max(
        calc(env(safe-area-inset-bottom, 0px) + var(--spacing-lg)),
        calc(var(--tg-content-safe-area-inset-bottom, 0px) + var(--spacing-lg)),
        var(--spacing-lg)
    );
    overflow-y: auto;
}

.duel-completed-container {
    background: var(--color-bg-secondary);
    border: 4px solid var(--color-accent-cyan);
    border-radius: var(--radius-lg);
    padding: var(--spacing-2xl);
    max-width: 900px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    animation: slideIn var(--transition-normal) ease-out;
}

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

.duel-completed-title {
    font-size: clamp(16px, 4vw, 20px);
    color: var(--color-accent-cyan);
    text-align: center;
    margin-bottom: var(--spacing-xl);
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}

.duel-completed-rank {
    font-size: clamp(32px, 8vw, 48px);
    text-align: center;
    margin-bottom: var(--spacing-xl);
    font-weight: bold;
    text-shadow: 0 0 15px currentColor;
}

.duel-completed-rank.rank-gold {
    color: #FFD700;
}

.duel-completed-rank.rank-silver {
    color: #C0C0C0;
}

.duel-completed-rank.rank-bronze {
    color: #CD7F32;
}

.duel-completed-stats {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-2xl);
    padding: var(--spacing-lg);
    background: var(--color-bg-primary);
    border-radius: var(--radius-md);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: clamp(12px, 2.8vw, 14px);
}

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

.stat-value {
    color: var(--color-accent-yellow);
    font-weight: bold;
    font-size: clamp(14px, 3.2vw, 16px);
}

.duel-completed-leaderboard-section {
    margin-bottom: var(--spacing-2xl);
}

.leaderboard-subtitle {
    font-size: clamp(14px, 3.5vw, 16px);
    color: var(--color-text-secondary);
    text-align: center;
    margin-bottom: var(--spacing-lg);
}

.duel-completed-leaderboard {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    max-height: 300px;
    overflow-y: auto;
    padding: var(--spacing-md);
    background: var(--color-bg-primary);
    border-radius: var(--radius-md);
}

.leaderboard-entry {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--color-bg-secondary);
    border-radius: var(--radius-sm);
    font-size: clamp(11px, 2.5vw, 13px);
    transition: background var(--transition-fast);
}

.leaderboard-entry.current-player {
    background: rgba(255, 215, 0, 0.15);
    border: 2px solid var(--color-accent-yellow);
}

.entry-rank {
    min-width: 40px;
    color: var(--color-accent-cyan);
    font-weight: bold;
    font-size: clamp(12px, 2.8vw, 14px);
}

.entry-name {
    flex: 1;
    color: var(--color-text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.entry-score {
    min-width: 60px;
    text-align: right;
    color: var(--color-accent-yellow);
    font-weight: bold;
    font-size: clamp(13px, 3vw, 15px);
}

.duel-completed-actions {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.primary-btn,
.secondary-btn,
.tertiary-btn {
    padding: var(--spacing-lg);
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-primary);
    font-size: clamp(12px, 2.8vw, 14px);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-transform: uppercase;
    min-height: 48px;
}

.primary-btn {
    background: var(--color-accent-green);
    color: var(--color-bg-primary);
    box-shadow: var(--shadow-sm);
}

.primary-btn:hover {
    background: var(--color-accent-green-dark);
    transform: scale(1.05);
}

.secondary-btn {
    background: var(--color-accent-blue);
    color: var(--color-text-primary);
    box-shadow: var(--shadow-sm);
}

.secondary-btn:hover {
    background: var(--color-accent-blue-dark);
    transform: scale(1.05);
}

.tertiary-btn {
    background: transparent;
    color: var(--color-text-muted);
    border: 2px solid var(--color-text-muted);
}

.tertiary-btn:hover {
    color: var(--color-text-primary);
    border-color: var(--color-text-primary);
}

.no-results {
    text-align: center;
    color: var(--color-text-muted);
    font-size: clamp(11px, 2.5vw, 12px);
    padding: var(--spacing-xl);
}

/* Mobile responsiveness - Reduced padding and spacing */
@media (max-width: 600px) {
    .duel-completed-container {
        padding: var(--spacing-lg);
        max-width: 100%;
    }

    .leaderboard-entry {
        padding: var(--spacing-sm);
    }

    .primary-btn,
    .secondary-btn,
    .tertiary-btn {
        padding: var(--spacing-md) var(--spacing-lg);
    }
}
/* ============================================
   CREDITS SCREEN (Amiga-style scrolling)
   ============================================ */

#creditsScreen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #000 0%, #001 50%, #000 100%);
    z-index: 1000;
    overflow: hidden;
}

#creditsScrollContainer {
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

#creditsText {
    position: absolute;
    width: 100%;
    text-align: center;
    font-family: 'Press Start 2P', monospace;
    font-size: 16px;
    line-height: 2.5;
    color: #00ffff;
    text-shadow: 0 0 10px #00ffff, 0 0 20px #00ffff;
    padding: 0 20px;
    white-space: pre-line;
    animation: scrollUp 60s linear infinite;
}


#creditsScreen .back-btn {
    position: absolute;
    top: max(
        calc(env(safe-area-inset-top, 0px) + 20px),
        calc(var(--tg-content-safe-area-inset-top, 0px) + 20px),
        20px
    );
    left: 20px;
    z-index: 1001;
    background: rgba(0, 255, 255, 0.1);
    border: 2px solid #00ffff;
    color: #00ffff;
    padding: 10px 20px;
    font-family: 'Press Start 2P', monospace;
    font-size: 12px;
    cursor: pointer;
    text-shadow: 0 0 5px #00ffff;
    transition: all 0.3s ease;
}

#creditsScreen .back-btn:hover {
    background: rgba(0, 255, 255, 0.2);
    box-shadow: 0 0 15px #00ffff;
    transform: scale(1.05);
}

/* Mobile adjustments */
@media (max-width: 768px) {
    #creditsText {
        font-size: 12px;
        line-height: 2.2;
        padding: 0 15px;
    }

    #creditsScreen .back-btn {
        top: max(
            calc(env(safe-area-inset-top, 0px) + 60px),
            calc(var(--tg-content-safe-area-inset-top, 0px) + 60px),
            60px
        );
        font-size: 10px;
        padding: 8px 15px;
    }
}
@keyframes scrollUp {
    0% {
        top: 100%;
        transform: translateY(0);
    }
    100% {
        top: -100%;
        transform: translateY(-100%);
    }
}


/* PLASMA EFFECT - VERY BRIGHT AND VISIBLE */
#creditsScreen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 30%, rgba(255, 0, 255, 0.8), transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(0, 255, 255, 0.8), transparent 40%),
        radial-gradient(circle at 50% 50%, rgba(0, 150, 255, 0.7), transparent 45%),
        radial-gradient(circle at 90% 20%, rgba(255, 100, 200, 0.7), transparent 35%),
        radial-gradient(circle at 10% 80%, rgba(100, 255, 255, 0.6), transparent 40%);
    background-size: 300% 300%, 350% 350%, 280% 280%, 320% 320%, 290% 290%;
    animation: plasmaMove 12s ease-in-out infinite;
    z-index: 1;
    mix-blend-mode: screen;
}

/* Animated grid/tunnel effect */
#creditsScreen::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 49px,
            rgba(0, 255, 255, 0.15) 49px,
            rgba(0, 255, 255, 0.15) 50px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 49px,
            rgba(255, 0, 255, 0.15) 49px,
            rgba(255, 0, 255, 0.15) 50px
        );
    background-size: 50px 50px;
    animation: gridMove 20s linear infinite, gridPulse 3s ease-in-out infinite;
    pointer-events: none;
    z-index: 2;
    perspective: 500px;
}

@keyframes plasmaMove {
    0%, 100% {
        background-position: 0% 0%, 100% 100%, 50% 50%, 80% 20%, 10% 80%;
        filter: hue-rotate(0deg);
    }
    25% {
        background-position: 100% 50%, 0% 50%, 80% 80%, 20% 80%, 90% 10%;
        filter: hue-rotate(90deg);
    }
    50% {
        background-position: 50% 100%, 50% 0%, 20% 20%, 70% 30%, 30% 70%;
        filter: hue-rotate(180deg);
    }
    75% {
        background-position: 0% 50%, 100% 50%, 60% 60%, 30% 70%, 70% 30%;
        filter: hue-rotate(270deg);
    }
}

@keyframes gridMove {
    0% {
        transform: scale(1) translateY(0);
    }
    100% {
        transform: scale(1.5) translateY(50px);
    }
}

@keyframes gridPulse {
    0%, 100% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
}

/* Ensure scroll container is above background effects */
#creditsScrollContainer {
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 3;
}

/* Darker background to make effects pop */
#creditsScreen {
    background: #000510;
}

/* ============================================================================
   SPLASH SCREEN (BornBadBoys Production Logo)
   ============================================================================ */

.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000000;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999; /* Highest priority - above everything */
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
    cursor: pointer;
}

.splash-screen.visible {
    opacity: 1;
}

/* Fade-out synced with brutal zoom glitch - 1s for smooth transition */
.splash-screen.fade-out {
    opacity: 0;
    transition: opacity 1.0s ease-in-out;
}

.splash-content {
    position: relative;
    width: 100%;
    max-width: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-2xl);
}

.splash-logo {
    width: 100%;
    max-width: 600px;
    display: block;
}

.splash-logo-img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
    /* Subtle animation with glitch effect */
    animation: splash-logo-appear 0.8s cubic-bezier(0.34, 1.56, 0.64, 1),
               splash-logo-glitch 4s ease-in-out 1s infinite;
}

@keyframes splash-logo-appear {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    60% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Strong glitch/distortion effect - MUCH MORE VISIBLE! */
@keyframes splash-logo-glitch {
    0%, 70%, 100% {
        transform: scale(1) skewX(0deg) translateX(0);
        filter: hue-rotate(0deg) blur(0px) brightness(1);
    }

    /* GLITCH MOMENT 1 - MAJOR DISTORTION */
    74% {
        transform: scale(1.05) skewX(3deg) translateX(8px);
        filter: hue-rotate(20deg) blur(1px) brightness(1.1);
    }

    75% {
        transform: scale(0.95) skewX(-4deg) translateX(-10px);
        filter: hue-rotate(-25deg) blur(1.5px) brightness(0.9);
    }

    76% {
        transform: scale(1.03) skewX(2deg) translateX(5px);
        filter: hue-rotate(15deg) blur(0.8px) brightness(1.05);
    }

    77% {
        transform: scale(0.98) skewX(-2deg) translateX(-6px);
        filter: hue-rotate(-15deg) blur(0.6px) brightness(0.95);
    }

    78% {
        transform: scale(1) skewX(0deg) translateX(0);
        filter: hue-rotate(0deg) blur(0px) brightness(1);
    }

    /* GLITCH MOMENT 2 - BRUTAL FINAL DESTRUCTION WITH ZOOM OUT */
    84% {
        transform: scale(1.15) skewX(-5deg) translateY(12px) translateX(-8px);
        filter: hue-rotate(-30deg) blur(2px) brightness(1.15);
    }

    85% {
        transform: scale(1.35) skewX(6deg) translateY(-15px) translateX(10px);
        filter: hue-rotate(35deg) blur(2.5px) brightness(0.85);
    }

    86% {
        transform: scale(1.6) skewX(-4deg) translateY(10px) translateX(-12px) rotate(-2deg);
        filter: hue-rotate(-40deg) blur(2.2px) brightness(1.12);
    }

    87% {
        transform: scale(1.9) skewX(5deg) translateY(-12px) translateX(14px) rotate(2deg);
        filter: hue-rotate(38deg) blur(2.8px) brightness(0.88);
    }

    88% {
        transform: scale(2.2) skewX(-3deg) translateY(8px) translateX(-6px) rotate(-1deg);
        filter: hue-rotate(-25deg) blur(1.8px) brightness(1.1);
    }

    89% {
        transform: scale(2.5) skewX(4deg) translateY(-10px) translateX(8px) rotate(1deg);
        filter: hue-rotate(30deg) blur(2px) brightness(0.9);
    }

    90% {
        transform: scale(2.8) skewX(-2deg) translateY(6px) translateX(-5px);
        filter: hue-rotate(-20deg) blur(1.5px) brightness(1.08);
    }

    91% {
        transform: scale(3.1) skewX(3deg) translateY(-8px) translateX(6px);
        filter: hue-rotate(25deg) blur(1.8px) brightness(0.92);
    }

    92% {
        transform: scale(3.4) skewX(-1deg) translateY(4px) translateX(-3px);
        filter: hue-rotate(-15deg) blur(1.2px) brightness(1.05);
    }

    93% {
        transform: scale(3.7) skewX(2deg) translateY(-5px) translateX(4px);
        filter: hue-rotate(18deg) blur(1.4px) brightness(0.95);
    }

    94% {
        transform: scale(4.0) skewX(-0.5deg) translateY(2px) translateX(-2px);
        filter: hue-rotate(-10deg) blur(0.8px) brightness(1.02);
    }

    95% {
        transform: scale(4.3) skewX(1deg) translateY(-3px) translateX(2px);
        filter: hue-rotate(12deg) blur(1px) brightness(0.98);
    }

    96%, 100% {
        transform: scale(4.5) skewX(0deg) translateX(0) translateY(0) rotate(0deg);
        filter: hue-rotate(0deg) blur(0px) brightness(1);
    }
}

.splash-hint {
    margin-top: var(--spacing-2xl);
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 2px;
    text-align: center;
    opacity: 0;
    animation: splash-hint-fade-in 0.5s ease-in 1.5s forwards;
}

@keyframes splash-hint-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 0.4;
        transform: translateY(0);
    }
}

/* Mobile adjustments */
@media (max-width: 767px) {
    .splash-content {
        max-width: 95%;
    }

    .splash-logo {
        max-width: 320px; /* Match mobile logo width */
    }

    .splash-hint {
        font-size: 8px;
        margin-top: var(--spacing-lg);
    }
}

/* Desktop adjustments */
@media (min-width: 768px) {
    .splash-logo {
        max-width: 700px;
    }

    .splash-hint {
        font-size: 12px;
    }
}

/* Extra large screens */
@media (min-width: 1200px) {
    .splash-logo {
        max-width: 800px;
    }
}

/* ============================================================================
   SKIN SELECT SCREEN
   ============================================================================ */

/* ========================================
   SKIN SELECT SCREEN - Pixelated Retro Style
   ======================================== */

#skinSelectBackBtn {
    align-self: flex-start;
    margin-bottom: 16px;
    padding: 12px 24px;
    font-size: 14px;
    font-family: 'Press Start 2P', 'Courier New', monospace;
    background: linear-gradient(135deg, rgba(20, 30, 50, 0.85), rgba(15, 20, 40, 0.9));
    border: 2px solid rgba(0, 255, 255, 0.4);
    border-radius: 12px;
    color: #00ffff;
    letter-spacing: 2px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), inset 0 0 20px rgba(0, 255, 255, 0.05);
}

#skinSelectBackBtn:hover {
    transform: translateY(-3px) scale(1.02);
    background: linear-gradient(135deg, rgba(25, 35, 60, 0.9), rgba(20, 25, 50, 0.95));
    border-color: rgba(0, 255, 255, 0.7);
    box-shadow: 0 8px 20px rgba(0, 255, 255, 0.25), inset 0 0 25px rgba(0, 255, 255, 0.1);
    color: #00ffff;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.6);
}

#skinSelectBackBtn:active {
    transform: translateY(0px) scale(0.98);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), inset 0 0 15px rgba(0, 255, 255, 0.08);
}

#skinSelectBackBtn:focus-visible {
    outline: 3px solid #00ffff;
    outline-offset: 4px;
}

.skin-select-content {
    width: 92%;
    max-width: 600px;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 0 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 8px 16px 8px;
}

.skin-select-title {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(24px, 5vw, 32px);
    color: #ffe14d;
    text-align: center;
    margin: 12px 0 0 0;
    text-shadow: 3px 3px 0 rgba(0,0,0,0.6), 0 0 20px rgba(255, 225, 77, 0.5);
    letter-spacing: 2px;
    flex-shrink: 0;
}

.skin-select-subtitle {
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    margin: -8px 0 0 0;
    letter-spacing: 1px;
    flex-shrink: 0;
}

/* Skin Stats */
.skin-stats {
    display: flex;
    gap: 24px;
    justify-content: center;
    padding: 12px;
    background: rgba(15, 20, 40, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.18);
    border-radius: 10px;
    flex-shrink: 0;
}

.skin-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.skin-stat-value {
    font-family: 'Press Start 2P', monospace;
    font-size: 20px;
    color: #ffe14d;
    text-shadow: 0 0 10px rgba(255, 225, 77, 0.6);
}

.skin-stat-label {
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Skins Grid */
.skins-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
    padding: 8px 0;
    flex-shrink: 1;
    min-height: 0;
    overflow-y: auto;
}

/* Skin Card - Pixelated Game Style */
.skin-card {
    background: rgba(15, 20, 40, 0.6);
    border: 3px solid rgba(255, 255, 255, 0.18);
    border-radius: 12px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: all 0.3s;
    cursor: pointer;
    position: relative;
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.2);
}

.skin-card.unlocked:hover {
    background: rgba(30, 40, 70, 0.8);
    border-color: rgba(0, 255, 120, 0.6);
    transform: translateY(-4px);
    box-shadow: 0 10px 22px rgba(0, 255, 120, 0.25);
}

.skin-card.selected {
    border-color: rgba(0, 255, 255, 0.8);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.4);
    background: rgba(0, 255, 255, 0.05);
}

.skin-card.equipped {
    border-color: rgba(255, 215, 0, 0.7);
    background: rgba(255, 215, 0, 0.08);
}

.skin-card.locked {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(10, 10, 20, 0.6);
    border-color: rgba(120, 120, 150, 0.3);
}

.skin-card.locked:hover {
    transform: none;
    background: rgba(10, 10, 20, 0.6);
    border-color: rgba(120, 120, 150, 0.3);
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.2);
}

/* Rarity Colors - Enhanced for visibility */
.skin-card.rarity-common.unlocked {
    border-color: rgba(150, 150, 150, 0.35);
}

.skin-card.rarity-rare.unlocked {
    border-color: rgba(0, 150, 255, 0.4);
}

.skin-card.rarity-epic.unlocked {
    border-color: rgba(163, 53, 238, 0.4);
}

.skin-card.rarity-legendary.unlocked {
    border-color: rgba(255, 215, 0, 0.45);
}

.skin-card.rarity-rare.unlocked:hover {
    border-color: rgba(0, 150, 255, 0.8);
    box-shadow: 0 10px 22px rgba(0, 150, 255, 0.35);
}

.skin-card.rarity-epic.unlocked:hover {
    border-color: rgba(163, 53, 238, 0.8);
    box-shadow: 0 10px 22px rgba(163, 53, 238, 0.35);
}

.skin-card.rarity-legendary.unlocked:hover {
    border-color: rgba(255, 215, 0, 0.8);
    box-shadow: 0 10px 22px rgba(255, 215, 0, 0.4);
}

/* Skin Card Image */
.skin-card-image {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.skin-sprite {
    width: 80%;
    height: 80%;
    object-fit: contain;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

.skin-icon-large {
    font-size: 64px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
}

/* Equipped Badge */
.equipped-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #4ecdc4;
    color: #000;
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Locked Overlay */
.locked-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.lock-icon {
    font-size: 48px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
}

/* Skin Card Info */
.skin-card-info {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.skin-card-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

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

.skin-name {
    font-family: 'Press Start 2P', monospace;
    font-size: 12px;
    color: var(--color-text-primary);
    margin: 0;
    flex: 1;
}

.skin-rarity {
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    text-transform: uppercase;
    margin: 0;
}

.skin-rarity.rarity-common { color: #999; }
.skin-rarity.rarity-rare { color: #0096ff; }
.skin-rarity.rarity-epic { color: #a335ee; }
.skin-rarity.rarity-legendary { color: #ffd700; }

/* Unlock Info */
.skin-unlock-info {
    margin-top: 4px;
    padding: 6px 8px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 6px;
    text-align: center;
}

.skin-price {
    font-family: 'Press Start 2P', monospace;
    font-size: 11px;
    color: #ffd700;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.6);
}

.skin-unlock-text {
    font-family: 'Press Start 2P', monospace;
    font-size: 7px;
    color: rgba(255, 255, 255, 0.6);
    letter-spacing: 0.5px;
}

/* Select Button (in card) - Subtle indicator */
.skin-select-btn {
    width: 100%;
    padding: 6px;
    background: rgba(0, 0, 0, 0.3);
    color: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    font-family: 'Press Start 2P', monospace;
    font-size: 7px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: none;
}

.skin-select-btn:hover {
    background: rgba(0, 255, 255, 0.15);
    color: #00ffff;
    border-color: rgba(0, 255, 255, 0.5);
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.2);
}

.skin-select-btn:active {
    background: rgba(0, 255, 255, 0.25);
    transform: scale(0.98);
}

/* Skin Actions */
.skin-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 0;
    margin-top: 8px;
    flex-shrink: 0;
}

.skin-action-btn {
    padding: 14px 24px;
    font-family: 'Press Start 2P', monospace;
    font-size: 11px;
    border-radius: 10px;
    border: 3px solid;
    cursor: pointer;
    transition: all 0.3s;
    min-width: 180px;
    letter-spacing: 1px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.skin-action-btn.primary {
    background: linear-gradient(135deg, rgba(0, 255, 120, 0.9) 0%, rgba(0, 200, 100, 0.9) 100%);
    border-color: rgba(0, 255, 120, 0.8);
    color: #000;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.skin-action-btn.primary:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(0, 255, 120, 1) 0%, rgba(0, 220, 110, 1) 100%);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 255, 120, 0.5);
    border-color: rgba(0, 255, 120, 1);
}

.skin-action-btn.primary:active:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 255, 120, 0.4);
}

.skin-action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: rgba(60, 60, 80, 0.6);
    border-color: rgba(120, 120, 150, 0.4);
    color: rgba(255, 255, 255, 0.4);
}

/* Success Message */
.skin-success-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background: linear-gradient(135deg, rgba(0, 255, 120, 0.95) 0%, rgba(0, 200, 100, 0.95) 100%);
    color: #000;
    padding: 20px 32px;
    border-radius: 12px;
    border: 3px solid rgba(0, 255, 120, 1);
    font-family: 'Press Start 2P', monospace;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 40px rgba(0, 255, 120, 0.4);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 10000;
}

.skin-success-message.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.success-icon {
    font-size: 32px;
}

.success-text {
    font-weight: bold;
}

/* Debug Actions */
.debug-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 12px;
    flex-shrink: 0;
    padding-bottom: 8px;
}

.debug-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    padding: 8px 12px;
    background: rgba(60, 60, 80, 0.6);
    border: 2px solid rgba(120, 120, 150, 0.4);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: all 0.3s;
    letter-spacing: 0.5px;
}

.debug-btn:hover {
    background: rgba(80, 80, 100, 0.8);
    border-color: rgba(150, 150, 180, 0.6);
    transform: translateY(-2px);
    color: rgba(255, 255, 255, 0.9);
}

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

/* Mobile Adjustments */
@media (max-width: 767px) {
    #skinSelectBackBtn {
        font-size: 11px;
        padding: 10px 18px;
        margin-bottom: 12px;
    }

    .skin-select-content {
        width: 95%;
        padding: 0 4px 12px 4px;
    }

    .skin-select-title {
        font-size: 20px;
        margin: 8px 0 0 0;
    }

    .skin-select-subtitle {
        font-size: 8px;
    }

    .skin-stats {
        gap: 16px;
        padding: 10px;
    }

    .skin-stat-value {
        font-size: 16px;
    }

    .skins-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 10px;
    }

    .skin-card {
        padding: 10px;
        gap: 8px;
    }

    .skin-name {
        font-size: 9px;
    }

    .skin-rarity {
        font-size: 7px;
    }

    .skin-select-btn {
        font-size: 6px;
        padding: 5px;
    }

    .skin-action-btn {
        font-size: 9px;
        padding: 12px 18px;
        min-width: 140px;
    }

    .debug-btn {
        font-size: 7px;
        padding: 6px 10px;
    }
}
