/* Algemene reset en basis stijlen */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100dvh;  /* Gebruik dvh voor mobiel (dynamic viewport height) */
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    /* Verwijder overflow: hidden - laat natuurlijke scroll toe op mobiel */
}

/* Op desktop houden we overflow hidden, op mobiel niet */
@media (min-width: 901px) {
    body {
        height: 100dvh;
        overflow: hidden;
    }
}

/* Hoofdcontainer - breder gemaakt voor 1400px */
.game-container {
    max-width: 1400px;
    width: 100%;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Op desktop: max-height beperken, op mobiel niet */
@media (min-width: 901px) {
    .game-container {
        max-height: 100%;
    }
}

/* Header sectie */
.game-header {
    background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
    color: white;
    padding: 15px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    flex-shrink: 0;
}

.game-header h1 {
    font-size: 1.8em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.game-header h1::before {
    content: "🧩";
    font-size: 1.2em;
}

/* Level info paneel */
.level-info {
    background: rgba(255,255,255,0.15);
    padding: 8px 20px;
    border-radius: 10px;
    display: flex;
    gap: 25px;
    flex-wrap: wrap;
}

.info-item {
    display: flex;
    gap: 8px;
    align-items: baseline;
}

.info-label {
    font-size: 0.9em;
    opacity: 0.8;
}

.info-value {
    font-size: 1.3em;
    font-weight: bold;
    color: #ffd700;
}

/* MAIN CONTENT */
.main-content {
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* Op desktop: beperk hoogte en voorkom overflow */
@media (min-width: 901px) {
    .main-content {
        min-height: 0;
        overflow: hidden;
    }
}

/* Horizontale control bar */
.control-bar {
    background: #f7fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 12px 25px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 30px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 15px;
}

.control-group-title {
    font-size: 0.75em;
    color: #718096;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    white-space: nowrap;
}

.control-buttons-row {
    display: flex;
    gap: 10px;
}

.level-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.level-nav-buttons {
    display: flex;
    gap: 8px;
}

.info-text {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #4a5568;
    flex-wrap: wrap;
}

.info-text .separator {
    color: #cbd5e0;
    font-weight: bold;
}

.control-group-info {
    margin-left: auto;
}

/* Canvas container */
.canvas-container {
    background: #2d3748;
    padding: 25px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Op desktop: flex krimpen toestaan */
@media (min-width: 901px) {
    .canvas-container {
        flex: 1;
        min-height: 0;
        overflow: hidden;
    }
}

#sokobanCanvas {
    max-width: 100%;
    display: block;
    background: #1a202c;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    touch-action: none;
}

/* Op desktop: behoud aspect ratio met contain */
@media (min-width: 901px) {
    #sokobanCanvas {
        max-height: 100%;
        width: auto;
        height: auto;
        object-fit: contain;
    }
}

/* Op mobiel: canvas neemt volledige breedte */
@media (max-width: 900px) {
    #sokobanCanvas {
        width: 100%;
        height: auto;
    }
}

/* Level selector styling */
.level-selector {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px 35px 10px 15px;
    font-size: 0.9em;
    font-weight: 500;
    color: #2d3748;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 140px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234a5568' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'></polyline></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.level-selector:hover {
    border-color: #667eea;
}

.level-selector:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102,126,234,0.2);
}

.level-selector:disabled {
    background-color: #edf2f7;
    cursor: wait;
    opacity: 0.7;
}

/* Navigatie knoppen */
.nav-button {
    background: white;
    border: 2px solid #cbd5e0;
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    color: #4a5568;
    white-space: nowrap;
}

.nav-button:hover {
    background: #4a5568;
    border-color: #4a5568;
    color: white;
}

/* Control buttons */
.control-button {
    background: white;
    border: 2px solid #e2e8f0;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: #2d3748;
    white-space: nowrap;
}

.control-button:hover {
    background: #667eea;
    border-color: #667eea;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102,126,234,0.3);
}

.control-button:active {
    transform: translateY(0);
}

.control-button .key {
    background: #2d3748;
    color: white;
    padding: 3px 8px;
    border-radius: 5px;
    font-family: monospace;
    font-size: 10px;
    font-weight: bold;
}

.control-button:hover .key {
    background: white;
    color: #667eea;
}

/* Speciale knoppen */
.button-undo {
    border-color: #ed8936;
    color: #dd6b20;
}

.button-undo:hover {
    background: #ed8936;
    border-color: #ed8936;
}

/* Footer */
.game-footer {
    background: #edf2f7;
    padding: 10px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    font-size: 13px;
    color: #718096;
    flex-shrink: 0;
}

.back-link {
    color: #667eea;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.3s ease;
}

.back-link:hover {
    color: #764ba2;
    transform: translateX(-3px);
}

/* ========== MOBIEL SPECIFIEKE STIJLEN ========== */

/* Grotere touch targets op mobiel */
@media (max-width: 900px) {
    .control-button,
    .nav-button {
        padding: 12px 16px;
        font-size: 14px;
        min-height: 48px;  /* Apple's aanbevolen minimum */
    }
    
    .level-selector {
        padding: 12px 35px 12px 15px;
        font-size: 16px;  /* Voorkomt zoom op iOS */
        min-height: 48px;
    }
    
    .control-button .key,
    .nav-button .key {
        padding: 4px 10px;
        font-size: 12px;
    }
}

/* Responsive design - tablet */
@media (max-width: 900px) {
    body {
        padding: 5px;
    }
    
    .control-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 12px 15px;
    }
    
    .control-group {
        flex-wrap: wrap;
        justify-content: space-between;
    }
    
    .control-group-info {
        margin-left: 0;
    }
    
    .level-controls {
        flex-wrap: wrap;
    }
    
    .info-text {
        justify-content: center;
        width: 100%;
        font-size: 14px;
    }
    
    .canvas-container {
        padding: 10px;
    }
}

/* Responsive design - telefoon */
@media (max-width: 600px) {
    .game-header {
        flex-direction: column;
        text-align: center;
        padding: 12px 15px;
    }
    
    .level-info {
        justify-content: center;
        gap: 15px;
    }
    
    .control-group {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        width: 100%;
    }
    
    .control-group-title {
        text-align: center;
    }
    
    .control-buttons-row {
        width: 100%;
        flex-direction: row;
    }
    
    .control-button {
        flex: 1;
        justify-content: center;
    }
    
    .level-controls {
        width: 100%;
        flex-direction: column;
        gap: 10px;
    }
    
    .level-selector {
        width: 100%;
        min-width: 0;
        text-align: center;
    }
    
    .level-nav-buttons {
        width: 100%;
        flex-direction: row;
    }
    
    .nav-button {
        flex: 1;
        justify-content: center;
    }
    
    .canvas-container {
        padding: 5px;
    }
    
    .info-value {
        font-size: 1.1em;
    }
    
    .game-footer {
        flex-direction: column;
        text-align: center;
        padding: 10px 15px;
    }
}

/* Zeer kleine schermen */
@media (max-width: 400px) {
    .game-header h1 {
        font-size: 1.4em;
    }
    
    .control-bar {
        padding: 8px 10px;
    }
    
    .info-text {
        flex-direction: column;
        gap: 4px;
    }
    
    .info-text .separator {
        display: none;
    }
    
    .control-button .key,
    .nav-button .key {
        display: none;  /* Verberg toets hints op zeer kleine schermen */
    }
}

/* Animatie voor oplossen */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

.solving {
    animation: pulse 1s ease-in-out infinite;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}
