/* =============================================
   CSS Variables
   ============================================= */
:root {
    --color-primary-btn: #d4f000;
    --color-primary-btn-text: #1a0a6b;
    --color-secondary-btn-border: rgba(255, 255, 255, 0.5);
    --color-text: #ffffff;
    --color-text-muted: rgba(255, 255, 255, 0.80);
    --font-main: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
    --radius-btn: 50px;
}

/* --- Reset --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* --- Base --- */
body {
    font-family: var(--font-main);
    background-color: #111;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100dvh;
}

/* --- App Container --- */
.app {
    width: 100vw;
    height: 100dvh;
    max-width: 430px;
    background-image: url('../../assets/imgs/GameBG.png');
    background-size: cover;
    background-position: center bottom;
    background-repeat: no-repeat;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: clamp(12px, 4vw, 20px) clamp(12px, 4.5vw, 18px) clamp(14px, 5vw, 28px);
    color: var(--color-text);
    text-align: center;
    overflow: hidden;
}

/* --- Ad Banner --- */
.ad-banner {
    width: 100%;
    border-radius: 14px;
    padding: clamp(10px, 3vw, 18px) 16px;
    flex-shrink: 0;
    min-height: 0;
}

/* --- Hero Section --- */
.hero {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: clamp(12px, 4vw, 20px);
    flex-shrink: 0;
}

.hero__img {
    width: clamp(110px, 32vw, 150px);
    height: auto;
    margin-top: clamp(8px, 2.5vw, 16px);
    object-fit: contain;
}

/* --- Content --- */
.content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(8px, 2.5vw, 12px);
    margin-bottom: clamp(16px, 5vw, 28px);
    padding: 0 6px;
    flex-shrink: 0;
}

.content__heading {
    font-size: clamp(18px, 5.5vw, 24px);
    line-height: 1.45;
}

.content__desc {
    font-size: clamp(12px, 3.5vw, 14px);
    font-weight: 400;
    line-height: 1.6;
    color: var(--color-text-muted);
    max-width: 320px;
}

/* --- Action Buttons --- */
.actions {
    display: flex;
    flex-direction: column;
    gap: clamp(8px, 2.5vw, 12px);
    width: 100%;
    flex-shrink: 0;
}

.btn {
    width: 90%;
    padding: clamp(10px, 3vw, 13px) 24px;
    border-radius: var(--radius-btn);
    font-size: clamp(12px, 3.5vw, 13px);
    font-weight: 700;
    cursor: pointer;
    border: none;
    font-family: var(--font-main);
    margin: auto;
}

.btn:active {
    transform: scale(0.97);
    opacity: 0.9;
}

.btn--primary {
    background-color: var(--color-primary-btn);
    color: var(--color-primary-btn-text);
}

.btn--primary:hover {
    background-color: #c8e400;
}

.btn--secondary {
    background-color: transparent;
    color: var(--color-text);
    border: 1px solid var(--color-secondary-btn-border);
}

.btn--secondary:hover {
    background-color: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.85);
}

/* --- Footer --- */
.footer {
    margin-top: auto;
    width: 100%;
    display: flex;
    justify-content: center;
}

.footer__logo {
    height: clamp(24px, 6vw, 32px);
    width: auto;
    object-fit: contain;
    opacity: 0.9;
}


/* =============================================
   Desktop Phone Frame
   ============================================= */
@media (min-width: 600px) {
    body {
        background: #0a0a1a;
        padding: 32px 0;
        align-items: flex-start;
        min-height: 100vh;
    }

    .app {
        border-radius: 32px;
        box-shadow:
            0 0 0 8px #1a1a2e,
            0 0 0 10px #2a2a4e,
            0 24px 64px rgba(0, 0, 0, 0.7);
        max-height: calc(100vh - 64px);
        overflow-y: auto;
    }

    .app::-webkit-scrollbar {
        display: none;
    }
}

/* =============================================
   Matches Page
   ============================================= */
.app--matches {
    overflow: hidden;
    align-items: stretch;
    padding: clamp(12px, 4vw, 20px) clamp(10px, 4vw, 16px);
    position: relative;
}

.app--matches::-webkit-scrollbar {
    display: none;
}

/* --- Back Button --- */
.back-btn {
    position: absolute;
    top: 30px;
    left: 16px;
    width: clamp(32px, 8vw, 36px);
    height: clamp(32px, 8vw, 36px);
    border-radius: 50%;
    background: linear-gradient(135deg, #510BCD, #1D0C78);
    border: 0;
    color: #fff;
    font-size: clamp(22px, 6vw, 28px);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    line-height: 1;
    direction: ltr;
    unicode-bidi: embed;
}

.back-btn:hover {
    box-shadow: 0 0 14px rgba(0, 207, 255, 0.8);
}

.app--matches .ad-banner {
    margin-top: clamp(48px, 12vw, 64px);
    min-height: 0;
}

/* Collapse ad-banner when the GPT slot renders nothing */
.app--matches .ad-banner:empty,
.app--matches .ad-banner div[id^="div-gpt-ad"]:empty {
    margin: 0;
    padding: 0;
}

/* --- Section Title --- */
.section-title {
    width: 100%;
    background-color: #d4f000;
    color: #1a0a6b;
    font-size: clamp(14px, 4vw, 16px);
    font-weight: 800;
    text-align: center;
    padding: clamp(9px, 2.5vw, 12px) 16px;
    border-radius: 16px 16px 0 0;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 5;
}

/* --- Matches List --- */
.matches {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    overflow-y: auto;
    flex: 1;
    padding: 0 0 12px;
}

.matches::-webkit-scrollbar {
    display: none;
}

/* Loading / empty / error states */
.loading-msg,
.matches-empty,
.matches-error {
    text-align: center;
    padding: 24px;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
}

.matches-error {
    color: #f87171;
}

/* --- Match Card --- */
.match-card {
    background-color: rgba(60, 30, 140, 0.7);
    border-radius: 16px;
    padding: clamp(10px, 3vw, 16px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: clamp(20px, 10vw, 50px);
    flex-shrink: 0;
}

.match-card:first-child {
    border-radius: 0 0 16px 16px;
    margin-top: 0;
}

.match-card:last-child {
    border-bottom: none;
}

/* --- Matches Header --- */
.matches-header {
    width: 100%;
    flex-shrink: 0;
    margin-bottom: 10px;
}

.matches-header .section-title {
    margin-bottom: 0;
}

.matches-header .match-card {
    border-radius: 0 0 16px 16px;
}

/* --- Team Block --- */
.match-card__team {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex: 1;
}

.match-card__team img {
    width: clamp(40px, 12vw, 52px);
    height: clamp(40px, 12vw, 52px);
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.team-name {
    font-size: clamp(12px, 3.5vw, 14px);
    font-weight: 700;
    color: #fff;
}

.team-score {
    font-size: clamp(10px, 2.8vw, 11px);
    font-weight: 400;
    color: rgba(255, 255, 255, 0.65);
}

/* --- Cheer Button --- */
.btn-cheer {
    background-color: #d4f000;
    border: none;
    border-radius: 50px;
    padding: clamp(6px, 2vw, 8px) clamp(12px, 4vw, 17px);
    font-size: clamp(11px, 3.2vw, 13px);
    font-weight: 800;
    font-family: var(--font-main);
    cursor: pointer;
    flex-shrink: 0;
}

.btn-cheer:active {
    transform: scale(0.96);
}

.btn-cheer:hover {
    background-color: #c8e400;
}


/* =============================================
   Cheer Page
   ============================================= */
.app--cheer {
    position: relative;
    align-items: center;
    padding: clamp(12px, 4vw, 20px) clamp(12px, 4.5vw, 20px) clamp(16px, 5vw, 28px);
}

.app--cheer .ad-banner {
    margin-top: clamp(24px, 7vw, 35px);
    margin-bottom: clamp(12px, 4vw, 20px);
}

/* --- Hero --- */
.cheer-hero {
    display: flex;
    justify-content: center;
    margin-bottom: clamp(10px, 3vw, 16px);
}

.cheer-hero__img {
    width: clamp(110px, 32vw, 150px);
    height: auto;
    object-fit: contain;
    margin-top: 3px;
    margin-bottom: 7px;
}

/* --- Title --- */
.cheer-title {
    font-size: clamp(18px, 5.5vw, 24px);
    color: #fff;
    text-align: center;
    margin-bottom: clamp(14px, 4vw, 24px);
    line-height: 1.3;
}

/* --- Teams VS Block --- */
.cheer-teams {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(6px, 2.5vw, 12px);
    width: 100%;
    margin-bottom: clamp(10px, 3vw, 16px);
}

/* --- Team Card --- */
.cheer-team {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(4px, 1.5vw, 8px);
    background-color: rgba(60, 30, 140, 0.75);
    border-radius: 20px;
    padding: clamp(10px, 3.5vw, 18px) clamp(6px, 2vw, 10px);
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.cheer-team img {
    width: clamp(48px, 14vw, 64px);
    height: clamp(48px, 14vw, 64px);
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.cheer-team__name {
    font-size: clamp(13px, 4vw, 16px);
    font-weight: 700;
    color: #fff;
}

.cheer-team__score {
    font-size: clamp(10px, 3vw, 12px);
    font-weight: 400;
    color: rgba(255, 255, 255, 0.65);
}

/* Active (selected) team — yellow highlight */
.cheer-team--active {
    background-color: #d4f000;
    border: none;
}

.cheer-team--active .cheer-team__name {
    color: #1a0a6b;
}

.cheer-team--active .cheer-team__score {
    color: rgba(26, 10, 107, 0.85);
}

.cheer-team--active img {
    border-color: rgba(26, 10, 107, 0.3);
}

/* --- VS Badge --- */
.cheer-vs {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cheer-vs img {
    width: clamp(28px, 8vw, 36px);
    height: auto;
    object-fit: contain;
}

/* --- CTA Button --- */
.cheer-btn {
    width: 100%;
    margin-bottom: 0;
}

.cheer-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}


/* =============================================
   Result Page
   ============================================= */
.app--result {
    position: relative;
    align-items: center;
    padding: clamp(12px, 4vw, 20px) clamp(12px, 4.5vw, 20px) clamp(16px, 5vw, 28px);
    overflow-y: auto;
}

.app--result::-webkit-scrollbar {
    display: none;
}

.app--result .ad-banner {
    margin-top: clamp(26px, 7vw, 36px);
    margin-bottom: clamp(10px, 3vw, 16px);
}

/* --- Hero --- */
.result-hero {
    display: flex;
    justify-content: center;
    margin-bottom: -4px;
    flex-shrink: 0;
}

.result-hero__img {
    width: clamp(110px, 32vw, 150px);
    height: auto;
    object-fit: contain;
    margin-top: 5px;
}

/* --- Award Image --- */
.result-flag-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: clamp(-30px, -8vw, -42px);
    position: relative;
    flex-shrink: 0;
}

.result-award {
    width: clamp(180px, 55vw, 250px);
    height: auto;
    object-fit: contain;
}

/* Team flag centered inside the award circle */
.result-team-flag {
    position: absolute;
    top: 49%;
    left: 50%;
    transform: translate(-50%, -52%);
    width: clamp(72px, 22vw, 100px);
    height: clamp(72px, 22vw, 100px);
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(255, 255, 255, 0.4);
}

/* --- Result Text --- */
.result-text {
    text-align: center;
    margin-bottom: 6px;
    flex-shrink: 0;
}

.result-text__title {
    font-size: clamp(28px, 9vw, 40px);
    color: #fff;
    margin-bottom: -16px;
}

.result-text__score {
    font-size: clamp(20px, 6.5vw, 28px);
    font-weight: 800;
    color: #d4f000;
}

.result-text__score span {
    font-size: clamp(26px, 8vw, 36px);
}

/* --- Action Buttons --- */
.result-actions {
    display: flex;
    flex-direction: row-reverse;
    gap: 10px;
    width: 100%;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.result-actions .btn {
    flex: 1;
    padding: clamp(8px, 2.5vw, 10px) 0;
    font-size: clamp(11px, 3vw, 12px);
}

.play-agian {
    background-color: #E8FF01;
    color: #000;
}

/* --- Scores Row --- */
.result-scores {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 4px 16px;
    margin-top: auto;
    flex-shrink: 0;
}

.result-scores__team {
    display: flex;
    align-items: center;
    gap: 10px;
}

.result-scores__team img {
    width: clamp(32px, 9vw, 40px);
    height: clamp(32px, 9vw, 40px);
    border-radius: 50%;
    object-fit: cover;
}

.result-scores__team span {
    font-size: clamp(13px, 4vw, 15px);
    font-weight: 700;
    color: #fff;
}


/* =============================================
   Rankings Page
   ============================================= */
.app--rankings {
    position: relative;
    align-items: stretch;
    padding: clamp(12px, 4vw, 20px) clamp(10px, 4vw, 16px);
    overflow: hidden;
}

.app--rankings .ad-banner {
    margin-top: clamp(34px, 9vw, 44px);
    margin-bottom: clamp(8px, 3vw, 14px);
}

/* --- Rankings Header Bar --- */
.rankings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #d4f000;
    border-radius: 12px;
    padding: clamp(7px, 2.2vw, 10px) 14px;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.rankings-header__title {
    font-size: clamp(13px, 4vw, 16px);
    font-weight: 800;
    color: #1a0a6b;
}

.rankings-header__update {
    font-size: clamp(10px, 2.8vw, 11px);
    font-weight: 400;
    color: #1a0a6b;
    opacity: 0.7;
}

/* --- Column Labels --- */
.rankings-cols {
    display: flex;
    align-items: center;
    padding: 0 12px 8px;
    flex-shrink: 0;
}

.rankings-cols__rank {
    font-size: clamp(10px, 3vw, 12px);
    font-weight: 700;
    color: rgba(255, 255, 255, 0.6);
    width: 48px;
    text-align: center;
    flex-shrink: 0;
}

.rankings-cols__team {
    font-size: clamp(10px, 3vw, 12px);
    font-weight: 700;
    color: rgba(255, 255, 255, 0.6);
    flex: 1;
    text-align: center;
}

.rankings-cols__goals {
    font-size: clamp(10px, 3vw, 12px);
    font-weight: 700;
    color: rgba(255, 255, 255, 0.6);
    width: 90px;
    text-align: left;
    flex-shrink: 0;
}

/* --- Rankings List --- */
.rankings-list {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex: 1;
    gap: 6px;
    -webkit-mask-image: linear-gradient(to bottom, black 80%, transparent 100%);
    mask-image: linear-gradient(to bottom, black 80%, transparent 100%);
}

.rankings-list::-webkit-scrollbar {
    display: none;
}

/* --- Rank Row --- */
.rank-row {
    display: flex;
    align-items: center;
    padding: clamp(7px, 2.2vw, 10px) 12px;
    background-color: rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    gap: 10px;
}

.rank-row__num {
    width: 28px;
    text-align: center;
    font-size: clamp(13px, 4vw, 16px);
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
}

.rank-row__num--active {
    background-color: #d4f000;
    color: #1a0a6b;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.rank-row img {
    width: clamp(30px, 9vw, 38px);
    height: clamp(30px, 9vw, 38px);
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.rank-row__name {
    flex: 1;
    font-size: clamp(11px, 3.2vw, 13px);
    font-weight: 600;
    color: #fff;
    text-align: right;
}

.rank-row__goals {
    width: 90px;
    font-size: clamp(11px, 3.2vw, 13px);
    font-weight: 600;
    color: #fff;
    text-align: left;
    flex-shrink: 0;
}

/* faded rows — text stays white; the list mask handles the visual fade */
.rank-row--faded .rank-row__name,
.rank-row--faded .rank-row__goals,
.rank-row--faded .rank-row__num {
    color: #fff;
}

/* active row */
.rank-row--active .rank-row__name,
.rank-row--active .rank-row__goals {
    color: #fff;
    font-weight: 700;
}

