/* General Page Structure */
body {
    background-color: #f8f9fa;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    color: #343a40;
    line-height: 1.6;
}

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 3rem 2rem;
}

/* Game Section */
#game-section {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    padding: 2.5rem;
    margin-bottom: 3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.puzzle-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    width: 100%;
    box-sizing: border-box;
}

#puzzle-board {
    display: grid;
    grid-template-columns: repeat(4, 100px);
    grid-template-rows: repeat(4, 100px);
    gap: 8px;
    padding: 10px;
    box-sizing: border-box;
    background-color: #495057;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    aspect-ratio: 1 / 1;
}

.puzzle-cell {
    background-color: #007bff;
    color: white;
    font-size: 2.5rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.3s, transform 0.2s ease;
}

.puzzle-cell:not(.empty):hover {
    background-color: #0056b3;
    transform: scale(1.05);
}

.puzzle-cell.empty {
    background-color: #6c757d;
    cursor: default;
}

.puzzle-controls {
    text-align: center;
}

#restart {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s;
}

#restart:hover {
    background-color: #0056b3;
}

#puzzle-message {
    display: block;
    margin-top: 1rem;
    font-size: 1.1rem;
    font-weight: 500;
    min-height: 24px;
}

@media (max-width: 480px) {
    #puzzle-board {
        grid-template-columns: repeat(4, 1fr);
        grid-template-rows: repeat(4, 1fr);
        width: 90vw;
        height: 90vw;
        max-width: 400px;
        max-height: 400px;
        gap: 5px;
        padding: 8px;
    }

    .puzzle-cell {
        width: auto;
        height: auto;
        font-size: 1.8rem;
    }
}

.puzzle-controls-note {
    font-size: 0.9rem;
    color: #6c757d;
}

/* Internal Navigation / More Games */
.internal-nav {
    text-align: center;
    margin-bottom: 3rem;
}

.internal-nav h3 {
    font-size: 2.5rem;
    font-weight: 600;
    color: #003366;
    margin-top: 0;
    margin-bottom: 2rem;
}

.game-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
}

.game-btn {
    background: #f8f9fa;
    border-radius: 10px;
    text-align: center;
    padding: 1.5rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid #e9ecef;
    color: #343a40;
    text-decoration: none;
}

.game-btn:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}

.game-btn img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.game-btn span {
    font-size: 1.3rem;
    font-weight: 600;
}

/* Info Sections & Cards */
.info-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 3rem;
}

.info-card {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    padding: 2.5rem;
}

.info-card.full-width {
    grid-column: 1 / -1;
}

.info-card h2 {
    font-size: 2rem;
    font-weight: 600;
    color: #003366;
    margin-top: 0;
    margin-bottom: 1.5rem;
}

.info-card p, .info-card li {
    color: #343a40;
}

.info-card ul, .info-card ol {
    padding-left: 20px;
}

/* Responsive Design */
@media (max-width: 992px) {
    .info-section {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    main {
        padding: 2rem 1rem;
    }
    #game-section, .info-card {
        padding: 2rem;
    }
    .internal-nav h3, .info-card h2 {
        font-size: 2rem;
    }
    #puzzle-board {
        width: 100%;
        height: auto;
        /* Let JS handle these */
        /* grid-template-columns: repeat(4, 20vw); */
        /* grid-template-rows: repeat(4, 20vw); */
        max-width: 90vw;
        max-height: 90vw;
        /* gap: 1.5vw; */
        /* padding: 2vw; */
    }
    .puzzle-cell {
        /* font-size: 8vw; */
    }
}

@media (orientation: portrait) and (max-width: 540px) {
    #game-section {
        padding: 1.25rem;
    }
    #puzzle-board {
        /* Let JS handle these */
        /* grid-template-columns: repeat(4, 21vw); */
        /* grid-template-rows: repeat(4, 21vw); */
        /* gap: 1.25vw; */
        /* padding: 2vw; */
        max-width: 94vw;
        max-height: 94vw;
        margin-left: auto;
        margin-right: auto;
    }
    .puzzle-cell {
        /* font-size: 8.5vw; */
    }
    #restart {
        width: 100%;
        max-width: 240px;
    }
}

@media (orientation: portrait) and (max-width: 430px) {
    #puzzle-board {
        /* Let JS handle these */
        /* grid-template-columns: repeat(4, 20.5vw); */
        /* grid-template-rows: repeat(4, 20.5vw); */
        /* gap: 1.1vw; */
        max-width: 92vw;
        max-height: 92vw;
    }
    .puzzle-cell {
        /* font-size: 8vw; */
    }
    #restart {
        max-width: 200px;
    }
}

@media (orientation: landscape) and (max-height: 520px) {
    #game-section {
        padding: 1.25rem;
        width: min(100%, 520px);
        margin-left: auto;
        margin-right: auto;
    }
    main {
        padding: 1.5rem 1rem;
    }
    #puzzle-board {
        /* Let JS handle these */
        /* grid-template-columns: repeat(4, min(14vw, 14vh)); */
        /* grid-template-rows: repeat(4, min(14vw, 14vh)); */
        /* gap: min(1vw, 1vh); */
        /* padding: min(1.5vw, 1.5vh); */
        margin-left: auto;
        margin-right: auto;
    }
    .puzzle-container {
        width: 100%;
        max-width: 480px;
        margin-left: auto;
        margin-right: auto;
    }
    .puzzle-cell {
        /* font-size: min(6vw, 6vh); */
    }
    #restart {
        width: 100%;
        max-width: 260px;
    }
}
