:root {
    --felt-dark: #0f2b1d;
    --felt-light: #1a5c40;
    --rail-leather: #1a0f0a;
    --bg-gradient-start: #1a1a1a;
    --bg-gradient-end: #000000;
    --text-white: #f0f0f0;
    --gold: #ffd700;
    --gold-dim: #b89c28;
    --glass-bg: rgba(20, 20, 20, 0.65);
    --glass-border: rgba(255, 255, 255, 0.08);
    --btn-fold: #ff4757;
    --btn-check: #2ed573;
    --btn-raise: #ffa502;
    --btn-restart: #2bcbba;
}

* { box-sizing: border-box; user-select: none; }

body {
    margin: 0;
    height: 100vh; 
    height: 100dvh; 
    font-family: 'Inter', sans-serif;
    background-color: #050505;
    background-image: radial-gradient(circle at 50% 30%, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    color: var(--text-white);
}

.top-hud {
    width: 100%;
    padding: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    position: relative;
    min-height: 80px; 
    background: linear-gradient(to bottom, rgba(0,0,0,0.6), rgba(0,0,0,0));
}

.game-branding h1 {
    font-family: 'Playfair Display', serif;
    font-size: 1.8rem;
    margin: 0;
    letter-spacing: 3px;
    color: #fff;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
    font-weight: 700;
}

.gold-text { color: var(--gold); }

.tournament-status-bar {
    margin-top: 6px;
    z-index: 101;
}

.pill-info {
    font-family: 'Roboto Mono', monospace;
    font-size: 0.7rem;
    color: #ccc;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    padding: 6px 18px;
    border-radius: 30px; 
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    letter-spacing: 0.5px;
}

#game-stage {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    position: relative;
    perspective: 1000px; 
}

#mesa-wrapper {
    position: relative;
    width: 600px; 
    height: 300px;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#mesa {
    width: 100%;
    height: 100%;
    border-radius: 150px;
    position: relative;
    background-color: var(--felt-light);
    background-image: 
        radial-gradient(ellipse at center, rgba(255,255,255,0.1) 0%, transparent 70%),
        radial-gradient(ellipse at center, transparent 50%, var(--felt-dark) 100%),
        url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.06'/%3E%3C/svg%3E");
    box-shadow: 
        inset 0 0 60px rgba(0,0,0,0.9), 
        0 0 0 10px #0a0503,          
        0 0 0 22px var(--rail-leather),
        0 0 0 23px rgba(255,255,255,0.12), 
        0 30px 70px rgba(0,0,0,0.8);   
}

#mesa::before {
    content: '';
    position: absolute;
    top: 45px; bottom: 45px; left: 90px; right: 90px;
    border: 2px solid rgba(255,255,255,0.06);
    border-radius: 120px;
    pointer-events: none;
}

/* Botão PWA Centralizado na Mesa acima da contagem */
#pwa-install-btn {
    display: none; /* Controlado pelo JS */
    position: absolute; 
    top: 22%; /* Altura perfeita para ficar acima do RAZZ */
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Roboto Mono', monospace;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(212, 175, 55, 0.4); 
    color: var(--gold); 
    padding: 6px 14px; 
    border-radius: 12px; 
    cursor: pointer; 
    z-index: 1000;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
}
#pwa-install-btn:hover { 
    background: rgba(0, 0, 0, 0.8);
    color: #ffffff;
    border-color: var(--gold);
    transform: translateX(-50%) scale(1.05);
}

.feltro-brand {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -80%);
    font-family: 'Playfair Display', serif;
    font-size: 2.2rem;
    color: rgba(0,0,0,0.15); 
    font-weight: 700;
    letter-spacing: 4px;
    pointer-events: none;
    text-shadow: 0 1px 1px rgba(255,255,255,0.05);
}

#pote-container {
    position: absolute;
    top: 60%; left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 10;
    width: 220px;
}

.pote-display {
    font-family: 'Roboto Mono', monospace;
    color: var(--gold);
    font-size: 0.95rem;
    font-weight: 700;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    padding: 4px 14px;
    border-radius: 12px;
    border: 1px solid rgba(212, 175, 55, 0.2);
    display: inline-block;
    margin-bottom: 6px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.status-text {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.9);
    text-shadow: 0 2px 4px #000;
    font-weight: 500;
    min-height: 1.2em;
    letter-spacing: 0.5px;
}

.jogador-pos {
    position: absolute;
    width: 90px;
    height: 70px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 20;
}

.pos-4 { top: -50px; left: 25%; }
.pos-5 { top: -50px; right: 25%; }
.pos-6 { top: 15%; right: -50px; }
.pos-7 { bottom: 15%; right: -50px; }
.pos-1 { bottom: -65px; left: 50%; transform: translateX(-50%); z-index: 30; }
.pos-8 { bottom: -35px; right: 15%; }
.pos-2 { bottom: 15%; left: -50px; }
.pos-3 { top: 15%; left: -50px; }

.info-jogador-mesa {
    background: #1e272e; 
    background: linear-gradient(145deg, #2f3640, #1e272e);
    border: 1px solid #4b6584;
    color: #fff;
    padding: 4px 10px;
    border-radius: 20px; 
    font-size: 0.65rem;
    text-align: center;
    min-width: 80px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.6);
    margin-top: 6px;
    font-weight: 600;
    display: flex;
    justify-content: center;
    gap: 4px;
    transition: all 0.3s ease;
}

.jogador-ativo .info-jogador-mesa {
    border-color: var(--gold);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
    background: linear-gradient(145deg, #303030, #101010);
    transform: scale(1.05);
}

.ganhador .info-jogador-mesa {
    border-color: var(--btn-check);
    box-shadow: 0 0 20px rgba(46, 213, 115, 0.5);
}

.dealer-button {
    width: 18px; height: 18px;
    background: #f5f6fa; color: #000;
    border-radius: 50%;
    font-size: 0.65rem; font-weight: 900;
    display: flex; align-items: center; justify-content: center;
    position: absolute;
    top: -8px; right: -6px;
    border: 1px solid #bdc3c7;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
    z-index: 25;
}

.aposta-rodada {
    position: absolute;
    top: -22px;
    background: rgba(0,0,0,0.8);
    color: var(--gold);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-family: 'Roboto Mono';
    border: 1px solid rgba(255,215,0,0.3);
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.cartas-jogador {
    display: flex;
    justify-content: center;
    height: 40px;
    perspective: 600px;
}

.carta {
    width: 28px; height: 40px;
    background: #fdfdfd; 
    border-radius: 4px;
    display: flex; justify-content: center; align-items: center;
    font-size: 0.85rem; font-weight: 700; color: #2d3436;
    box-shadow: -1px 2px 5px rgba(0,0,0,0.4);
    margin-right: -15px; 
    border: 1px solid #dcdde1;
    transition: transform 0.2s, margin-top 0.2s;
}

.carta:last-child { margin-right: 0; }
.carta.vermelha { color: #e84118; }

.carta.virada {
    background-color: #2c3e50;
    background-image: repeating-linear-gradient(45deg, #2c3e50, #2c3e50 5px, #34495e 5px, #34495e 10px);
    border: 2px solid #fff; 
    color: transparent;
}

.carta.winning-card {
    transform: translateY(-10px);
    box-shadow: 0 0 10px var(--gold);
    border-color: var(--gold);
    z-index: 10;
}

#jogador-1 .carta {
    width: 38px; height: 54px; font-size: 1.1rem; margin-right: -20px;
    box-shadow: 0 -3px 8px rgba(0,0,0,0.5);
}
#jogador-1 .carta:hover { transform: translateY(-15px) scale(1.1); z-index: 50; }

#bottom-hud {
    width: 100%;
    padding: 20px;
    background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px; 
    z-index: 100;
    overflow: visible; 
}

.player-stats-panel {
    display: flex;
    align-items: center;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    padding: 10px 30px;
    border-radius: 50px;
    gap: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    position: relative; 
    margin-bottom: 5px;
}

.stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.stat-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    color: #888;
    letter-spacing: 1.5px;
    margin-bottom: 4px;
    font-weight: 600;
}
.stat-value {
    font-family: 'Roboto Mono', monospace;
    font-weight: 700;
    font-size: 1rem;
    color: #fff;
    text-shadow: 0 0 10px rgba(255,255,255,0.2);
}
.stat-value.highlight { color: #70a1ff; }

.stat-divider { width: 1px; height: 30px; background: rgba(255,255,255,0.1); }

.chip-count-widget { position: relative; display: flex; justify-content: center; }

.chip-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 8px 18px;
    border-radius: 25px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
}
.chip-btn:hover { background: rgba(255,255,255,0.1); border-color: var(--gold-dim); }
.chip-btn .icon { color: var(--gold); font-size: 1.1rem; }
.chip-btn .label { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: #ddd; }

.chip-list {
    position: absolute;
    bottom: 150%; 
    left: 50%;
    transform: translateX(-50%) scale(0.95);
    opacity: 0;
    pointer-events: none;
    background: rgba(15, 15, 15, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid #333;
    border-radius: 12px;
    padding: 0;
    list-style: none;
    width: 220px;
    max-height: 0;
    overflow: hidden;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 10px 40px rgba(0,0,0,0.8);
    z-index: 1000; 
}

.placar-aberto .chip-list { 
    max-height: 300px; 
    overflow-y: auto; 
    transform: translateX(-50%) scale(1);
    opacity: 1;
    pointer-events: auto;
    border-color: var(--gold-dim);
}

.chip-list li {
    display: flex;
    justify-content: space-between;
    padding: 10px 15px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    font-size: 0.8rem;
}
.chip-list li:last-child { border-bottom: none; }
.placar-nome { color: #ccc; }
.placar-saldo { color: var(--gold); font-family: 'Roboto Mono'; }
.placar-humano .placar-nome { color: #fff; font-weight: bold; }
.placar-eliminado { opacity: 0.4; text-decoration: line-through; }

.action-bar {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 10px;
}

.btn {
    border: none;
    border-radius: 12px;
    padding: 0 20px;
    height: 48px;
    font-family: 'Inter', sans-serif;
    font-weight: 800;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: white;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    min-width: 85px;
    outline: none;
    position: relative;
    overflow: hidden;
}

.btn:active:not(:disabled) { transform: scale(0.96); }

.btn:disabled { 
    background: #2f3640; 
    color: #7f8c8d; 
    cursor: not-allowed; 
    box-shadow: none; 
    opacity: 0.7;
}

.btn-fold { 
    background-color: var(--btn-fold); 
    box-shadow: 0 4px 15px rgba(255, 71, 87, 0.3);
}
.btn-fold:hover:not(:disabled) { 
    background-color: #ff6b81; 
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 71, 87, 0.4);
}

.btn-call { 
    background-color: var(--btn-check); 
    color: #0a3d25; 
    box-shadow: 0 4px 15px rgba(46, 213, 115, 0.3);
}
.btn-call:hover:not(:disabled) { 
    background-color: #7bed9f; 
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(46, 213, 115, 0.4);
}

.btn-raise { 
    background-color: var(--btn-raise); 
    color: #3d260a;
    box-shadow: 0 4px 15px rgba(255, 165, 2, 0.3);
}
.btn-raise:hover:not(:disabled) { 
    background-color: #ffc048; 
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 165, 2, 0.4);
}

.btn-restart { 
    background-color: var(--btn-restart);
    color: #05332e;
    margin-top: 10px;
    width: 200px;
    box-shadow: 0 4px 15px rgba(43, 203, 186, 0.3);
}
.btn-restart:hover {
    transform: translateY(-2px);
    background-color: #55e6c1;
}

@media (max-width: 700px) {
    #mesa-wrapper { 
        transform: scale(0.70); 
        margin-top: -20px; 
    }
    #bottom-hud {
        padding-bottom: 40px; 
        justify-content: flex-end;
    }
    .player-stats-panel { padding: 8px 20px; gap: 15px; border-radius: 30px; }
    .chip-btn .label { display: none; } 
    .chip-btn { padding: 8px 12px; }
    .btn { padding: 0 15px; min-width: 70px; font-size: 0.7rem; height: 42px; }
    h1 { font-size: 1.4rem; }
    .top-hud { min-height: 60px; }
}

@media (max-width: 500px) {
    #mesa-wrapper { 
        transform: scale(0.6); 
        margin-top: -40px; 
    }
    #bottom-hud {
        padding-bottom: 60px;
    }
    .player-stats-panel { gap: 10px; padding: 6px 15px; }
    .stat-value { font-size: 0.9rem; }
}

