:root {
    --clr-gold: #D4AF37;
    --clr-gold-glow: rgba(212, 175, 55, 0.6);
    --clr-silver: #C0C0C0;
    --clr-bronze: #CD7F32;
    --clr-blue: #00f3ff;
    --clr-blue-glow: rgba(0, 243, 255, 0.4);
    --clr-red: #ff4757;
    --clr-green: #2ecc71;
    --clr-dark: #0a0a0c;
    --clr-bg: #121214;
    --glass: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --font-main: 'Outfit', sans-serif;
    --font-title: 'Bangers', cursive;
}

.live-stats {
    position: absolute;
    top: 10px;
    left: 18px;
    z-index: 1000;
    font-size: 0.65rem;
    font-weight: 900;
    color: rgba(255,255,255,0.8);
    display: flex;
    flex-direction: column;
    gap: 2px;
    pointer-events: none;
}

.live-stats .count { color: var(--clr-gold); margin-right: 4px; }
.live-stats .online { color: #2ecc71; margin-right: 4px; }

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
    background-color: var(--clr-dark);
    color: #fff;
    font-family: var(--font-main);
    overflow: hidden;
    height: 100vh;
}

.app-container {
    width: 100%; height: 100vh;
    max-width: 500px; margin: 0 auto;
    position: relative; overflow: hidden;
    background: #000;
}

.stadium-bg {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background-image: linear-gradient(to bottom, rgba(10, 10, 12, 0.6), rgba(10, 10, 12, 0.95)),
                      url('../assets/stadium.png');
    background-size: cover; background-position: center;
    z-index: -2;
    pointer-events: none;
}

.overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle at top, rgba(0, 243, 255, 0.1), transparent 70%);
    z-index: -1;
    pointer-events: none;
}

/* SCREEN MANAGEMENT */
.screen {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    display: none; flex-direction: column; padding: 20px;
    opacity: 0; pointer-events: none;
    transition: opacity 0.4s ease, transform 0.4s ease;
    transform: translateY(20px);
    overflow: hidden;
}
.screen.active { 
    display: flex;
    opacity: 1; 
    pointer-events: all; 
    transform: translateY(0); 
}
.hidden { display: none !important; }

.glass-panel {
    background: var(--glass); backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border); border-radius: 24px; padding: 20px;
}

/* BUTTONS */
button { cursor: pointer; border: none; font-family: var(--font-main); font-weight: 700; border-radius: 14px; transition: all 0.2s ease; }
.btn-primary {
    background: var(--clr-gold); color: #000; padding: 18px; font-size: 1.1rem;
    text-transform: uppercase; letter-spacing: 2px; font-weight: 900;
    box-shadow: 0 4px 20px var(--clr-gold-glow);
}
.btn-primary:active { transform: scale(0.96); }
.btn-secondary { background: var(--glass); color: #fff; border: 1px solid var(--glass-border); padding: 12px; }
.btn-minimal { background: transparent; color: var(--clr-gold); font-size: 0.7rem; padding: 10px; opacity: 0.8; text-align: center; width: 100%; }

/* FIX HOME MOBILE */
#screen-welcome {
    justify-content: flex-end;
    padding: 18px;
    overflow: hidden;
}

.main-logo {
    position: absolute;
    top: 3vh;
    right: -22vw;
    width: min(72vw, 340px);
    max-width: 340px;
    height: auto;
    opacity: 0.55;
    z-index: 0;
    pointer-events: none;
    animation: logoSlideSoft 14s ease-in-out infinite alternate;
}

@keyframes logoSlideSoft {
    from { transform: translateX(0) scale(1); }
    to { transform: translateX(-16vw) scale(1.04); }
}

.hero-header {
    position: relative;
    z-index: 2;
    margin-top: 0;
    margin-bottom: 10px;
    text-align: left;
    width: 100%;
}

.title-glow {
    font-size: clamp(2.2rem, 11vw, 3.4rem);
    line-height: 0.9;
    font-family: var(--font-title);
    color: #fff;
    text-shadow: 0 0 20px var(--clr-gold-glow);
}

.subtitle {
    font-size: clamp(0.65rem, 3.2vw, 0.9rem);
    letter-spacing: 2px;
    color: var(--clr-gold);
    font-weight: 900;
}

/* FIX: Rimozione simboli spuri/quadratini sopra il logo */
.main-logo::before,
.main-logo::after,
.title-glow::before,
.title-glow::after,
.hero-header::before,
.hero-header::after {
    content: none !important;
    display: none !important;
}

/* Safari iPhone Fix: font-size 16px to prevent zoom */
input, textarea, select {
    font-size: 16px !important;
}

.mobile-input {
    position: relative !important;
    z-index: 9999 !important;
    pointer-events: auto !important;
    touch-action: manipulation !important;
    -webkit-user-select: text !important;
    user-select: text !important;
}

.setup-form, .admin-access {
    position: relative;
    z-index: 3;
}

.setup-form {
    width: 100%;
    padding: 16px;
    border-radius: 22px;
    max-height: 44vh;
    overflow-y: auto;
}

.setup-step label {
    display: block;
    font-size: 0.75rem;
    font-weight: 900;
    color: var(--clr-gold);
    margin-bottom: 10px;
    letter-spacing: 1px;
}

.setup-step input {
    width: 100%;
    min-width: 0;
    height: 46px;
    padding: 0 12px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: rgba(0,0,0,0.35);
    color: #fff;
    font-size: 1rem;
    margin-bottom: 12px;
}

.setup-step .btn-primary {
    width: 100%;
    height: 54px;
    padding: 0 16px;
    font-size: 1rem;
}

.btn-fire.pulse {
    animation: btnPulse 1s infinite alternate;
}
@keyframes btnPulse {
    from { transform: scale(1); box-shadow: 0 4px 15px var(--clr-gold-glow); }
    to { transform: scale(1.05); box-shadow: 0 8px 30px var(--clr-gold); }
}

.rioni-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    max-height: 32vh;
    overflow-y: auto;
    padding-right: 4px;
}

.rione-card {
    min-height: 72px;
    padding: 8px;
    border-radius: 14px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.rione-card img {
    width: 34px;
    height: 34px;
    object-fit: contain;
    flex-shrink: 0;
}

.rione-card span {
    font-size: 0.62rem;
    line-height: 1.05;
    font-weight: 900;
}

.rione-card.selected {
    border-color: var(--clr-gold);
    background: rgba(212,175,55,0.18);
}

.mode-selection {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.btn-mode {
    height: 92px;
    padding: 10px;
    border-radius: 16px;
    background: rgba(255,255,255,0.06);
    color: #fff;
    border: 1px solid var(--glass-border);
}

.btn-mode .icon { font-size: 2rem; display: block; }
.btn-mode .label { font-size: 0.7rem; color: var(--clr-gold); font-weight: 900; }

.admin-access { margin-top: 8px; }
/* GAME HUD */
.game-hud {
    height: 80px; display: grid; grid-template-columns: 1fr 90px 1fr;
    align-items: center; padding: 6px; background: linear-gradient(to bottom, rgba(0,0,0,0.9), transparent);
    z-index: 100;
}
.team-info { display: flex; align-items: center; gap: 6px; }
.team-info img { width: 32px; height: 32px; filter: drop-shadow(0 0 5px rgba(255,255,255,0.3)); }
.rione-name { font-size: 0.5rem; color: var(--clr-gold); font-weight: 900; letter-spacing: 1px; }
.player-name { font-size: 0.7rem; font-weight: 700; color: #fff; }
.team-score { font-family: var(--font-title); font-size: 2.2rem; color: #fff; text-shadow: 0 0 10px rgba(255,255,255,0.3); }

#screen-game {
    padding: 10px 12px 0;
    overflow: hidden;
}

.arena-viewport {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding-top: 10px;
    padding-bottom: 4px;
}

.pitch-scene {
    position: relative;
    height: 90px;
    min-height: 90px;
    margin-top: auto;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    overflow: visible;
}

.ball-wrapper {
    position: absolute;
    left: 50%;
    bottom: 55px;
    transform: translateX(-50%);
    z-index: 50;
    overflow: visible;
}

.ball {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-image: url('../palla.png'); 
    background-size: cover;
    background-position: center;
    transform-origin: center;
    box-shadow: 0 12px 25px rgba(0,0,0,0.7); 
    transition: transform 0.6s cubic-bezier(0.2, 0, 0.2, 1);
}

.ball-shadow {
    position: absolute;
    left: 50%;
    bottom: -9px;
    width: 42px;
    height: 10px;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.45);
    border-radius: 50%;
    filter: blur(5px);
}

.goal-scene {
    position: relative; 
    width: 92%; 
    height: clamp(110px, 16vh, 140px); 
    margin: 0 auto;
    margin-top: 20px;
    transform-style: preserve-3d;
}
.goal-frame { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 5; pointer-events: none; transition: transform 0.1s; }
.post { position: absolute; bottom: 0; width: 10px; height: 100%; background: #fff; box-shadow: 0 0 20px rgba(0,0,0,0.5); }
.post.left { left: 0; } .post.right { right: 0; }
.crossbar { position: absolute; top: 0; left: 0; width: 100%; height: 10px; background: #fff; }

.goal-net {
    position: absolute; top: 10px; left: 10px; right: 10px; bottom: 0;
    background: radial-gradient(circle, transparent 20%, rgba(255,255,255,0.1) 20%);
    background-size: 12px 12px; border: 1px solid rgba(255,255,255,0.1);
    transition: transform 0.2s ease-out; transform-origin: top;
}

.shooting-zones {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(3, 1fr);
    pointer-events: auto;
}

.zone {
    position: relative;
    border: 1px solid rgba(255,255,255,0.04);
    cursor: pointer;
    touch-action: manipulation;
}

.zone::after {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    border: 2px solid rgba(255,255,255,0.35);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.zone.selected {
    background: rgba(0,243,255,0.18);
    border-color: var(--clr-blue);
}

.zone.selected::after {
    background: var(--clr-blue);
    border-color: #fff;
    box-shadow: 0 0 18px var(--clr-blue);
    transform: translate(-50%, -50%) scale(1.3);
}

/* Trajectory Line */
.trajectory-line {
    position: absolute; bottom: 45px; left: 50%;
    width: 2px; height: 0; background: linear-gradient(to top, var(--clr-blue), transparent);
    transform-origin: bottom center; z-index: 15; pointer-events: none;
    transition: height 0.3s ease; opacity: 0;
}
.trajectory-line.show { opacity: 0.6; }

/* Level Up Banner */
.level-up-banner {
    position: absolute; top: 20%; left: 0; width: 100%;
    background: rgba(212, 175, 55, 0.9); color: #000;
    padding: 15px; text-align: center; font-family: var(--font-title);
    font-size: 1.8rem; z-index: 600; transform: scaleY(0);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.level-up-banner.show { transform: scaleY(1); }

/* Score Popup */
.score-popup {
    position: absolute; color: var(--clr-gold); font-family: var(--font-title);
    font-size: 1.5rem; text-shadow: 0 0 15px #000; z-index: 550; text-align: center; transform: translateX(-50%);
    pointer-events: none; animation: scorePopupMove 2.5s forwards;
}
@keyframes scorePopupMove {
    0% { transform: translate(-50%, 0); opacity: 1; }
    80% { transform: translate(-50%, -80px); opacity: 1; }
    100% { transform: translate(-50%, -100px); opacity: 0; }
}

.goalkeeper {
    position: absolute; bottom: 0; left: 50%;
    width: 110px; height: 135px;
    transform: translateX(-50%) translateZ(0);
    transform-origin: 50% 85%;
    background-image: url('../assets/goalkeeper.png');
    background-size: contain; background-repeat: no-repeat; background-position: bottom center;
    z-index: 4; filter: drop-shadow(0 20px 25px rgba(0,0,0,0.6));
    transition: transform 0.2s cubic-bezier(.15,.85,.25,1.15);
    will-change: transform;
}

.gk-shadow {
    position: absolute; bottom: -15px; left: 50%; transform: translateX(-50%);
    width: 80%; height: 15px; background: rgba(0,0,0,0.4);
    border-radius: 50%; filter: blur(8px); transition: all 0.3s;
}

/* GK ANIMATIONS */
.gk-idle { animation: gkIdle3D 2s ease-in-out infinite; }
.gk-ready { animation: gkReadyPulse 0.5s ease-in-out infinite alternate; }

@keyframes gkIdle3D {
    0%, 100% { transform: translateX(-50%) translateY(0) scale(1) rotateX(0deg); }
    50% { transform: translateX(-50%) translateY(-5px) scale(1.03) rotateX(5deg); }
}
@keyframes gkReadyPulse {
    from { transform: translateX(-50%) translateY(0) scale(1); filter: drop-shadow(0 15px 20px rgba(0,0,0,0.5)); }
    to { transform: translateX(-50%) translateY(-8px) scale(1.08); filter: drop-shadow(0 25px 30px rgba(0,0,0,0.8)); }
}

.gk-dive-high-left { animation: gkDiveHighLeft 0.8s cubic-bezier(.15,.85,.25,1.15) forwards, gkBounce 0.3s 0.8s; }
.gk-dive-high-right { animation: gkDiveHighRight 0.8s cubic-bezier(.15,.85,.25,1.15) forwards, gkBounce 0.3s 0.8s; }
.gk-dive-low-left { animation: gkDiveLowLeft 0.8s cubic-bezier(.15,.85,.25,1.15) forwards, gkBounce 0.2s 0.8s; }
.gk-dive-low-right { animation: gkDiveLowRight 0.8s cubic-bezier(.15,.85,.25,1.15) forwards, gkBounce 0.2s 0.8s; }

@keyframes gkBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(8px) scaleY(0.92); }
}
.gk-center { animation: gkCenterSave 0.6s cubic-bezier(.15,.85,.25,1.15) forwards; }

@keyframes gkDiveHighLeft {
    0% { transform: translateX(-50%) scale(1); }
    20% { transform: translateX(-60%) translateY(-15px) scale(1.1); }
    60% { transform: translateX(-140%) translateY(-85px) rotate(-40deg) scale(1.2, 1.05); }
    100% { transform: translateX(-160%) translateY(-60px) rotate(-55deg) scale(1.1); }
}
@keyframes gkDiveHighRight {
    0% { transform: translateX(-50%) scale(1); }
    20% { transform: translateX(-40%) translateY(-15px) scale(1.1); }
    60% { transform: translateX(40%) translateY(-85px) rotate(40deg) scale(1.2, 1.05); }
    100% { transform: translateX(60%) translateY(-60px) rotate(55deg) scale(1.1); }
}
@keyframes gkDiveLowLeft {
    0% { transform: translateX(-50%) scale(1); }
    20% { transform: translateX(-65%) translateY(8px) scale(1.1); }
    60% { transform: translateX(-145%) translateY(30px) rotate(-25deg) scale(1.2, .95); }
    100% { transform: translateX(-160%) translateY(40px) rotate(-35deg) scale(1.1); }
}
@keyframes gkDiveLowRight {
    0% { transform: translateX(-50%) scale(1); }
    20% { transform: translateX(-35%) translateY(8px) scale(1.1); }
    60% { transform: translateX(45%) translateY(30px) rotate(25deg) scale(1.2, .95); }
    100% { transform: translateX(60%) translateY(40px) rotate(35deg) scale(1.1); }
}
@keyframes gkCenterSave {
    0% { transform: translateX(-50%) scale(1); }
    50% { transform: translateX(-50%) translateY(-45px) scale(1.25); }
    100% { transform: translateX(-50%) translateY(-25px) scale(1.1); }
}

/* BALL & EFFECTS */
.ball-wrapper { position: absolute; bottom: 45px; z-index: 50; }
.ball {
    width: 40px; height: 40px; border-radius: 50%;
    background-image: url('../palla.png'); background-size: cover;
    box-shadow: 0 12px 25px rgba(0,0,0,0.7); transition: transform 0.6s cubic-bezier(0.2, 0, 0.2, 1);
}
.ball.ball-flying { animation: ballSpin 0.6s linear infinite; }
@keyframes ballSpin { from { transform: rotate(0deg); } to { transform: rotate(720deg); } }

.ball-trail {
    position: absolute; top: 50%; left: 50%; width: 100%; height: 100%;
    background: radial-gradient(circle, var(--clr-blue) 0%, transparent 80%);
    opacity: 0; transform: translate(-50%, -50%) scale(1); pointer-events: none;
}
.ball-flying .ball-trail { opacity: 0.5; animation: trailPulse 0.6s infinite alternate; }
@keyframes trailPulse { from { transform: translate(-50%, -50%) scale(1); opacity: 0.3; } to { transform: translate(-50%, -50%) scale(2.5); opacity: 0; } }

/* FEEDBACK TEXT */
.feedback-text {
    position: absolute; top: 30%; left: 50%; transform: translate(-50%, -50%);
    width: 100%; text-align: center; font-family: var(--font-title);
    font-size: clamp(2rem, 8vw, 3rem); color: #fff; text-shadow: 0 0 20px rgba(0,0,0,0.8);
    z-index: 500; pointer-events: none; opacity: 0; line-height: 0.9; padding: 0 10px;
}
.feedback-text.show { opacity: 1; animation: goalPop 0.5s ease; }

@keyframes goalPop {
    0% { transform: translate(-50%, -50%) scale(0.6); }
    60% { transform: translate(-50%, -50%) scale(1.2); }
    100% { transform: translate(-50%, -50%) scale(1); }
}

/* FIFA STYLE LEADERBOARD */
.podium-container {
    display: flex; align-items: flex-end; justify-content: center; gap: 12px;
    margin: 30px 0; padding: 0 10px; height: 180px;
}
.podium-card {
    flex: 1; background: var(--glass); border-radius: 20px 20px 10px 10px;
    display: flex; flex-direction: column; align-items: center; position: relative;
    padding-bottom: 15px; border: 1px solid var(--glass-border);
    animation: slideUp 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; opacity: 0;
}
@keyframes slideUp { from { transform: translateY(50px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.podium-card.rank-1 { 
    height: 100%; border-color: var(--clr-gold); 
    box-shadow: 0 0 40px rgba(212, 175, 55, 0.4); 
    z-index: 10; 
    animation: slideUp 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards, rank1Glow 2s infinite alternate;
}
@keyframes rank1Glow {
    from { box-shadow: 0 0 20px rgba(212, 175, 55, 0.2); }
    to { box-shadow: 0 0 50px rgba(212, 175, 55, 0.5); }
}

.rank-badge {
    position: absolute; top: -15px; width: 40px; height: 40px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-family: var(--font-title); font-size: 1.5rem;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
}
.rank-1 .rank-badge { background: var(--clr-gold); color: #000; box-shadow: 0 0 20px var(--clr-gold); }
.rank-2 .rank-badge { background: var(--clr-silver); color: #000; }
.rank-3 .rank-badge { background: var(--clr-bronze); color: #000; }

.podium-avatar { width: 45px; height: 45px; margin-top: 30px; object-fit: contain; }
.podium-name { font-weight: 900; font-size: 0.8rem; margin-top: 10px; text-align: center; }
.podium-score { color: var(--clr-gold); font-family: var(--font-title); font-size: 1.4rem; }

.lb-list { display: flex; flex-direction: column; gap: 8px; max-height: 400px; overflow-y: auto; padding-right: 5px; }

/* Leaderboard Filters */
.lb-filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 15px;
}

.lb-filters input, .lb-filters select {
    height: 40px;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: #fff;
    padding: 0 10px;
    font-size: 0.8rem;
    font-family: var(--font-main);
}
.lb-row {
    display: grid; grid-template-columns: 40px 1fr 1fr 70px;
    background: rgba(255,255,255,0.03); border-radius: 12px; padding: 12px;
    align-items: center; border: 1px solid transparent; animation: slideInRow 0.4s ease forwards; opacity: 0;
}
@keyframes slideInRow { from { transform: translateX(-20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.current-match-row {
    background: linear-gradient(90deg, rgba(212, 175, 55, 0.15), rgba(0, 243, 255, 0.05));
    border-color: var(--clr-gold); box-shadow: 0 0 15px rgba(212, 175, 55, 0.1);
}

.lb-pos { font-family: var(--font-title); font-size: 1.2rem; opacity: 0.7; }
.lb-name { font-weight: 700; font-size: 0.9rem; }
.lb-rione { font-size: 0.6rem; color: var(--clr-gold); font-weight: 900; }
.lb-stats { font-size: 0.6rem; opacity: 0.6; }
.lb-points { font-family: var(--font-title); font-size: 1.1rem; color: var(--clr-gold); text-align: right; }

/* RESULTS CARD PRO */
.result-header-card {
    position: relative;
    overflow: hidden;
    padding: 30px 20px;
}

.result-header-card::after {
    content: '';
    position: absolute;
    right: -15%;
    bottom: -15%;
    width: 140px;
    height: 140px;
    background-image: var(--winner-logo);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: right bottom;
    opacity: 0.25;
    z-index: 0;
    pointer-events: none;
}

.result-header-card * {
    position: relative;
    z-index: 2;
}

.score-board {
    display: flex; align-items: center; justify-content: center; gap: 20px; margin: 20px 0;
}
.team-res { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.team-res img { width: 80px; height: 80px; object-fit: contain; }
.team-res span { font-family: var(--font-title); font-size: 4rem; line-height: 1; }
.vs-label { font-family: var(--font-title); font-size: 1.5rem; opacity: 0.5; }
.winner-announcement { font-weight: 900; color: var(--clr-gold); font-size: 1.2rem; text-transform: uppercase; margin-top: 15px; }

.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }

/* FX LAYERS */
.fx-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1000; }
.flash-goal { animation: flashWhite 0.4s forwards; }
@keyframes flashWhite { from { background: #fff; opacity: 0.6; } to { background: transparent; opacity: 0; } }

.screen-shake { animation: shake 0.3s cubic-bezier(.36,.07,.19,.97) both; }
@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

.particles-container { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 600; }
.particle { position: absolute; width: 6px; height: 6px; border-radius: 50%; animation: particleMove 0.8s ease-out forwards; }
@keyframes particleMove {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(var(--tx), var(--ty)) scale(0); opacity: 0; }
}

.game-controls {
    position: relative;
    z-index: 1000;
    flex-shrink: 0;
    width: calc(100% + 24px);
    margin-left: -12px;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    border-radius: 24px 24px 0 0;
    background: rgba(10,10,12,0.92);
    border-top: 1px solid rgba(255,255,255,0.12);
    backdrop-filter: blur(14px);
}

.power-system {
    width: 100%;
    margin-bottom: 12px;
}

.power-labels {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--clr-gold);
    font-weight: 900;
    font-size: 0.78rem;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.power-bar-container {
    position: relative;
    width: 100%;
    height: 14px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.18);
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.65);
}

.power-fill {
    height: 100%;
    width: 0%;
    border-radius: 999px;
    background: linear-gradient(90deg, #2ecc71 0%, #f1c40f 55%, #ff4757 100%);
    box-shadow: 0 0 18px rgba(212,175,55,0.45);
    transition: width 0.04s linear;
}

.power-perfect-zone {
    position: absolute;
    top: 0;
    left: 85%;
    width: 10%;
    height: 100%;
    border-left: 2px solid #fff;
    border-right: 2px solid #fff;
    background: rgba(255,255,255,0.22);
    box-shadow: 0 0 14px rgba(255,255,255,0.7);
}

.action-footer {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.game-hint {
    text-align: center;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.72);
    font-weight: 700;
}

.btn-fire,
#btn-next-turn {
    width: 100%;
    height: 48px;
    border-radius: 16px;
    font-family: var(--font-title);
    font-size: 1.4rem;
    letter-spacing: 1px;
}
#screen-admin {
    overflow: hidden;
    padding: 0;
}

.admin-top {
    height: 64px;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.admin-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 0 18px 10px;
}

.tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 12px 18px 90px;
}

.tab-content.active {
    display: block;
}

#roster-editor {
    max-height: calc(100vh - 180px);
    overflow-y: auto;
}

.roster-card {
    padding: 12px;
    margin-bottom: 10px;
    background: var(--glass); 
    border: 1px solid var(--glass-border);
    border-radius: 16px;
}

.roster-card h4 {
    font-size: 0.72rem;
    color: var(--clr-gold); 
    margin-bottom: 10px; 
    display: flex; 
    align-items: center; 
    justify-content: space-between;
    gap: 8px;
}

.official-badge {
    background: var(--clr-gold);
    color: #000;
    font-size: 0.5rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 900;
    letter-spacing: 1px;
}

.roster-card img {
    width: 22px;
    height: 22px;
}

.roster-inputs {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.roster-inputs div { display: flex; flex-direction: column; gap: 4px; }

.roster-inputs label {
    font-size: 0.62rem;
    font-weight: 700;
}

.roster-inputs input {
    height: 40px;
    font-size: 0.85rem;
    background: rgba(0,0,0,0.3); 
    border: 1px solid var(--glass-border); 
    color: #fff; 
    border-radius: 8px;
    padding: 0 10px;
}

/* CLUTCH MODE FX */
.clutch-mode {
    filter: brightness(0.8) contrast(1.2);
    transition: filter 1s ease;
}

.clutch-mode .arena-viewport {
    transform: scale(1.05);
    transition: transform 1s ease;
}

.clutch-text {
    position: absolute;
    top: 22%;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-title);
    font-size: 2.2rem;
    color: #ff3e3e;
    text-shadow: 0 0 25px rgba(255, 0, 0, 0.8);
    z-index: 999;
    letter-spacing: 2px;
    animation: clutchPulse 1.5s infinite alternate;
}

@keyframes clutchPulse {
    from { opacity: 0.7; transform: translateX(-50%) scale(1); }
    to { opacity: 1; transform: translateX(-50%) scale(1.1); }
}

/* ========================================== */
/* DRIBBLE ARENA STYLES                       */
/* ========================================== */
.dribble-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px calc(15px + env(safe-area-inset-bottom));
    background: rgba(10,10,12,0.95);
    border-top: 1px solid rgba(255,255,255,0.1);
    z-index: 100;
}

.joystick-zone {
    width: 130px;
    height: 130px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
}

.joystick-base {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    border: 2px solid rgba(255,255,255,0.2);
    position: relative;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
}

.joystick-knob {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--clr-blue);
    box-shadow: 0 0 15px var(--clr-blue);
    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: -20px;
    margin-left: -20px;
    pointer-events: none;
    transition: transform 0.2s;
}

.dribble-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    flex: 1;
    margin-left: 20px;
}

.d-btn {
    height: 55px;
    border-radius: 14px;
    font-family: var(--font-title);
    font-size: 1.2rem;
    letter-spacing: 1px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    touch-action: manipulation;
}
.d-btn:active { transform: scale(0.95); }

.sprint { grid-column: span 2; background: #ff4757; color: #fff; box-shadow: 0 0 15px rgba(255,71,87,0.4); }
.skill { background: var(--clr-gold); color: #000; }
.jump { background: var(--clr-blue); color: #000; }

@media (max-height: 750px) {
    .goal-scene {
        height: 100px;
    }

    .game-hud {
        height: 70px;
    }

    .pitch-scene {
        height: 70px;
    }
}

.rioni-main-ranking {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  max-height: 62vh;
  padding-right: 4px;
}

.rione-ranking-card {
  display: grid;
  grid-template-columns: 34px 44px 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255,255,255,0.06);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.12);
}

.rione-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.rione-rank {
  font-weight: 900;
  color: var(--clr-gold);
}

.rione-info {
  text-align: left;
}

.rione-info small {
  display: block;
  opacity: 0.65;
  font-size: 0.68rem;
}

.rione-score {
  font-family: var(--font-title);
  font-size: 1.5rem;
  color: var(--clr-gold);
}

.rione-detail {
  position: absolute;
  inset: 20px;
  z-index: 999;
  background: rgba(0,0,0,0.95);
  border-radius: 22px;
  padding: 16px;
  overflow-y: auto;
}

.rione-detail-total {
  font-family: var(--font-title);
  font-size: 2rem;
  color: var(--clr-gold);
}

.rione-player-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rione-player-row {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(255,255,255,0.07);
}

.rione-player-row small {
  display: block;
  opacity: 0.6;
  font-size: 0.65rem;
}

.clickable-logo {
    cursor: pointer;
    transition: transform 0.25s ease, filter 0.25s ease;
    animation: logoPulse 2.5s ease-in-out infinite alternate;
}

.clickable-logo:hover {
    transform: scale(1.05);
    filter: drop-shadow(0 0 20px rgba(212,175,55,0.6));
}

.clickable-logo:active {
    transform: scale(0.95);
}

@keyframes logoPulse {
    0% { transform: scale(1); }
    100% { transform: scale(1.03); }
}

.logo-cta {
    position: absolute;
    top: calc(3vh + 80px);
    right: 20px;
    font-size: 0.6rem;
    color: var(--clr-gold);
    font-weight: 900;
    opacity: 0.8;
}

/* Penalty Arena V2 Updates */
.power-fill {
    transition: width 0.035s linear;
}

.power-fill.danger-power {
    box-shadow: 0 0 18px rgba(255, 71, 87, 0.8);
}

.power-fill.perfect-power {
    box-shadow: 0 0 25px rgba(212, 175, 55, 1);
    background: linear-gradient(90deg, #ff4757, #ffd700, #ffffff);
}

.net-burst {
    animation: netBurst 0.7s ease-out;
}

@keyframes netBurst {
    0% { transform: scaleY(1); }
    35% { transform: scaleY(1.25) translateY(6px); }
    100% { transform: scaleY(1); }
}

.goal-flash {
    animation: goalFlash 0.6s ease-out;
}

@keyframes goalFlash {
    0% { filter: drop-shadow(0 0 0 gold); }
    40% { filter: drop-shadow(0 0 30px gold); }
    100% { filter: drop-shadow(0 0 0 gold); }
}

.post-shake {
    animation: postShake 0.45s ease;
}

@keyframes postShake {
    0% { transform: translateX(0); }
    20% { transform: translateX(-5px); }
    40% { transform: translateX(5px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(3px); }
    100% { transform: translateX(0); }
}

.gk-mindgame {
    animation: keeperMindGame 0.7s ease-in-out infinite alternate;
}

@keyframes keeperMindGame {
    0% { transform: translateX(calc(-50% - 6px)) scale(1.02); }
    100% { transform: translateX(calc(-50% + 6px)) scale(1.04); }
}

/* FIX TAP INPUT PENALTY ARENA */
.glass-panel {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 20px;
}

.mobile-input, .mobile-select {
    width: 100%;
    height: 50px;
    background: rgba(0,0,0,0.6) !important;
    color: #fff !important;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 12px;
    padding: 0 15px;
    font-size: 16px !important;
    appearance: none;
    -webkit-appearance: none;
    margin-bottom: 5px;
}

.mobile-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 20px;
}

#screen-setup select,
#screen-setup input {
    pointer-events: auto !important;
    touch-action: auto !important;
    user-select: auto !important;
    -webkit-user-select: auto !important;
}
