/* css/style.css - Conga Uruguaya */

:root {
    --felt-color: #0d3b1e;
    --felt-gradient: radial-gradient(circle at 50% 50%, #114c27 0%, #092c15 70%, #051a0c 100%);
    --gold: #f1c40f;
    --gold-dark: #b7950b;
    --wood-border: #3e2723;
    --card-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    --card-hover-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    --font-main: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

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

body {
    font-family: var(--font-main);
    background: #05140b;
    color: #ffffff;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Tablero de Juego (Paño Verde) */
#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: 1400px;
    background: var(--felt-gradient);
    border: 8px solid var(--wood-border);
    box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.8), 0 0 40px rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
}

/* Barra Superior */
#top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    z-index: 100;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--gold);
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: 0.5px;
}

.top-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: white;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: var(--gold);
    transform: translateY(-1px);
}

/* Área de Rivales (Superior y Laterales) */
#opponents-area {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    padding: 8px 16px;
    z-index: 10;
}

.opponent-badge {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 14px;
    padding: 8px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.opponent-badge.active-turn {
    border-color: var(--gold);
    box-shadow: 0 0 15px rgba(241, 196, 15, 0.5);
    background: rgba(241, 196, 15, 0.15);
}

.opponent-name {
    font-size: 0.9rem;
    font-weight: bold;
    color: #eee;
}

.opponent-score {
    font-size: 0.8rem;
    color: #bbb;
}

.opponent-cards-mini {
    display: flex;
    justify-content: center;
    margin-top: 4px;
}

.mini-card-back {
    width: 22px;
    height: 32px;
    background: url('../assets/cards_tatu/carta_reverso.png') no-repeat center/cover;
    border-radius: 3px;
    margin-left: -12px;
    box-shadow: -1px 0 3px rgba(0, 0, 0, 0.5);
}
.mini-card-back:first-child {
    margin-left: 0;
}

.mini-card-front {
    width: 22px;
    height: 32px;
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 3px;
    margin-left: -12px;
    box-shadow: -1px 0 3px rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.25);
    background-color: #fff;
}
.mini-card-front:first-child {
    margin-left: 0;
}

/* Centro de la Mesa: Mazo de Robo y Pozo de Descarte */
#center-table {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 36px;
    margin: auto 0;
    z-index: 20;
}

.pile-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    position: relative;
    transition: transform 0.2s ease;
}

.pile-container:hover {
    transform: scale(1.04);
}

.pile-label {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.8);
    background: rgba(0, 0, 0, 0.4);
    padding: 2px 8px;
    border-radius: 6px;
}

/* Cartas de Mazo y Pozo */
.card-pile {
    width: clamp(80px, 14vw, 105px);
    height: clamp(120px, 21vw, 158px);
    border-radius: 8px;
    position: relative;
    box-shadow: var(--card-shadow);
    transition: all 0.2s ease;
}

.deck-pile {
    background: url('../assets/cards_tatu/carta_reverso.png') no-repeat center/cover;
    border: 2px solid rgba(255, 255, 255, 0.4);
    transition: box-shadow 0.25s ease, transform 0.2s ease, opacity 0.3s ease, border-color 0.2s ease;
}

.deck-pile.highlight-draw {
    border-color: var(--gold);
    animation: pulseGlow 1.2s infinite alternate;
}

.discard-pile-card {
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.discard-pile-card.highlight-draw {
    border-color: var(--gold);
    box-shadow: 0 0 20px rgba(241, 196, 15, 0.8);
    animation: pulseGlow 1.2s infinite alternate;
}

@keyframes pulseGlow {
    0% { transform: scale(1); filter: drop-shadow(0 0 4px var(--gold)); }
    100% { transform: scale(1.05); filter: drop-shadow(0 0 14px var(--gold)); }
}

/* Banner de Estado y Turno */
#turn-status-banner {
    background: rgba(0, 0, 0, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 6px 18px;
    margin: 0 auto 6px auto;
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 30;
}

/* Mesa de Cartas Bajadas (Corte y Acomodo) */
#table-melds-area {
    width: 95%;
    max-width: 900px;
    background: rgba(10, 25, 15, 0.92);
    border: 2px solid var(--gold);
    border-radius: 14px;
    padding: 10px 14px;
    margin: 4px auto 8px auto;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: fadeInDown 0.3s ease;
}

#table-melds-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(241, 196, 15, 0.4);
    padding-bottom: 6px;
    margin-bottom: 8px;
    font-size: 0.95rem;
    font-weight: bold;
    color: var(--gold);
}

#table-melds-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    max-height: 190px;
    overflow-y: auto;
}

.meld-group-box {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    padding: 6px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.meld-group-title {
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    color: #e0e0e0;
    letter-spacing: 0.5px;
}

.meld-cards-row {
    display: flex;
    justify-content: center;
    align-items: center;
}

.meld-card-mini {
    width: clamp(50px, 9vw, 68px);
    height: clamp(74px, 13.5vw, 100px);
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 6px;
    margin: 0 -8px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5);
    position: relative;
    transition: transform 0.2s ease;
}

.meld-card-mini:first-child {
    margin-left: 0;
}
.meld-card-mini:last-child {
    margin-right: 0;
}

.meld-card-mini.card-acomodada {
    border: 2px solid #2ecc71;
    box-shadow: 0 0 12px rgba(46, 204, 113, 0.8);
    transform: translateY(-4px);
}

.card-placeable {
    border: 2px solid #2ecc71 !important;
    box-shadow: 0 0 18px rgba(46, 204, 113, 0.95), var(--card-hover-shadow) !important;
    cursor: pointer !important;
    transform: translateY(-14px) !important;
}

.badge-colocar {
    position: absolute;
    top: 4px;
    right: 4px;
    background: #27ae60;
    color: white;
    font-size: 0.65rem;
    font-weight: 900;
    padding: 2px 5px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.7);
    animation: pulseColocar 1.2s infinite alternate;
}

@keyframes pulseColocar {
    0% { transform: scale(1); }
    100% { transform: scale(1.12); }
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-12px); }
    to { opacity: 1; transform: translateY(0); }
}

#turn-status-banner.my-turn {
    border-color: var(--gold);
    color: var(--gold);
    background: rgba(20, 45, 25, 0.85);
}

/* Mano del Jugador (Abanico) */
#player-hand-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    padding-bottom: 12px;
    min-height: 175px;
    z-index: 40;
}

.hand-fan {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    position: relative;
}

/* Cartas de la mano */
.hand-card {
    width: clamp(86px, 15.5vw, 114px);
    height: clamp(128px, 23vw, 170px);
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 8px;
    margin: 0 -14px;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    box-shadow: var(--card-shadow);
    transition: transform 0.2s cubic-bezier(0.2, 0, 0.2, 1), box-shadow 0.2s ease;
    position: relative;
    transform-origin: bottom center;
}

.hand-card:not(.is-dragging):hover {
    transform: translateY(-24px) scale(1.08) !important;
    z-index: 50 !important;
    box-shadow: var(--card-hover-shadow);
}

.hand-card.selected-card:not(.is-dragging) {
    transform: translateY(-30px) scale(1.1) !important;
    box-shadow: 0 0 20px rgba(241, 196, 15, 0.9), var(--card-hover-shadow);
    z-index: 60 !important;
    border: 2px solid var(--gold);
}

.hand-card.is-dragging {
    z-index: 100 !important;
    cursor: grabbing !important;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.8), 0 0 25px rgba(241, 196, 15, 0.7) !important;
    transition: none !important;
    filter: brightness(1.08);
}

/* Etiquetas de combinación (LIGADA / SUELTA) */
.card-meld-badge {
    position: absolute;
    top: 4px;
    left: 4px;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 2px 5px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

.badge-ligada {
    background: #27ae60;
    color: white;
}

.badge-suelta {
    background: #c0392b;
    color: white;
}

/* Barra de Acciones del Jugador */
#player-actions-toolbar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    z-index: 100;
    flex-shrink: 0;
}

.btn-action {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 700;
    padding: 10px 18px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-action:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.btn-action:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    filter: none;
}

.btn-primary-action {
    background: #2980b9;
    border-color: #3498db;
}
.btn-primary-action:hover:not(:disabled) {
    background: #3498db;
}

/* Botón de Descartar */
.btn-discard-action {
    background: linear-gradient(135deg, #c0392b, #962d22);
    border: 1px solid #e74c3c;
    color: #fff;
    font-weight: 700;
}

.btn-discard-action:hover:not(:disabled) {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    box-shadow: 0 0 15px rgba(231, 76, 60, 0.7);
}

.btn-discard-action.can-discard {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    border-color: #ff7675;
    box-shadow: 0 0 18px rgba(231, 76, 60, 0.85);
    animation: pulseDiscardBtn 1.2s infinite alternate;
}

@keyframes pulseDiscardBtn {
    0% { box-shadow: 0 0 8px rgba(231, 76, 60, 0.6); filter: brightness(1); }
    100% { box-shadow: 0 0 22px rgba(231, 76, 60, 1); filter: brightness(1.12); }
}

/* Botón de Cortar (Destacado en Oro con Pulso cuando es válido) */
.btn-cut-action {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    border-color: var(--gold);
    color: #000;
    font-weight: 800;
    box-shadow: 0 4px 15px rgba(243, 156, 18, 0.4);
}

.btn-cut-action.can-cut {
    background: linear-gradient(135deg, #f1c40f, #f39c12);
    animation: pulseCutBtn 1.2s infinite alternate;
    box-shadow: 0 0 20px rgba(241, 196, 15, 0.9);
}

@keyframes pulseCutBtn {
    0% { box-shadow: 0 0 10px rgba(241, 196, 15, 0.5); filter: brightness(1); }
    100% { box-shadow: 0 0 25px rgba(241, 196, 15, 1); filter: brightness(1.15); }
}

/* Indicador de Deadwood (Puntos Sueltos) */
.deadwood-indicator {
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}

.deadwood-indicator.can-cut-text {
    border-color: var(--gold);
    color: var(--gold);
}

/* Modales */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 16px;
}

.modal-card {
    background: #142a1c;
    border: 2px solid var(--gold);
    border-radius: 16px;
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.25rem;
    color: var(--gold);
    font-weight: 800;
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Pantalla de Inicio / Lobby */
#start-screen {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, #0e3d20 0%, #061c0e 100%);
    z-index: 500;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    text-align: center;
}

.hero-logo {
    font-size: clamp(2rem, 6vw, 3.2rem);
    font-weight: 900;
    color: var(--gold);
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.8);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.hero-subtitle {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 28px;
    max-width: 440px;
}

.menu-options-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    width: 100%;
    max-width: 380px;
}

.menu-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 14px 20px;
    border-radius: 12px;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s ease;
}

.menu-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: var(--gold);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.menu-btn.primary {
    background: linear-gradient(135deg, #f39c12, #d35400);
    border-color: var(--gold);
    color: #000;
    font-weight: 800;
}

/* Botón Siguiente Mano Flotante */
#btn-siguiente-mano {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 900;
    min-width: 240px;
    padding: 16px 28px;
    font-size: 1.2rem;
    font-weight: 800;
    background: linear-gradient(135deg, #f1c40f, #e67e22);
    color: #000;
    border: 2px solid #fff;
    border-radius: 14px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.8), 0 0 20px rgba(241, 196, 15, 0.6);
    cursor: pointer;
    text-transform: uppercase;
    animation: pulseDealBtn 1.4s infinite alternate;
}

@keyframes pulseDealBtn {
    0% { transform: translate(-50%, -50%) scale(1); }
    100% { transform: translate(-50%, -50%) scale(1.05); }
}

/* Responsividad Mobile Vertical */
@media (max-width: 768px) {
    #center-table {
        gap: 16px;
        margin: 4px 0;
    }
    
    .card-pile {
        width: clamp(66px, 16vw, 82px);
        height: clamp(98px, 24vw, 122px);
    }

    #player-hand-container {
        min-height: 135px;
        padding-bottom: 6px;
    }

    .hand-card {
        margin: 0 -10px;
        width: clamp(70px, 17vw, 90px);
        height: clamp(105px, 25vw, 135px);
    }

    #player-actions-toolbar {
        flex-wrap: wrap;
        gap: 6px;
        padding: 6px 8px;
    }

    .btn-action {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .deadwood-indicator {
        font-size: 0.8rem;
        padding: 4px 10px;
    }
}

/* Responsividad para pantallas o ventanas de poca altura (notebooks, landscape, teclados) */
@media (max-height: 700px) {
    #top-bar {
        padding: 4px 12px;
    }
    #opponents-area {
        padding: 4px 8px;
        gap: 8px;
    }
    .opponent-badge {
        padding: 3px 8px;
    }
    #turn-status-banner {
        padding: 3px 12px;
        font-size: 0.82rem;
        margin-bottom: 2px;
    }
    .card-pile {
        width: 68px;
        height: 100px;
    }
    #center-table {
        margin: 2px 0;
    }
    #player-hand-container {
        min-height: 120px;
        padding-bottom: 2px;
    }
    .hand-card {
        width: 68px;
        height: 102px;
    }
    #player-actions-toolbar {
        padding: 4px 8px;
    }
}
