@import url('https://fonts.googleapis.com/css2?family=Russo+One&family=Roboto:wght@400;700&display=swap');

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background: radial-gradient(circle at center, #ffeb3b 0%, #008400 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    /* Ajuste para mobile: dvh se adapta à barra do navegador */
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    font-family: 'Roboto', sans-serif;
    color: white;
    overflow: hidden;
    touch-action: none;
}

.game-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 450px;
    max-height: 850px;
    background: #000;
    overflow: hidden;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
}

@media (min-width: 500px) {
    .game-container {
        border: 4px solid #333;
        border-radius: 15px;
        height: 95vh;
    }
}

canvas {
    background: #2e7d32;
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    box-sizing: border-box;
}

/* TELAS */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.96);
    background-image: linear-gradient(rgba(253, 253, 253, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 20px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    text-align: center;
    overflow-y: auto;
}

.title {
    font-family: 'Russo One', sans-serif;
    font-size: 42px;
    background: linear-gradient(180deg, #ffeb3b 0%, #008400 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0px 4px 0px rgba(0, 0, 0, 0.5));
    margin: 0;
    line-height: 1.1;
    text-transform: uppercase;
}

.subtitle {
    letter-spacing: 6px;
    font-size: 14px;
    color: #888;
    margin-bottom: 40px;
    text-transform: uppercase;
    font-weight: bold;
}

h2 {
    font-family: 'Russo One', sans-serif;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-shadow: 2px 2px 0 #000;
}

button {
    font-family: 'Russo One', sans-serif;
    border: none;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.1s;
    -webkit-tap-highlight-color: transparent;
}

button:active {
    transform: scale(0.96) translateY(2px);
}

.btn-primary {
    background: linear-gradient(180deg, #00e676 0%, #00a152 100%);
    color: white;
    padding: 18px 40px;
    font-size: 22px;
    border-radius: 8px;
    box-shadow: 0 6px 0 #00600f, 0 10px 10px rgba(0, 0, 0, 0.3);
    width: 85%;
    margin-bottom: 12px;
    border: 1px solid #4caf50;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid #555;
    color: #ccc;
    padding: 12px 25px;
    margin-top: 15px;
    font-size: 14px;
    border-radius: 6px;
    transition: background 0.2s;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-role {
    background: #f5f5f5;
    color: #222;
    width: 85%;
    padding: 20px;
    margin: 8px 0;
    font-size: 18px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    font-weight: bold;
    box-shadow: 0 5px 0 #999;
}

/* SELEÇÃO DE TIMES */
#teams-scroll {
    width: 95%;
    height: 55vh;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 20px;
    border: 1px solid #333;
}

#teams-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    padding-bottom: 20px;
}

.team-card {
    background: linear-gradient(145deg, #2a2a2a, #222);
    padding: 12px 5px;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid #444;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s;
}

.team-card:active {
    transform: scale(0.95);
    border-color: #ffeb3b;
    background: #333;
}

.team-flag-img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    margin-bottom: 8px;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.5));
}

.team-name-card {
    font-size: 10px;
    color: #eee;
    font-weight: bold;
    letter-spacing: 0.5px;
}

/* HUB */
#match-info-card {
    background: linear-gradient(180deg, #252525 0%, #1a1a1a 100%);
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
    width: 85%;
    border: 1px solid #444;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

.versus-display {
    font-family: 'Russo One';
    display: flex;
    justify-content: center;
    gap: 15px;
    align-items: center;
}

.hub-team-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 80px;
}

.hub-logo {
    width: 50px;
    height: 50px;
    object-fit: contain;
    margin-bottom: 5px;
    filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.5));
}

/* --- TABELA MODERNA --- */
.modern-table-header {
    display: flex;
    background: #333;
    padding: 10px;
    border-radius: 8px 8px 0 0;
    font-size: 11px;
    color: #888;
    font-weight: bold;
    text-transform: uppercase;
}

.modern-table-body {
    display: flex;
    flex-direction: column;
    background: rgba(30, 30, 30, 0.8);
    border-radius: 0 0 8px 8px;
    border: 1px solid #333;
}

.standings-row {
    display: flex;
    align-items: center;
    padding: 12px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 13px;
    transition: background 0.2s;
}

.standings-row:last-child {
    border-bottom: none;
}

.standings-row:hover {
    background: rgba(255, 255, 255, 0.05);
}

.row-qualified {
    border-left: 3px solid #00e676;
    background: linear-gradient(90deg, rgba(0, 230, 118, 0.05) 0%, transparent 50%);
}

.row-third {
    border-left: 3px solid #ff9800;
    background: linear-gradient(90deg, rgba(255, 152, 0, 0.05) 0%, transparent 50%);
}

.row-eliminated {
    border-left: 3px solid #ff5252;
    color: #888;
}

.table-logo {
    width: 24px;
    height: 24px;
    object-fit: contain;
    margin: 0 8px;
}

/* HUD STRUCTURE */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.top-hud-container {
    width: 100%;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0) 100%);
    padding-top: 15px;
    padding-bottom: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: auto;
}

.placar-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(10, 10, 10, 0.9);
    backdrop-filter: blur(5px);
    width: 90%;
    max-width: 380px;
    padding: 8px 12px;
    border-radius: 12px;
    border: 1px solid #333;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    margin-bottom: 5px;
    transition: border-color 0.5s;
}

.sudden-death-hud {
    border-color: #ff5252 !important;
    box-shadow: 0 0 20px rgba(255, 82, 82, 0.4) !important;
    animation: pulseBorder 1s infinite alternate;
}

@keyframes pulseBorder {
    from {
        border-color: #ff5252;
    }

    to {
        border-color: #550000;
    }
}

.team-score-container {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 90px;
    justify-content: center;
}

.hud-logo-small {
    width: 30px;
    height: 30px;
    object-fit: contain;
}

.hud-team-name {
    font-family: 'Russo One';
    font-size: 14px;
    color: #fff;
    text-shadow: 1px 1px 0 #000;
}

.big-num {
    font-size: 28px;
    display: block;
    line-height: 1;
    color: #ffeb3b;
    text-shadow: 0 2px 0 #b3a216;
    margin: 0 6px;
}

.timer {
    font-size: 9px;
    color: #bbb;
    text-transform: uppercase;
    font-weight: bold;
    text-align: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 3px 8px;
    border-radius: 4px;
    min-width: 40px;
}

#narrator-box {
    margin-top: 5px;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    padding: 4px 15px;
    border-radius: 15px;
    font-size: 11px;
    font-style: italic;
    border: 1px solid rgba(255, 255, 255, 0.2);
    text-shadow: 1px 1px 0 #000;
    pointer-events: none;
    transition: opacity 0.3s;
}

/* --- AJUSTE DOS BOTÕES PARA MOBILE --- */
#powerup-container {
    position: absolute;
    /* Subindo mais para não ser cortado pela barra de navegação */
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    width: 90%;
    max-width: 400px;
    justify-content: space-between;
    pointer-events: auto;
    z-index: 50;
    /* Garante que fique acima da safe area do iPhone/Android */
    padding-bottom: env(safe-area-inset-bottom);
}

.pwr-btn {
    background: linear-gradient(180deg, #333 0%, #111 100%);
    color: #fff;
    border: 2px solid #555;
    border-radius: 50%;
    width: 80px;
    height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 10px;
    font-family: 'Russo One';
    box-shadow: 0 6px 0 #000, 0 10px 10px rgba(0, 0, 0, 0.5);
    transition: transform 0.1s, box-shadow 0.1s;
}

.pwr-btn:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #000;
}

.pwr-active-fire {
    background: linear-gradient(180deg, #ff5722 0%, #d84315 100%) !important;
    border-color: #ffab91 !important;
    box-shadow: 0 0 20px #ff5722, 0 6px 0 #bf360c !important;
}

.pwr-active-chip {
    background: linear-gradient(180deg, #29b6f6 0%, #0277bd 100%) !important;
    border-color: #81d4fa !important;
    box-shadow: 0 0 20px #29b6f6, 0 6px 0 #01579b !important;
}

.pwr-used {
    opacity: 0.3 !important;
    filter: grayscale(1);
    pointer-events: none;
}

.penalty-dots-wrapper {
    display: flex;
    justify-content: space-between;
    width: 90%;
    max-width: 380px;
    margin-top: 5px;
}

.dots-row {
    display: flex;
    gap: 4px;
    height: 12px;
    align-items: center;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #333;
    border: 1px solid #555;
    transition: all 0.3s;
}

.dot.goal {
    background: #00e676;
    border-color: #00a152;
    box-shadow: inset 0 2px 2px rgba(255, 255, 255, 0.4);
}

.dot.miss {
    background: #ff1744;
    border-color: #b71c1c;
    box-shadow: inset 0 2px 2px rgba(255, 255, 255, 0.3);
}

.dot.pending {
    background: #555;
}

#feedback-msg {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.5);
    font-family: 'Russo One';
    font-size: 56px;
    text-shadow: 0 4px 0 #000, 0 0 30px rgba(255, 255, 255, 0.8);
    white-space: nowrap;
    opacity: 0;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
    z-index: 20;
}

#pressure-vignette {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, transparent 60%, rgba(0, 0, 0, 0.8) 100%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 1s;
    z-index: 4;
}

.pulse-anim {
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 0.3;
    }

    50% {
        transform: scale(1.05);
        opacity: 0.6;
    }

    100% {
        transform: scale(1);
        opacity: 0.3;
    }
}

/* NOVO ESTILO DE BRACKET COM LOGOS */
.bracket-match {
    background: linear-gradient(90deg, #222, #1a1a1a);
    padding: 10px;
    margin-bottom: 8px;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    border: 1px solid #333;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.bracket-match.player-match {
    border: 1px solid #ffeb3b;
    background: linear-gradient(90deg, #333, #222);
}

.bracket-team {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 45%;
}

.bracket-team-right {
    justify-content: flex-end;
    text-align: right;
}

.bracket-logo {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.bracket-vs {
    color: #666;
    font-size: 10px;
    font-weight: bold;
}

/* LISTA DE RANKING (Ajuste para centralização) */
#ranking-list {
    width: 90%;
    height: 60%;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
}

/* Classe para quando está vazio */
.empty-state {
    flex: 1;
    /* Ocupa todo o espaço vertical disponível */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #888;
    text-align: center;
    width: 100%;
    height: 100%;
}

.ranking-item {
    display: flex;
    justify-content: space-between;
    padding: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 14px;
}

.ranking-item:last-child {
    border-bottom: none;
}

.rank-date {
    color: #888;
    font-size: 12px;
}

/* SPEED RADAR */
#speed-radar {
    position: absolute;
    bottom: 120px;
    left: 20px;
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid #00e676;
    border-radius: 12px;
    padding: 10px;
    text-align: center;
    font-family: 'Russo One';
    transform: scale(0);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 60;
    min-width: 80px;
}

.radar-show {
    transform: scale(1) !important;
}

.speed-bar-bg {
    width: 100%;
    height: 6px;
    background: #333;
    margin-top: 5px;
    border-radius: 3px;
    overflow: hidden;
}

.speed-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #00e676, #ffeb3b, #ff5252);
    transition: width 0.5s ease-out;
}