@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* App Header styles handled by header.js */
.app-header-placeholder {
    display: none;
}

/* Header and Language Switcher managed by header.js */


.game-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 20px;
    max-width: 1100px;
    width: 95%;
    margin: 100px auto 30px;
    /* Space for fixed header */
    display: flex;
    flex-direction: column;
    color: #333;
    font-family: 'Outfit', sans-serif;
    min-height: 600px;
    /* Ensure box is always visible */
    position: relative;
    /* Added to keep child absolute elements inside */
    z-index: 10;
}

/* Modal de jugadores */
.modal {
    position: absolute;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    /* Changed from center to prevent overlap */
    opacity: 1;
    transition: opacity 0.3s ease;
    overflow-y: auto;
    padding: 80px 0 20px;
    /* More top padding for header space */
    border-radius: 20px;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
    display: none;
}

.modal-content {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 1000;
    animation: slideIn 0.5s ease-out;
    border: none;
}

@keyframes slideIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-content h2 {
    font-size: 2em;
    color: #667eea;
    margin-bottom: 10px;
    line-height: 1.3;
    -webkit-text-fill-color: initial;
    background: none;
}

.modal-content .subtitle {
    font-size: 1.05em;
    color: #555;
    margin-bottom: 20px;
}

.input-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: #cbd5e1;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.input-group input,
.modal-content button {
    width: 100%;
    margin-top: 1rem;
}

/* Tutorial Section */
.tutorial-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    text-align: left;
}

.tutorial-section h3 {
    font-size: 1.1rem;
    color: #667eea;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tutorial-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.8rem;
}

@media (min-width: 600px) {
    .tutorial-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.tutorial-item {
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
    background: white;
    padding: 0.8rem;
    border-radius: 12px;
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.tutorial-icon {
    font-size: 1.2rem;
    min-width: 24px;
}

.tutorial-item p {
    font-size: 0.85rem;
    color: #555;
    line-height: 1.3;
    margin: 0;
}

.input-group input,
.input-group select {
    width: 100%;
    padding: 12px;
    background: white;
    border: 2px solid #667eea;
    border-radius: 8px;
    color: #333;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s ease;
    text-align: center;
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: #818cf8;
    background: rgba(0, 0, 0, 0.3);
    box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.2);
}

.input-group select option {
    background-color: #1e293b;
    color: #fff;
}

#startGame {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 30px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    transition: all 0.3s;
    margin-top: 15px;
}

#startGame:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.6);
}

/* App Container */
#gameContainer {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeIn 0.6s ease forwards;
}

#gameContainer.hidden {
    display: none;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    width: 100%;
    position: relative;
    z-index: 200;
    /* Ensure icon is above the absolute modal */
}

.header h1 {
    font-size: 1.6em;
    color: #667eea;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.game-icon-small {
    height: 40px;
    width: auto;
    object-fit: contain;
}

.back-btn {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(245, 87, 108, 0.4);
}

.back-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 87, 108, 0.6);
}

.status-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: #f0f4ff;
    padding: 0.75rem 1.5rem;
    border-radius: 99px;
    border: 1px solid rgba(102, 126, 234, 0.1);
    margin-bottom: 20px;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #22c55e;
    box-shadow: 0 0 10px #22c55e;
}

#currentPlayer {
    font-size: 1rem;
    color: #667eea;
    font-weight: 600;
}

.button-group {
    display: flex;
    gap: 1rem;
}

.btn-secondary,
.btn-primary {
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

/* Game Layout */
.game-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    align-items: start;
}

.panel {
    background: #f0f4ff;
    border: 1px solid rgba(102, 126, 234, 0.1);
    border-radius: 24px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.panel-title {
    font-size: 1.1rem;
    color: #667eea;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 2rem;
    font-weight: 700;
    width: 100%;
    text-align: center;
    border-bottom: 1px solid rgba(102, 126, 234, 0.2);
    padding-bottom: 1rem;
}

/* Tablero */
#board {
    display: grid;
    grid-template-columns: repeat(4, 80px);
    grid-template-rows: repeat(4, 80px);
    gap: 12px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.3);
}

.cell {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: default;
    transition: all 0.3s ease;
    position: relative;
}

.cell.active-target {
    cursor: pointer;
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.3);
    animation: pulse 2s infinite;
}

.cell.active-target:hover {
    background: rgba(99, 102, 241, 0.2);
    transform: scale(1.02);
}

.cell.highlight {
    background: rgba(34, 197, 94, 0.15);
    border-color: #22c55e;
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.2);
}

/* Piezas */
#availablePieces {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    width: 100%;
    justify-content: center;
    /* Para que las piezas no salten */
    min-height: 250px;
}

.piece-wrapper {
    width: 60px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    transition: all 0.3s;
}

.piece-wrapper.selectable:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
    cursor: pointer;
}

/* Diseño de las piezas */
.piece {
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

/* Colores: */
.piece.light {
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
    border: 1px solid #fff;
}

.piece.dark {
    background: linear-gradient(135deg, #475569 0%, #334155 100%);
    border: 1px solid #64748b;
}

/* Formas: */
.piece.round {
    border-radius: 50%;
}

.piece.square {
    border-radius: 8px;
}

/* Altura (simulada con tamaño y sombra) */
.piece.tall {
    width: 44px;
    height: 44px;
    z-index: 2;
}

.piece.short {
    width: 34px;
    height: 34px;
}

/* Relleno (Solido vs Hueco) */
.piece.hollow::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40%;
    height: 40%;
    background: #f0f4ff;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.piece.hollow.round::after {
    border-radius: 50%;
}

.piece.hollow.square::after {
    border-radius: 4px;
}

/* Pieza Seleccionada Showcase */
.selection-area {
    margin-top: 2rem;
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 160px;
}

.selection-area p {
    color: #cbd5e1;
    /* Brighter color for better visibility */
    margin-bottom: 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
}

.selected-piece-container {
    width: 80px;
    height: 80px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.08);
    /* Slightly more opaque */
    border-radius: 50%;
    border: 2px dashed rgba(255, 255, 255, 0.3);
    /* Slightly more visible */
}

/* Mensajes */
.message {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #10b981;
    color: white;
    padding: 1rem 2rem;
    border-radius: 99px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    font-weight: 600;
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2000;
}

.message.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.message.draw {
    background: #f59e0b;
}

@keyframes fadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(99, 102, 241, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .game-container {
        margin: 80px 10px 10px 10px;
        padding: 15px;
        max-width: 100%;
    }

    .game-layout {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    #availablePieces {
        grid-template-columns: repeat(4, 1fr);
        min-height: auto;
    }

    .panel {
        max-width: 100%;
        padding: 1.5rem;
    }

    /* Header Mobile Adjustments for Quarto handled by header.js */
}

@media (max-width: 600px) {
    .game-container {
        margin-top: 70px;
        padding: 10px;
    }

    .modal-content {
        padding: 1.5rem;
        /* Menos padding vertical para que quepa mejor */
    }

    .modal-content h2 {
        font-size: 2rem;
    }

    .header-left h1 {
        font-size: 1.8rem;
    }

    #board {
        grid-template-columns: repeat(4, 1fr);
        grid-template-rows: repeat(4, auto);
        width: 100%;
        max-width: 320px;
        gap: 8px;
        padding: 8px;
    }

    .cell {
        aspect-ratio: 1 / 1;
        width: 100%;
        height: auto;
    }

    #availablePieces {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.5rem;
    }

    .piece-wrapper {
        width: 100%;
        aspect-ratio: 1 / 1;
        height: auto;
    }

    .selection-area {
        margin-top: 1rem;
        padding: 1rem;
        min-height: 120px;
    }

    .selected-piece-container {
        width: 60px;
        height: 60px;
    }

    .piece.tall {
        width: 80%;
        height: 80%;
    }

    .piece.short {
        width: 60%;
        height: 60%;
    }
}