@font-face {
    font-family: 'TitleFont';
    src: url('/malnate/branding/font/font.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

:root {
    --red: #e40613;
    --red-dark: #ae0f0b;
    --gold: #af9a63;
    --text-primary: #2a0e0b;
    --text-secondary: #7a5a55;
}

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

html, body { height: 100%; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 22px 16px 16px;
    color: var(--text-primary);
    background-color: #faf6f4;
    background-image:
        radial-gradient(1000px 500px at 100% 0%, rgba(228, 6, 19, 0.07), transparent 60%),
        radial-gradient(800px 460px at 0% 100%, rgba(175, 154, 99, 0.09), transparent 60%);
}

.intro { text-align: center; animation: rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) both; }

.intro .section-ornament {
    width: 104px;
    aspect-ratio: 1313 / 500;
    margin: 0 auto 4px;
    background-color: var(--gold);
    -webkit-mask: url('/malnate/branding/design.svg') center / contain no-repeat;
    mask: url('/malnate/branding/design.svg') center / contain no-repeat;
}

.intro h1 {
    font-family: 'TitleFont', 'Inter', sans-serif;
    font-weight: 400;
    font-size: clamp(28px, 6vw, 40px);
    letter-spacing: 0.5px;
    line-height: 1.1;
    color: var(--red);
}

.intro h1 .amp { color: var(--gold); }

.intro p {
    margin-top: 6px;
    font-size: clamp(13px, 2.4vw, 15px);
    color: var(--text-secondary);
    font-weight: 600;
}

/* ---- Layout: colonna singola su mobile, campo + colonne laterali su pc ---- */

.game-grid {
    width: 100%;
    display: flex;
    justify-content: center;
    animation: rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.1s both;
}

.board {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.side { display: none; }

/* ---- Card di vetro condivise ---- */

.scoreboard, .side-card {
    padding: 12px 18px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(18px) saturate(160%);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
    border-top: 4px solid var(--red);
    box-shadow: 0 10px 28px rgba(42, 14, 11, 0.10);
}

.scoreboard {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.team, .score-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.team { min-width: 84px; }

.team .name, .score-card .name {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.team.you .name, .score-card.you .name { color: var(--red-dark); }
.team.cpu .name, .score-card.cpu .name { color: #af9a63; }

.team .goals, .score-card .goals {
    font-family: 'TitleFont', 'Inter', sans-serif;
    font-size: 34px;
    line-height: 1;
}

.team.you .goals, .score-card.you .goals { color: var(--red); }
.team.cpu .goals, .score-card.cpu .goals { color: var(--gold); }

.score-card.cpu { border-top-color: var(--gold); }
.score-card .goals { font-size: 46px; }

.diff {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.label {
    display: block;
    text-align: center;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.chips { display: flex; gap: 5px; justify-content: center; }

.chips button {
    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
    padding: 5px 10px;
    border-radius: 14px;
    border: 1.5px solid rgba(174, 15, 11, 0.25);
    background: rgba(255, 255, 255, 0.7);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.chips button.active {
    background: linear-gradient(135deg, var(--red), var(--red-dark));
    border-color: transparent;
    color: #fff;
    box-shadow: 0 4px 12px rgba(228, 6, 19, 0.35);
}

/* difficoltà in verticale nella colonna laterale */
.chips-v { flex-direction: column; margin-top: 8px; }
.chips-v button { width: 100%; padding: 8px 10px; font-size: 12px; }

/* ---- Tabellone pubblicitario a bordocampo (stile LED) ---- */

.ad-board {
    height: 38px;
    border-radius: 12px;
    overflow: hidden;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0) 45%),
        #14181d;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 22px rgba(42, 14, 11, 0.18), inset 0 0 18px rgba(0, 0, 0, 0.55);
}

.ad-track {
    display: flex;
    width: max-content;
    height: 100%;
    animation: ad-scroll 30s linear infinite;
}

.ad-set {
    display: flex;
    align-items: center;
    gap: 46px;
    padding-right: 46px; /* stesso passo del gap: il loop non "salta" */
}

.ad-item {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #f5efdf;
    text-shadow: 0 0 10px rgba(175, 154, 99, 0.35);
}

.ad-item img {
    height: 24px;
    width: auto;
    max-width: 110px;
    object-fit: contain;
    display: block;
}

@keyframes ad-scroll {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); }
}

/* ---- Campo ---- */

.stage {
    position: relative;
    width: 100%;
    border-radius: 22px;
    overflow: hidden;
    box-shadow: 0 16px 44px rgba(42, 14, 11, 0.18);
    line-height: 0;
}

#pitch {
    width: 100%;
    display: block;
    touch-action: none;
    cursor: crosshair;
}

.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    text-align: center;
    padding: 20px;
    line-height: 1.3;
    background: rgba(20, 40, 20, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}

.overlay.show { opacity: 1; pointer-events: auto; }

.overlay .big {
    font-family: 'TitleFont', 'Inter', sans-serif;
    font-size: clamp(32px, 9vw, 52px);
    color: #fff;
    text-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
}

.overlay .big.gold { color: var(--gold); }

.overlay .sub {
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.92);
    max-width: 280px;
}

.overlay .btn {
    font-family: inherit;
    margin-top: 4px;
    padding: 12px 32px;
    border: none;
    border-radius: 26px;
    background: linear-gradient(135deg, var(--red), var(--red-dark));
    color: #fff;
    font-weight: 800;
    font-size: 14px;
    letter-spacing: 0.5px;
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(228, 6, 19, 0.45);
    transition: transform 0.2s;
}

.overlay .btn:hover { transform: translateY(-2px); }

.goal-flash {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
}

.goal-flash.show { animation: goalpop 1.1s cubic-bezier(0.22, 1, 0.36, 1) both; }

.goal-flash span {
    font-family: 'TitleFont', 'Inter', sans-serif;
    font-size: clamp(44px, 13vw, 84px);
    line-height: 1.05;   /* .stage ha line-height 0: senza, il testo su 2 righe si sovrappone */
    text-align: center;
    color: #fff;
    text-shadow: 0 6px 26px rgba(0, 0, 0, 0.5);
}

.goal-flash.against span { color: var(--gold); }

@keyframes goalpop {
    0%   { opacity: 0; transform: scale(0.4); }
    18%  { opacity: 1; transform: scale(1.08); }
    30%  { transform: scale(1); }
    75%  { opacity: 1; }
    100% { opacity: 0; transform: scale(1.05); }
}

/* ---- Bottoni azione (riga sotto il campo su mobile, colonna a destra su pc) ---- */

.actions {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.actions a, .actions button, .stack a, .stack button {
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    padding: 10px 16px;
    border-radius: 20px;
    border: 1.5px solid rgba(174, 15, 11, 0.25);
    background: rgba(255, 255, 255, 0.8);
    color: var(--red-dark);
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.actions a:hover, .actions button:hover, .stack a:hover, .stack button:hover {
    background: #fff;
    border-color: var(--red);
    transform: translateY(-2px);
}

/* ---- Footer (copiato dal portale) ---- */

.mini-footer {
    margin-top: auto;
    text-align: center;
    padding: 18px 16px 0;
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.7;
}

.mini-footer a { color: var(--red); font-weight: 600; text-decoration: none; }
.mini-footer a:hover { text-decoration: underline; }
.mini-footer .sep { margin: 0 6px; opacity: 0.5; }

@keyframes rise {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .intro, .game-grid { animation: none; }
    .ad-track { animation: none; }
}

/* Schermi stretti: comprime la scoreboard così le 3 colonne stanno nel viewport */
@media (max-width: 440px) {
    body { overflow-x: hidden; }
    .scoreboard { gap: 6px; padding: 10px 12px; }
    .team { min-width: 58px; }
    .chips { gap: 4px; }
    .chips button { padding: 5px 7px; font-size: 10px; }
    .label { font-size: 9px; }
}

/* Desktop: punteggi e comandi ai lati, campo dimensionato sull'altezza finestra (niente scroll) */
@media (min-width: 920px) {
    .game-grid {
        display: grid;
        /* larghezza campo = altezza disponibile * 420/640, tra 320 e 560px */
        grid-template-columns: 190px clamp(320px, calc((100dvh - 245px) * 0.656), 560px) 190px;
        gap: 18px;
        justify-content: center;
        align-items: start;
    }

    /* col tabellone sponsor visibile il campo cede i suoi 38px + 12px di gap */
    .game-grid:has(.ad-board:not([hidden])) {
        grid-template-columns: 190px clamp(320px, calc((100dvh - 295px) * 0.656), 560px) 190px;
    }

    body { gap: 10px; padding-top: 16px; }
    .intro p { margin-top: 4px; }
    .mini-footer { padding-top: 10px; }

    .board { max-width: none; }
    .board .scoreboard, .board .actions { display: none; }

    .side {
        display: flex;
        flex-direction: column;
        gap: 12px;
        position: sticky;
        top: 22px;
    }
}
