:root {
    --bg-color: #0b0f19;
    --panel-bg: rgba(20, 25, 40, 0.6);
    --glass-border: rgba(255, 255, 255, 0.1);
    --primary: #00ffcc;
    --secondary: #ff007f;
    --font-color: #e0e5ec;
    --cell-bg: #161c2d;
    --cell-active: rgba(0, 255, 204, 0.3);
    --cell-fixed: #8b9bb4;
    --cell-border: #232c43;
    --cell-thick-border: #4d5c7c;
}

/* Themes */
body.theme-neon_gold {
    --primary: #ffd700;
    --secondary: #ff8c00;
    --bg-color: #1a1805;
    --panel-bg: rgba(40, 35, 10, 0.6);
}

body.theme-cyber_red {
    --primary: #ff003c;
    --secondary: #00f0ff;
    --bg-color: #120005;
    --panel-bg: rgba(30, 0, 10, 0.6);
}

body.theme-midnight {
    --primary: #7b68ee;
    --secondary: #00ced1;
    --bg-color: #0a0a1a;
    --panel-bg: rgba(10, 10, 40, 0.6);
}

body.theme-fire {
    --primary: #ff4500;
    --secondary: #ffd700;
    --bg-color: #1a0a00;
    --panel-bg: rgba(40, 15, 0, 0.6);
}

body.theme-play_gold {
    --primary: #00ff88;
    --secondary: #ffd700;
    --bg-color: #0a1a0f;
    --panel-bg: rgba(0, 40, 20, 0.6);
}

body.theme-royal_purple {
    --primary: #b388ff;
    --secondary: #ff80ab;
    --bg-color: #0d0020;
    --panel-bg: rgba(20, 0, 50, 0.6);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-color);
    background-image: radial-gradient(circle at 10% 20%, rgba(0, 255, 204, 0.05) 0%, transparent 40%),
                      radial-gradient(circle at 90% 80%, rgba(255, 0, 127, 0.05) 0%, transparent 40%);
    color: var(--font-color);
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background 0.5s;
}

.glass {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

.hidden {
    display: none !important;
}

/* ── SPLASH SCREEN ──────────────────────────────────────────────────────────── */
#splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-color);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.6s ease;
}

.splash-content {
    text-align: center;
}

.splash-glitch {
    font-size: 3.5rem;
    font-weight: 900;
    text-transform: uppercase;
    position: relative;
    color: var(--primary);
    text-shadow: 0 0 20px var(--primary);
    margin-bottom: 1rem;
    animation: splashPulse 2s ease-in-out infinite;
}

.splash-glitch::before,
.splash-glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.splash-glitch::before {
    animation: glitch-slice1 3s infinite linear alternate-reverse;
    clip-path: polygon(0 0, 100% 0, 100% 35%, 0 35%);
    color: var(--secondary);
    transform: translate(-3px, -3px);
    opacity: 0.6;
}

.splash-glitch::after {
    animation: glitch-slice2 2s infinite linear alternate-reverse;
    clip-path: polygon(0 65%, 100% 65%, 100% 100%, 0 100%);
    color: #4488ff;
    transform: translate(3px, 3px);
    opacity: 0.6;
}

@keyframes glitch-slice1 {
    0% { transform: translate(-3px, -3px); opacity: 0.6; }
    20% { transform: translate(2px, -5px); opacity: 0.8; }
    40% { transform: translate(-4px, 0px); opacity: 0.4; }
    60% { transform: translate(3px, -2px); opacity: 0.7; }
    80% { transform: translate(-2px, -4px); opacity: 0.3; }
    100% { transform: translate(-3px, -3px); opacity: 0.6; }
}

@keyframes glitch-slice2 {
    0% { transform: translate(3px, 3px); opacity: 0.6; }
    20% { transform: translate(-2px, 5px); opacity: 0.3; }
    40% { transform: translate(4px, 0px); opacity: 0.8; }
    60% { transform: translate(-3px, 2px); opacity: 0.4; }
    80% { transform: translate(2px, 4px); opacity: 0.7; }
    100% { transform: translate(3px, 3px); opacity: 0.6; }
}

@keyframes splashPulse {
    0%, 100% { text-shadow: 0 0 20px var(--primary); }
    50% { text-shadow: 0 0 40px var(--primary), 0 0 60px rgba(0,255,204,0.3); }
}

.splash-subtitle {
    color: var(--cell-fixed);
    font-size: 1rem;
    margin-bottom: 2.5rem;
}

.splash-loader {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255,255,255,0.08);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.splash-fade-out {
    opacity: 0;
    pointer-events: none;
}

/* ── TAB LAYOUT ──────────────────────────────────────────────────────────────── */
#lobby {
    width: 100vw;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.tab-content-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 72px;
    display: flex;
    flex-direction: column;
}

.tab-content {
    display: none;
    flex: 1;
    padding: 1.5rem 1rem;
    animation: tabFadeIn 0.25s ease;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
    align-items: center;
}

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

/* ── TAB BAR ──────────────────────────────────────────────────────────────────── */
#tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: rgba(11, 15, 25, 0.94);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 40;
    padding: 0 env(safe-area-inset-bottom);
}

.tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    background: none;
    border: none;
    color: rgba(255,255,255,0.35);
    font-size: 1.35rem;
    cursor: pointer;
    padding: 6px 4px 4px;
    transition: all 0.2s;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

.tab-btn .tab-label {
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.tab-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: 20%;
    right: 20%;
    height: 2px;
    background: var(--primary);
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.2s;
    box-shadow: 0 0 8px var(--primary);
}

.tab-btn.active {
    color: var(--primary);
    text-shadow: 0 0 10px rgba(0,255,204,0.4);
}

.tab-btn.active::after {
    opacity: 1;
}

.tab-btn:active {
    transform: scale(0.92);
}

.lobby-container {
    padding: 2rem 1.5rem;
    text-align: center;
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
}

.shop-container {
    padding: 1.5rem;
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
}

.shop-balance {
    font-size: 1.2rem;
    color: gold;
    font-weight: bold;
    margin: 10px 0;
}

.shop-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    max-height: 400px;
}

.shop-item {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    padding: 10px;
    border-radius: 8px;
    text-align: left;
}

.shop-item h4 { color: var(--primary); margin-bottom: 5px; }

.shop-btn {
    margin-top: 8px;
    padding: 6px 12px;
    background: var(--primary);
    color: #000;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    width: 100%;
}
.shop-btn:disabled {
    background: #555;
    cursor: not-allowed;
}

.shop-btn.equip-btn {
    background: var(--secondary);
    color: #fff;
}

/* Shop Tabs */
.shop-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}

.shop-tab {
    flex: 1;
    padding: 7px 4px;
    font-size: 0.78rem;
    font-weight: bold;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--font-color);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.shop-tab:hover {
    background: rgba(255, 255, 255, 0.1);
}

.shop-tab.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #000;
    border-color: transparent;
    box-shadow: 0 0 10px rgba(0, 255, 204, 0.3);
}

.user-panel {
    padding: 1.5rem;
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
}

.leaderboard-container {
    padding: 1.5rem;
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
}

#leaderboard-list {
    list-style: none;
    margin-top: 1rem;
    overflow-y: auto;
    max-height: 400px;
}

#leaderboard-list li {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    font-size: 1.1rem;
}

.vip-badge {
    color: gold;
    font-size: 0.9rem;
    margin-left: 5px;
    background: rgba(255, 215, 0, 0.2);
    padding: 2px 5px;
    border-radius: 4px;
}

.modern-input {
    margin-top: 20px;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--primary);
    background: rgba(0, 0, 0, 0.2);
    color: #fff;
    font-size: 1.1rem;
    outline: none;
    text-align: center;
}
.modern-input:focus {
    box-shadow: 0 0 10px var(--primary);
}

.user-display {
    margin-top: 15px;
    padding: 10px;
    background: rgba(0,255,204,0.1);
    border-radius: 8px;
}

.glitch {
    font-size: 3rem;
    font-weight: 900;
    text-transform: uppercase;
    position: relative;
    color: var(--primary);
    text-shadow: 0px 0px 10px var(--primary);
    margin-bottom: 20px;
}

.primary-btn {
    margin-top: 1.5rem;
    padding: 12px 24px;
    font-size: 1.2rem;
    font-weight: bold;
    color: #fff;
    background: linear-gradient(45deg, var(--primary), var(--secondary));
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(0, 255, 204, 0.4);
}

.gold-btn {
    margin-top: 5px;
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: bold;
    color: #000;
    background: linear-gradient(45deg, #ffd700, #ff8c00);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.4);
    animation: popIn 0.5s;
}

.gold-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.6);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 255, 204, 0.6);
}

.secondary-btn {
    margin-top: 10px;
    padding: 12px 24px;
    font-size: 1.1rem;
    font-weight: bold;
    color: #fff;
    background: transparent;
    border: 2px solid var(--primary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.secondary-btn:hover {
    background: rgba(255,255,255,0.1);
}

#queue-status {
    margin-top: 1rem;
    color: var(--secondary);
    font-weight: 500;
}

/* GAME SCREEN */
#game-screen {
    width: 100vw;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    margin: 1rem;
    border-radius: 12px;
}

.name-display {
    color: var(--primary);
    font-size: 1rem;
    font-weight: 400;
    margin-left: 8px;
    background: rgba(0,255,204,0.1);
    padding: 2px 8px;
    border-radius: 4px;
}

.glitch-timer {
    font-size: 3rem;
    color: #fff;
    text-shadow: 0 0 10px var(--primary);
    font-variant-numeric: tabular-nums;
}

.status-center {
    display: flex;
    align-items: center;
    gap: 8px;
}

.abandon-btn {
    background: rgba(255,60,80,0.15);
    border: 1px solid rgba(255,60,80,0.4);
    color: #ff4466;
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
}
.abandon-btn:hover {
    background: rgba(255,60,80,0.3);
    box-shadow: 0 0 10px rgba(255,60,80,0.4);
}

.powers-container {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    min-height: 40px;
}

.power-btn {
    background: rgba(255, 0, 127, 0.2);
    border: 1px solid var(--secondary);
    color: #fff;
    border-radius: 8px;
    padding: 8px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.power-btn:hover {
    background: var(--secondary);
    box-shadow: 0 0 10px var(--secondary);
}

.op-status-ring {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 3px solid #333;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--primary);
    position: relative;
    margin-top: 10px;
}

/* ── Layout principal do jogo ─────────────────────────────────────────────── */
main {
    flex: 1;
    display: flex;
    gap: 0.8rem;
    justify-content: center;
    align-items: center;
    padding-top: 0.5rem;
    padding-bottom: 2rem;
    flex-wrap: nowrap;
}

/* ── Área central: poderes + tabuleiro + numpad ───────────────────────────── */
.board-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

/* Wrapper que coloca barras + tabuleiro lado a lado, alinhados pelo topo */
.board-with-bars {
    display: flex;
    flex-direction: row;
    align-items: stretch;   /* barras esticam para a mesma altura do tabuleiro */
    gap: 8px;
}

/* ── Barra de poderes acima do tabuleiro ─────────────────────────────────── */
.powers-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    min-height: 44px;
    align-items: center;
    width: 100%;
    max-width: 480px;
}

/* Botão de poder — só ícone, tooltip no hover/touch */
.powers-bar .power-btn {
    width: 52px;
    height: 52px;
    padding: 0;
    font-size: 1.5rem;
    border-radius: 12px;
    background: rgba(255, 0, 127, 0.15);
    border: 1px solid rgba(255, 0, 127, 0.4);
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    /* Área de toque maior que o visual — essencial para mobile */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* Área invisível de toque estendida — +8px em cada lado */
.powers-bar .power-btn::before {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 18px;
}

.powers-bar .power-btn:hover,
.powers-bar .power-btn:focus,
.powers-bar .power-btn:active {
    background: rgba(255, 0, 127, 0.4);
    box-shadow: 0 0 16px rgba(255, 0, 127, 0.6);
    transform: scale(1.12);
}

/* Tooltip do poder */
.powers-bar .power-btn::after {
    content: attr(data-name);
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(10, 14, 26, 0.95);
    border: 1px solid rgba(255, 0, 127, 0.4);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
    padding: 4px 10px;
    border-radius: 6px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 10;
}

.powers-bar .power-btn:hover::after,
.powers-bar .power-btn:focus::after {
    opacity: 1;
}

/* Mobile — botão ainda maior para facilitar o toque */
@media (max-width: 600px) {
    .powers-bar .power-btn {
        width: 64px;
        height: 64px;
        font-size: 1.8rem;
        border-radius: 16px;
        border-width: 2px;
    }
    .powers-bar .power-btn::before {
        inset: -12px;
        border-radius: 22px;
    }
    .powers-bar {
        gap: 12px;
        min-height: 72px;
    }
}

/* Raridade — borda colorida */
.powers-bar .power-btn[data-rarity="common"]    { border-color: rgba(100,200,100,0.5); }
.powers-bar .power-btn[data-rarity="rare"]      { border-color: rgba(80,120,255,0.6); background: rgba(80,120,255,0.15); }
.powers-bar .power-btn[data-rarity="epic"]      { border-color: rgba(180,80,255,0.6); background: rgba(180,80,255,0.15); }
.powers-bar .power-btn[data-rarity="legendary"] { border-color: rgba(255,180,0,0.7);  background: rgba(255,180,0,0.15); box-shadow: 0 0 10px rgba(255,180,0,0.35); }

.premium-power-bar {
    width: 100%;
    max-width: 480px;
    font-size: 0.9rem;
    padding: 8px 16px;
}

/* ── Barras de progresso laterais ────────────────────────────────────────── */
.progress-bar-side {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    /* Sem height fixo — estica para combinar com o tabuleiro via align-items:stretch no pai */
    flex-shrink: 0;
    width: 28px;
}

.progress-bar-track {
    flex: 1;                   /* ocupa toda a altura disponível */
    width: 18px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-end; /* fill sobe de baixo para cima */
    position: relative;
    min-height: 200px;
}

.progress-bar-fill {
    width: 100%;
    height: 0%;
    border-radius: 10px;
    transition: height 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.my-fill {
    background: linear-gradient(to top, var(--primary), #00c9a7);
    box-shadow: 0 0 8px rgba(0,255,204,0.4);
}

.opp-fill {
    background: linear-gradient(to top, var(--secondary), #ff4060);
    box-shadow: 0 0 8px rgba(255,0,127,0.4);
}

/* Brilho pulsante quando > 80% */
.progress-bar-fill.danger {
    animation: progressPulse 1s ease-in-out infinite;
}

@keyframes progressPulse {
    0%, 100% { box-shadow: 0 0 8px rgba(255,0,127,0.4); }
    50%       { box-shadow: 0 0 20px rgba(255,0,127,0.8); }
}

.progress-bar-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
    min-width: 32px;
    text-align: center;
}

#opp-progress-bar-wrap .progress-bar-label {
    color: var(--secondary);
}

.progress-bar-name {
    font-size: 0.65rem;
    color: var(--muted);
    text-align: center;
    max-width: 50px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    letter-spacing: 0.5px;
}

/* Mobile — barras menores, layout adaptado */
@media (max-width: 600px) {
    main {
        gap: 4px;
        padding-bottom: 1rem;
        flex-wrap: nowrap;
        align-items: center;
        padding-top: 0.5rem;
    }

    .progress-bar-side {
        width: 16px;
    }

    .progress-bar-track {
        width: 10px;
        min-height: 150px;
    }

    .progress-bar-name {
        display: none;
    }

    .progress-bar-label {
        font-size: 0.6rem;
    }
}

/* Tablet/desktop — esconde mini-board quando barras estão visíveis */
@media (min-width: 601px) {
    .opp-board-panel {
        display: none;
    }
}

.board-wrapper {
    background: var(--panel-bg);
    padding: 10px;
    border-radius: 12px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

#sudoku-board {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    gap: 1px;
    background: var(--cell-border);
    border: 3px solid var(--cell-thick-border);
}

.cell {
    width: 50px;
    height: 50px;
    background: var(--cell-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    user-select: none;
}

.cell:nth-child(3n) { border-right: 2px solid var(--cell-thick-border); }
.cell:nth-child(n+19):nth-child(-n+27),
.cell:nth-child(n+46):nth-child(-n+54) {
    border-bottom: 2px solid var(--cell-thick-border);
}

.cell.fixed { color: var(--cell-fixed); cursor: not-allowed; }
.cell.active { background: var(--cell-active); box-shadow: inset 0 0 10px var(--primary); }
.cell.correct { color: var(--primary); text-shadow: 0 0 5px var(--primary); }
.cell.error-anim { animation: shake 0.4s ease-in-out; color: var(--secondary); }

.controls { padding: 2rem; }
.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.num-btn {
    width: 60px; height: 60px; border-radius: 12px;
    background: rgba(255, 255, 255, 0.05); border: 1px solid var(--glass-border);
    color: #fff; font-size: 1.5rem; font-weight: bold; cursor: pointer; transition: all 0.2s;
}
.num-btn:hover { background: rgba(255, 255, 255, 0.1); transform: scale(1.05); }
.num-btn:active { transform: scale(0.95); background: var(--primary); color: #000; }
.clear-btn { background: rgba(255, 0, 127, 0.1); color: var(--secondary); }

.glass-overlay {
    position: absolute; top: 0; left: 0; width: 100vw; height: 100vh;
    display: flex; justify-content: center; align-items: center; z-index: 100;
    backdrop-filter: blur(10px); background: rgba(0,0,0,0.6);
}
.overlay-content { text-align: center; background: var(--panel-bg); padding: 3rem; border-radius: 16px; border: 1px solid var(--glass-border); }
.overlay-content h1 { font-size: 4rem; margin-bottom: 2rem; color: #fff; text-shadow: 0 0 20px var(--primary); }

#screen-fx { position: absolute; top: 0; left: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 50; transition: background 0.3s; }

@keyframes popIn { 0% { transform: scale(0); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* Novas Classes de Poderes e Ligas */
.invert-vision { transform: rotate(180deg); transition: transform 0.3s ease; }
.shuffle-vision { animation: shuffle-shake 0.2s infinite; opacity: 0.8; filter: blur(1px); }
@keyframes shuffle-shake {
    0% { transform: translate(2px, 1px) rotate(0deg); }
    25% { transform: translate(-3px, 0px) rotate(1deg); }
    50% { transform: translate(-1px, 2px) rotate(-1deg); }
    75% { transform: translate(2px, 1px) rotate(-1deg); }
    100% { transform: translate(1px, -2px) rotate(-1deg); }
}
.blindness-overlay {
    position: absolute; top:0; left:0; width:100%; height:100%;
    background: black; z-index: 100; opacity: 0; pointer-events: none; transition: opacity 0.3s ease;
}
.blindness-active { opacity: 0.95; pointer-events: all; animation: flicker 0.2s infinite alternate; }
@keyframes flicker { 0% { opacity: 0.95; } 100% { opacity: 0.8; } }

/* ── Painel de Defesa (Lobby) ─────────────────────────────────────────────── */
.defense-status-panel {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding: 10px 12px;
    background: rgba(0, 255, 204, 0.07);
    border: 1px solid rgba(0, 255, 204, 0.25);
    border-radius: 10px;
}

.defense-status-panel #defense-status-icon {
    font-size: 1.8rem;
    flex-shrink: 0;
}

.defense-status-panel > div:nth-child(2) {
    flex: 1;
}

.defense-activate-btn {
    padding: 6px 14px;
    background: linear-gradient(135deg, var(--primary), #00c9a7);
    color: #000;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.defense-activate-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 10px var(--primary);
}

.defense-activate-btn:disabled {
    background: #555;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Indicador de escudo ativo na tela de jogo */
.defense-hud {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8rem;
    background: rgba(0, 255, 204, 0.12);
    border: 1px solid rgba(0, 255, 204, 0.3);
    border-radius: 8px;
    padding: 3px 8px;
    margin-top: 6px;
    color: var(--primary);
    animation: popIn 0.3s ease;
}

/* ── Modal Nível do Bot ───────────────────────────────────────────────────── */
.bot-level-content {
    max-width: 420px;
    width: 92vw;
}

.bot-level-content h2 {
    font-size: 1.8rem;
    color: var(--primary);
    margin-bottom: 0;
}

.bot-level-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.bot-level-btn {
    display: grid;
    grid-template-columns: 2rem 1fr;
    grid-template-rows: auto auto;
    column-gap: 12px;
    align-items: center;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--font-color);
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
}

.bot-level-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary);
    transform: translateX(4px);
}

.bot-level-icon {
    grid-row: 1 / 3;
    font-size: 1.6rem;
    display: flex;
    align-items: center;
}

.bot-level-name {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--primary);
}

.bot-level-desc {
    font-size: 0.82rem;
    color: var(--cell-fixed);
}

/* ── Mini-board do Oponente ───────────────────────────────────────────────── */
.opp-board-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px;
    gap: 8px;
    align-self: center;
}

.opp-board-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--secondary);
    padding: 0 2px;
}

.opp-board-pct {
    font-size: 0.9rem;
    color: var(--primary);
    background: rgba(0,255,204,0.1);
    padding: 2px 7px;
    border-radius: 6px;
}

.opp-sudoku-board {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    gap: 1px;
    background: var(--cell-border);
    border: 2px solid var(--cell-thick-border);
}

.opp-cell {
    width: 22px;
    height: 22px;
    background: var(--cell-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.6rem;
    font-weight: bold;
    user-select: none;
    transition: background 0.2s;
}

.opp-cell.opp-fixed {
    color: var(--cell-fixed);
}

.opp-cell.opp-filled {
    color: var(--secondary);
    background: rgba(255, 0, 127, 0.12);
    animation: oppCellPop 0.25s ease;
}

.opp-cell:nth-child(3n) { border-right: 1px solid var(--cell-thick-border); }
.opp-cell:nth-child(n+19):nth-child(-n+27),
.opp-cell:nth-child(n+46):nth-child(-n+54) {
    border-bottom: 1px solid var(--cell-thick-border);
}

@keyframes oppCellPop {
    0%   { transform: scale(1.4); background: rgba(255, 0, 127, 0.4); }
    100% { transform: scale(1);   background: rgba(255, 0, 127, 0.12); }
}

/* ── Overlay de Poder no Mini-board ──────────────────────────────────────── */
.opp-power-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s ease;
    z-index: 10;
}

.opp-power-overlay.opp-overlay-show {
    opacity: 1;
}

.opp-power-overlay.opp-overlay-fade {
    opacity: 0;
    transition: opacity 0.6s ease;
}

.opp-power-emoji {
    font-size: 1.8rem;
    filter: drop-shadow(0 0 6px rgba(255,255,255,0.8));
    animation: popIn 0.3s ease;
}

.opp-power-label {
    font-size: 0.7rem;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0,0,0,0.9);
    text-align: center;
    padding: 2px 6px;
    background: rgba(0,0,0,0.5);
    border-radius: 4px;
}

/* ── Row Verify Popup ─────────────────────────────────────────────────────── */
.row-verify-content {
    max-width: 300px;
    width: 80vw;
    padding: 1.5rem 2rem;
}

.row-verify-icon {
    font-size: 2.5rem;
    margin-bottom: 0.25rem;
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.row-verify-warning {
    color: rgba(255, 215, 0, 0.8);
    font-size: 0.82rem;
    margin-top: 0.5rem;
}

/* ── Row Highlight States ─────────────────────────────────────────────────── */
.cell.row-pending {
    background: rgba(255, 215, 0, 0.15);
    box-shadow: inset 0 0 8px rgba(255, 215, 0, 0.4);
}

.cell.row-correct {
    background: rgba(0, 255, 100, 0.2);
    box-shadow: inset 0 0 10px rgba(0, 255, 100, 0.5);
    animation: rowCorrectFlash 0.4s ease;
}

.cell.row-error {
    background: rgba(255, 0, 60, 0.2);
    box-shadow: inset 0 0 10px rgba(255, 0, 60, 0.5);
    animation: rowErrorFlash 0.4s ease;
}

@keyframes rowCorrectFlash {
    0% { background: rgba(0, 255, 100, 0.6); }
    100% { background: rgba(0, 255, 100, 0.2); }
}

@keyframes rowErrorFlash {
    0% { background: rgba(255, 0, 60, 0.6); }
    100% { background: rgba(255, 0, 60, 0.2); }
}

/* ── Row Feedback Toast ───────────────────────────────────────────────────── */
.row-feedback-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: bold;
    z-index: 300;
    text-align: center;
    max-width: 90vw;
    animation: slideUp 0.3s ease;
    backdrop-filter: blur(10px);
}

.row-feedback-success {
    background: rgba(0, 255, 100, 0.2);
    border: 1px solid rgba(0, 255, 100, 0.5);
    color: #00ff64;
    box-shadow: 0 4px 20px rgba(0, 255, 100, 0.3);
}

.row-feedback-error {
    background: rgba(255, 0, 60, 0.2);
    border: 1px solid rgba(255, 0, 60, 0.5);
    color: #ff003c;
    box-shadow: 0 4px 20px rgba(255, 0, 60, 0.3);
}

@keyframes slideUp {
    from { transform: translateX(-50%) translateY(20px); opacity: 0; }
    to   { transform: translateX(-50%) translateY(0);    opacity: 1; }
}

/* ── Google Login Button ──────────────────────────────────────────────────── */
.google-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    background: rgba(255,255,255,0.08);
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 8px;
}
.google-btn:hover { background: rgba(255,255,255,0.15); border-color: rgba(255,255,255,0.4); }

.login-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px 0 4px;
    color: var(--cell-fixed);
    font-size: 0.82rem;
}
.login-divider::before, .login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--glass-border);
}

/* ── Pix Modal ────────────────────────────────────────────────────────────── */
.pix-modal-content {
    max-width: 420px;
    width: 92vw;
    max-height: 90vh;
    overflow-y: auto;
}
.pix-modal-content h2 { font-size: 1.6rem; color: var(--primary); margin-bottom: 0; }

.pix-packages {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.pix-pkg {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s;
}
.pix-pkg:hover { border-color: var(--primary); background: rgba(0,255,204,0.06); }
.pix-pkg-info h4 { font-size: 0.95rem; font-weight: 700; }
.pix-pkg-info p  { font-size: 0.78rem; color: var(--muted); }
.pix-pkg-price {
    font-size: 1.1rem;
    font-weight: 900;
    color: var(--primary);
    white-space: nowrap;
}

/* ── Seletor de Idioma ────────────────────────────────────────────────────── */
.lang-btn {
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
}
.lang-btn:hover { background: rgba(255,255,255,0.15); transform: scale(1.1); }
.lang-btn.active { border-color: var(--primary); background: rgba(0,255,204,0.1); }

/* ── Dica do Dia ──────────────────────────────────────────────────────────── */
.tip-box {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: rgba(0,255,204,0.06);
    border: 1px solid rgba(0,255,204,0.2);
    border-radius: 10px;
    padding: 10px 12px;
    margin-top: 12px;
    font-size: 0.82rem;
    color: var(--muted);
    line-height: 1.5;
}
.tip-box span:first-child { font-size: 1.1rem; flex-shrink: 0; }

/* ── Conquistas ───────────────────────────────────────────────────────────── */
.achievements-preview { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 10px; }
.achievements-preview h3 { font-size: 0.9rem; color: var(--primary); margin-bottom: 8px; }

.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
    max-height: 55vh;
    overflow-y: auto;
    padding: 4px;
}
.achievement-card {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 8px;
    text-align: center;
    transition: all 0.2s;
}
.achievement-card.unlocked { border-color: rgba(255,215,0,0.4); background: rgba(255,215,0,0.06); }
.achievement-card.locked   { opacity: 0.4; filter: grayscale(0.8); }
.achievement-card .ach-icon { font-size: 1.8rem; margin-bottom: 4px; }
.achievement-card .ach-name { font-size: 0.75rem; font-weight: 700; }
.achievement-card .ach-desc { font-size: 0.68rem; color: var(--muted); margin-top: 2px; }
.achievement-card .ach-reward { font-size: 0.7rem; color: gold; margin-top: 4px; }
.achievement-card .ach-bar { height: 4px; background: rgba(255,255,255,0.1); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.achievement-card .ach-bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--secondary)); border-radius: 2px; transition: width 0.5s; }

.achievements-modal-content { max-width: 500px; width: 95vw; max-height: 85vh; overflow-y: auto; }
.achievements-modal-content h2 { font-size: 1.6rem; color: var(--primary); margin-bottom: 1rem; }

.achievement-toast {
    position: fixed;
    bottom: 5rem;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, rgba(255,215,0,0.2), rgba(255,165,0,0.15));
    border: 1px solid rgba(255,215,0,0.5);
    border-radius: 14px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 400;
    animation: slideUp 0.4s ease;
    max-width: 90vw;
    box-shadow: 0 4px 20px rgba(255,215,0,0.3);
}
.achievement-toast .t-icon { font-size: 1.8rem; }
.achievement-toast .t-text { font-size: 0.88rem; }
.achievement-toast .t-text strong { color: gold; display: block; font-size: 0.95rem; }

/* ── Caminho de Troféus (Lobby) ───────────────────────────────────────────── */
.trophy-road {
    background: rgba(255,255,255,0.05); border-radius: 12px; padding: 15px; text-align: center; margin-bottom: 20px;
    border: 1px solid rgba(255,255,255,0.1); width: 100%;
}
.league-badge { font-size: 2.5rem; margin-bottom: 5px; text-shadow: 0 0 10px rgba(255,255,255,0.5); }
.trophy-bar-bg { background: rgba(0,0,0,0.5); height: 10px; border-radius: 10px; overflow: hidden; margin-top: 10px; }
.trophy-bar-fill { background: linear-gradient(90deg, gold, orange); height: 100%; width: 0%; transition: width 1s ease; }

/* Tab content on very small screens */
@media (max-width: 480px) {
    .tab-content { padding: 1rem 0.75rem; }
    .lobby-container { padding: 1.5rem 1rem; }
    .shop-container { padding: 1.25rem 0.75rem; }
    .leaderboard-container { padding: 1.25rem 0.75rem; }
    .user-panel { padding: 1.25rem 0.75rem; }
    .splash-glitch { font-size: 2.5rem; }
    .tab-btn { font-size: 1.2rem; }
    .tab-btn .tab-label { font-size: 0.55rem; }
}

@media (max-width: 768px) {
    main { flex-direction: column; padding-bottom: 5rem; }
    header { flex-direction: column; text-align: center; gap: 10px; margin: 0.5rem; padding: 1rem; }
    .cell { width: 35px; height: 35px; font-size: 1.1rem; }
    .glitch { font-size: 2rem; }
    .glitch-timer { font-size: 2.5rem; }
    .overlay-content h1 { font-size: 2.5rem; }
}

/* ── Lobby Ad Banner (Web) ────────────────────────────────────────────────── */
#lobby-ad-banner {
    position: fixed;
    bottom: 64px; /* Sits right above the 64px high tab-bar */
    left: 0;
    right: 0;
    min-height: 50px;
    max-height: 90px;
    background: rgba(11, 15, 25, 0.94);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 39;
    overflow: hidden;
    padding: 4px env(safe-area-inset-right) 4px env(safe-area-inset-left);
    box-sizing: border-box;
}
