: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);
    font-weight: 800;
    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;
}

.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.matched.player2-match .card-front {
    box-shadow: 0 0 0 3px #ff6b9d, var(--shadow) !important;
}

.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;
}*/
.card-country {
    font-size: clamp(0.704rem, 1.407vw, 0.987rem);
    font-weight: 700;
    color: #555;
    text-align: center;
    line-height: 1.1;
    max-width: 90%;
    margin-top: 10px;

    overflow: hidden;
    white-space: normal;
    overflow-wrap: break-word;

    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

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; }
}
/* WIN STREAK SECTION */
.streak-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding-left: 10px;
    border-left: 1px solid #eee;
    min-width: 70px;
}

.streak-label {
    font-size: 0.55rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: #8a8a8a;
    display: flex;
    align-items: center;
    gap: 4px;
    line-height: 1;
}

.streak-icon {
    font-size: 0.85rem;
    line-height: 1;
}

.streak-count {
    font-weight: 800;
    font-size: 0.85rem;
    color: var(--text);
    line-height: 1;
}

/* Color coding per player */
.player-card.p1  .streak-count { color: var(--p1); }
.player-card.p2  .streak-count { color: var(--p2); }
.player-card.cpu .streak-count { color: var(--cpu); }

.streak-dots {
    display: flex;
    gap: 4px;
}

.streak-dot {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.55rem;
    color: white;
    font-weight: 800;
    transition: background .25s ease, transform .25s ease;
}

.player-card.p1  .streak-dot.filled { background: var(--p1); }
.player-card.p2  .streak-dot.filled { background: var(--p2); }
.player-card.cpu .streak-dot.filled { background: var(--cpu); }

.streak-dot.filled { transform: scale(1.05); }
.streak-dot.pop { animation: dotPop .4s ease; }

@keyframes dotPop {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.4); }
    100% { transform: scale(1.05); }
}

.streak-icon.celebrate { animation: iconPop .55s ease; }

@keyframes iconPop {
    0%   { transform: scale(0.4) rotate(-20deg); opacity: 0; }
    60%  { transform: scale(1.5) rotate(8deg);   opacity: 1; }
    100% { transform: scale(1)   rotate(0);      opacity: 1; }
}


/* ========================================================
   🪨 📜 ✂️  ROCK PAPER SCISSORS TIEBREAKER OVERLAY
   ======================================================== */
#tiebreakOverlay {
    display: none;
    position: fixed;
    inset: 0;
    background:
            radial-gradient(circle at 20% 30%, rgba(255, 107, 53, 0.25), transparent 40%),
            radial-gradient(circle at 80% 70%, rgba(78, 205, 196, 0.20), transparent 40%),
            radial-gradient(circle at 50% 50%, rgba(255, 206, 78, 0.18), transparent 50%),
            linear-gradient(135deg, #1a0a2e 0%, #2d1b4e 50%, #1a0a2e 100%);
    z-index: 500;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    padding: 12px;
    overflow: hidden;
}
#tiebreakOverlay.show { display: flex; }

/* Animated sparks drifting across the background */
#tiebreakOverlay::before,
#tiebreakOverlay::after {
    content: '';
    position: absolute;
    width: 200%;
    height: 200%;
    top: -50%;
    left: -50%;
    background-image:
            radial-gradient(2px 2px at 20% 30%, rgba(255,206,78,0.6), transparent),
            radial-gradient(1px 1px at 60% 70%, rgba(78,205,196,0.5), transparent),
            radial-gradient(2px 2px at 80% 20%, rgba(255,107,157,0.5), transparent),
            radial-gradient(1px 1px at 30% 80%, rgba(255,255,255,0.5), transparent),
            radial-gradient(2px 2px at 90% 50%, rgba(255,206,78,0.4), transparent),
            radial-gradient(1px 1px at 10% 60%, rgba(167,139,250,0.5), transparent);
    animation: sparkDrift 20s linear infinite;
    pointer-events: none;
}
#tiebreakOverlay::after {
    animation-duration: 28s;
    animation-direction: reverse;
    opacity: 0.6;
}
@keyframes sparkDrift {
    from { transform: translate(0, 0) rotate(0deg); }
    to   { transform: translate(-50px, -80px) rotate(360deg); }
}

.tb-title {
    position: relative;
    z-index: 2;
    font-family: 'Baloo 2', cursive;
    font-weight: 800;
    font-size: clamp(1.6rem, 4.5vw, 2.8rem);
    color: #ffce4e;
    text-align: center;
    text-shadow:
            0 0 16px rgba(255, 206, 78, 0.7),
            3px 3px 0 #ff6b35,
            6px 6px 12px rgba(0,0,0,0.4);
    letter-spacing: 1px;
    animation: tbTitlePulse 1.4s ease-in-out infinite alternate;
    line-height: 1;
    margin-bottom: 2px;
}
@keyframes tbTitlePulse {
    from { transform: scale(1);    text-shadow: 0 0 16px rgba(255,206,78,0.7), 3px 3px 0 #ff6b35; }
    to   { transform: scale(1.04); text-shadow: 0 0 28px rgba(255,206,78,1),   3px 3px 0 #ff6b35, 0 0 50px rgba(255,107,53,0.5); }
}

.tb-subtitle {
    position: relative;
    z-index: 2;
    font-family: 'Baloo 2', cursive;
    color: rgba(255,255,255,0.85);
    font-size: clamp(0.75rem, 1.5vw, 0.95rem);
    text-align: center;
    margin-bottom: 14px;
    max-width: 540px;
    line-height: 1.3;
}

.tb-arena {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: clamp(14px, 4vw, 36px);
    width: 100%;
    max-width: 760px;
}

.tb-vs {
    align-self: center;
    font-family: 'Baloo 2', cursive;
    font-weight: 800;
    font-size: clamp(1.6rem, 3.5vw, 2.4rem);
    color: #fff;
    text-shadow: 0 0 20px rgba(255,206,78,0.8), 0 2px 8px rgba(0,0,0,0.5);
    animation: vsFlicker 0.9s ease-in-out infinite alternate;
}
@keyframes vsFlicker {
    from { opacity: 0.7; transform: scale(1); }
    to   { opacity: 1;   transform: scale(1.15); }
}

.tb-player {
    flex: 1;
    max-width: 280px;
    background: rgba(255,255,255,0.08);
    backdrop-filter: blur(12px);
    border-radius: 22px;
    border: 3px solid rgba(255,255,255,0.18);
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transition: all 0.4s ease;
    position: relative;
    overflow: hidden;
}
.tb-player.p1-side { border-color: rgba(78, 205, 196, 0.6); }
.tb-player.p2-side { border-color: rgba(255, 107, 157, 0.6); }
.tb-player.cpu-side { border-color: rgba(167, 139, 250, 0.6); }

.tb-player.winner {
    border-color: #ffce4e;
    background: rgba(255, 206, 78, 0.18);
    box-shadow:
            0 0 40px rgba(255, 206, 78, 0.8),
            0 0 80px rgba(255, 107, 53, 0.4),
            inset 0 0 30px rgba(255, 206, 78, 0.25);
    transform: scale(1.04);
}
.tb-player.loser {
    opacity: 0.45;
    filter: grayscale(0.6);
    transform: scale(0.96);
}

.tb-player-name {
    font-family: 'Baloo 2', cursive;
    font-weight: 800;
    font-size: clamp(0.85rem, 1.6vw, 1.1rem);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.4);
}
.tb-player.p1-side .tb-player-name { color: #4ecdc4; }
.tb-player.p2-side .tb-player-name { color: #ff6b9d; }
.tb-player.cpu-side .tb-player-name { color: #c4b5fd; }

/* The big icon frame where R/P/S is revealed */
.tb-icon-frame {
    width: clamp(80px, 14vw, 120px);
    height: clamp(80px, 14vw, 120px);
    border-radius: 18px;
    background: rgba(0,0,0,0.25);
    border: 2px dashed rgba(255,255,255,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: border 0.3s ease;
}
.tb-player.locked .tb-icon-frame {
    border-style: solid;
    border-color: rgba(255,206,78,0.5);
    background: rgba(255,206,78,0.08);
}
.tb-player.revealed .tb-icon-frame {
    border-color: rgba(255,255,255,0.4);
    background: rgba(255,255,255,0.12);
}

.tb-icon-display {
    font-size: clamp(2.6rem, 6vw, 4.2rem);
    line-height: 1;
    transition: transform 0.3s ease;
    position: relative;
    z-index: 1;
}
.tb-icon-display.spinning {
    animation: rpsSpin 0.08s linear infinite;
}
@keyframes rpsSpin {
    0% { transform: rotateY(0deg); }
    100% { transform: rotateY(360deg); }
}
.tb-player.revealed .tb-icon-display {
    animation: rpsLand 0.5s cubic-bezier(.34,1.56,.64,1);
}
@keyframes rpsLand {
    0%   { transform: scale(0.3) rotate(-20deg); }
    60%  { transform: scale(1.3) rotate(8deg);   }
    100% { transform: scale(1)   rotate(0deg);   }
}

/* The "?" placeholder before lock-in */
.tb-question {
    font-size: clamp(2.6rem, 6vw, 4rem);
    font-weight: 800;
    color: rgba(255,255,255,0.35);
    animation: questionPulse 1.4s ease-in-out infinite alternate;
}
@keyframes questionPulse {
    from { transform: scale(1);    opacity: 0.35; }
    to   { transform: scale(1.12); opacity: 0.7;  }
}

.tb-status {
    font-family: 'Baloo 2', cursive;
    font-weight: 700;
    font-size: clamp(0.7rem, 1.3vw, 0.85rem);
    color: rgba(255,255,255,0.7);
    min-height: 1.1em;
    text-align: center;
}
.tb-status.ready { color: #ffce4e; }

.tb-lockin {
    font-family: 'Baloo 2', cursive;
    font-weight: 800;
    font-size: clamp(0.9rem, 1.8vw, 1.15rem);
    letter-spacing: 1.2px;
    padding: 10px 22px;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    background: linear-gradient(135deg, #ff6b35, #ffce4e);
    color: #1a0a2e;
    box-shadow:
            0 5px 0 #c94e20,
            0 0 20px rgba(255,206,78,0.4);
    transition: all 0.15s ease;
    text-transform: uppercase;
    animation: lockInPulse 1.2s ease-in-out infinite;
}
@keyframes lockInPulse {
    0%, 100% { box-shadow: 0 5px 0 #c94e20, 0 0 20px rgba(255,206,78,0.4); }
    50%      { box-shadow: 0 5px 0 #c94e20, 0 0 35px rgba(255,206,78,0.9); }
}
.tb-lockin:hover  { transform: translateY(-2px); }
.tb-lockin:active { transform: translateY(3px); box-shadow: 0 2px 0 #c94e20; }
.tb-lockin:disabled,
.tb-player.locked .tb-lockin {
    background: #475569;
    color: #94a3b8;
    cursor: default;
    box-shadow: 0 4px 0 #334155;
    animation: none;
}
.tb-player.revealed .tb-lockin {
    display: none;
}

.tb-locked-tag {
    display: none;
    font-family: 'Baloo 2', cursive;
    font-weight: 800;
    font-size: clamp(0.7rem, 1.3vw, 0.85rem);
    color: #22c55e;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    text-shadow: 0 0 10px rgba(34, 197, 94, 0.6);
}
.tb-player.locked .tb-locked-tag { display: block; }

/* The big "3 ... 2 ... 1 ... GO!" countdown */
.tb-countdown {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.5);
    font-family: 'Baloo 2', cursive;
    font-weight: 800;
    font-size: clamp(5rem, 18vw, 12rem);
    color: #ffce4e;
    text-shadow:
            0 0 30px rgba(255, 206, 78, 0.9),
            0 0 60px rgba(255, 107, 53, 0.7),
            4px 4px 0 #ff6b35;
    z-index: 10;
    pointer-events: none;
    opacity: 0;
    transition: none;
}
.tb-countdown.show {
    animation: countdownPop 0.65s cubic-bezier(.34,1.56,.64,1) forwards;
}
@keyframes countdownPop {
    0%   { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
    40%  { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
    80%  { transform: translate(-50%, -50%) scale(1);   opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1.3); opacity: 0; }
}

.tb-result-banner {
    position: relative;
    z-index: 2;
    margin-top: 16px;
    font-family: 'Baloo 2', cursive;
    font-weight: 800;
    font-size: clamp(1rem, 2.2vw, 1.45rem);
    text-align: center;
    color: #fff;
    text-shadow: 0 0 14px rgba(255,206,78,0.8), 0 2px 6px rgba(0,0,0,0.5);
    min-height: 1.4em;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.4s ease, transform 0.4s ease;
    padding: 0 12px;
}
.tb-result-banner.show {
    opacity: 1;
    transform: translateY(0);
}

.tb-actions {
    position: relative;
    z-index: 2;
    margin-top: 14px;
    display: none;
}
.tb-actions.show { display: flex; gap: 10px; }

.tb-continue {
    font-family: 'Baloo 2', cursive;
    font-weight: 800;
    font-size: clamp(0.9rem, 1.8vw, 1.1rem);
    letter-spacing: 1px;
    padding: 11px 26px;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    background: #fff;
    color: #1a0a2e;
    box-shadow: 0 5px 0 #cbd5e1, 0 0 24px rgba(255,255,255,0.4);
    transition: transform 0.15s ease;
    text-transform: uppercase;
}
.tb-continue:hover  { transform: translateY(-2px); }
.tb-continue:active { transform: translateY(3px); box-shadow: 0 2px 0 #cbd5e1; }

/* 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; }

    /* Compact streak section on iPhone landscape */
    .player-card { padding: 5px 9px; gap: 7px; }
    .player-score { font-size: 1.35rem; }
    .streak-section { padding-left: 7px; min-width: 60px; gap: 3px; }
    .streak-label { font-size: 0.5rem; gap: 3px; }
    .streak-icon { font-size: 0.78rem; }
    .streak-count { font-size: 0.78rem; }
    .streak-dot { width: 12px; height: 12px; font-size: 0.5rem; }
    .streak-dots { gap: 3px; }
}
