* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #1a472a;
    --primary-light: #2d5a3d;
    --accent: #2563eb;
    --accent-hover: #3b82f6;
    --bg-dark: #0d1f14;
    --bg-card: #152a1c;
    --text: #2563eb;
    --text-muted: #60a5fa;
    --border: #ffffff;
    --danger: #dc3545;
    --success: #28a745;
}

html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: url('fondo.png') center center fixed;
    background-size: cover;
    background-repeat: no-repeat;
    background-attachment: fixed;
    min-height: 100vh;
    min-height: -webkit-fill-available;
    color: var(--text);
    overflow-x: hidden;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.15);
    z-index: -1;
    pointer-events: none;
}

/* Pantallas */
.screen {
    display: none !important;
    min-height: 100vh;
    position: relative;
}

#auth-screen.screen.active {
    display: flex !important;
    align-items: center;
    justify-content: center;
}

#game-screen.screen.active {
    display: block !important;
    background: url('fondo.png') center center fixed;
    background-size: cover;
    background-attachment: fixed;
}

/* Auth Screen */
#auth-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-icon {
    text-align: center;
    margin-bottom: 20px;
    min-height: 100px;
}

.login-img {
    max-width: 140px;
    max-height: 120px;
    width: auto;
    height: auto;
    border: 2px solid #ffffff;
    border-radius: 12px;
    display: block;
    margin: 0 auto;
    object-fit: contain;
    box-shadow: 0 0 15px rgba(255,255,255,0.4);
}

.auth-container {
    background: rgba(15, 23, 42, 0.85);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    border: 3px solid #ffffff;
}

.auth-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 24px;
}

.auth-tab {
    flex: 1;
    padding: 12px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    border-bottom: 2px solid transparent;
    transition: all 0.3s;
}

.auth-tab.active {
    color: var(--text);
    border-bottom-color: var(--border);
}

.auth-tab:hover:not(.active) {
    color: var(--accent);
}

.auth-form {
    display: none;
    min-height: 280px;
}

.auth-form.active {
    display: block !important;
}

.auth-form h2 {
    margin-bottom: 20px;
    color: var(--text);
    font-size: 1.5rem;
}

.auth-form input {
    width: 100%;
    padding: 14px 16px;
    margin-bottom: 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: rgba(0,0,0,0.3);
    color: var(--text);
    font-size: 1rem;
}

.auth-input-slim {
    padding: 8px 12px !important;
    margin-bottom: 10px !important;
    font-size: 0.9rem !important;
    border: 1px solid #ffffff !important;
}

.auth-form input::placeholder {
    color: var(--text-muted);
}

.auth-form input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(255,255,255,0.3);
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--accent);
    border: 2px solid var(--border);
    border-radius: 8px;
    color: #ffffff;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    touch-action: manipulation;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.4);
}

.btn-login-transparent {
    padding: 8px 16px !important;
    background: transparent !important;
    border: 1px solid #ffffff !important;
    color: #ffffff !important;
}

.btn-login-transparent:hover {
    background: rgba(255,255,255,0.1) !important;
}

.link-compra-key-box {
    margin-top: 12px;
    padding: 10px 16px;
    border: 1px solid rgba(255,255,255,0.5);
    border-radius: 8px;
    text-align: center;
    background: rgba(0,0,0,0.2);
}

.link-compra-key {
    display: inline-block;
    color: #60a5fa;
    font-size: 0.9rem;
    text-decoration: none;
}

.link-compra-key:hover {
    color: #93c5fd;
    text-decoration: underline;
}

.error-msg {
    color: var(--danger);
    font-size: 0.9rem;
    margin-top: 12px;
    min-height: 20px;
}

/* Cuadros delgados - bordes azul brillante */
.box-slim {
    padding: 6px 12px;
    border: 1px solid #3b82f6;
    border-radius: 4px;
    background: rgba(0,0,0,0.2);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.4);
}

.box-slim {
    border-bottom: 1px solid rgba(59, 130, 246, 0.6);
}

/* Header móvil */
.game-header-mobile {
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 500px;
    margin: 0 auto;
}

.logo-box {
    padding: 6px 12px;
    border: 1px solid #3b82f6;
    border-radius: 4px;
    text-align: center;
    background: rgba(0,0,0,0.2);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.4);
}

.logo-box .logo {
    color: #ffffff;
    font-size: 0.95rem;
}

.logo-blink {
    animation: blink 1.5s ease-in-out infinite;
    display: inline-block;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.date-box {
    padding: 6px 12px;
    border: 1px solid #3b82f6;
    border-radius: 4px;
    text-align: center;
    font-size: 0.8rem;
    color: #ffffff;
    background: rgba(0,0,0,0.2);
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.3);
}

.balance-box-mobile {
    padding: 6px 12px;
    border: 1px solid #3b82f6;
    border-radius: 4px;
    text-align: center;
    background: rgba(0,0,0,0.2);
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.3);
}

.balance-box-mobile .balance-label,
.balance-box-mobile .balance-amount {
    color: #ffffff;
}

.balance-box-mobile .balance-amount {
    font-size: 1rem;
}

.header-buttons {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.btn-side {
    padding: 6px 12px;
    background: transparent;
    border: 1px solid #3b82f6;
    color: #ffffff;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.3);
}

.btn-side:hover {
    background: rgba(59, 130, 246, 0.2);
}

/* Vistas del juego - mostrar/ocultar */
.game-view {
    display: none;
    min-height: 100vh;
}

.game-view.active {
    display: block;
}

.game-board-page {
    padding: 16px;
    max-width: 500px;
    margin: 0 auto;
}

.btn-regresar {
    display: block;
    width: 100%;
    margin-bottom: 16px;
    padding: 10px 16px;
    background: transparent;
    border: 1px solid #3b82f6;
    color: #ffffff;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.3);
}

.btn-regresar:hover {
    background: rgba(59, 130, 246, 0.2);
}

.btn-cerrar {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 8px 16px;
    background: transparent;
    border: 1px solid #3b82f6;
    color: #ffffff;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
}

.btn-cerrar:hover {
    background: rgba(59, 130, 246, 0.2);
}

/* Botones de acción delgados */
.btn-action-slim {
    padding: 6px 10px;
    background: transparent;
    border: 1px solid #3b82f6;
    color: #ffffff;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.3);
}

.btn-action-slim:hover {
    background: rgba(59, 130, 246, 0.2);
}

.bet-section label,
.bet-section input,
.action-buttons .btn-action-slim {
    color: #ffffff !important;
}

.bet-section input {
    font-size: 0.85rem;
}

.bet-section input::placeholder {
    color: rgba(255,255,255,0.7);
}

.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.action-buttons .btn-action-slim {
    flex: 1;
    min-width: 90px;
}

/* Game Header (legacy - mantener para desktop) */
.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: rgba(15, 23, 42, 0.9);
    border-bottom: 2px solid #ffffff;
    box-shadow: 0 0 15px rgba(255,255,255,0.3);
    flex-wrap: wrap;
    gap: 16px;
}

.header-left .logo {
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--text);
}

.header-center .balance-box {
    background: rgba(0,0,0,0.3);
    padding: 12px 24px;
    border-radius: 12px;
    border: 2px solid #ffffff;
    box-shadow: 0 0 10px rgba(255,255,255,0.3);
}

.balance-label {
    color: var(--text-muted);
    margin-right: 8px;
}

.balance-amount {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.time-box {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text);
    background: rgba(0,0,0,0.3);
    padding: 8px 16px;
    border-radius: 8px;
    border: 2px solid #ffffff;
}

.btn-logout {
    padding: 8px 16px;
    background: rgba(220, 53, 69, 0.3);
    border: 1px solid var(--danger);
    color: var(--danger);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: var(--danger);
    color: white;
}

.btn-admin {
    padding: 8px 16px;
    background: transparent;
    border: 2px solid #ffffff;
    color: #ffffff;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    box-shadow: 0 0 10px rgba(255,255,255,0.3);
}

.btn-admin:hover {
    background: rgba(255,255,255,0.1);
    box-shadow: 0 0 15px rgba(255,255,255,0.5);
}

.admin-section {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid rgba(255,255,255,0.2);
}

.admin-section:last-child {
    border-bottom: none;
}

.admin-section h3 {
    font-size: 1rem;
    color: var(--text);
    margin-bottom: 12px;
}

/* Game Main */
.game-main {
    padding: 24px 16px;
    max-width: 500px;
    margin: 0 auto;
}

.game-controls {
    margin-bottom: 24px;
}

.bet-section {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.bet-section label {
    font-weight: 500;
    color: #ffffff;
}

.bet-section input[type="number"] {
    width: 120px;
    padding: 8px 12px;
    border: 1px solid #ffffff;
    border-radius: 6px;
    background: rgba(0,0,0,0.3);
    color: #ffffff;
    font-size: 0.95rem;
}

.btn-action {
    padding: 10px 18px;
    background: transparent;
    border: 2px solid #ffffff;
    color: #2563eb;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(255,255,255,0.3);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-action:hover {
    background: var(--accent);
    color: #ffffff;
}

/* Game Board */
.game-board-container {
    background: rgba(15, 23, 42, 0.9);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #3b82f6;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.4);
}

.game-board-container .game-info p,
.game-board-container #game-status {
    color: #ffffff;
    font-size: 0.9rem;
}

.game-info {
    margin-bottom: 20px;
    text-align: center;
}

.game-info p {
    margin: 4px 0;
    color: var(--text-muted);
}

#game-status {
    color: var(--text);
    font-weight: 500;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    max-width: 320px;
    margin: 0 auto 20px;
}

.cell {
    aspect-ratio: 1;
    min-width: 50px;
    min-height: 50px;
    background: rgba(0,0,0,0.3);
    border: 2px solid #ffffff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

.cell:hover:not(.revealed):not(.disabled) {
    background: var(--primary-light);
    transform: scale(1.05);
}

.cell.revealed {
    cursor: default;
}

.cell.revealed.mine {
    background: linear-gradient(145deg, #8b0000 0%, #dc3545 100%);
    border-color: #ff6b6b;
}

.cell.revealed.safe {
    background: linear-gradient(145deg, #1e5631 0%, #28a745 100%);
    border-color: #4ade80;
}

.cell.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#btn-mostrar-juego,
#btn-new-game {
    display: block;
    margin: 12px auto 0;
    max-width: 100%;
    width: 100%;
    border: 1px solid #3b82f6;
    color: #ffffff;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}

#btn-mostrar-juego {
    margin-top: 16px;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: rgba(15, 23, 42, 0.95);
    border-radius: 16px;
    padding: 32px;
    max-width: 450px;
    width: 100%;
    position: relative;
    border: 2px solid #ffffff;
    box-shadow: 0 0 25px rgba(255,255,255,0.4);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 20px;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-close:hover {
    color: var(--text);
}

.modal-content h2 {
    margin-bottom: 16px;
    color: var(--text);
}

.modal-info {
    margin-bottom: 20px;
    color: var(--text-muted);
}

.spei-info {
    background: rgba(0,0,0,0.3);
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.spei-info p {
    margin: 8px 0;
}

.btn-copy {
    margin-left: 8px;
    padding: 4px 10px;
    font-size: 0.8rem;
    background: var(--accent);
    border: 2px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    color: #ffffff;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-muted);
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #ffffff;
    border-radius: 8px;
    background: rgba(0,0,0,0.3);
    color: #2563eb;
}

.modal-content .btn-primary {
    margin-top: 8px;
}

.result-msg {
    margin-top: 12px;
    min-height: 20px;
}

.result-msg.success {
    color: var(--success);
}

.result-msg.error {
    color: var(--danger);
}

/* Retiros pendientes */
.retiros-pendientes-box,
.retiros-pendientes-admin {
    margin-bottom: 20px;
    padding: 12px;
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    border: 1px solid rgba(59, 130, 246, 0.5);
}
.retiros-pendientes-box h3,
.retiros-pendientes-admin h3 {
    font-size: 0.95rem;
    margin-bottom: 8px;
    color: #ffffff;
}
.lista-retiros {
    max-height: 120px;
    overflow-y: auto;
}
.retiro-item {
    padding: 6px 10px;
    margin: 4px 0;
    background: rgba(0,0,0,0.3);
    border-radius: 4px;
    font-size: 0.85rem;
    color: #e0e7ff;
}
.retiro-item.admin {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.retiro-id {
    font-weight: bold;
    color: #93c5fd;
}
.retiro-monto {
    color: #4ade80;
}
.retiro-user {
    color: #fbbf24;
}
.retiro-clabe {
    font-size: 0.8rem;
    word-break: break-all;
}
.retiro-fecha {
    font-size: 0.75rem;
    color: #94a3b8;
}
.sin-retiros {
    color: #94a3b8;
    font-size: 0.9rem;
    font-style: italic;
}
.modal-admin-wide {
    max-width: 520px;
}

.form-select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #ffffff;
    border-radius: 8px;
    background: rgba(0,0,0,0.3);
    color: #2563eb;
    font-size: 1rem;
}

.btn-retiro-pagado, .btn-retiro-eliminar {
    padding: 4px 10px;
    font-size: 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 4px;
}
.btn-retiro-pagado {
    background: #28a745;
    border: 1px solid #28a745;
    color: white;
}
.btn-retiro-eliminar {
    background: #dc3545;
    border: 1px solid #dc3545;
    color: white;
}
.retiro-pagado {
    opacity: 0.7;
    border-left: 3px solid #28a745;
}
.retiro-estado.success {
    color: #28a745;
    font-weight: bold;
}
.retiro-banco {
    font-size: 0.8rem;
    color: #93c5fd;
}

/* ============ ANDROID / MÓVIL ============ */
@media (max-width: 600px) {
    body {
        padding: 0;
    }
    
    #auth-screen {
        padding: 12px;
        align-items: flex-start;
        padding-top: max(12px, env(safe-area-inset-top));
    }
    
    .auth-container {
        width: 100%;
        max-width: 100%;
        padding: 24px 20px;
        margin: auto;
        border-radius: 12px;
    }
    
    .login-icon {
        min-height: 80px;
        margin-bottom: 16px;
    }
    
    .login-img {
        max-width: 120px;
        max-height: 100px;
    }
    
    .auth-tabs {
        margin-bottom: 20px;
    }
    
    .auth-tab {
        padding: 14px 10px;
        font-size: 0.95rem;
    }
    
    .auth-form h2 {
        font-size: 1.3rem;
        margin-bottom: 16px;
    }
    
    .auth-form input,
    .auth-input-slim {
        padding: 14px 16px !important;
        font-size: 16px !important;
        min-height: 48px;
        margin-bottom: 12px !important;
    }
    
    .btn-primary,
    .btn-login-transparent {
        min-height: 48px;
        padding: 14px 20px !important;
        font-size: 1rem;
    }
    
    .link-compra-key-box {
        padding: 14px 16px;
        margin-top: 14px;
    }
    
    .link-compra-key {
        font-size: 0.95rem;
        padding: 8px 0;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Game Header móvil */
    .game-header {
        flex-direction: column;
        padding: 12px 16px;
        gap: 12px;
    }
    
    .header-left .logo {
        font-size: 1.1rem;
        text-align: center;
    }
    
    .header-center .balance-box {
        padding: 10px 20px;
        width: 100%;
        text-align: center;
    }
    
    .balance-amount {
        font-size: 1.3rem;
    }
    
    .header-right {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }
    
    .time-box {
        font-size: 0.9rem;
        padding: 8px 12px;
    }
    
    .btn-logout,
    .btn-admin {
        min-height: 44px;
        padding: 10px 18px;
        font-size: 0.9rem;
    }
    
    /* Game Main móvil */
    .game-main {
        padding: 16px;
    }
    
    .game-controls {
        margin-bottom: 16px;
    }
    
    .bet-section {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .bet-section input[type="number"] {
        width: 100%;
        min-height: 48px;
        padding: 12px 16px;
        font-size: 16px;
    }
    
    .btn-action {
        min-height: 48px;
        padding: 14px 20px;
        font-size: 0.95rem;
    }
    
    /* Tablero móvil */
    .game-board-container {
        padding: 20px 16px;
        border-radius: 12px;
    }
    
    .game-board {
        max-width: 100%;
        gap: 6px;
        margin: 0 auto 16px;
    }
    
    .cell {
        min-width: 44px;
        min-height: 44px;
        font-size: 1.3rem;
    }
    
    #btn-new-game {
        min-height: 48px;
        padding: 14px 24px;
        width: 100%;
        max-width: 100%;
    }
    
    /* Modales móvil */
    .modal {
        padding: 12px;
        align-items: flex-start;
        padding-top: max(20px, env(safe-area-inset-top));
        overflow-y: auto;
    }
    
    .modal-content {
        padding: 24px 20px;
        margin: auto;
        max-height: calc(100vh - 40px);
        overflow-y: auto;
    }
    
    .modal-close {
        top: 12px;
        right: 16px;
        font-size: 1.8rem;
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .form-group input {
        min-height: 48px;
        padding: 14px 16px;
        font-size: 16px;
    }
    
    .btn-copy {
        min-height: 36px;
        padding: 8px 14px;
    }
    
    .spei-info p {
        font-size: 0.9rem;
        word-break: break-all;
    }
}

/* Pantallas muy pequeñas (Android pequeño) */
@media (max-width: 360px) {
    .auth-container {
        padding: 20px 16px;
    }
    
    .header-left .logo {
        font-size: 1rem;
    }
    
    .cell {
        min-width: 40px;
        min-height: 40px;
        font-size: 1.1rem;
    }
    
    .game-board {
        gap: 4px;
    }
}
