/* ========== Variables CSS ==========  */
:root {
    --tower-color: #8B4513;
    --base-color: #654321;
    --disk-1: #FF6B6B;
    --disk-2: #4ECDC4;
    --disk-3: #45B7D1;
    --disk-4: #FFA07A;
    --disk-5: #98D8C8;
    --disk-6: #F7DC6F;
    --disk-7: #BB8FCE;
    --selected-glow: #FFD700;
}

/* ========== Layout Principal ==========  */
.game-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.game-wrapper {
    width: 100%;
    max-width: 1200px;
}

/* ========== Modales ==========  */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content h2 {
    margin: 0 0 20px 0;
    color: #333;
    text-align: center;
    font-size: 2em;
}

.game-instructions {
    background: #f0f8ff;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    line-height: 1.6;
    color: #555;
    border-left: 4px solid #4ECDC4;
}

/* ========== Formularios ==========  */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 600;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #4ECDC4;
}

/* ========== Botones ==========  */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin: 5px;
}

.btn-primary {
    background: linear-gradient(135deg, #4ECDC4, #45B7D1);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(78, 205, 196, 0.4);
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
    transform: translateY(-2px);
}

/* ========== Contenedor del Juego ==========  */
#gameContainer {
    background: white;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.game-header h1 {
    margin: 0;
    color: #333;
    font-size: 1.8em;
}

/* ========== Info del Juego ==========  */
.game-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
}

.info-item {
    text-align: center;
    padding: 10px;
}

.info-item span:first-child {
    display: block;
    font-size: 0.9em;
    color: #666;
    margin-bottom: 5px;
}

.highlight {
    font-size: 1.4em;
    font-weight: bold;
    color: #4ECDC4;
}

/* ========== Tablero de Juego ==========  */
#gameBoard {
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    min-height: 350px;
    padding: 20px 10px;
    background: linear-gradient(to bottom, #e8f5f7 0%, #b8dce2 100%);
    border-radius: 10px;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
    /* Prevent overflow on tiny screens */
}

/* ========== Torres ==========  */
.tower {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    cursor: pointer;
    transition: transform 0.2s;
    position: relative;
    max-width: 250px;
}

.tower:hover {
    transform: translateY(-5px);
}

.tower.selected {
    animation: pulse 0.5s infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: translateY(-5px);
    }

    50% {
        transform: translateY(-10px);
    }
}

.tower-disks {
    position: relative;
    min-height: 250px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    width: 100%;
    /* Altura relativa al número de discos */
    height: 100%;
}

.tower-disks::before {
    content: '';
    position: absolute;
    bottom: 0;
    width: 8px;
    height: 100%;
    background: var(--tower-color);
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.tower-base {
    width: 100%;
    height: 15px;
    background: var(--base-color);
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    margin-top: 5px;
}

.tower-label {
    margin-top: 10px;
    font-weight: 600;
    color: #333;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ========== Discos ==========  */
.disk {
    height: 24px;
    /* Slightly taller for easier touch */
    border-radius: 12px;
    margin: 1px 0;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

.disk:hover {
    transform: translateX(-50%) scale(1.05);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
}

.disk[data-size="1"] {
    background: var(--disk-1);
}

.disk[data-size="2"] {
    background: var(--disk-2);
}

.disk[data-size="3"] {
    background: var(--disk-3);
}

.disk[data-size="4"] {
    background: var(--disk-4);
}

.disk[data-size="5"] {
    background: var(--disk-5);
}

.disk[data-size="6"] {
    background: var(--disk-6);
}

.disk[data-size="7"] {
    background: var(--disk-7);
}

.tower.selected .disk:last-child {
    animation: diskGlow 0.5s infinite;
}

@keyframes diskGlow {

    0%,
    100% {
        box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
    }

    50% {
        box-shadow: 0 3px 20px var(--selected-glow), 0 0 30px var(--selected-glow);
    }
}

/* ========== Controles del Juego ==========  */
.game-controls {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
}

/* ========== Mensajes ==========  */
.message {
    margin-top: 20px;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
    display: none;
}

.message.error {
    background: #ffebee;
    color: #c62828;
    border: 2px solid #ef5350;
}

.message.info {
    background: #e3f2fd;
    color: #1565c0;
    border: 2px solid #42a5f5;
}

/* ========== Modal de Victoria ==========  */
.victory-content {
    text-align: center;
}

.victory-message {
    font-size: 1.2em;
    color: #555;
    margin-bottom: 20px;
}

.victory-stats {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.stat-item {
    margin: 10px 0;
}

.stat-label {
    color: #666;
    font-weight: 600;
    margin-right: 10px;
}

.stat-value {
    color: #4ECDC4;
    font-size: 1.5em;
    font-weight: bold;
}

.record-message {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: white;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 600;
    display: none;
    animation: celebrationPulse 1s infinite;
}

@keyframes celebrationPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

.victory-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.victory-buttons .btn {
    flex: 1;
    min-width: 150px;
}

/* ========== Responsive Design ==========  */
@media (max-width: 768px) {
    .game-page {
        padding: 5px;
    }

    #gameContainer {
        padding: 10px;
    }

    .game-header h1 {
        font-size: 1.4em;
    }

    #gameBoard {
        min-height: 320px;
        padding: 20px 5px;
        gap: 5px;
    }

    .tower-disks {
        min-height: 220px;
    }

    .tower {
        max-width: none;
        flex: 1;
    }

    .disk {
        height: 22px;
    }

    .game-info {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 10px;
        font-size: 0.85em;
    }
}

@media (max-width: 480px) {
    #gameBoard {
        min-height: 280px;
    }

    .tower-disks {
        min-height: 200px;
    }

    .tower-label {
        font-size: 0.7em;
        letter-spacing: 0;
    }

    .disk {
        height: 18px;
    }

    /* Mensaje sutil para sugerir rotación si el espacio es crítico */
    .game-wrapper::before {
        content: "📱 Sugerencia: Gira tu móvil para una mejor experiencia";
        display: block;
        text-align: center;
        font-size: 11px;
        color: #666;
        margin-bottom: 8px;
        opacity: 0.8;
    }
}

@media (max-height: 500px) and (orientation: landscape) {
    .game-page {
        padding: 0;
    }

    #gameBoard {
        min-height: 180px;
    }

    .tower-disks {
        min-height: 140px;
    }

    .game-info {
        display: flex;
        justify-content: center;
        margin-bottom: 10px;
        padding: 5px;
    }
}

/* ========== Utilidades ==========  */
.hidden {
    display: none !important;
}