﻿
        #faraone-memory-game {
            --f-red: #e30613;
            --f-red-dark: #b8040e;
            --f-red-soft: #ffe8ea;
            --bg: #0f1115;
            --surface: #1a1d24;
            --surface-card: #222630;
            --text: #ffffff;
            --text-muted: #8e95a5;
            --border: rgba(255, 255, 255, 0.08);
            --radius: 14px;

            --img-width: 100%;
            --img-pos-x: center;
            --img-shift-x: 0%;
            --img-shift-y: 0%;
            --img-scale: 1;
            --cover-img-display: block;
        }

        #faraone-memory-game, #faraone-memory-game * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
            user-select: none;
            -webkit-tap-highlight-color: transparent;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
        }

        #faraone-memory-game {
            /* background-color: var(--bg); */
            color: var(--text);
            min-height: 100dvh;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 6px 8px;
            overflow-x: hidden;
            position: relative;
            transition: padding 0.3s ease;
        }

        /* Płótno efektów cząsteczkowych */
        #faraone-memory-game #fxCanvas {
            position: fixed;
            inset: 0;
            width: 100vw;
            height: 100vh;
            pointer-events: none;
            z-index: 90;
        }

        /* --- KONTENER GŁÓWNY --- */
        #faraone-memory-game .main-container {
            background-color: var(--bg);
            width: 100%;
            max-width: 680px;
            display: flex;
            flex-direction: column;
            gap: 8px;
            margin: auto;
            padding: 20px;
            position: relative;
            transition: max-width 0.3s ease;
        }

        #faraone-memory-game:not(.tv-mode) .main-container {
            gap: 6px;
        }

        #faraone-memory-game:not(.tv-mode) .menu-sidebar {
            width: 100%;
            margin-bottom: 0;
        }

        #faraone-memory-game:not(.tv-mode) .board-wrapper {
            margin-top: 0;
        }

        /* --- LEWE MENU / PANEL STEROWANIA --- */
        #faraone-memory-game .menu-sidebar {
            display: flex;
            flex-direction: column;
            gap: 4px;
            width: 100%;
        }

        #faraone-memory-game .menu-header-top {
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            padding: 10px 14px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 10px;
            flex-wrap: wrap;
        }

        #faraone-memory-game .brand {
            display: flex;
            align-items: center;
        }

        #faraone-memory-game .brand-logo-img {
            height: 24px;
            max-width: 170px;
            object-fit: contain;
            display: block;
        }

        #faraone-memory-game .header-actions {
            display: flex;
            gap: 6px;
            flex-wrap: wrap;
        }

        /* --- STATYSTYKI --- */
        #faraone-memory-game .stats-bar {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 8px;
        }

        #faraone-memory-game .stat-card {
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            padding: 8px 10px;
            text-align: center;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
        }

        #faraone-memory-game .stat-card.bump {
            transform: scale(1.08);
        }

        #faraone-memory-game .stat-label {
            font-size: 0.65rem;
            font-weight: 700;
            text-transform: uppercase;
            color: var(--text-muted);
            letter-spacing: 0.5px;
        }

        #faraone-memory-game .stat-val {
            font-size: 1.15rem;
            font-weight: 800;
            font-variant-numeric: tabular-nums;
            margin-top: 2px;
            color: #fff;
        }

        /* --- PANEL OPCJI --- */
        #faraone-memory-game .action-bar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 8px;
        }

        #faraone-memory-game .action-bar-label {
            font-size: 1rem;
            font-weight: 700;
            color: var(--text-muted);
        }

        #faraone-memory-game .grid-toggle {
            display: flex;
            background: var(--surface);
            border: 1px solid var(--border);
            padding: 3px;
            border-radius: 10px;
        }

        #faraone-memory-game .grid-btn {
            border: none;
            background: transparent;
            color: var(--text-muted);
            font-weight: 700;
            font-size: 1rem;
            padding: 10px;
            border-radius: 7px;
            cursor: pointer;
            transition: 0.2s;
        }

        #faraone-memory-game .grid-label-portrait {
            display: none;
        }

        #faraone-memory-game .grid-btn.active {
            background: var(--f-red);
            color: #fff;
        }

        #faraone-memory-game .btn-action {
            background: var(--surface);
            border: 1px solid var(--border);
            color: var(--text);
            padding: 7px 11px;
            border-radius: 10px;
            font-size: 0.75rem;
            font-weight: 700;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
            cursor: pointer;
            transition: 0.2s cubic-bezier(0.2, 0.8, 0.4, 1.2);
        }

        #faraone-memory-game .btn-action:hover {
            background: var(--surface-card);
            border-color: var(--f-red);
            transform: translateY(-1px);
        }

        #faraone-memory-game .btn-action:active {
            transform: scale(0.95);
        }

        #faraone-memory-game .btn-action.active {
            background: var(--f-red);
            color: #fff;
            border-color: var(--f-red);
        }

        /* --- PLANSZA GRY --- */
        #faraone-memory-game .board-wrapper {
            width: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        #faraone-memory-game .board-container {
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            padding: 8px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
            width: 100%;
            height: auto;
            min-height: 0;
            position: relative;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        #faraone-memory-game .grid {
            display: grid;
            width: 100%;
            margin: auto;
        }

        #faraone-memory-game .grid.size-8x6 {
            grid-template-columns: repeat(8, minmax(0, 1fr));
            gap: 4px;
        }

        #faraone-memory-game .grid.size-6x6 {
            grid-template-columns: repeat(6, minmax(0, 1fr));
            gap: 5px;
        }

        #faraone-memory-game .grid.size-4x4 {
            grid-template-columns: repeat(4, minmax(0, 1fr));
            gap: 6px;
        }

        /* --- KARTY (ZAWSZE KWADRATOWE 1:1) --- */
        #faraone-memory-game .card {
            width: 100%;
            min-width: 0;
            aspect-ratio: 1 / 1 !important;
            cursor: pointer;
            display: block;
            position: relative;
            z-index: 1;
        }

        #faraone-memory-game .card:not(.flipped):not(.matched):hover {
            z-index: 15;
        }

        #faraone-memory-game .card-inner {
            position: relative;
            width: 100%;
            height: 100%;
            border-radius: 10px;
            transition: transform 0.2s cubic-bezier(0.2, 0.85, 0.4, 1.25), box-shadow 0.2s ease, filter 0.2s ease;
        }

        #faraone-memory-game .grid.size-8x6 .card-inner {
            border-radius: 7px;
        }

        /* Efekt Hover */
        #faraone-memory-game .card:not(.flipped):not(.matched):hover .card-inner {
            transform: translateY(-4px) scale(1.05);
            box-shadow: 0 8px 20px rgba(227, 6, 19, 0.45), 0 0 0 2px rgba(255, 255, 255, 0.4);
            filter: brightness(1.12);
        }

        /* Efekt Click */
        #faraone-memory-game .card:not(.flipped):not(.matched):active .card-inner {
            transform: translateY(0) scale(0.93);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
            transition-duration: 0.08s;
        }

        /* Odkrycie płaskie */
        #faraone-memory-game .card.flipped .card-inner {
            animation: cardPop 0.28s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
        }

        @keyframes cardPop {
            0% {
                transform: scale(0.92);
            }

            50% {
                transform: scale(1.08);
            }

            100% {
                transform: scale(1);
            }
        }

        /* Trafienie pary */
        #faraone-memory-game .card.matched .card-inner {
            box-shadow: 0 0 0 3px #ffd700, 0 0 22px rgba(255, 215, 0, 0.85);
            animation: candyMatchPulse 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
        }

        @keyframes candyMatchPulse {
            0% {
                transform: scale(1);
                filter: brightness(1);
            }

            40% {
                transform: scale(1.15);
                filter: brightness(1.25) drop-shadow(0 0 12px #ffd700);
            }

            75% {
                transform: scale(0.97);
            }

            100% {
                transform: scale(1);
                filter: brightness(1);
            }
        }

        /* Błąd */
        #faraone-memory-game .card.mismatch .card-inner {
            animation: flatShake 0.4s ease-in-out;
        }

        @keyframes flatShake {

            0%,
            100% {
                transform: translateX(0);
            }

            20% {
                transform: translateX(-6px);
            }

            40% {
                transform: translateX(6px);
            }

            60% {
                transform: translateX(-4px);
            }

            80% {
                transform: translateX(4px);
            }
        }

        /* ŚCIANKI KARTY */
        #faraone-memory-game .card-face {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            border-radius: 10px;
            overflow: hidden;
            transition: opacity 0.18s ease, transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
        }

        #faraone-memory-game .grid.size-8x6 .card-face {
            border-radius: 7px;
        }

        /* AWERS */
        #faraone-memory-game .card-back {
            background: var(--f-red);
            box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 2;
            opacity: 1;
            pointer-events: auto;
            transform: scale(1);
        }

        #faraone-memory-game .card-back-img {
            display: var(--cover-img-display);
            position: absolute;
            top: 0;
            left: 0;
            width: var(--img-width);
            height: 100%;
            object-fit: contain;
            object-position: var(--img-pos-x) center;
            transform: translate(var(--img-shift-x), var(--img-shift-y)) scale(var(--img-scale));
            transform-origin: left center;
            pointer-events: none;
        }

        #faraone-memory-game .card-back-svg {
            width: 60%;
            height: 60%;
            fill: #ffffff;
            filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
            display: block;
            margin: auto;
        }

        /* REWERS */
        #faraone-memory-game .card-front {
            background: #ffffff;
            border: 1px solid rgba(255, 255, 255, 0.2);
            z-index: 1;
            opacity: 0;
            pointer-events: none;
            transform: scale(0.94);
        }

        #faraone-memory-game .card-front img {
            position: absolute;
            top: 0;
            left: 0;
            width: var(--img-width);
            height: 100%;
            object-fit: contain;
            object-position: var(--img-pos-x) center;
            transform: translate(var(--img-shift-x), var(--img-shift-y)) scale(var(--img-scale));
            transform-origin: left center;
            display: block;
            pointer-events: none;
        }

        #faraone-memory-game .card.flipped .card-back,
        #faraone-memory-game .card.matched .card-back {
            opacity: 0;
            pointer-events: none;
            transform: scale(0.95);
        }

        #faraone-memory-game .card.flipped .card-front,
        #faraone-memory-game .card.matched .card-front {
            opacity: 1;
            pointer-events: auto;
            transform: scale(1);
            z-index: 3;
        }

        /* --- BOCZNY PASEK NA ZDJĘCIE REKLAMOWE / TRYB TV --- */
        #faraone-memory-game .ad-sidebar {
            display: none;
            flex-direction: column;
            width: auto;
            max-width: min(40vw, 520px);
            flex-shrink: 0;
            color: inherit;
            text-decoration: none;
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            padding: 8px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
            overflow: hidden;
            height: 100%;
        }

        #faraone-memory-game .ad-banner-slot {
            width: auto;
            height: 100%;
            flex: 1;
            min-height: 100%;
            min-width: 0;
            background: var(--surface-card);
            border: 2px dashed rgba(255, 255, 255, 0.15);
            border-radius: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
            overflow: hidden;
            cursor: pointer;
            transition: border-color 0.2s, background 0.2s;
        }

        #faraone-memory-game .ad-banner-slot:hover {
            border-color: var(--f-red);
            background: rgba(227, 6, 19, 0.05);
        }

        #faraone-memory-game .ad-banner-slot.has-image {
            border: none;
            background: transparent;
        }

        #faraone-memory-game .ad-banner-slot img {
            width: auto;
            max-width: 100%;
            height: 100%;
            object-fit: contain;
            display: block;
        }

        #faraone-memory-game .ad-slot-inner {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 10px;
            color: var(--text-muted);
            font-size: 0.75rem;
            font-weight: 700;
            text-align: center;
            padding: 16px;
            pointer-events: none;
        }

        #faraone-memory-game .board-ad {
            display: none;
            width: 100%;
            justify-content: center;
            overflow: hidden;
            color: inherit;
            text-decoration: none;
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            padding: 8px;
        }

        #faraone-memory-game .ad-banner-slot img,
        #faraone-memory-game .board-ad img {
            display: block;
            max-width: 100%;
            object-fit: contain;
            border-radius: 12px;
        }

        @media (min-width: 1101px) {
            #faraone-memory-game:not(.tv-mode) .board-ad-horizontal {
                display: flex;
            }

            #faraone-memory-game:not(.tv-mode) .board-ad-horizontal img {
                width: 100%;
                height: min(30dvh, 200px);
            }
        }

        /* ==========================================================================
           --- STYLIZACJA TRYBU TV: PEŁNY UKŁAD WERTYKALNY PO LEWEJ STRONIE ---
           ========================================================================== */
        #faraone-memory-game.tv-mode {
            padding: 10px 16px;
            height: 100dvh;
            min-height: 100dvh;
            overflow: hidden;
            justify-content: center;
        }

        #faraone-memory-game.tv-mode .main-container {
            max-width: 100%;
            width: 100%;
            height: calc(100dvh - 20px);
            display: flex;
            flex-direction: row;
            align-items: stretch;
            justify-content: center;
            gap: 14px;
        }

        /* LEWA STRONA: PIONOWE ROZMIESZCZENIE ELEMENTÓW */
        #faraone-memory-game.tv-mode .menu-sidebar {
            width: 300px;
            min-width: 280px;
            max-width: 320px;
            flex-shrink: 0;
            height: 100%;
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            padding: 16px 14px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
            display: flex;
            flex-direction: column;
            justify-content: flex-start;
            gap: 12px;
            overflow-y: auto;
        }

        #faraone-memory-game.tv-mode .menu-header-top {
            background: transparent;
            border: none;
            padding: 0;
            display: flex;
            flex-direction: column;
            align-items: stretch;
            gap: 12px;
        }

        #faraone-memory-game.tv-mode .brand {
            justify-content: center;
            padding-bottom: 4px;
        }

        #faraone-memory-game.tv-mode .brand-logo-img {
            height: 28px;
            max-width: 190px;
        }

        /* Przyciski ułożone wertykalnie */
        #faraone-memory-game.tv-mode .header-actions {
            display: flex;
            flex-direction: column;
            gap: 6px;
            width: 100%;
        }

        #faraone-memory-game.tv-mode .btn-action {
            width: 100%;
            padding: 9px 12px;
            font-size: 0.8rem;
            justify-content: center;
        }

        /* Statystyki wertykalnie */
        #faraone-memory-game.tv-mode .stats-bar {
            display: flex;
            flex-direction: column;
            gap: 6px;
            width: 100%;
        }

        #faraone-memory-game.tv-mode .stat-card {
            flex-direction: row;
            justify-content: space-between;
            align-items: center;
            padding: 9px 14px;
            background: var(--surface-card);
        }

        #faraone-memory-game.tv-mode .stat-label {
            font-size: 0.75rem;
            letter-spacing: 1px;
        }

        #faraone-memory-game.tv-mode .stat-val {
            font-size: 1.15rem;
            margin-top: 0;
        }

        /* Rozmiar pola wertykalnie */
        #faraone-memory-game.tv-mode .action-bar {
            flex-direction: column;
            align-items: stretch;
            gap: 6px;
            margin-top: auto;
        }

        #faraone-memory-game.tv-mode .grid-toggle {
            width: 100%;
            display: flex;
            flex-direction: column;
            gap: 4px;
            background: var(--surface-card);
            padding: 4px;
        }

        #faraone-memory-game.tv-mode .grid-btn {
            width: 100%;
            text-align: center;
            padding: 10px;
            font-size: 1rem;
        }

        /* ŚRODEK: PLANSZA I IDEALNIE KWADRATOWE KARTY */
        #faraone-memory-game.tv-mode .board-wrapper {
            flex: 1;
            height: 100%;
            min-height: 0;
            min-width: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            overflow: hidden;
        }

        #faraone-memory-game.tv-mode .board-container {
            width: 100%;
            height: 100%;
            min-height: 0;
            padding: 8px;
            overflow: hidden;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        #faraone-memory-game.tv-mode .grid {
            height: 100%;
            width: auto;
            max-width: 100%;
            max-height: 100%;
            margin: auto;
            display: grid;
            align-content: center;
            justify-content: center;
        }

        #faraone-memory-game.tv-mode .grid.size-8x6 {
            aspect-ratio: 8 / 6;
            grid-template-columns: repeat(8, minmax(0, 1fr));
            grid-template-rows: repeat(6, minmax(0, 1fr));
            gap: 5px;
        }

        #faraone-memory-game.tv-mode .grid.size-6x6 {
            aspect-ratio: 6 / 6;
            grid-template-columns: repeat(6, minmax(0, 1fr));
            grid-template-rows: repeat(6, minmax(0, 1fr));
            gap: 6px;
        }

        #faraone-memory-game.tv-mode .grid.size-4x4 {
            aspect-ratio: 4 / 4;
            grid-template-columns: repeat(4, minmax(0, 1fr));
            grid-template-rows: repeat(4, minmax(0, 1fr));
            gap: 8px;
        }

        /* PRAWA STRONA: ZDJĘCIE REKLAMOWE */
        #faraone-memory-game.tv-mode .ad-sidebar {
            display: flex;
            width: auto;
            max-width: min(36vw, 680px);
            min-width: 0;
            height: 100%;
            min-height: 0;
        }

        #faraone-memory-game.tv-mode .ad-banner-slot {
            width: auto;
            min-height: 100%;
            height: 100%;
            min-width: 0;
        }

        #faraone-memory-game.tv-mode .ad-banner-slot img {
            width: auto;
            max-width: 100%;
            height: 100%;
            object-fit: contain;
            display: block;
        }

        @media (max-width: 1100px) {
            #faraone-memory-game.tv-mode {
                height: auto;
                min-height: 100dvh;
                overflow-x: hidden;
                overflow-y: auto;
                align-items: stretch;
                padding: 6px 8px;
            }

            #faraone-memory-game.tv-mode .main-container {
                width: 100%;
                max-width: 680px;
                height: auto;
                min-height: 0;
                flex-direction: column;
                align-items: stretch;
                gap: 8px;
                margin: 0 auto;
            }

            #faraone-memory-game.tv-mode .menu-sidebar {
                width: 100%;
                min-width: 0;
                max-width: none;
                height: auto;
                padding: 10px;
                gap: 8px;
                overflow: visible;
            }

            #faraone-memory-game.tv-mode .menu-header-top {
                flex-direction: row;
                align-items: center;
                flex-wrap: wrap;
                gap: 8px;
            }

            #faraone-memory-game.tv-mode .brand {
                justify-content: flex-start;
                padding-bottom: 0;
            }

            #faraone-memory-game.tv-mode .header-actions {
                flex-direction: row;
                flex: 1 1 100%;
                justify-content: center;
                flex-wrap: wrap;
            }

            #faraone-memory-game.tv-mode .btn-action {
                width: auto;
                flex: 1 1 auto;
            }

            #faraone-memory-game.tv-mode .stats-bar {
                display: grid;
                grid-template-columns: repeat(3, minmax(0, 1fr));
                flex-direction: row;
            }

            #faraone-memory-game.tv-mode .stat-card {
                flex-direction: column;
                padding: 6px 4px;
            }

            #faraone-memory-game.tv-mode .action-bar {
                flex-direction: row;
                align-items: center;
                margin-top: 0;
            }

            #faraone-memory-game.tv-mode .grid-toggle {
                flex-direction: row;
                flex-wrap: wrap;
            }

            #faraone-memory-game.tv-mode .grid-btn {
                width: auto;
                flex: 1 1 auto;
            }

            #faraone-memory-game.tv-mode .board-wrapper {
                flex: 0 0 auto;
                width: 100%;
                height: auto;
                min-height: 0;
                overflow: visible;
            }

            #faraone-memory-game.tv-mode .board-container {
                width: 100%;
                height: auto;
            }

            #faraone-memory-game.tv-mode .grid {
                width: 100%;
                height: auto;
                max-height: none;
            }

            #faraone-memory-game.tv-mode .ad-sidebar {
                width: 100%;
                max-width: none;
                height: auto;
                padding: 6px;
            }

            #faraone-memory-game.tv-mode .ad-banner-slot {
                width: 100%;
                height: auto;
                min-height: 0;
                flex: 0 0 auto;
            }

            #faraone-memory-game.tv-mode .ad-banner-slot img {
                width: auto;
                height: auto;
                max-width: 100%;
                max-height: min(32dvh, 280px);
                object-fit: contain;
            }
        }

        @media (max-width: 701px) {
            #faraone-memory-game #btnTvMode {
                display: none;
            }

            #faraone-memory-game .board-ad-square {
                display: flex;
            }

            #faraone-memory-game .board-ad-square img {
                width: 100%;
                height: auto;
            }

            #faraone-memory-game.tv-mode .ad-sidebar {
                display: none;
            }
        }

        @media (max-width: 701px) and (orientation: portrait) {
            #faraone-memory-game:not(.tv-mode) .grid.size-8x6 {
                aspect-ratio: 6 / 8;
                grid-template-columns: repeat(6, minmax(0, 1fr));
                grid-template-rows: repeat(8, minmax(0, 1fr));
            }

            #faraone-memory-game:not(.tv-mode) .grid-label-default {
                display: none;
            }

            #faraone-memory-game:not(.tv-mode) .grid-label-portrait {
                display: inline;
            }
        }

        @media (min-width: 702px) and (max-width: 1100px) {
            #faraone-memory-game:not(.tv-mode) .board-ad-horizontal {
                display: flex;
            }

            #faraone-memory-game:not(.tv-mode) .board-ad-horizontal img {
                width: 100%;
                height: min(30dvh, 240px);
            }

            #faraone-memory-game.tv-mode .ad-sidebar {
                display: none;
            }

            #faraone-memory-game.tv-mode .board-ad-horizontal {
                display: flex;
            }

            #faraone-memory-game.tv-mode .board-ad-horizontal img {
                width: 100%;
                height: min(28dvh, 220px);
            }
        }

        @media (min-width: 702px) and (max-width: 1100px) {
            #faraone-memory-game:not(.tv-mode) {
                height: 100dvh;
                min-height: 100dvh;
                overflow-y: auto;
                align-items: stretch;
                justify-content: flex-start;
                padding: 4px;
            }

            #faraone-memory-game:not(.tv-mode) .main-container {
                width: 100%;
                max-width: none;
                height: 100%;
                min-height: 0;
                gap: 4px;
                margin: 0;
            }

            #faraone-memory-game:not(.tv-mode) .menu-sidebar {
                flex: 0 0 auto;
            }

            #faraone-memory-game:not(.tv-mode) .board-wrapper {
                flex: 1 1 0;
                height: auto;
                min-height: 0;
                overflow: hidden;
            }

            #faraone-memory-game:not(.tv-mode) .board-container {
                height: 100%;
            }

            #faraone-memory-game:not(.tv-mode) .grid {
                width: auto;
                height: 100%;
                max-width: 100%;
                max-height: 100%;
                align-content: center;
                justify-content: center;
            }

            #faraone-memory-game:not(.tv-mode) .grid.size-8x6 {
                aspect-ratio: 8 / 6;
                grid-template-columns: repeat(8, minmax(0, 1fr));
                grid-template-rows: repeat(6, minmax(0, 1fr));
            }

            #faraone-memory-game:not(.tv-mode) .grid.size-6x6 {
                aspect-ratio: 6 / 6;
                grid-template-columns: repeat(6, minmax(0, 1fr));
                grid-template-rows: repeat(6, minmax(0, 1fr));
            }

            #faraone-memory-game:not(.tv-mode) .grid.size-4x4 {
                aspect-ratio: 4 / 4;
                grid-template-columns: repeat(4, minmax(0, 1fr));
                grid-template-rows: repeat(4, minmax(0, 1fr));
            }

            #faraone-memory-game:not(.tv-mode) .board-ad-horizontal {
                flex: 0 0 auto;
            }

            #faraone-memory-game:not(.tv-mode) .board-ad-horizontal img {
                height: min(14dvh, 110px);
            }
        }

        @media (min-width: 702px) and (max-width: 1100px) {
            #faraone-memory-game.tv-mode {
                height: 100dvh;
                min-height: 0;
                overflow: hidden;
                padding: 8px;
            }

            #faraone-memory-game.tv-mode .main-container {
                display: grid;
                grid-template-columns: minmax(176px, 20%) minmax(0, 1fr) minmax(125px, 20%);
                grid-template-rows: minmax(0, 1fr);
                width: 100%;
                max-width: none;
                height: calc(100dvh - 16px);
                min-height: 0;
                gap: clamp(6px, 1vw, 12px);
                margin: auto;
            }

            #faraone-memory-game.tv-mode .menu-sidebar {
                width: auto;
                min-width: 0;
                max-width: none;
                height: 100%;
                min-height: 0;
                padding: 10px 8px;
                overflow-x: hidden;
                overflow-y: auto;
            }

            #faraone-memory-game.tv-mode .menu-header-top {
                flex-direction: column;
                align-items: stretch;
                flex-wrap: nowrap;
            }

            #faraone-memory-game.tv-mode .brand {
                justify-content: center;
            }

            #faraone-memory-game.tv-mode .header-actions {
                flex-direction: column;
                flex: 0 0 auto;
                flex-wrap: nowrap;
            }

            #faraone-memory-game.tv-mode .btn-action {
                width: 100%;
                flex: 0 0 auto;
            }

            #faraone-memory-game.tv-mode .stats-bar {
                display: flex;
                flex-direction: column;
            }

            #faraone-memory-game.tv-mode .stat-card {
                flex-direction: row;
                padding: 7px 9px;
            }

            #faraone-memory-game.tv-mode .action-bar {
                flex-direction: column;
                align-items: stretch;
                margin-top: auto;
            }

            #faraone-memory-game.tv-mode .grid-toggle {
                flex-direction: column;
                flex-wrap: nowrap;
            }

            #faraone-memory-game.tv-mode .grid-btn {
                width: 100%;
                flex: 0 0 auto;
            }

            #faraone-memory-game.tv-mode .board-wrapper {
                width: auto;
                height: 100%;
                min-height: 0;
                min-width: 0;
                flex: initial;
                overflow: hidden;
            }

            #faraone-memory-game.tv-mode .board-container {
                width: 100%;
                height: 100%;
            }

            #faraone-memory-game.tv-mode .grid {
                width: auto;
                height: 100%;
                max-width: 100%;
                max-height: 100%;
            }

            #faraone-memory-game.tv-mode .ad-sidebar {
                display: flex;
                width: auto;
                max-width: none;
                height: 100%;
                min-height: 0;
                padding: 6px;
            }

            #faraone-memory-game.tv-mode .ad-banner-slot {
                width: 100%;
                height: 100%;
                min-height: 0;
                flex: 1 1 auto;
            }

            #faraone-memory-game.tv-mode .ad-banner-slot img {
                width: 100%;
                height: 100%;
                max-width: 100%;
                max-height: 100%;
                object-fit: contain;
            }

            #faraone-memory-game.tv-mode .board-ad-square,
            #faraone-memory-game.tv-mode .board-ad-horizontal {
                display: none;
            }
        }

        @media (min-width: 702px) and (max-width: 1100px) and (orientation: portrait) {
            #faraone-memory-game:not(.tv-mode) .board-ad-horizontal img {
                width: 100%;
                height: auto;
                max-height: min(30dvh, 260px);
            }
        }

        /* --- LATAJĄCE NAPISY POCHWAŁY --- */
        #faraone-memory-game .candy-popup {
            position: fixed;
            pointer-events: none;
            z-index: 100;
            font-weight: 900;
            text-transform: uppercase;
            letter-spacing: 1.5px;
            font-size: 2.1rem;
            color: #ffcc00;
            -webkit-text-stroke: 3px #ffffff;
            paint-order: stroke fill;
            text-shadow:
                0 4px 15px rgba(0, 0, 0, 0.95),
                0 0 25px rgba(255, 215, 0, 0.8);
            filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.8));
            transform: translate(-50%, -50%) scale(0.4);
            animation: candyPopText 0.9s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
        }

        @keyframes candyPopText {
            0% {
                opacity: 0;
                transform: translate(-50%, -20%) scale(0.4);
            }

            25% {
                opacity: 1;
                transform: translate(-50%, -60%) scale(1.25);
            }

            70% {
                opacity: 1;
                transform: translate(-50%, -85%) scale(1.05);
            }

            100% {
                opacity: 0;
                transform: translate(-50%, -120%) scale(0.9);
            }
        }

        /* --- MODAL WYGRANEJ I RANKINGU --- */
        #faraone-memory-game .modal-overlay {
            position: fixed;
            inset: 0;
            background: rgba(10, 11, 14, 0.88);
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 20px;
            opacity: 0;
            pointer-events: none;
            visibility: hidden;
            transition: opacity 0.3s ease, visibility 0.3s ease;
            z-index: 999999;
        }

        #faraone-memory-game .modal-overlay.active {
            opacity: 1 !important;
            pointer-events: auto !important;
            visibility: visible !important;
        }

        #faraone-memory-game .modal-content {
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 20px;
            padding: 24px 20px;
            width: 100%;
            max-width: 400px;
            text-align: center;
            box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
            transform: translateY(20px) scale(0.95);
            transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            max-height: 90vh;
            overflow-y: auto;
        }

        #faraone-memory-game .modal-overlay.active .modal-content {
            transform: translateY(0) scale(1) !important;
        }

        /* Ikona pucharu w oknie wygranej */
        #faraone-memory-game .modal-trophy-img {
            height: 60px;
            width: auto;
            max-width: 85px;
            object-fit: contain;
            margin-bottom: 8px;
            display: block;
            animation: trophyBounce 1.5s infinite ease-in-out;
            filter: drop-shadow(0 4px 12px rgba(227, 6, 19, 0.4));
        }

        /* Ikona pucharu w oknie TOP 10 */
        #faraone-memory-game .leaderboard-trophy-img {
            height: 48px;
            width: auto;
            max-width: 70px;
            object-fit: contain;
            margin-bottom: 8px;
            display: block;
            filter: drop-shadow(0 4px 10px rgba(227, 6, 19, 0.35));
        }

        @keyframes trophyBounce {

            0%,
            100% {
                transform: translateY(0) scale(1);
            }

            50% {
                transform: translateY(-10px) scale(1.1);
            }
        }

        #faraone-memory-game .modal-title {
            font-size: 1.4rem;
            font-weight: 800;
            margin-bottom: 4px;
            color: #fff;
        }

        #faraone-memory-game .modal-subtitle {
            color: var(--text-muted);
            font-size: 0.85rem;
            margin-bottom: 16px;
        }

        #faraone-memory-game .btn-main {
            width: 100%;
            background: var(--f-red);
            color: #fff;
            border: none;
            padding: 12px;
            border-radius: 12px;
            font-size: 0.95rem;
            font-weight: 800;
            cursor: pointer;
            transition: 0.2s cubic-bezier(0.2, 0.8, 0.4, 1.2);
        }

        #faraone-memory-game .btn-main:hover {
            background: var(--f-red-dark);
            transform: translateY(-2px);
        }

        #faraone-memory-game .btn-main:active {
            transform: scale(0.97);
        }

        #faraone-memory-game .btn-secondary {
            width: 100%;
            background: var(--surface-card);
            border: 1px solid var(--border);
            color: var(--text);
            padding: 11px;
            border-radius: 12px;
            font-size: 0.85rem;
            font-weight: 700;
            cursor: pointer;
            transition: 0.2s;
            margin-top: 8px;
        }

        #faraone-memory-game .btn-secondary:hover {
            border-color: var(--f-red);
            background: rgba(227, 6, 19, 0.1);
        }

        /* --- STYLE FORMULARZA ZAPISU WYNIKU --- */
        #faraone-memory-game .save-score-card {
            width: 100%;
            background: var(--surface-card);
            border: 1px solid var(--border);
            border-radius: 12px;
            padding: 12px;
            margin-bottom: 14px;
            display: flex;
            flex-direction: column;
            gap: 8px;
            text-align: left;
        }

        #faraone-memory-game .save-score-card label {
            font-size: 0.7rem;
            font-weight: 800;
            text-transform: uppercase;
            color: var(--text-muted);
            letter-spacing: 0.5px;
        }

        #faraone-memory-game .score-input {
            width: 100%;
            background: #0f1115;
            border: 1px solid var(--border);
            border-radius: 8px;
            padding: 9px 12px;
            color: #fff;
            font-size: 0.85rem;
            font-weight: 600;
            outline: none;
            transition: border-color 0.2s;
        }

        #faraone-memory-game .score-input:focus {
            border-color: var(--f-red);
        }

        #faraone-memory-game .score-input::placeholder {
            color: #646b7a;
            font-size: 0.8rem;
        }

        #faraone-memory-game .btn-save-score {
            width: 100%;
            background: #2563eb;
            color: #fff;
            border: none;
            padding: 10px;
            border-radius: 8px;
            font-weight: 800;
            font-size: 0.85rem;
            cursor: pointer;
            transition: 0.2s;
        }

        #faraone-memory-game .btn-save-score:hover {
            background: #1d4ed8;
        }

        #faraone-memory-game .btn-save-score:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        #faraone-memory-game .save-msg {
            font-size: 0.78rem;
            text-align: center;
            font-weight: 700;
            display: none;
        }

        #faraone-memory-game .save-msg.success {
            display: block;
            color: #4ade80;
        }

        #faraone-memory-game .save-msg.error {
            display: block;
            color: #f87171;
        }

        /* --- STYLIZACJA TABELI TOP 10 --- */
        #faraone-memory-game .leaderboard-table-wrapper {
            width: 100%;
            max-height: 520px;
            overflow-y: auto;
            border: 1px solid var(--border);
            border-radius: 10px;
            margin-bottom: 14px;
            background: var(--surface-card);
        }

        #faraone-memory-game .leaderboard-tabs {
            display: grid;
            grid-template-columns: repeat(3, minmax(0, 1fr));
            gap: 6px;
            width: 100%;
            margin: 0 0 10px;
        }

        #faraone-memory-game .leaderboard-tab {
            min-width: 0;
            padding: 9px 6px;
            border: 1px solid var(--border);
            border-radius: 8px;
            background: var(--surface);
            color: var(--text-muted);
            font-size: 0.8rem;
            font-weight: 800;
            cursor: pointer;
            transition: 0.2s;
        }

        #faraone-memory-game .leaderboard-tab:hover {
            border-color: var(--f-red);
            color: var(--text);
        }

        #faraone-memory-game .leaderboard-tab.active {
            border-color: var(--f-red);
            background: var(--f-red);
            color: #fff;
        }

        #faraone-memory-game .leaderboard-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 0.75rem;
            text-align: left;
        }

        #faraone-memory-game .leaderboard-table th {
            background: rgba(0, 0, 0, 0.35);
            padding: 10px 14px;
            font-weight: 800;
            color: var(--text-muted);
            text-transform: uppercase;
            position: sticky;
            top: 0;
            border-bottom: 1px solid var(--border);
        }

        #faraone-memory-game .leaderboard-table td {
            padding: 10px 14px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.04);
            font-weight: 600;
        }

        #faraone-memory-game .leaderboard-table th:first-child,
        #faraone-memory-game .leaderboard-table td:first-child {
            width: 52px;
            padding-left: 16px;
            padding-right: 12px;
        }

        #faraone-memory-game .leaderboard-table th:last-child,
        #faraone-memory-game .leaderboard-table td:last-child {
            padding-right: 16px;
        }

        #faraone-memory-game .leaderboard-table tr:last-child td {
            border-bottom: none;
        }

        #faraone-memory-game .leaderboard-table tr:hover {
            background: rgba(255, 255, 255, 0.02);
        }

        #faraone-memory-game .rank-badge {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            font-weight: 800;
            font-size: 0.7rem;
            background: rgba(255, 255, 255, 0.08);
        }

        #faraone-memory-game .rank-1 .rank-badge {
            background: #ffd700;
            color: #000;
        }

        #faraone-memory-game .rank-2 .rank-badge {
            background: #c0c0c0;
            color: #000;
        }

        #faraone-memory-game .rank-3 .rank-badge {
            background: #cd7f32;
            color: #fff;
        }

        #faraone-memory-game .lb-company {
            font-size: 0.68rem;
            color: var(--text-muted);
            display: block;
        }

        @media (max-width: 380px) {
            #faraone-memory-game .grid.size-6x6 {
                gap: 3px;
            }

            #faraone-memory-game .grid.size-8x6 {
                gap: 2px;
            }

            #faraone-memory-game .brand-logo-img {
                height: 19px;
                max-width: 130px;
            }

            #faraone-memory-game .candy-popup {
                font-size: 1.5rem;
                -webkit-text-stroke: 2px #ffffff;
            }
        }

        #faraone-memory-game .main-container:fullscreen {
            display: grid;
            grid-template-columns: minmax(200px, 22%) minmax(0, 1fr) minmax(120px, 22%);
            grid-template-rows: minmax(0, 1fr);
            align-items: stretch;
            justify-content: stretch;
            width: 100vw;
            max-width: none;
            height: 100vh;
            height: 100dvh;
            min-height: 0;
            margin: 0;
            padding: 10px;
            gap: 10px;
            overflow: hidden;
            background-color: var(--bg);
        }

        #faraone-memory-game .main-container:fullscreen .menu-sidebar {
            width: auto;
            min-width: 0;
            max-width: none;
            height: 100%;
            min-height: 0;
            overflow-y: auto;
        }

        #faraone-memory-game .main-container:fullscreen .board-wrapper {
            width: auto;
            height: 100%;
            min-width: 0;
            min-height: 0;
            overflow: hidden;
        }

        #faraone-memory-game .main-container:fullscreen .board-container {
            width: 100%;
            height: 100%;
            min-height: 0;
            overflow: hidden;
        }

        #faraone-memory-game .main-container:fullscreen .grid {
            width: auto;
            height: 100%;
            max-width: 100%;
            max-height: 100%;
        }

        #faraone-memory-game .main-container:fullscreen .ad-sidebar {
            display: flex;
            width: auto;
            max-width: none;
            min-width: 0;
            height: 100%;
            min-height: 0;
        }

        @media (max-width: 1100px) {
            #faraone-memory-game .main-container:fullscreen {
                grid-template-columns: minmax(0, 1fr);
                grid-template-rows: auto minmax(0, 1fr);
                padding: 6px;
                gap: 6px;
            }

            #faraone-memory-game .main-container:fullscreen .menu-sidebar {
                width: 100%;
                height: auto;
                padding: 8px;
                overflow: visible;
            }

            #faraone-memory-game .main-container:fullscreen .board-wrapper {
                flex: 1 1 0;
                width: 100%;
                height: auto;
                min-height: 0;
            }

            #faraone-memory-game .main-container:fullscreen .board-container {
                height: 100%;
            }

            #faraone-memory-game .main-container:fullscreen .grid {
                width: auto;
                height: 100%;
                max-width: 100%;
                max-height: 100%;
            }

            #faraone-memory-game .main-container:fullscreen .board-ad-square,
            #faraone-memory-game .main-container:fullscreen .board-ad-horizontal,
            #faraone-memory-game .main-container:fullscreen .ad-sidebar {
                display: none;
            }
        }

        @media (max-width: 701px) {
            #faraone-memory-game #btnFullscreen {
                display: flex;
            }
        }
    
