:root {
    --bg: #07162e;
    --bg2: #0b2b5d;
    --panel: rgba(9, 24, 49, .78);
    --panel2: rgba(255, 255, 255, .09);
    --text: #f8fbff;
    --muted: #a9b9d7;
    --line: rgba(255, 255, 255, .18);
    --accent: #30e7ff;
    --accent2: #b4ff2e;
    --danger: #ff416c;
    --shadow: 0 24px 80px rgba(0, 0, 0, .4);
    --radius: 24px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: radial-gradient(circle at 20% 0%, #154f95 0, transparent 34%), linear-gradient(145deg, var(--bg), #071021 54%, #081a35); color: var(--text); overflow-x: hidden; }
body { min-height: 100dvh; touch-action: manipulation; }
button, input, a { font: inherit; }
button, a { user-select: none; }

.app-shell { position: relative; min-height: 100dvh; padding: max(12px, env(safe-area-inset-top)) 12px max(14px, env(safe-area-inset-bottom)); overflow: hidden; }
.stadium-glow { position: fixed; width: 290px; height: 290px; border-radius: 50%; filter: blur(70px); opacity: .42; pointer-events: none; }
.stadium-glow-a { background: #23e5ff; left: -110px; top: 20%; }
.stadium-glow-b { background: #9cff24; right: -130px; bottom: 7%; }

.topbar { position: relative; z-index: 2; display: grid; grid-template-columns: 74px 1fr 54px; align-items: center; gap: 8px; max-width: 900px; margin: 0 auto 10px; }
.brand-lockup { display: flex; align-items: center; gap: 10px; justify-content: center; min-width: 0; }
.brand-ball { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 18px; background: linear-gradient(145deg, rgba(255,255,255,.18), rgba(255,255,255,.05)); border: 1px solid var(--line); box-shadow: inset 0 1px 0 rgba(255,255,255,.22), 0 12px 30px rgba(0,0,0,.28); }
.brand-kicker { color: var(--accent2); text-transform: uppercase; font-size: 10px; letter-spacing: .16em; font-weight: 800; }
h1 { margin: 0; font-size: clamp(18px, 4.2vw, 28px); line-height: 1; letter-spacing: -.04em; white-space: nowrap; }
h2 { margin: 0 0 8px; font-size: clamp(25px, 7vw, 44px); line-height: .96; letter-spacing: -.055em; }
p { line-height: 1.45; }

.screen { position: relative; z-index: 1; display: none; width: min(100%, 900px); margin: 0 auto; }
.screen.active { display: block; animation: screenIn .28s ease both; }
@keyframes screenIn { from { opacity: 0; transform: translateY(12px) scale(.99); } to { opacity: 1; transform: translateY(0) scale(1); } }
.hidden { display: none !important; }

.glass-card { background: linear-gradient(145deg, rgba(255,255,255,.12), rgba(255,255,255,.045)), var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.16); backdrop-filter: blur(16px); }
.compact { border-radius: 18px; }
.hero-card, .setup-card, .lobby-card, .queue-card, .ranking-card { padding: 18px; }

.hero-card { min-height: calc(100dvh - 92px); display: flex; flex-direction: column; justify-content: flex-end; gap: 14px; overflow: hidden; }
.hero-card p { color: var(--muted); margin: 0 0 8px; font-size: 15px; max-width: 620px; }
.hero-field-preview { position: relative; height: min(48dvh, 430px); min-height: 250px; margin: -4px -4px 8px; border-radius: 25px; overflow: hidden; background: linear-gradient(90deg, rgba(103,220,60,.88) 0 12.5%, rgba(65,182,46,.9) 12.5% 25%, rgba(103,220,60,.88) 25% 37.5%, rgba(65,182,46,.9) 37.5% 50%, rgba(103,220,60,.88) 50% 62.5%, rgba(65,182,46,.9) 62.5% 75%, rgba(103,220,60,.88) 75% 87.5%, rgba(65,182,46,.9) 87.5% 100%); box-shadow: inset 0 0 0 3px rgba(255,255,255,.22); }
.hero-field-preview::before { content: ""; position: absolute; inset: 28px 18%; border: 5px solid rgba(255,255,255,.58); border-radius: 16px; }
.hero-field-preview::after { content: ""; position: absolute; left: 50%; top: 50%; width: 120px; height: 120px; transform: translate(-50%,-50%); border-radius: 50%; border: 5px solid rgba(255,255,255,.48); }
.mini-puck, .mini-ball { position: absolute; display: grid; place-items: center; border-radius: 50%; font-size: 32px; box-shadow: 0 18px 26px rgba(0,0,0,.32), inset 0 7px 10px rgba(255,255,255,.45), inset 0 -10px 12px rgba(0,0,0,.18); }
.mini-puck { width: 88px; height: 88px; border: 8px solid #0a65ff; background: radial-gradient(circle at 34% 22%, #fff, #eaf0ff 24%, #2845d9 25%, #fffb 44%, #fb2d55 46%, #123 100%); }
.mini-puck-1 { left: 15%; bottom: 18%; animation: puckFloat 2.7s ease-in-out infinite; }
.mini-puck-2 { right: 12%; top: 18%; animation: puckFloat 2.4s ease-in-out .4s infinite; }
.mini-ball { width: 54px; height: 54px; right: 18%; bottom: 36%; background: #fff; font-size: 30px; animation: ballPulse 1.2s ease-in-out infinite; }
.shot-line { position: absolute; left: 32%; bottom: 28%; width: 46%; height: 20px; border-radius: 999px; background: linear-gradient(90deg, transparent, rgba(48,231,255,.92), rgba(180,255,46,.9), transparent); filter: blur(1px); transform: rotate(-16deg); animation: shotFlash 1.25s ease-in-out infinite; }
@keyframes puckFloat { 50% { transform: translateY(-10px) rotate(5deg); } }
@keyframes ballPulse { 50% { transform: scale(1.08); filter: brightness(1.25); } }
@keyframes shotFlash { 50% { opacity: .55; transform: rotate(-16deg) scaleX(.88); } }

.home-actions { display: grid; grid-template-columns: 1fr; gap: 10px; }
.primary-btn, .secondary-btn, .ghost-btn { border: 0; border-radius: 18px; min-height: 50px; padding: 13px 16px; color: var(--text); cursor: pointer; font-weight: 900; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: transform .16s ease, filter .16s ease, border-color .16s ease; }
.primary-btn { background: linear-gradient(135deg, #16cfff, #2cff96 54%, #ccff33); color: #041020; box-shadow: 0 14px 34px rgba(47, 245, 184, .28), inset 0 1px 0 rgba(255,255,255,.45); }
.secondary-btn { background: linear-gradient(145deg, rgba(255,255,255,.16), rgba(255,255,255,.06)); border: 1px solid var(--line); }
.ghost-btn { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); color: #dce8ff; }
.primary-btn:active, .secondary-btn:active, .ghost-btn:active { transform: translateY(1px) scale(.99); }
.primary-btn:hover, .secondary-btn:hover, .ghost-btn:hover { filter: brightness(1.07); }
.primary-btn:disabled, .secondary-btn:disabled, .ghost-btn:disabled {
    cursor: default;
    opacity: .72;
    filter: saturate(.75);
    transform: none;
}

.small { min-height: 42px; padding: 8px 10px; border-radius: 14px; font-size: 13px; }
.full { width: 100%; margin-top: 12px; }

.section-title-row { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.eyebrow { color: var(--accent2); text-transform: uppercase; letter-spacing: .16em; font-size: 11px; font-weight: 900; }
.field-label { display: block; color: #d7e5ff; font-size: 13px; font-weight: 800; margin: 12px 0 7px; }
.name-input, .team-search, .readonly-link { width: 100%; min-height: 48px; border-radius: 16px; border: 1px solid rgba(255,255,255,.17); background: rgba(0,0,0,.22); color: var(--text); outline: 0; padding: 0 14px; font-weight: 750; }
.name-input:focus, .team-search:focus { border-color: rgba(48,231,255,.72); box-shadow: 0 0 0 4px rgba(48,231,255,.12); }
.team-toolbar { margin-top: 8px; }
.team-pill { align-self: flex-start; border: 1px solid rgba(255,255,255,.16); background: rgba(255,255,255,.07); border-radius: 999px; padding: 8px 10px; color: #eaf3ff; font-size: 12px; font-weight: 900; white-space: nowrap; display: inline-flex; align-items: center; gap: 7px; }
.teams-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 10px; max-height: 45dvh; overflow: auto; padding-right: 2px; }
.team-card { border: 1px solid rgba(255,255,255,.14); border-radius: 18px; background: linear-gradient(145deg, rgba(255,255,255,.1), rgba(255,255,255,.04)); color: var(--text); min-height: 76px; display: flex; align-items: center; gap: 10px; padding: 10px; cursor: pointer; text-align: left; position: relative; overflow: hidden; }
.team-card::before { content: ""; position: absolute; inset: auto 0 0; height: 5px; background: var(--c1); box-shadow: 0 -1px 18px var(--c1); }
.team-card.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(48,231,255,.16); }
.team-card.disabled,
.team-card:disabled {
    opacity: .45;
    cursor: not-allowed;
    filter: grayscale(.28);
}
.team-card.disabled::after,
.team-card:disabled::after {
    content: "Elegido";
    position: absolute;
    right: 8px;
    top: 8px;
    padding: 4px 7px;
    border-radius: 999px;
    background: rgba(255,255,255,.14);
    color: #eaf3ff;
    font-size: 10px;
    font-weight: 1000;
    letter-spacing: .02em;
}

.flag-badge { position: relative; display: inline-grid; place-items: center; overflow: hidden; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.22); box-shadow: inset 0 1px 0 rgba(255,255,255,.22), 0 8px 18px rgba(0,0,0,.18); flex: 0 0 auto; }
.flag-badge img { width: 100%; height: 100%; object-fit: cover; display: block; }
.flag-badge small { position: absolute; right: 2px; bottom: 1px; min-width: 16px; padding: 1px 3px; border-radius: 999px; background: rgba(2,10,22,.78); color: #fff; font-size: 7px; line-height: 1.1; font-weight: 1000; letter-spacing: .02em; text-shadow: 0 1px 1px rgba(0,0,0,.35); }
.team-flag { width: 48px; height: 34px; border-radius: 11px; }
.team-pill-flag { width: 28px; height: 20px; border-radius: 7px; }
.score-flag { width: 25px; height: 17px; border-radius: 5px; }
.score-flag small, .team-pill-flag small { display: none; }
.team-meta { min-width: 0; }
.team-name { font-weight: 950; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.team-group { color: var(--muted); font-size: 11px; margin-top: 2px; font-weight: 800; }
.muted { color: var(--muted); }
.centered { text-align: center; }

.code-box { font-size: clamp(28px, 13vw, 62px); font-weight: 1000; letter-spacing: .12em; text-align: center; padding: 18px 8px; border-radius: 20px; background: rgba(0,0,0,.22); border: 1px solid rgba(255,255,255,.14); margin: 14px 0; color: #baff33; text-shadow: 0 0 18px rgba(186,255,51,.35); }
.lobby-actions { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 12px; }
.waiting-pulse { display: flex; justify-content: center; gap: 9px; margin: 22px 0 4px; }
.waiting-pulse span { width: 12px; height: 12px; background: var(--accent); border-radius: 50%; animation: dots 1s infinite ease-in-out; }
.waiting-pulse span:nth-child(2) { animation-delay: .15s; }
.waiting-pulse span:nth-child(3) { animation-delay: .3s; }
@keyframes dots { 50% { opacity: .32; transform: translateY(-7px); } }
.spinner-ball { width: 112px; height: 112px; margin: 26px auto; display: grid; place-items: center; border-radius: 50%; font-size: 60px; background: rgba(255,255,255,.09); border: 1px solid var(--line); animation: spinBall .9s linear infinite; }
@keyframes spinBall { to { transform: rotate(360deg); } }

.game-screen { width: min(100%, 760px); }
.game-layout { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 8px; min-height: calc(100dvh - 84px); }
.scoreboard { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: 8px; }
.player-score { min-width: 0; display: grid; grid-template-columns: 14px 1fr auto; align-items: center; gap: 7px; background: rgba(0,0,0,.16); border: 1px solid rgba(255,255,255,.1); border-radius: 15px; padding: 8px; }
.player-score strong { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; min-width: 0; }
.player-score strong span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-score b { font-size: 25px; line-height: 1; }
.team-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--dot, #fff); box-shadow: 0 0 14px var(--dot, #fff); }
.match-status { text-align: center; min-width: 82px; }
#turnBadge { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--accent2); font-weight: 1000; margin-bottom: 2px; }
.timer-ring { width: 44px; height: 44px; display: grid; place-items: center; margin: auto; border-radius: 50%; border: 3px solid rgba(48,231,255,.72); background: rgba(0,0,0,.22); box-shadow: inset 0 0 12px rgba(48,231,255,.2); font-weight: 1000; }
.match-clock { display: inline-block; margin-top: 3px; padding: 2px 8px; border-radius: 999px; background: rgba(0,0,0,.24); border: 1px solid rgba(255,255,255,.12); color: #fff; font-size: 11px; font-weight: 1000; letter-spacing: .04em; }
.match-clock.danger { color: #ff416c; box-shadow: 0 0 16px rgba(255,65,108,.24); }
.canvas-wrap { position: relative; width: 100%; min-height: 0; display: grid; place-items: center; }
#gameCanvas { width: min(96vw, 560px, calc(62.5dvh - 124px)); height: auto; aspect-ratio: 10 / 16; max-height: 810px; border-radius: 24px; background: #42a92f; box-shadow: 0 30px 80px rgba(0,0,0,.42), inset 0 0 0 1px rgba(255,255,255,.2); cursor: crosshair; touch-action: none; display: block; }
.game-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; padding: 8px; }
.game-actions .ghost-btn { min-height: 44px; border-radius: 14px; padding: 8px 4px; font-size: 13px; }
.goal-overlay { position: absolute; inset: 0; display: grid; place-items: center; font-size: clamp(48px, 20vw, 120px); font-weight: 1000; color: #fff; text-shadow: 0 0 10px #30e7ff, 0 0 36px rgba(180,255,46,.8), 0 8px 0 rgba(0,0,0,.22); animation: goalPop 1.1s ease both; pointer-events: none; }
@keyframes goalPop { 0% { opacity: 0; transform: scale(.4) rotate(-8deg); } 18% { opacity: 1; transform: scale(1.12) rotate(2deg); } 70% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(1.5); } }
.finish-overlay, .modal { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: rgba(0,0,0,.52); padding: 16px; backdrop-filter: blur(8px); }
.finish-card, .modal-card { width: min(100%, 430px); padding: 20px; text-align: center; }
.finish-card h2, .modal-card h2 { font-size: 32px; }
.modal-card { position: relative; text-align: left; }
.modal-close { position: absolute; right: 12px; top: 12px; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: rgba(255,255,255,.1); color: #fff; font-size: 28px; cursor: pointer; }

.ranking-list { display: grid; gap: 8px; margin-top: 12px; }
.rank-row { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; padding: 12px; border-radius: 16px; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.06); }
.rank-pos { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 1000; background: rgba(255,255,255,.1); }
.rank-name { font-weight: 950; }
.rank-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.rank-rating { font-weight: 1000; color: var(--accent2); }
.toast { position: fixed; z-index: 20; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(calc(100vw - 24px), 460px); padding: 13px 16px; border-radius: 16px; background: rgba(5, 16, 34, .95); border: 1px solid rgba(255,255,255,.16); box-shadow: 0 18px 50px rgba(0,0,0,.45); color: #fff; text-align: center; font-weight: 850; }

@media (min-width: 720px) {
    .app-shell { padding: 18px; }
    .topbar { grid-template-columns: 100px 1fr 70px; margin-bottom: 14px; }
    .hero-card, .setup-card, .lobby-card, .queue-card, .ranking-card { padding: 28px; }
    .hero-card { min-height: calc(100dvh - 120px); }
    .home-actions { grid-template-columns: repeat(2, 1fr); max-width: 690px; }
    .teams-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); max-height: 52dvh; }
    .lobby-actions { grid-template-columns: 1fr 1fr; }
    .game-layout { min-height: calc(100dvh - 112px); }
    .scoreboard { padding: 10px; }
    .player-score strong { font-size: 14px; }
    #gameCanvas { width: min(92vw, 620px, calc(62.5dvh - 132px)); height: auto; }
}

@media (max-height: 720px) {
    .brand-ball { width: 38px; height: 38px; border-radius: 14px; }
    h1 { font-size: 17px; }
    .topbar { margin-bottom: 6px; }
    .teams-grid { max-height: 36dvh; }
    #gameCanvas { width: min(96vw, 560px, calc(62.5dvh - 109px)); height: auto; }
    .game-layout { gap: 6px; }
    .primary-btn, .secondary-btn, .ghost-btn { min-height: 44px; }
}

/* v15: home mobile-first polish */
.app-shell {
    overflow-x: hidden;
    overflow-y: auto;
}

#btnSound {
    width: 42px;
    height: 42px;
    min-width: 42px;
    min-height: 42px;
    padding: 0;
    border-radius: 999px;
    font-size: 19px;
    line-height: 1;
    justify-self: end;
    background: linear-gradient(145deg, rgba(255,255,255,.16), rgba(255,255,255,.055));
    box-shadow: inset 0 1px 0 rgba(255,255,255,.16), 0 8px 20px rgba(0,0,0,.22);
}

@media (max-width: 719px) {
    .app-shell {
        padding: max(8px, env(safe-area-inset-top)) 9px max(10px, env(safe-area-inset-bottom));
    }

    .stadium-glow {
        width: 210px;
        height: 210px;
        filter: blur(58px);
        opacity: .34;
    }

    .topbar {
        grid-template-columns: 42px minmax(0, 1fr) 42px;
        max-width: 100%;
        min-height: 52px;
        margin: 0 auto 8px;
        padding: 7px 8px;
        border: 1px solid rgba(255,255,255,.12);
        border-radius: 18px;
        background: linear-gradient(145deg, rgba(255,255,255,.10), rgba(255,255,255,.035)), rgba(6, 20, 43, .68);
        box-shadow: 0 12px 34px rgba(0,0,0,.24), inset 0 1px 0 rgba(255,255,255,.12);
        backdrop-filter: blur(14px);
        gap: 6px;
    }

    .brand-lockup {
        justify-content: center;
        gap: 7px;
        overflow: hidden;
    }

    .brand-ball {
        width: 32px;
        height: 32px;
        min-width: 32px;
        border-radius: 12px;
        font-size: 17px;
    }

    .brand-kicker {
        font-size: 8px;
        letter-spacing: .14em;
        line-height: 1;
    }

    h1 {
        font-size: clamp(15px, 4.8vw, 20px);
        letter-spacing: -.045em;
        line-height: 1.02;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .topbar .small:not(#btnSound) {
        min-height: 36px;
        padding: 0 8px;
        border-radius: 12px;
        font-size: 12px;
    }

    #btnSound {
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
        font-size: 17px;
    }

    .home-screen {
        width: 100%;
    }

    .hero-card {
        min-height: calc(100dvh - 70px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
        padding: 11px;
        gap: 9px;
        justify-content: start;
        border-radius: 22px;
    }

    .hero-field-preview {
        height: clamp(195px, 34dvh, 270px);
        min-height: 0;
        margin: 0 0 4px;
        border-radius: 20px;
        box-shadow: inset 0 0 0 2px rgba(255,255,255,.22), 0 14px 34px rgba(0,0,0,.20);
    }

    .hero-field-preview::before {
        inset: 22px 17%;
        border-width: 4px;
        border-radius: 14px;
    }

    .hero-field-preview::after {
        width: 92px;
        height: 92px;
        border-width: 4px;
    }

    .mini-puck {
        width: clamp(62px, 18vw, 76px);
        height: clamp(62px, 18vw, 76px);
        border-width: 6px;
        font-size: clamp(23px, 7vw, 30px);
    }

    .mini-puck-1 {
        left: 14%;
        bottom: 16%;
    }

    .mini-puck-2 {
        right: 11%;
        top: 16%;
    }

    .mini-ball {
        width: clamp(42px, 13vw, 52px);
        height: clamp(42px, 13vw, 52px);
        right: 18%;
        bottom: 34%;
        font-size: clamp(23px, 7vw, 30px);
    }

    .shot-line {
        left: 30%;
        bottom: 27%;
        width: 48%;
        height: 16px;
    }

    .hero-card h2 {
        margin: 2px 0 0;
        font-size: clamp(30px, 8.6vw, 38px);
        line-height: .94;
        letter-spacing: -.06em;
    }

    .hero-card p {
        margin: 0 0 2px;
        font-size: clamp(13px, 3.8vw, 15px);
        line-height: 1.32;
        max-width: 100%;
    }

    .home-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        margin-top: 3px;
    }

    .home-actions .primary-btn {
        grid-column: 1 / -1;
        min-height: 50px;
        border-radius: 16px;
        font-size: clamp(15px, 4.2vw, 17px);
    }

    .home-actions .secondary-btn,
    .home-actions .ghost-btn {
        min-height: 44px;
        border-radius: 15px;
        padding: 8px 9px;
        font-size: clamp(13px, 3.8vw, 15px);
        line-height: 1.1;
    }

    #btnOpenRanking {
        grid-column: 1 / -1;
        min-height: 40px;
        background: rgba(255,255,255,.07);
    }
}

@media (max-width: 719px) and (max-height: 720px) {
    .app-shell {
        padding-top: max(6px, env(safe-area-inset-top));
        padding-bottom: max(6px, env(safe-area-inset-bottom));
    }

    .topbar {
        min-height: 46px;
        padding: 5px 7px;
        margin-bottom: 6px;
    }

    .brand-ball {
        width: 28px;
        height: 28px;
        min-width: 28px;
        font-size: 15px;
    }

    #btnSound {
        width: 32px;
        height: 32px;
        min-width: 32px;
        min-height: 32px;
        font-size: 15px;
    }

    .hero-card {
        min-height: calc(100dvh - 58px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
        padding: 9px;
        gap: 7px;
    }

    .hero-field-preview {
        height: clamp(170px, 30dvh, 215px);
        border-radius: 18px;
    }

    .hero-card h2 {
        font-size: clamp(26px, 7.7vw, 32px);
    }

    .hero-card p {
        font-size: 13px;
        line-height: 1.24;
    }

    .home-actions {
        gap: 7px;
    }

    .home-actions .primary-btn {
        min-height: 46px;
    }

    .home-actions .secondary-btn,
    .home-actions .ghost-btn {
        min-height: 39px;
        border-radius: 13px;
        font-size: 13px;
    }

    #btnOpenRanking {
        min-height: 36px;
    }
}

@media (min-width: 720px) {
    #btnSound {
        width: 48px;
        height: 48px;
        min-width: 48px;
        min-height: 48px;
        font-size: 20px;
    }

    .hero-card h2 {
        max-width: 680px;
    }
}


/* v15: fixed internal topbar/brand placement inside Miljueguitos frame.
   When the back button is hidden, CSS grid auto-placement was putting the logo in
   the first tiny column, clipping "Miljueguitos / Fútbol de Chapitas" on mobile. */
.topbar > #btnBack {
    grid-column: 1;
}

.topbar > .brand-lockup {
    grid-column: 2;
    min-width: 0;
    width: 100%;
    justify-content: center;
    overflow: hidden;
}

.topbar > #btnSound {
    grid-column: 3;
}

.brand-lockup > div {
    min-width: 0;
    overflow: hidden;
}

.brand-lockup h1 {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 719px) {
    .topbar > .brand-lockup {
        justify-content: flex-start;
    }

    .brand-kicker {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

@media (max-width: 380px) {
    .brand-kicker {
        display: none;
    }

    .brand-ball {
        width: 30px;
        height: 30px;
        min-width: 30px;
    }

    h1 {
        font-size: clamp(15px, 4.5vw, 18px);
    }
}

/* v20: animated tutorial on the home screen explaining the slingshot shot */
.hero-field-preview {
    isolation: isolate;
}

.tutorial-badge {
    position: absolute;
    left: 12px;
    top: 12px;
    z-index: 6;
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(4, 14, 30, .62);
    border: 1px solid rgba(255,255,255,.18);
    color: #f2fbff;
    font-size: 11px;
    font-weight: 1000;
    letter-spacing: .09em;
    text-transform: uppercase;
    box-shadow: 0 10px 24px rgba(0,0,0,.22);
    backdrop-filter: blur(10px);
}

.tutorial-ring {
    position: absolute;
    left: 17%;
    bottom: 20%;
    width: 104px;
    height: 104px;
    z-index: 1;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,.24);
    box-shadow: 0 0 0 10px rgba(48,231,255,.08), 0 0 26px rgba(48,231,255,.16);
    animation: tutorialRingPulse 3.4s ease-in-out infinite;
}

.tutorial-ring-2 {
    left: auto;
    right: 13%;
    bottom: 31%;
    width: 74px;
    height: 74px;
    border-color: rgba(255,255,255,.18);
    box-shadow: 0 0 0 8px rgba(180,255,46,.07), 0 0 22px rgba(180,255,46,.12);
    animation-delay: 1.65s;
}

.drag-band,
.drag-pull-arrow,
.tutorial-hand,
.tutorial-callout {
    position: absolute;
    z-index: 6;
    pointer-events: none;
}

.drag-band {
    left: 18%;
    bottom: 26%;
    width: 74px;
    height: 8px;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(255,255,255,.08), rgba(48,231,255,.9), rgba(48,231,255,.1));
    transform-origin: 100% 50%;
    filter: blur(.2px) drop-shadow(0 0 8px rgba(48,231,255,.42));
    opacity: 0;
    animation: bandStretch 3.4s ease-in-out infinite;
}

.drag-pull-arrow {
    left: 11%;
    bottom: 18%;
    width: 54px;
    height: 20px;
    opacity: 0;
    animation: pullArrowCue 3.4s ease-in-out infinite;
}

.drag-pull-arrow::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    width: 42px;
    height: 0;
    border-top: 3px dashed rgba(255,255,255,.76);
    transform: translateY(-50%);
}

.drag-pull-arrow::after {
    content: "";
    position: absolute;
    left: -1px;
    top: 50%;
    width: 12px;
    height: 12px;
    border-left: 3px solid rgba(255,255,255,.9);
    border-bottom: 3px solid rgba(255,255,255,.9);
    transform: translateY(-50%) rotate(45deg);
}

.tutorial-hand {
    left: 20%;
    bottom: 13%;
    font-size: 26px;
    line-height: 1;
    filter: drop-shadow(0 6px 10px rgba(0,0,0,.28));
    animation: tutorialHandMove 3.4s ease-in-out infinite;
}

.tutorial-callout {
    padding: 8px 10px;
    border-radius: 14px;
    background: rgba(4, 14, 30, .68);
    border: 1px solid rgba(255,255,255,.14);
    color: #eef7ff;
    font-size: 12px;
    font-weight: 900;
    line-height: 1.1;
    box-shadow: 0 12px 28px rgba(0,0,0,.22);
    backdrop-filter: blur(10px);
    opacity: 0;
}

.tutorial-callout-drag {
    left: 10px;
    bottom: 12px;
    animation: dragCallout 3.4s ease-in-out infinite;
}

.tutorial-callout-release {
    right: 10px;
    top: 52%;
    max-width: 152px;
    text-align: right;
    animation: releaseCallout 3.4s ease-in-out infinite;
}

.hero-tutorial-copy {
    display: grid;
    gap: 6px;
    margin-top: -2px;
}

.hero-tip-pill {
    display: inline-flex;
    align-items: center;
    justify-self: start;
    min-height: 28px;
    padding: 0 12px;
    border-radius: 999px;
    background: rgba(48,231,255,.12);
    border: 1px solid rgba(48,231,255,.28);
    color: #dffcff;
    font-size: 11px;
    font-weight: 1000;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.hero-tutorial-copy p {
    margin: 0;
    color: #dfeafc;
    font-size: 14px;
    line-height: 1.35;
}

.hero-tutorial-copy strong {
    color: #fff;
}

.hero-field-preview .mini-puck,
.hero-field-preview .mini-ball,
.hero-field-preview .shot-line {
    z-index: 3;
}

.hero-field-preview .mini-puck-1 {
    animation: puckSlingshot 3.4s cubic-bezier(.2,.8,.22,1) infinite;
}

.hero-field-preview .mini-puck-2 {
    animation: opponentGuard 3.4s ease-in-out infinite;
}

.hero-field-preview .mini-ball {
    animation: tutorialBallKick 3.4s cubic-bezier(.2,.8,.22,1) infinite;
}

.hero-field-preview .shot-line {
    opacity: 0;
    animation: tutorialShotTrail 3.4s ease-in-out infinite;
}

@keyframes tutorialRingPulse {
    0%, 15%, 100% { opacity: .2; transform: scale(.94); }
    28%, 38% { opacity: .75; transform: scale(1.02); }
    55%, 70% { opacity: .28; transform: scale(.98); }
}

@keyframes bandStretch {
    0%, 16%, 100% { opacity: 0; transform: rotate(-18deg) scaleX(.25); }
    23%, 36% { opacity: 1; transform: rotate(-18deg) scaleX(1); }
    40%, 100% { opacity: 0; transform: rotate(-18deg) scaleX(.15); }
}

@keyframes pullArrowCue {
    0%, 16%, 100% { opacity: 0; transform: translate(10px,-8px); }
    22%, 36% { opacity: .95; transform: translate(0,0); }
    40%, 100% { opacity: 0; transform: translate(-8px,2px); }
}

@keyframes tutorialHandMove {
    0%, 14%, 100% { opacity: 0; transform: translate(0,0) scale(.95); }
    20% { opacity: 1; transform: translate(0,0) scale(1); }
    35% { opacity: 1; transform: translate(-34px,16px) scale(1.02); }
    43% { opacity: 0; transform: translate(18px,-10px) scale(.98); }
    100% { opacity: 0; }
}

@keyframes dragCallout {
    0%, 16%, 100% { opacity: 0; transform: translateY(8px); }
    22%, 38% { opacity: 1; transform: translateY(0); }
    43%, 100% { opacity: 0; transform: translateY(6px); }
}

@keyframes releaseCallout {
    0%, 42% { opacity: 0; transform: translateY(8px); }
    48%, 74% { opacity: 1; transform: translateY(0); }
    82%, 100% { opacity: 0; transform: translateY(-4px); }
}

@keyframes puckSlingshot {
    0%, 16%, 100% { transform: translate(0, 0) scale(1) rotate(0); }
    26% { transform: translate(-16px, 8px) scale(1.03) rotate(-6deg); }
    36% { transform: translate(-36px, 18px) scale(1.06) rotate(-10deg); }
    45% { transform: translate(40px, -16px) scale(1.01) rotate(8deg); }
    55% { transform: translate(52px, -22px) scale(1) rotate(5deg); }
    68% { transform: translate(18px, -8px) scale(1) rotate(1deg); }
    82% { transform: translate(2px, 0) scale(1) rotate(0); }
}

@keyframes tutorialBallKick {
    0%, 42%, 100% { transform: translate(0,0) scale(1); filter: brightness(1); }
    48% { transform: translate(14px, -6px) scale(1.08); filter: brightness(1.08); }
    58% { transform: translate(32px, -16px) scale(1.04); filter: brightness(1.12); }
    70% { transform: translate(20px, -10px) scale(1.02); filter: brightness(1.04); }
    82% { transform: translate(0,0) scale(1); filter: brightness(1); }
}

@keyframes tutorialShotTrail {
    0%, 37%, 100% { opacity: 0; transform: rotate(-16deg) scaleX(.6); }
    44% { opacity: .8; transform: rotate(-16deg) scaleX(1.06); }
    54% { opacity: 1; transform: rotate(-16deg) scaleX(1); }
    68% { opacity: .15; transform: rotate(-16deg) scaleX(.82); }
}

@keyframes opponentGuard {
    0%, 100% { transform: translateY(0) rotate(0); }
    24% { transform: translateY(-6px) rotate(3deg); }
    50% { transform: translate(-4px, 5px) rotate(-3deg); }
    76% { transform: translateY(-2px) rotate(2deg); }
}

@media (max-width: 719px) {
    .tutorial-badge {
        left: 10px;
        top: 10px;
        padding: 6px 10px;
        font-size: 10px;
    }

    .tutorial-ring {
        width: 82px;
        height: 82px;
        left: 16%;
        bottom: 18%;
    }

    .tutorial-ring-2 {
        width: 60px;
        height: 60px;
        right: 13%;
        bottom: 30%;
    }

    .drag-band {
        left: 18%;
        bottom: 24%;
        width: 58px;
        height: 7px;
    }

    .drag-pull-arrow {
        left: 10%;
        bottom: 16%;
        width: 44px;
    }

    .drag-pull-arrow::before {
        width: 34px;
        border-top-width: 2px;
    }

    .drag-pull-arrow::after {
        width: 10px;
        height: 10px;
        border-left-width: 2px;
        border-bottom-width: 2px;
    }

    .tutorial-hand {
        left: 20%;
        bottom: 11%;
        font-size: 22px;
    }

    .tutorial-callout {
        padding: 6px 8px;
        font-size: 11px;
        border-radius: 12px;
    }

    .tutorial-callout-drag {
        left: 8px;
        bottom: 8px;
    }

    .tutorial-callout-release {
        right: 8px;
        top: 50%;
        max-width: 126px;
    }

    .hero-tutorial-copy {
        gap: 5px;
    }

    .hero-tip-pill {
        min-height: 24px;
        padding: 0 9px;
        font-size: 9px;
        letter-spacing: .1em;
    }

    .hero-tutorial-copy p {
        font-size: 12.5px;
        line-height: 1.28;
    }
}

@media (max-width: 719px) and (max-height: 720px) {
    .hero-tutorial-copy p {
        font-size: 12px;
        line-height: 1.24;
    }

    .tutorial-callout {
        font-size: 10px;
    }
}


/* v63: optimización automática para celulares/PCs viejos.
   Se activa desde JS con <html class="perf-low">. También se puede forzar con:
   ?rendimiento=1 o localStorage.setItem('mgf_perf','low') */
.perf-low .stadium-glow {
    display: none;
}

.perf-low .glass-card,
.perf-low .topbar,
.perf-low .finish-overlay,
.perf-low .modal,
.perf-low .modal-card,
.perf-low .finish-card {
    backdrop-filter: none !important;
}

.perf-low .glass-card {
    box-shadow: 0 10px 26px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.10);
}

.perf-low .hero-field-preview,
.perf-low #gameCanvas {
    box-shadow: 0 12px 26px rgba(0,0,0,.28), inset 0 0 0 1px rgba(255,255,255,.16);
}

.perf-low .mini-puck-1,
.perf-low .mini-puck-2,
.perf-low .mini-ball,
.perf-low .shot-line,
.perf-low .tutorial-ring,
.perf-low .tutorial-ring-2,
.perf-low .tutorial-hand,
.perf-low .drag-band,
.perf-low .drag-pull-arrow,
.perf-low .tutorial-callout-drag,
.perf-low .tutorial-callout-release {
    animation-duration: 4.2s !important;
}

.perf-low .tutorial-ring,
.perf-low .tutorial-ring-2 {
    box-shadow: none;
}

.perf-low .primary-btn,
.perf-low .secondary-btn,
.perf-low .ghost-btn,
.perf-low #btnSound {
    transition: none;
}

@media (max-width: 719px) {
    .perf-low .hero-field-preview {
        height: clamp(160px, 28dvh, 220px);
    }
}


/* v63: botón manual para celulares lentos y modo ultra fluido */
.perf-floating-btn {
    position: fixed;
    z-index: 24;
    right: calc(12px + env(safe-area-inset-right));
    bottom: calc(14px + env(safe-area-inset-bottom));
    width: 42px;
    height: 42px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,.18);
    background: linear-gradient(145deg, rgba(48,231,255,.26), rgba(180,255,46,.18)), rgba(6,18,38,.86);
    color: #fff;
    box-shadow: 0 12px 32px rgba(0,0,0,.30), inset 0 1px 0 rgba(255,255,255,.18);
    font-weight: 1000;
    font-size: 18px;
    display: grid;
    place-items: center;
    cursor: pointer;
}

.perf-floating-btn.active {
    background: linear-gradient(135deg, #30e7ff, #b4ff2e);
    color: #041020;
}

.perf-ultra .stadium-glow,
.perf-ultra .tutorial-ring,
.perf-ultra .tutorial-ring-2,
.perf-ultra .tutorial-callout,
.perf-ultra .drag-pull-arrow {
    display: none !important;
}

.perf-ultra .glass-card,
.perf-ultra .topbar,
.perf-ultra .finish-overlay,
.perf-ultra .modal,
.perf-ultra .modal-card,
.perf-ultra .finish-card {
    backdrop-filter: none !important;
}

.perf-ultra .mini-puck-1,
.perf-ultra .mini-puck-2,
.perf-ultra .mini-ball,
.perf-ultra .shot-line,
.perf-ultra .tutorial-hand,
.perf-ultra .drag-band {
    animation: none !important;
}

.perf-ultra .glass-card,
.perf-ultra .hero-field-preview,
.perf-ultra #gameCanvas {
    box-shadow: 0 8px 20px rgba(0,0,0,.25), inset 0 0 0 1px rgba(255,255,255,.12) !important;
}

.perf-ultra .primary-btn,
.perf-ultra .secondary-btn,
.perf-ultra .ghost-btn,
.perf-ultra #btnSound,
.perf-ultra .perf-floating-btn {
    transition: none !important;
}

@media (max-width: 719px) {
    .perf-floating-btn {
        width: 38px;
        height: 38px;
        right: calc(8px + env(safe-area-inset-right));
        bottom: calc(10px + env(safe-area-inset-bottom));
        font-size: 16px;
    }

    .perf-ultra .hero-field-preview {
        height: clamp(145px, 25dvh, 190px);
    }
}


/* v63: mantener ratio de cancha 10:16 siempre.
   La optimización de performance baja DPR/calidad, pero nunca estira la cancha. */
@media (orientation: landscape) and (max-height: 520px) {
    #gameCanvas {
        width: min(92vw, 560px, calc(62.5dvh - 92px));
        height: auto;
    }

    .game-layout {
        min-height: auto;
        gap: 6px;
    }

    .scoreboard {
        padding: 6px;
    }

    .game-actions {
        padding: 6px;
    }
}

@media (max-height: 430px) {
    #gameCanvas {
        width: min(88vw, 460px, calc(62.5dvh - 74px));
        height: auto;
        border-radius: 18px;
    }

    .game-actions .ghost-btn {
        min-height: 34px;
        font-size: 12px;
    }

    .timer-ring {
        width: 36px;
        height: 36px;
    }
}


/* v63: darle más protagonismo a la cancha en mobile.
   Compacta el header interno, el marcador y los botones solo durante la pantalla de juego. */
@media (max-width: 719px) {
    .game-active .app-shell {
        padding-top: max(4px, env(safe-area-inset-top));
        padding-bottom: max(6px, env(safe-area-inset-bottom));
    }

    .game-active .topbar {
        min-height: 38px;
        padding: 4px 6px;
        margin-bottom: 5px;
        border-radius: 14px;
        grid-template-columns: 58px minmax(0, 1fr) 34px;
        gap: 5px;
    }

    .game-active .topbar .small:not(#btnSound) {
        min-height: 30px;
        height: 30px;
        padding: 0 7px;
        border-radius: 10px;
        font-size: 11px;
        line-height: 1;
    }

    .game-active .brand-ball {
        width: 26px;
        height: 26px;
        min-width: 26px;
        border-radius: 10px;
        font-size: 14px;
    }

    .game-active .brand-lockup {
        gap: 6px;
    }

    .game-active .brand-kicker {
        display: none;
    }

    .game-active h1 {
        font-size: clamp(14px, 4.2vw, 18px);
        line-height: 1;
        letter-spacing: -.04em;
    }

    .game-active #btnSound {
        width: 32px;
        height: 32px;
        min-width: 32px;
        min-height: 32px;
        font-size: 14px;
    }

    .game-active .game-layout {
        min-height: auto;
        gap: 5px;
        grid-template-rows: auto auto auto;
    }

    .game-active .scoreboard {
        padding: 5px;
        gap: 5px;
        border-radius: 14px;
    }

    .game-active .player-score {
        min-height: 42px;
        padding: 5px 7px;
        border-radius: 12px;
        grid-template-columns: 10px minmax(0, 1fr) auto;
        gap: 5px;
    }

    .game-active .player-score strong {
        font-size: 11px;
        gap: 4px;
    }

    .game-active .player-score b {
        font-size: 22px;
    }

    .game-active .team-dot {
        width: 10px;
        height: 10px;
    }

    .game-active .score-flag {
        width: 22px;
        height: 15px;
        border-radius: 5px;
    }

    .game-active .match-status {
        min-width: 54px;
    }

    .game-active #turnBadge {
        font-size: 9px;
        margin-bottom: 1px;
        letter-spacing: .07em;
    }

    .game-active .timer-ring {
        width: 34px;
        height: 34px;
        border-width: 3px;
        font-size: 13px;
    }

    .game-active .match-clock {
        margin-top: 1px;
        padding: 1px 7px;
        font-size: 10px;
    }

    .game-active #gameCanvas {
        width: min(97vw, 560px, calc(62.5dvh - 74px));
        height: auto;
        border-radius: 19px;
    }

    .game-active .game-actions {
        padding: 5px;
        gap: 5px;
        border-radius: 14px;
    }

    .game-active .game-actions .ghost-btn {
        min-height: 34px;
        border-radius: 11px;
        padding: 5px 4px;
        font-size: 11px;
    }
}

@media (max-width: 719px) and (max-height: 720px) {
    .game-active .topbar {
        min-height: 34px;
        padding: 3px 6px;
        margin-bottom: 4px;
    }

    .game-active .brand-ball {
        width: 23px;
        height: 23px;
        min-width: 23px;
        font-size: 12px;
    }

    .game-active h1 {
        font-size: 14px;
    }

    .game-active #btnSound {
        width: 28px;
        height: 28px;
        min-width: 28px;
        min-height: 28px;
        font-size: 12px;
    }

    .game-active .player-score {
        min-height: 36px;
    }

    .game-active .player-score b {
        font-size: 19px;
    }

    .game-active .timer-ring {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }

    .game-active #gameCanvas {
        width: min(97vw, 560px, calc(62.5dvh - 58px));
        height: auto;
        border-radius: 17px;
    }

    .game-active .game-actions .ghost-btn {
        min-height: 30px;
        font-size: 10px;
    }
}

@media (orientation: landscape) and (max-height: 520px) {
    .game-active #gameCanvas {
        width: min(92vw, 560px, calc(62.5dvh - 48px));
        height: auto;
    }

    .game-active .scoreboard,
    .game-active .game-actions {
        padding: 4px;
    }
}


/* v63: mobile gameplay must fit in one screen.
   Sacrificamos header/marcador/botones para priorizar la cancha.
   La cancha mantiene ratio 10:16 y se agranda hasta el máximo que entra. */
html.game-active,
html.game-active body {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden !important;
}

.game-active .app-shell {
    height: 100dvh;
    min-height: 0;
    max-height: 100dvh;
    overflow: hidden !important;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
}

.game-active main {
    min-height: 0;
    overflow: hidden;
}

.game-active .game-screen.active {
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.game-active .game-layout {
    height: 100%;
    min-height: 0;
    overflow: hidden;
    grid-template-rows: auto minmax(0, 1fr) auto;
}

.game-active .canvas-wrap {
    min-height: 0;
    height: 100%;
    overflow: hidden;
    align-content: center;
}

@media (max-width: 719px) {
    .game-active .app-shell {
        padding: max(2px, env(safe-area-inset-top)) 4px max(3px, env(safe-area-inset-bottom));
    }

    .game-active .topbar {
        min-height: 28px;
        height: 28px;
        padding: 2px 4px;
        margin: 0 auto 3px;
        border-radius: 11px;
        grid-template-columns: 46px minmax(0, 1fr) 26px;
        gap: 4px;
        box-shadow: 0 5px 14px rgba(0,0,0,.18), inset 0 1px 0 rgba(255,255,255,.08);
    }

    .game-active .topbar .small:not(#btnSound) {
        min-height: 24px;
        height: 24px;
        padding: 0 5px;
        border-radius: 8px;
        font-size: 0;
        line-height: 1;
    }

    .game-active .topbar .small:not(#btnSound)::after {
        content: "←";
        font-size: 16px;
        font-weight: 1000;
        line-height: 1;
    }

    .game-active .brand-ball {
        display: none;
    }

    .game-active .brand-lockup {
        justify-content: center;
        gap: 0;
        min-width: 0;
    }

    .game-active .brand-kicker {
        display: none;
    }

    .game-active h1 {
        font-size: clamp(12px, 3.5vw, 15px);
        line-height: 1;
        letter-spacing: -.03em;
        opacity: .92;
    }

    .game-active #btnSound {
        width: 24px;
        height: 24px;
        min-width: 24px;
        min-height: 24px;
        padding: 0;
        font-size: 11px;
        border-radius: 9px;
    }

    .game-active .game-layout {
        gap: 3px;
    }

    .game-active .scoreboard {
        padding: 3px;
        gap: 3px;
        border-radius: 11px;
        box-shadow: 0 7px 16px rgba(0,0,0,.20), inset 0 1px 0 rgba(255,255,255,.08);
    }

    .game-active .player-score {
        min-height: 30px;
        padding: 3px 5px;
        border-radius: 9px;
        grid-template-columns: 8px minmax(0, 1fr) auto;
        gap: 4px;
    }

    .game-active .player-score strong {
        font-size: 10px;
        gap: 3px;
    }

    .game-active .player-score b {
        font-size: 17px;
        line-height: 1;
    }

    .game-active .team-dot {
        width: 8px;
        height: 8px;
    }

    .game-active .score-flag {
        width: 18px;
        height: 12px;
        border-radius: 4px;
    }

    .game-active .match-status {
        min-width: 42px;
    }

    .game-active #turnBadge {
        display: none;
    }

    .game-active .timer-ring {
        width: 28px;
        height: 28px;
        border-width: 2px;
        font-size: 11px;
        margin: 0 auto;
    }

    .game-active .match-clock {
        margin-top: 0;
        padding: 0 5px;
        font-size: 9px;
        line-height: 15px;
    }

    .game-active #gameCanvas {
        width: min(99vw, 620px, calc((100dvh - 74px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * 0.625));
        height: auto;
        border-radius: 16px;
        box-shadow: 0 10px 24px rgba(0,0,0,.32), inset 0 0 0 1px rgba(255,255,255,.16);
    }

    .game-active .game-actions {
        padding: 3px;
        gap: 3px;
        border-radius: 11px;
        box-shadow: 0 6px 14px rgba(0,0,0,.20), inset 0 1px 0 rgba(255,255,255,.08);
    }

    .game-active .game-actions .ghost-btn {
        min-height: 24px;
        height: 24px;
        border-radius: 8px;
        padding: 2px 3px;
        font-size: 10px;
        line-height: 1;
    }

    .game-active #btnSurrender {
        font-size: 0;
    }

    .game-active #btnSurrender::after {
        content: "Salir";
        font-size: 10px;
    }

    .game-active #btnShareMatch {
        font-size: 0;
    }

    .game-active #btnShareMatch::after {
        content: "Share";
        font-size: 10px;
    }

    .game-active #btnHow {
        font-size: 0;
    }

    .game-active #btnHow::after {
        content: "?";
        font-size: 13px;
        font-weight: 1000;
    }

    .game-active .perf-floating-btn {
        width: 32px;
        height: 32px;
        right: calc(5px + env(safe-area-inset-right));
        bottom: calc(5px + env(safe-area-inset-bottom));
        font-size: 14px;
        opacity: .78;
    }
}

@media (max-width: 719px) and (max-height: 720px) {
    .game-active .app-shell {
        padding-top: max(1px, env(safe-area-inset-top));
        padding-bottom: max(2px, env(safe-area-inset-bottom));
    }

    .game-active .topbar {
        min-height: 24px;
        height: 24px;
        margin-bottom: 2px;
    }

    .game-active h1 {
        font-size: 12px;
    }

    .game-active #btnSound {
        width: 21px;
        height: 21px;
        min-width: 21px;
        min-height: 21px;
        font-size: 10px;
    }

    .game-active .player-score {
        min-height: 27px;
    }

    .game-active .player-score strong {
        font-size: 9px;
    }

    .game-active .player-score b {
        font-size: 15px;
    }

    .game-active .timer-ring {
        width: 24px;
        height: 24px;
        font-size: 10px;
    }

    .game-active .match-clock {
        display: none;
    }

    .game-active .game-actions .ghost-btn {
        min-height: 21px;
        height: 21px;
        font-size: 9px;
    }

    .game-active #gameCanvas {
        width: min(99vw, 620px, calc((100dvh - 58px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * 0.625));
        height: auto;
        border-radius: 14px;
    }
}

@media (orientation: landscape) and (max-height: 520px) {
    .game-active .topbar {
        display: none;
    }

    .game-active .app-shell {
        grid-template-rows: minmax(0, 1fr);
    }

    .game-active #gameCanvas {
        width: min(90vw, 560px, calc((100dvh - 50px) * 0.625));
        height: auto;
    }

    .game-active .scoreboard {
        padding: 2px;
    }

    .game-active .game-actions {
        padding: 2px;
    }
}


/* v63: Modo Torneo */
.tournament-card {
    padding: 18px;
}

.tournament-status {
    display: grid;
    gap: 10px;
    margin: 8px 0 14px;
}

.tournament-hero-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px;
    border-radius: 16px;
    background: rgba(255,255,255,.07);
    border: 1px solid rgba(255,255,255,.12);
}

.tournament-next,
.tournament-result {
    margin: 0;
    color: #dce8ff;
    font-weight: 750;
}

.tournament-result.champion {
    color: var(--accent2);
}

.tournament-result.eliminated {
    color: #ffd4dc;
}

.tournament-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 14px;
}

.tournament-grid {
    display: grid;
    gap: 14px;
}

.tournament-grid h3 {
    margin: 0 0 8px;
    font-size: 18px;
}

.tournament-table,
.tournament-bracket {
    display: grid;
    gap: 7px;
}

.tg-row {
    display: grid;
    grid-template-columns: 1fr 44px 44px 44px;
    align-items: center;
    gap: 6px;
    min-height: 38px;
    padding: 8px 10px;
    border-radius: 13px;
    background: rgba(255,255,255,.055);
    border: 1px solid rgba(255,255,255,.10);
}

.tg-row span {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-weight: 850;
}

.tg-row b {
    text-align: center;
}

.tg-head {
    min-height: 28px;
    color: var(--accent2);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: .08em;
    background: rgba(0,0,0,.18);
}

.tg-row.you {
    border-color: rgba(48,231,255,.42);
    box-shadow: inset 0 0 0 1px rgba(48,231,255,.12);
}

.tb-stage {
    padding: 10px;
    border-radius: 16px;
    background: rgba(255,255,255,.055);
    border: 1px solid rgba(255,255,255,.10);
}

.tb-stage h4 {
    margin: 0 0 8px;
    color: var(--accent2);
}

.tb-stage p {
    margin: 0;
    color: var(--muted);
}

.tb-match {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 6px;
    padding: 7px 0;
    border-top: 1px solid rgba(255,255,255,.08);
}

.tb-match:first-of-type {
    border-top: 0;
}

.tb-match span {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 800;
}

.tb-match b,
.tb-match em {
    font-size: 12px;
    white-space: nowrap;
    text-align: center;
}

.tb-match small {
    grid-column: 1 / -1;
    color: var(--muted);
    font-size: 11px;
}

.tb-match.user {
    color: #fff;
}

.tournament-note {
    margin: 14px 0 0;
    font-size: 12px;
}

@media (min-width: 720px) {
    .tournament-grid {
        grid-template-columns: minmax(280px, .8fr) 1.2fr;
        align-items: start;
    }

    .tournament-card {
        padding: 24px;
    }
}

@media (max-width: 719px) {
    .tournament-card {
        padding: 12px;
    }

    .tournament-title-row {
        align-items: center;
    }

    .tournament-actions {
        grid-template-columns: 1fr;
    }

    .tg-row {
        grid-template-columns: 1fr 34px 34px 34px;
        padding: 7px 8px;
    }

    .tb-match {
        grid-template-columns: minmax(0, 1fr) 44px minmax(0, 1fr);
    }
}


/* v63: desktop gameplay más protagonista.
   Compacta header/marcador/botones también en desktop y agranda la cancha
   sin romper el ratio 10:16. */
@media (min-width: 720px) {
    .game-active .app-shell {
        padding: max(6px, env(safe-area-inset-top)) 10px max(7px, env(safe-area-inset-bottom));
        height: 100dvh;
        max-height: 100dvh;
        overflow: hidden !important;
    }

    .game-active .topbar {
        max-width: 760px;
        min-height: 38px;
        height: 38px;
        margin: 0 auto 5px;
        padding: 4px 7px;
        border-radius: 13px;
        grid-template-columns: 58px minmax(0, 1fr) 34px;
        gap: 6px;
        box-shadow: 0 7px 20px rgba(0,0,0,.22), inset 0 1px 0 rgba(255,255,255,.10);
    }

    .game-active .topbar .small:not(#btnSound) {
        min-height: 30px;
        height: 30px;
        padding: 0 7px;
        border-radius: 10px;
        font-size: 11px;
    }

    .game-active .brand-lockup {
        justify-content: center;
        gap: 6px;
    }

    .game-active .brand-ball {
        width: 26px;
        height: 26px;
        min-width: 26px;
        border-radius: 10px;
        font-size: 14px;
    }

    .game-active .brand-kicker {
        display: none;
    }

    .game-active h1 {
        font-size: 17px;
        line-height: 1;
        letter-spacing: -.035em;
    }

    .game-active #btnSound {
        width: 30px;
        height: 30px;
        min-width: 30px;
        min-height: 30px;
        padding: 0;
        border-radius: 10px;
        font-size: 13px;
    }

    .game-active .game-layout {
        width: min(96vw, 760px);
        max-width: 760px;
        margin: 0 auto;
        height: calc(100dvh - 56px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
        min-height: 0;
        gap: 5px;
        grid-template-rows: auto minmax(0, 1fr) auto;
    }

    .game-active .scoreboard {
        padding: 5px;
        gap: 6px;
        border-radius: 14px;
        box-shadow: 0 8px 24px rgba(0,0,0,.24), inset 0 1px 0 rgba(255,255,255,.10);
    }

    .game-active .player-score {
        min-height: 42px;
        padding: 5px 8px;
        border-radius: 12px;
        grid-template-columns: 10px minmax(0, 1fr) auto;
        gap: 6px;
    }

    .game-active .player-score strong {
        font-size: 12px;
        gap: 5px;
    }

    .game-active .player-score b {
        font-size: 25px;
        line-height: 1;
    }

    .game-active .team-dot {
        width: 10px;
        height: 10px;
    }

    .game-active .score-flag {
        width: 24px;
        height: 16px;
        border-radius: 5px;
    }

    .game-active .match-status {
        min-width: 60px;
    }

    .game-active #turnBadge {
        font-size: 9px;
        margin-bottom: 1px;
        letter-spacing: .08em;
    }

    .game-active .timer-ring {
        width: 38px;
        height: 38px;
        border-width: 3px;
        font-size: 14px;
    }

    .game-active .match-clock {
        margin-top: 1px;
        padding: 1px 8px;
        font-size: 10px;
        line-height: 16px;
    }

    .game-active .canvas-wrap {
        min-height: 0;
        height: 100%;
        display: grid;
        place-items: center;
        overflow: hidden;
    }

    .game-active #gameCanvas {
        width: min(96vw, 720px, calc((100dvh - 136px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * 0.625));
        height: auto;
        max-height: none;
        border-radius: 20px;
        box-shadow: 0 16px 42px rgba(0,0,0,.34), inset 0 0 0 1px rgba(255,255,255,.16);
    }

    .game-active .game-actions {
        padding: 4px;
        gap: 5px;
        border-radius: 13px;
        box-shadow: 0 7px 18px rgba(0,0,0,.20), inset 0 1px 0 rgba(255,255,255,.08);
    }

    .game-active .game-actions .ghost-btn {
        min-height: 30px;
        height: 30px;
        border-radius: 10px;
        padding: 4px 6px;
        font-size: 11px;
    }
}

/* Desktop bajo o notebooks: apretamos más todavía para que no se coma la cancha. */
@media (min-width: 720px) and (max-height: 760px) {
    .game-active .topbar {
        min-height: 30px;
        height: 30px;
        margin-bottom: 3px;
        padding: 3px 6px;
    }

    .game-active .topbar .small:not(#btnSound) {
        min-height: 24px;
        height: 24px;
        font-size: 10px;
    }

    .game-active .brand-ball {
        width: 22px;
        height: 22px;
        min-width: 22px;
        font-size: 12px;
    }

    .game-active h1 {
        font-size: 14px;
    }

    .game-active #btnSound {
        width: 24px;
        height: 24px;
        min-width: 24px;
        min-height: 24px;
        font-size: 11px;
    }

    .game-active .game-layout {
        height: calc(100dvh - 39px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
        gap: 3px;
    }

    .game-active .scoreboard {
        padding: 3px;
        gap: 4px;
    }

    .game-active .player-score {
        min-height: 32px;
        padding: 3px 6px;
    }

    .game-active .player-score strong {
        font-size: 10px;
    }

    .game-active .player-score b {
        font-size: 19px;
    }

    .game-active #turnBadge {
        display: none;
    }

    .game-active .timer-ring {
        width: 30px;
        height: 30px;
        font-size: 11px;
        border-width: 2px;
    }

    .game-active .match-clock {
        display: none;
    }

    .game-active #gameCanvas {
        width: min(96vw, 700px, calc((100dvh - 78px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * 0.625));
        border-radius: 17px;
    }

    .game-active .game-actions {
        padding: 3px;
        gap: 4px;
    }

    .game-active .game-actions .ghost-btn {
        min-height: 24px;
        height: 24px;
        font-size: 10px;
    }
}

/* Monitores anchos: permitimos un poco más de escala de cancha. */
@media (min-width: 1100px) and (min-height: 820px) {
    .game-active .topbar,
    .game-active .game-layout {
        max-width: 840px;
        width: min(94vw, 840px);
    }

    .game-active #gameCanvas {
        width: min(94vw, 760px, calc((100dvh - 136px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * 0.625));
    }
}


/* v63: fixture/previa torneo corregidos */
.tournament-subline {
    margin: -4px 0 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 650;
}

.tournament-next-card {
    padding: 14px;
    border-radius: 18px;
    background: linear-gradient(145deg, rgba(48,231,255,.15), rgba(180,255,46,.08)), rgba(255,255,255,.06);
    border: 1px solid rgba(48,231,255,.24);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.12);
}

.tournament-next-card h3 {
    margin: 3px 0 12px;
    font-size: 20px;
}

.next-versus {
    display: grid;
    grid-template-columns: minmax(0,1fr) auto minmax(0,1fr);
    align-items: center;
    gap: 10px;
}

.next-versus span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-weight: 900;
}

.next-versus b {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: rgba(0,0,0,.24);
    color: var(--accent2);
    border: 1px solid rgba(255,255,255,.12);
}

.fixture-highlight {
    border-color: rgba(180,255,46,.20);
    background: rgba(180,255,46,.055);
}

.tb-match em {
    color: var(--accent2);
    font-style: normal;
    opacity: .92;
}

@media (max-width: 719px) {
    .next-versus {
        grid-template-columns: 1fr;
        text-align: center;
        justify-items: center;
    }

    .next-versus b {
        width: 36px;
        height: 30px;
    }

    .tournament-next-card {
        padding: 11px;
    }
}


/* v63: estética de cancha tipo mesa de chapitas */
.game-active #gameCanvas {
    box-shadow:
        0 18px 40px rgba(0,0,0,.36),
        0 0 0 1px rgba(197,255,92,.12),
        inset 0 0 0 1px rgba(255,255,255,.06);
}


/* v63: desktop fit - hacer que toda la cancha entre en pantalla.
   Compactamos más header, scoreboard y acciones en desktop para que no se corte. */
@media (min-width: 720px) {
    .game-active .app-shell {
        padding: max(4px, env(safe-area-inset-top)) 8px max(5px, env(safe-area-inset-bottom));
        gap: 0;
    }

    .game-active .topbar {
        max-width: 720px;
        min-height: 32px;
        height: 32px;
        margin: 0 auto 4px;
        padding: 3px 6px;
        border-radius: 12px;
        grid-template-columns: 52px minmax(0, 1fr) 30px;
        gap: 5px;
    }

    .game-active .topbar .small:not(#btnSound) {
        min-height: 26px;
        height: 26px;
        padding: 0 6px;
        font-size: 10px;
        border-radius: 9px;
    }

    .game-active .brand-lockup {
        gap: 6px;
    }

    .game-active .brand-ball {
        width: 22px;
        height: 22px;
        min-width: 22px;
        font-size: 12px;
    }

    .game-active h1 {
        font-size: 15px;
        line-height: 1;
        letter-spacing: -.03em;
    }

    .game-active #btnSound {
        width: 26px;
        height: 26px;
        min-width: 26px;
        min-height: 26px;
        font-size: 12px;
        border-radius: 9px;
    }

    .game-active .game-layout {
        width: min(94vw, 720px);
        max-width: 720px;
        height: calc(100dvh - 40px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
        gap: 4px;
        grid-template-rows: auto minmax(0, 1fr) auto;
        margin: 0 auto;
    }

    .game-active .scoreboard {
        padding: 4px;
        gap: 4px;
        border-radius: 12px;
    }

    .game-active .player-score {
        min-height: 34px;
        padding: 4px 7px;
        border-radius: 10px;
        gap: 5px;
    }

    .game-active .player-score strong {
        font-size: 11px;
        gap: 4px;
    }

    .game-active .player-score b {
        font-size: 22px;
        line-height: 1;
    }

    .game-active .team-dot {
        width: 9px;
        height: 9px;
    }

    .game-active .score-flag {
        width: 22px;
        height: 15px;
        border-radius: 4px;
    }

    .game-active .match-status {
        min-width: 54px;
    }

    .game-active #turnBadge {
        font-size: 9px;
        margin-bottom: 1px;
        line-height: 1;
    }

    .game-active .timer-ring {
        width: 34px;
        height: 34px;
        border-width: 3px;
        font-size: 12px;
    }

    .game-active .match-clock {
        margin-top: 0;
        padding: 1px 7px;
        font-size: 10px;
        line-height: 14px;
    }

    .game-active .canvas-wrap {
        min-height: 0;
        height: 100%;
        overflow: hidden;
        display: grid;
        place-items: center;
    }

    .game-active #gameCanvas {
        width: min(92vw, 660px, calc((100dvh - 154px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * 0.625));
        height: auto;
        max-height: none;
        border-radius: 18px;
    }

    .game-active .game-actions {
        padding: 3px;
        gap: 4px;
        border-radius: 12px;
    }

    .game-active .game-actions .ghost-btn {
        min-height: 28px;
        height: 28px;
        font-size: 10px;
        border-radius: 9px;
        padding: 4px 6px;
    }
}

@media (min-width: 720px) and (max-height: 860px) {
    .game-active .topbar {
        min-height: 28px;
        height: 28px;
        margin-bottom: 3px;
        padding: 2px 6px;
    }

    .game-active .topbar .small:not(#btnSound) {
        min-height: 22px;
        height: 22px;
        font-size: 10px;
    }

    .game-active .brand-ball {
        width: 20px;
        height: 20px;
        min-width: 20px;
        font-size: 11px;
    }

    .game-active h1 {
        font-size: 14px;
    }

    .game-active #btnSound {
        width: 22px;
        height: 22px;
        min-width: 22px;
        min-height: 22px;
        font-size: 11px;
    }

    .game-active .game-layout {
        width: min(94vw, 700px);
        max-width: 700px;
        height: calc(100dvh - 34px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
        gap: 3px;
    }

    .game-active .scoreboard {
        padding: 3px;
        gap: 3px;
    }

    .game-active .player-score {
        min-height: 30px;
        padding: 3px 6px;
    }

    .game-active .player-score strong {
        font-size: 10px;
    }

    .game-active .player-score b {
        font-size: 18px;
    }

    .game-active #turnBadge {
        display: none;
    }

    .game-active .timer-ring {
        width: 28px;
        height: 28px;
        border-width: 2px;
        font-size: 10px;
    }

    .game-active .match-clock {
        display: none;
    }

    .game-active #gameCanvas {
        width: min(92vw, 620px, calc((100dvh - 118px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * 0.625));
        border-radius: 16px;
    }

    .game-active .game-actions {
        padding: 2px;
        gap: 3px;
    }

    .game-active .game-actions .ghost-btn {
        min-height: 24px;
        height: 24px;
        font-size: 10px;
        padding: 3px 6px;
    }
}

@media (min-width: 1200px) and (min-height: 900px) {
    .game-active .game-layout,
    .game-active .topbar {
        width: min(92vw, 760px);
        max-width: 760px;
    }

    .game-active #gameCanvas {
        width: min(92vw, 700px, calc((100dvh - 160px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * 0.625));
    }
}


/* v63: Timer general central + mini timer de turno dentro del jugador activo */
.scoreboard {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
}

.player-score {
    position: relative;
    grid-template-columns: 14px minmax(0, 1fr) auto auto;
    transition: border-color .16s ease, box-shadow .16s ease, background .16s ease, transform .16s ease;
}

.turn-mini-timer {
    min-width: 30px;
    height: 26px;
    padding: 0 7px;
    border-radius: 999px;
    display: none;
    place-items: center;
    font-size: 12px;
    font-weight: 1000;
    color: #061325;
    background: linear-gradient(135deg, #30e7ff, #b4ff2e);
    border: 1px solid rgba(255,255,255,.26);
    box-shadow: 0 0 16px rgba(48,231,255,.28), inset 0 1px 0 rgba(255,255,255,.35);
}

.turn-mini-timer.active {
    display: grid;
}

.turn-mini-timer.danger {
    background: linear-gradient(135deg, #ff416c, #ffcc33);
    color: #fff;
    box-shadow: 0 0 18px rgba(255,65,108,.42);
}

.player-score.active-turn {
    border-color: rgba(180,255,46,.66);
    background: linear-gradient(145deg, rgba(180,255,46,.16), rgba(48,231,255,.07)), rgba(0,0,0,.22);
    box-shadow:
        0 0 0 2px rgba(180,255,46,.18),
        0 0 24px rgba(180,255,46,.16),
        inset 0 1px 0 rgba(255,255,255,.16);
}

.player-score.active-turn::after {
    content: "";
    position: absolute;
    inset: -3px;
    border-radius: inherit;
    border: 2px solid rgba(180,255,46,.28);
    pointer-events: none;
}

.match-status {
    min-width: 72px;
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 3px;
}

#turnBadge {
    margin: 0;
    line-height: 1;
}

.timer-ring {
    display: none;
}

.match-clock-main,
.game-active .match-clock-main {
    display: inline-grid !important;
    place-items: center;
    min-width: 56px;
    height: 30px;
    margin: 0;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 13px;
    background: rgba(0,0,0,.34);
    border: 1px solid rgba(255,255,255,.18);
    box-shadow: inset 0 0 12px rgba(48,231,255,.16), 0 8px 18px rgba(0,0,0,.22);
}

.game-active #turnBadge {
    display: block !important;
}

@media (max-width: 719px) {
    .game-active .scoreboard {
        grid-template-columns: minmax(0, 1fr) 54px minmax(0, 1fr);
        gap: 3px;
    }

    .game-active .player-score {
        grid-template-columns: 8px minmax(0, 1fr) auto auto;
        min-height: 30px;
        padding: 3px 5px;
    }

    .game-active .player-score strong {
        font-size: 9.5px;
        gap: 3px;
    }

    .game-active .player-score b {
        font-size: 15px;
    }

    .game-active .turn-mini-timer {
        min-width: 24px;
        height: 21px;
        padding: 0 5px;
        font-size: 10px;
    }

    .game-active .match-status {
        min-width: 50px;
        gap: 1px;
    }

    .game-active #turnBadge {
        font-size: 7px;
        letter-spacing: .08em;
        display: block !important;
    }

    .game-active .match-clock-main {
        min-width: 45px;
        height: 23px;
        padding: 0 5px;
        font-size: 10px;
        line-height: 1;
    }

    .game-active .match-clock {
        display: inline-grid !important;
    }
}

@media (max-width: 719px) and (max-height: 720px) {
    .game-active .scoreboard {
        grid-template-columns: minmax(0, 1fr) 48px minmax(0, 1fr);
    }

    .game-active .player-score {
        min-height: 26px;
        padding: 2px 4px;
    }

    .game-active .score-flag {
        width: 16px;
        height: 11px;
    }

    .game-active .turn-mini-timer {
        min-width: 22px;
        height: 18px;
        padding: 0 4px;
        font-size: 9px;
    }

    .game-active .match-clock-main {
        min-width: 42px;
        height: 20px;
        font-size: 9px;
    }
}

@media (min-width: 720px) {
    .game-active .player-score {
        grid-template-columns: 10px minmax(0, 1fr) auto auto;
    }

    .game-active .match-status {
        min-width: 64px;
    }

    .game-active .match-clock-main {
        min-width: 56px;
        height: 28px;
        font-size: 12px;
    }

    .game-active .turn-mini-timer {
        min-width: 28px;
        height: 24px;
        font-size: 11px;
    }
}

@media (min-width: 720px) and (max-height: 860px) {
    .game-active .match-status {
        min-width: 54px;
    }

    .game-active .match-clock-main {
        min-width: 48px;
        height: 22px;
        font-size: 10px;
        padding: 0 6px;
    }

    .game-active .turn-mini-timer {
        min-width: 24px;
        height: 20px;
        font-size: 10px;
    }
}


/* v63: botones de torneo en menú principal */
.tournament-continue-btn {
    background: linear-gradient(135deg, rgba(180,255,46,.96), rgba(48,231,255,.92));
    color: #061325;
    border-color: rgba(255,255,255,.35);
    box-shadow: 0 14px 36px rgba(48,231,255,.20), inset 0 1px 0 rgba(255,255,255,.34);
}

.tournament-home-btn {
    position: relative;
}


/* v63: cuadro visual de eliminatorias */
.tournament-grid.knockout-mode {
    grid-template-columns: minmax(0, 1fr);
}

.tournament-grid.knockout-mode .tournament-group-panel {
    display: none;
}

.tournament-grid.knockout-mode .tournament-bracket-panel {
    min-width: 0;
}

.wc-bracket-shell {
    display: grid;
    gap: 10px;
    min-width: 0;
}

.wc-bracket-topline {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 18px;
    background:
        radial-gradient(circle at 10% 0%, rgba(180,255,46,.18), transparent 42%),
        linear-gradient(135deg, rgba(48,231,255,.10), rgba(255,255,255,.035));
    border: 1px solid rgba(255,255,255,.12);
}

.wc-bracket-topline h3 {
    margin: 2px 0 0;
    font-size: clamp(18px, 3vw, 25px);
    letter-spacing: -.04em;
}

.wc-swipe-hint {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
}

.wc-bracket-toolbar {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 2px 1px 5px;
    scrollbar-width: none;
}

.wc-bracket-toolbar::-webkit-scrollbar {
    display: none;
}

.wc-round-chip {
    min-height: 34px;
    padding: 6px 11px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,.12);
    background: rgba(255,255,255,.055);
    color: #dce8ff;
    font-weight: 900;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    cursor: pointer;
}

.wc-round-chip.active {
    color: #061325;
    background: linear-gradient(135deg, #30e7ff, #b4ff2e);
    border-color: rgba(255,255,255,.35);
    box-shadow: 0 8px 24px rgba(48,231,255,.20);
}

.wc-round-chip.done b {
    color: #b4ff2e;
}

.wc-round-chip.active.done b {
    color: #061325;
}

.wc-bracket-scroll {
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    scrollbar-color: rgba(48,231,255,.42) rgba(255,255,255,.04);
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,.11);
    background:
        radial-gradient(circle at 50% 10%, rgba(48,231,255,.09), transparent 34%),
        linear-gradient(180deg, rgba(5,16,35,.92), rgba(5,12,27,.98));
    box-shadow: inset 0 1px 0 rgba(255,255,255,.05), 0 18px 40px rgba(0,0,0,.22);
}

.wc-bracket-board {
    --column-width: 220px;
    --connector-width: 34px;
    display: flex;
    align-items: stretch;
    gap: 50px;
    min-width: max-content;
    padding: 18px 36px 22px 18px;
}

.wc-round-column {
    width: var(--column-width);
    flex: 0 0 var(--column-width);
    scroll-snap-align: center;
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 10px;
    border-radius: 18px;
    padding: 8px;
    transition: background .2s ease, box-shadow .2s ease;
}

.wc-round-column.current-round {
    background: rgba(48,231,255,.055);
    box-shadow: inset 0 0 0 1px rgba(48,231,255,.15);
}

.wc-round-header {
    min-height: 48px;
    display: grid;
    align-content: center;
    gap: 1px;
    padding: 7px 9px;
    border-radius: 13px;
    background: linear-gradient(135deg, rgba(255,255,255,.095), rgba(255,255,255,.035));
    border: 1px solid rgba(255,255,255,.11);
}

.wc-round-header span {
    font-size: 14px;
    font-weight: 1000;
    color: #fff;
}

.wc-round-header small {
    color: var(--muted);
    font-size: 10px;
    font-weight: 750;
}

.wc-round-pairs {
    min-height: 1060px;
    display: flex;
    flex-direction: column;
}

.wc-pair {
    position: relative;
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    gap: 8px;
}

.wc-pair.single {
    justify-content: center;
}

.wc-pair.has-connector::after {
    content: "";
    position: absolute;
    right: calc(var(--connector-width) * -0.55);
    top: 25%;
    bottom: 25%;
    width: 2px;
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(48,231,255,.12), rgba(180,255,46,.55), rgba(48,231,255,.12));
}

.wc-pair.has-connector::before {
    content: "";
    position: absolute;
    right: calc(var(--connector-width) * -1.5);
    top: 50%;
    width: calc(var(--connector-width) * .95);
    height: 2px;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(180,255,46,.55), rgba(48,231,255,.16));
}

.wc-match-card {
    position: relative;
    z-index: 1;
    display: grid;
    gap: 3px;
    min-height: 58px;
    padding: 6px;
    border-radius: 13px;
    color: #dce8ff;
    background: linear-gradient(145deg, rgba(255,255,255,.075), rgba(255,255,255,.025));
    border: 1px solid rgba(255,255,255,.12);
    box-shadow: 0 7px 18px rgba(0,0,0,.18), inset 0 1px 0 rgba(255,255,255,.06);
}

.wc-pair.has-connector .wc-match-card::after {
    content: "";
    position: absolute;
    right: calc(var(--connector-width) * -0.55);
    top: 50%;
    width: calc(var(--connector-width) * .55);
    height: 2px;
    background: rgba(180,255,46,.46);
}

.wc-match-card.placeholder {
    opacity: .42;
    border-style: dashed;
}

.wc-match-card.user-path {
    border-color: rgba(48,231,255,.48);
    box-shadow:
        0 0 0 1px rgba(48,231,255,.10),
        0 8px 22px rgba(48,231,255,.10),
        inset 0 1px 0 rgba(255,255,255,.10);
}

.wc-match-card.current-match {
    border-color: rgba(180,255,46,.76);
    background: linear-gradient(145deg, rgba(180,255,46,.18), rgba(48,231,255,.075));
    box-shadow:
        0 0 0 2px rgba(180,255,46,.12),
        0 0 26px rgba(180,255,46,.18),
        inset 0 1px 0 rgba(255,255,255,.15);
}

.wc-match-number {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 5px;
    padding: 0 2px 2px;
    color: var(--muted);
    font-size: 8px;
    font-weight: 850;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.wc-match-number small {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: #ffd76b;
    font-size: 8px;
}

.wc-bracket-team {
    position: relative;
    min-width: 0;
    min-height: 20px;
    padding: 2px 22px 2px 4px;
    border-radius: 7px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 4px;
    background: rgba(0,0,0,.14);
}

.wc-bracket-team + .wc-bracket-team {
    border-top: 1px solid rgba(255,255,255,.055);
}

.wc-bracket-team.winner {
    color: #f8ffe9;
    background: linear-gradient(90deg, rgba(180,255,46,.18), rgba(180,255,46,.035));
}

.wc-bracket-team.user-team {
    box-shadow: inset 3px 0 0 #30e7ff;
}

.wc-bracket-team.unknown {
    opacity: .55;
}

.wc-team-name {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    font-weight: 850;
}

.wc-team-name > span:last-child {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.wc-team-flag {
    width: 18px;
    height: 12px;
    flex: 0 0 auto;
    border-radius: 4px;
}

.wc-team-placeholder {
    width: 18px;
    height: 18px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: var(--muted);
    background: rgba(255,255,255,.08);
    font-style: normal;
}

.wc-bracket-team b {
    min-width: 13px;
    text-align: center;
    font-size: 11px;
}

.wc-bracket-team em {
    position: absolute;
    right: 3px;
    top: 50%;
    translate: 0 -50%;
    width: 15px;
    height: 15px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: #061325;
    background: #b4ff2e;
    font-size: 9px;
    font-style: normal;
    font-weight: 1000;
}

.wc-champion-column {
    width: 180px;
    flex: 0 0 180px;
    display: grid;
    place-items: center;
    scroll-snap-align: center;
}

.wc-champion-card {
    width: 100%;
    min-height: 190px;
    padding: 18px 12px;
    border-radius: 22px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 8px;
    text-align: center;
    background:
        radial-gradient(circle at 50% 15%, rgba(255,215,107,.22), transparent 48%),
        linear-gradient(160deg, rgba(255,215,107,.10), rgba(255,255,255,.035));
    border: 1px solid rgba(255,215,107,.22);
    box-shadow: 0 16px 40px rgba(0,0,0,.24), inset 0 1px 0 rgba(255,255,255,.10);
}

.wc-champion-card.crowned {
    border-color: rgba(255,215,107,.62);
    box-shadow: 0 0 34px rgba(255,215,107,.16), inset 0 1px 0 rgba(255,255,255,.16);
}

.wc-cup {
    font-size: 46px;
    filter: drop-shadow(0 8px 16px rgba(255,215,107,.24));
}

.wc-champion-card small {
    color: #ffd76b;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.wc-champion-card strong {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.wc-bracket-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 750;
}

.wc-bracket-legend span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.legend-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    display: inline-block;
}

.legend-dot.user { background: #30e7ff; }
.legend-dot.current { background: #b4ff2e; }
.legend-dot.winner { background: #ffd76b; }

@media (max-width: 719px) {
    .tournament-grid.knockout-mode {
        gap: 8px;
    }

    .wc-bracket-topline {
        padding: 10px;
        align-items: start;
    }

    .wc-swipe-hint {
        display: none;
    }

    .wc-bracket-board {
        --column-width: 188px;
        --connector-width: 28px;
        gap: 42px;
        padding: 14px 30px 18px 12px;
    }

    .wc-round-pairs {
        min-height: 940px;
    }

    .wc-match-card {
        min-height: 54px;
        padding: 5px;
        border-radius: 11px;
    }

    .wc-team-name {
        font-size: 9px;
    }

    .wc-round-header {
        min-height: 43px;
        padding: 6px 8px;
    }

    .wc-round-header span {
        font-size: 12px;
    }

    .wc-champion-column {
        width: 150px;
        flex-basis: 150px;
    }

    .wc-champion-card {
        min-height: 160px;
        padding: 14px 9px;
    }

    .wc-cup {
        font-size: 38px;
    }
}


/* v63: festejo de gol */
.goal-overlay {
    z-index: 6;
    align-content: center;
    gap: 2px;
    text-align: center;
    background: radial-gradient(circle at center, rgba(4,18,36,.08), transparent 58%);
    animation: goalCelebrationPop 5.15s cubic-bezier(.2,.86,.2,1) both;
}

.goal-overlay strong {
    display: block;
    font-size: clamp(46px, 17vw, 112px);
    line-height: .9;
    letter-spacing: -.08em;
    transform: skewX(-5deg);
    text-shadow:
        0 0 10px #30e7ff,
        0 0 36px rgba(180,255,46,.82),
        0 8px 0 rgba(0,0,0,.25);
}

.goal-overlay small {
    display: inline-grid;
    place-items: center;
    justify-self: center;
    min-width: 54px;
    min-height: 25px;
    padding: 4px 10px;
    margin-top: 8px;
    border-radius: 999px;
    color: #061325;
    background: linear-gradient(135deg, #30e7ff, #b4ff2e);
    border: 1px solid rgba(255,255,255,.45);
    box-shadow: 0 8px 22px rgba(48,231,255,.24);
    font-size: clamp(11px, 3vw, 16px);
    font-weight: 1000;
    letter-spacing: .08em;
}

@keyframes goalCelebrationPop {
    0% { opacity: 0; transform: scale(.34) rotate(-7deg); }
    12% { opacity: 1; transform: scale(1.13) rotate(2deg); }
    28% { opacity: 1; transform: scale(.98) rotate(0); }
    88% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(1.28); }
}


/* v63: bracket visual alineado con el recorrido oficial */
.wc-match-origin {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    padding: 0 2px 2px;
    color: rgba(220,232,255,.52);
    font-size: 7px;
    font-weight: 800;
    letter-spacing: .025em;
}

.wc-match-card.current-match .wc-match-origin {
    color: rgba(220,255,190,.76);
}

.wc-match-card.placeholder .wc-match-origin {
    color: rgba(220,232,255,.38);
}

@media (min-width: 720px) {
    .wc-match-origin {
        font-size: 7.5px;
    }
}


/* v63: optimización de render sin cambiar tamaño, proporción ni efectos */
#gameCanvas {
    contain: strict;
    image-rendering: auto;
    transform: translateZ(0);
    backface-visibility: hidden;
    will-change: contents;
}
