:root {
            --bg:        #fff9f0;
            --primary:   #ff6b35;
            --secondary: #ffce4e;
            --p1:        #4ecdc4;
            --p2:        #ff6b9d;
            --cpu:       #a78bfa;
            --card-bg:   #ffffff;
            --card-back: #5b5ea6;
            --text:      #2d2d2d;
            --shadow:    0 4px 14px rgba(0,0,0,0.15);
            --radius:    14px;
        }

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

        html, body {
            width: 100%;
            height: 100%;
            overflow: hidden;
            font-family: 'Baloo 2', cursive;
            color: var(--text);
            background:
                    radial-gradient(circle at 15% 12%, rgba(255,206,78,.35), transparent 30%),
                    radial-gradient(circle at 86% 18%, rgba(167,139,250,.24), transparent 32%),
                    linear-gradient(135deg, #fff8ed 0%, #fffdf9 48%, #f2f4ff 100%);
        }

        /* LANDSCAPE REQUIRED OVERLAY */
        #rotateOverlay {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.92);
            color: white;
            z-index: 9999;
            justify-content: center;
            align-items: center;
            text-align: center;
            padding: 20px;
        }

        #rotateOverlay .rotate-box {
            max-width: 360px;
            background: rgba(255,255,255,0.12);
            padding: 26px;
            border-radius: 22px;
            border: 2px solid rgba(255,255,255,0.25);
        }

        #rotateOverlay .rotate-icon {
            font-size: 4rem;
            margin-bottom: 10px;
        }

        #rotateOverlay h2 {
            font-size: 1.6rem;
            margin-bottom: 6px;
        }

        #rotateOverlay p {
            font-size: 1rem;
            opacity: 0.9;
        }

        @media screen and (orientation: portrait) and (max-width: 950px) {
            #rotateOverlay { display: flex; }
            .page { display: none !important; }
        }

        /* MAIN PAGE */
        .page {
            width: 100%;
            height: 100svh;
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 10px;
            gap: 10px;
        }

        h1 {
            font-size: clamp(1.5rem, 3vw, 2.8rem) !important;
            font-weight: 800 !important;
            color: var(--primary);
            text-shadow: 3px 3px 0 var(--secondary);
            text-align: center;
            line-height: 1;
        }

        .subtitle {
            font-size: clamp(.8rem, 1.2vw, 1rem);
            color: #7a6f67;
            text-align: center;
            margin-bottom: 4px;
        }

        /* MENU SCREENS */
        #modeScreen, #cpuSetupScreen {
            flex: 1;
            width: 100%;
            max-width: 980px;
            display: flex;
            align-items: center;
            justify-content: center;
            min-height: 0;
        }

        #cpuSetupScreen {
            display: none;
        }

        .menu-box {
            width: 100%;
            height: 100%;
            background:
                    radial-gradient(circle at 18% 20%, rgba(78, 205, 196, .16), transparent 28%),
                    radial-gradient(circle at 85% 10%, rgba(255, 107, 53, .12), transparent 30%);
            border-radius: 26px;
            box-shadow: 0 18px 60px rgba(0,0,0,0.15);
            border: 1px solid rgba(255,255,255,0.9);
            display: flex;
            flex-direction: row;
            align-items: center;
            justify-content: space-between;
            padding: 30px;
            gap: 30px;
        }
        .title-wrap {
            margin-top:10px;
        }
        .menu-left {
            flex: 1;
            display: flex;
            flex-direction: row;   /* row kar diya */
            align-items: center;
            justify-content: center;
            gap: 20px;
            flex-wrap: wrap;
        }

        .menu-right {
            width: 50%;

            display: flex;
            flex-direction: column;

            align-items: center;
            justify-content: center;

            gap: 18px;
        }

        .logo-container {
            /* width: min(420px, 78vw); */
            border-radius: 18px;
            box-shadow: 0 14px 40px rgba(0, 0, 0, 0.18);
            display: flex;
            gap: 15px;
            padding: 15px;
            align-items: center;
            justify-content: center
        }

        .menu-logo {
            border-radius: 30px;
            width: 100%;
            height: auto;
            object-fit: contain;
        }

        .menu-title {
            font-size: clamp(1.1rem, 2vw, 1.5rem);
            font-weight: 800;
            text-align: center;
            width: 144px;
        }

        .menu-buttons {
            display: flex;
            flex-direction: column;

            width: 100%;
            gap: 16px;
        }







        .btn-menu {
            flex: 1;
            min-width: 180px;
            max-width: 320px;
            border: none;
            border-radius: 22px;
            padding: 16px 18px;
            cursor: pointer;
            font-family: 'Baloo 2', cursive;
            font-size: 1.1rem;
            font-weight: 800;
            transition: transform .15s ease, box-shadow .15s ease;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 6px;
        }

        .btn-menu span.icon {
            font-size: 2.4rem;
        }

        .btn-menu:hover { transform: translateY(-3px); }
        .btn-menu:active { transform: translateY(2px); }

        .btn-2p {
            background: #dffaf7;
            color: #2a7a75;
            box-shadow: 0 7px 0 #a8deda;
        }

        .btn-cpu {
            background: #ede9fe;
            color: #5b21b6;
            box-shadow: 0 7px 0 #c4b5fd;
        }
        .btn-24cards {
            background: #ff6b359e;
            color: white;
            box-shadow: 0 6px 0 #c94e20d4;
        }

        .cpu-box h2 {
            font-size: clamp(1.3rem, 2vw, 1.8rem);
            font-weight: 800;
            color: #5b21b6;
        }

        .diff-buttons {
            display: flex;
            gap: 12px;
            flex-wrap: wrap;
            justify-content: center;
            margin-top:15px;
        }

        .btn-diff {
            padding: 12px 24px;
            border-radius: 999px;
            border: 3px solid transparent;
            font-family: 'Baloo 2', cursive;
            font-weight: 800;
            font-size: 1rem;
            cursor: pointer;
            background: white;
            transition: all .15s ease;
            box-shadow: 0 5px 16px rgba(0,0,0,0.08);
        }

        .btn-diff.easy { border-color:#4ade80; color:#166534; }
        .btn-diff.medium { border-color:#fb923c; color:#9a3412; }
        .btn-diff.hard { border-color:#f87171; color:#991b1b; }

        .btn-diff.selected,
        .btn-diff:hover {
            transform: translateY(-2px);
        }

        .btn-diff.easy.selected { background:#4ade80; color:white; }
        .btn-diff.medium.selected { background:#fb923c; color:white; }
        .btn-diff.hard.selected { background:#f87171; color:white; }

        .cpu-actions {
            display: flex;
            gap: 10px;
            flex-wrap: wrap;
            justify-content: center;
            margin-top: 15px;
        }

        .btn-action {
            border: none;
            border-radius: 999px;
            padding: 12px 28px;
            font-family: 'Baloo 2', cursive;
            font-weight: 800;
            font-size: 1rem;
            cursor: pointer;
            transition: transform .15s ease;
        }

        .btn-action:active { transform: translateY(2px); }

        .btn-start {
            background: var(--primary);
            color: white;
            box-shadow: 0 6px 0 #c94e20;
        }

        .btn-back {
            background: #e2e8f0;
            color: #475569;
            box-shadow: 0 6px 0 #cbd5e1;
        }

        /* GAME AREA */
        #gameArea {
            display: none;
            flex-direction: column;
            align-items: center;
            width: 100%;
            flex: 1;
            min-height: 0;
            gap: 8px;
        }

        .top-bar {
            flex-shrink: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            width: 100%;
            max-width: 960px;
            flex-wrap: nowrap;
        }

        .player-card {
            background: var(--card-bg);
            border-radius: 12px;
            padding: 6px 14px;
            text-align: center;
            box-shadow: var(--shadow);
            border: 3px solid transparent;
            transition: border-color .3s, transform .3s;
            white-space: nowrap;
        }

        .player-card.active { transform: translateY(-3px) scale(1.05); }
        .player-card.p1  { border-color: var(--p1);  }
        .player-card.p2  { border-color: var(--p2);  }
        .player-card.cpu { border-color: var(--cpu); }

        .player-name {
            font-size: 0.62rem;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: .8px;
        }

        .player-card.p1  .player-name { color: var(--p1);  }
        .player-card.p2  .player-name { color: var(--p2);  }
        .player-card.cpu .player-name { color: var(--cpu); }

        .player-score {
            font-size: 1.6rem;
            font-weight: 800;
            line-height: 1;
        }

        .turn-banner {
            background: var(--secondary);
            color: var(--text);
            font-size: 0.8rem;
            font-weight: 700;
            padding: 6px 16px;
            border-radius: 999px;
            box-shadow: 0 3px 8px rgba(0,0,0,.12);
            white-space: nowrap;
            transition: background .3s;
        }

        .turn-banner.cpu-thinking {
            background: #ede9fe;
            animation: pulse .8s infinite alternate;
        }

        @keyframes pulse { from{opacity:1} to{opacity:.5} }

        .bar-buttons { display: flex; gap: 8px; }

        .btn-sm {
            border: none;
            border-radius: 999px;
            padding: 7px 16px;
            font-family: 'Baloo 2', cursive;
            font-size: 0.8rem;
            font-weight: 700;
            cursor: pointer;
            transition: transform .1s, box-shadow .1s;
            white-space: nowrap;
        }

        .btn-sm.restart { background: var(--primary); color:#fff; box-shadow:0 4px 0 #c94e20; }
        .btn-sm.restart:hover  { background:#e55f28; }
        .btn-sm.restart:active { transform:translateY(3px); box-shadow:0 1px 0 #c94e20; }

        .btn-sm.menu    { background:#e2e8f0; color:#475569; box-shadow:0 4px 0 #cbd5e1; }
        .btn-sm.menu:hover  { background:#cbd5e1; }
        .btn-sm.menu:active { transform:translateY(3px); box-shadow:0 1px 0 #94a3b8; }

        .grid {
            width: 100%;
            max-width: 960px;

            flex: 1;
            min-height: 0;

            display: grid;

            /* 6 columns */
            grid-template-columns: repeat(6, 1fr);

            /* Auto-fit rows according to available height */
            grid-template-rows: repeat(3, 1fr);

            gap: 8px;

            height: 100%;
        }

        .card {
            width: 100%;
            height: 100%;

            /* remove old aspect ratio */
            aspect-ratio: unset;

            perspective: 600px;
            cursor: pointer;
        }
        .flag-img{
            width: 70px;
            height: 60px;
            object-fit: contain;
            border-radius: 10px;
            filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
        }
        .card-inner {
            width: 100%;
            height: 100%;
            position: relative;
            transform-style: preserve-3d;
            transition: transform .42s cubic-bezier(.4,0,.2,1);
            border-radius: var(--radius);
        }

        .card.flipped .card-inner,
        .card.matched .card-inner { transform: rotateY(180deg); }

        .card.matched .card-front {
            box-shadow: 0 0 0 3px #4caf50, var(--shadow);
            background: #e8f5e9;
        }

        .card-front, .card-back {
            position: absolute;
            inset: 0;
            border-radius: var(--radius);
            backface-visibility: hidden;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            user-select: none;
        }

        .card-back {
            background: var(--card-back);
            font-size: clamp(1.4rem, 3vw, 2rem);
            box-shadow: var(--shadow);
            border: 3px solid rgba(255,255,255,.18);
        }

        .card-front {
            background: var(--card-bg);
            transform: rotateY(180deg);
            font-size: clamp(3.11rem, 6.21vw, 4.88rem);
            box-shadow: var(--shadow);
            border: 3px solid #f0f0f0;
            padding: 2px 4px 4px;
        }

        .card-front > span:first-child {
            display: block;
            line-height: 0.82;
        }

        .card-country {
            font-size: clamp(0.704rem, 1.407vw, 0.987rem);
            font-weight: 700;
            color: #555;
            text-align: center;
            line-height: 0.95;
            max-width: 90%;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            margin-top: 10px;
        }

        body.cpu-turn .card:not(.flipped):not(.matched) { cursor: not-allowed; }

        .card:not(.flipped):not(.matched):hover .card-back {
            background: #7b7fc4;
            transform: translateY(-2px);
        }
        body.cpu-turn .card:not(.flipped):not(.matched) { cursor: not-allowed; }
        body.cpu-turn .card:not(.flipped):not(.matched):hover .card-back {
            background: var(--card-back); transform: none;
        }

        @keyframes shake {
            0%,100% { transform: rotateY(180deg) translateX(0); }
            25%      { transform: rotateY(180deg) translateX(-5px); }
            75%      { transform: rotateY(180deg) translateX(5px); }
        }
        .card.no-match .card-inner { animation: shake .38s ease; }

        /* WIN OVERLAY */
        .overlay {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,.5);
            backdrop-filter: blur(4px);
            justify-content: center;
            align-items: center;
            z-index: 100;
        }

        .overlay.show { display: flex; }

        .win-box {
            background: var(--card-bg);
            border-radius: 26px;
            padding: 30px 36px;
            text-align: center;
            box-shadow: 0 20px 60px rgba(0,0,0,.28);
            max-width: 340px;
            width: 90%;
            animation: popIn .38s cubic-bezier(.34,1.56,.64,1);
        }

        @keyframes popIn {
            from { transform:scale(.6); opacity:0; }
            to   { transform:scale(1);  opacity:1; }
        }

        .win-emoji  { font-size: 3.6rem; margin-bottom: 8px; }
        .win-title  { font-size: 1.8rem; font-weight: 800; color: var(--primary); margin-bottom: 4px; }
        .win-detail { font-size: 0.9rem; color: #666; margin-bottom: 20px; }

        .win-scores { display: flex; gap: 12px; justify-content: center; margin-bottom: 20px; }

        .win-score-badge {
            padding: 8px 18px;
            border-radius: var(--radius);
            font-weight: 700;
            font-size: 1rem;
        }

        .win-score-badge.p1  { background:#e0faf8; color:var(--p1);  border:2px solid var(--p1);  }
        .win-score-badge.p2  { background:#ffe8f4; color:var(--p2);  border:2px solid var(--p2);  }
        .win-score-badge.cpu { background:#ede9fe; color:var(--cpu); border:2px solid var(--cpu); }

        .win-btns { display:flex; gap:8px; justify-content:center; flex-wrap:wrap; }
        .win-btns .btn-sm { font-size:0.9rem; padding:9px 22px; }

        /* FUN FACT POPUP */
        #authorOverlay {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.62);
            backdrop-filter: blur(8px);
            justify-content: center;
            align-items: center;
            z-index: 300;
            padding: 18px;
        }

        #authorOverlay.show { display: flex; }

        .author-box {
            background: rgba(255,255,255,.96);
            border-radius: 30px;
            padding: 26px 20px;
            max-width: 400px;
            width: min(92vw, 400px);
            text-align: center;
            box-shadow: 0 26px 75px rgba(0,0,0,.34);
            animation: popIn .35s cubic-bezier(.34,1.56,.64,1);
        }

        .author-emoji { font-size: 3.4rem; margin-bottom: 10px; }

        .author-title {
            font-size: 1.55rem;
            font-weight: 800;
            color: var(--primary);
            margin-bottom: 8px;
        }

        .author-detail {
            font-size: .98rem;
            line-height: 1.45;
            color: #4a403b;
            margin-bottom: 18px;
        }

        .author-close {
            font-family: 'Baloo 2', cursive;
            border-radius: 999px;
            font-weight: 800;
            cursor: pointer;
            border: none;
            background: #eef2f7;
            color: #475569;
            padding: 10px 24px;
            box-shadow: 0 4px 0 #cbd5e1;
        }

        .author-close:active { transform: translateY(3px); box-shadow: 0 1px 0 #94a3b8; }

        /* EXTRA COMPACT MODE */
        @media screen and (orientation: landscape) and (max-height: 430px) {
            .menu-logo {width:300px;}
            .btn-menu { padding: 12px 14px; font-size: 1rem; }
            .btn-menu span.icon { font-size: 2rem; }
            .cpu-box h2 { font-size: 1.2rem; }
            .btn-diff { padding: 9px 16px; font-size: 0.95rem; }
            .btn-action { padding: 10px 18px; font-size: 0.95rem; }
        }
        
        #modeScreen{
            position: relative;
        }
.loged-in-container{
        position: absolute !important;
    right: 20px;
    top: 20px;
}
div#profile-popup::before {
    height: 0px;
    width: 0px;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 10px solid #ec4899;
    border-top: 10px solid transparent;
    position: relative;
    content: "";
    position: absolute;
    right: 64px;
    top: -20px;
}

