* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Helvetica Neue', 'Arial', sans-serif;
    background: #f8f9fa;
    color: #212529;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.container {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    max-width: 100vw;
    max-height: 100vh;
    padding: clamp(10px, 2vmin, 20px);
    display: flex;
    flex-direction: column;
}

header {
    text-align: center;
    margin-bottom: clamp(5px, 1vmin, 10px);
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.level-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.level-label {
    font-size: clamp(0.6em, 1.5vmin, 0.75em);
    letter-spacing: 2px;
    color: #6c757d;
    font-weight: 500;
    text-transform: uppercase;
}

.level-number {
    font-size: 1em;
    font-weight: 700;
    color: #212529;
}

.level-name {
    font-size: clamp(1.5em, 5vmin, 3em);
    letter-spacing: -1px;
    font-weight: 700;
    color: #212529;
    text-transform: uppercase;
}

.level-selector {
    background: #ffffff;
    border: none;
    border-radius: 0;
    padding: clamp(10px, 2vmin, 20px) clamp(5px, 1vmin, 10px);
    width: clamp(100px, 15vmin, 160px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex-shrink: 0;
}

/* Scrollbar styling for webkit browsers */
.level-selector::-webkit-scrollbar {
    width: 8px;
}

.level-selector::-webkit-scrollbar-track {
    background: #f8f9fa;
}

.level-selector::-webkit-scrollbar-thumb {
    background: #dee2e6;
    border-radius: 0;
}

.level-selector::-webkit-scrollbar-thumb:hover {
    background: #adb5bd;
}

.level-selector-title {
    font-size: clamp(0.7em, 1.5vmin, 0.85em);
    letter-spacing: 2px;
    margin-bottom: clamp(12px, 2vmin, 24px);
    text-align: center;
    color: #212529;
    font-weight: 700;
    text-transform: uppercase;
}

.level-selector-grid {
    display: flex;
    flex-direction: column;
    gap: clamp(8px, 1.5vmin, 15px);
}

.level-selector-btn {
    width: 100%;
    padding: clamp(4px, 1vmin, 8px);
    background: #ffffff;
    border: 2px solid #dee2e6;
    border-radius: 0;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.level-preview-canvas {
    display: block;
    width: 100%;
    height: auto;
}

.level-selector-btn:hover {
    border-color: #007bff;
    transform: translateX(-2px);
    box-shadow: -4px 0 8px rgba(0, 123, 255, 0.2);
}

.level-selector-btn:active {
    transform: translateX(0);
    box-shadow: none;
}

.game-area {
    display: flex;
    gap: clamp(10px, 2vmin, 15px);
    flex: 0 0 auto;
    min-height: 0;
    overflow: hidden;
    justify-content: center;
    align-items: flex-start;
    margin: 0 auto;
    width: 100%;
}

.lights-panel {
    background: #ffffff;
    border: none;
    border-radius: 0;
    padding: clamp(10px, 2vmin, 20px) clamp(5px, 1vmin, 10px);
    width: clamp(100px, 15vmin, 160px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex-shrink: 0;
}

/* Scrollbar styling for webkit browsers */
.lights-panel::-webkit-scrollbar {
    width: 8px;
}

.lights-panel::-webkit-scrollbar-track {
    background: #f8f9fa;
}

.lights-panel::-webkit-scrollbar-thumb {
    background: #dee2e6;
    border-radius: 0;
}

.lights-panel::-webkit-scrollbar-thumb:hover {
    background: #adb5bd;
}

.lights-title {
    font-size: clamp(0.6em, 1.5vmin, 0.8em);
    letter-spacing: 2px;
    margin-bottom: clamp(10px, 2vmin, 20px);
    text-align: center;
    color: #212529;
    font-weight: 700;
    text-transform: uppercase;
}

.lights-container {
    display: flex;
    flex-direction: column;
    gap: clamp(4px, 1vmin, 8px);
    overflow: visible;
}

.light {
    position: relative;
    background: #f8f9fa;
    border: none;
    border-radius: 0;
    padding: clamp(4px, 1vmin, 8px) clamp(2px, 0.5vmin, 5px);
    text-align: center;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(3px, 0.5vmin, 6px);
    opacity: 1;
    overflow: visible;
}

/* Bold geometric colors */
.light-color-1 { --light-color: #007bff; } /* Primary Blue */
.light-color-2 { --light-color: #28a745; } /* Success Green */
.light-color-3 { --light-color: #28a745; } /* Green */
.light-color-4 { --light-color: #dc3545; } /* Danger Red */
.light-color-5 { --light-color: #6f42c1; } /* Purple */
.light-color-6 { --light-color: #fd7e14; } /* Orange */

.light-glow {
    display: none;
}

.light-circle {
    width: clamp(40px, 6vmin, 70px);
    height: clamp(40px, 6vmin, 70px);
    border-radius: 50%;
    background: var(--light-color);
    border: 3px solid transparent;
    opacity: 0.5;
    transition: all 0.2s ease;
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.light.active .light-circle {
    opacity: 1;
    border-color: var(--light-color);
    transform: scale(1.15);
    box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.08);
}

.light.required {
    opacity: 1;
    background: #f8f9fa;
}

.light.disabled {
    display: none;
}

.light-status {
    font-size: clamp(1em, 2vmin, 1.5em);
    font-weight: 600;
    letter-spacing: 0.5px;
    color: #495057;
    transition: all 0.2s ease;
    position: relative;
    z-index: 1;
    font-family: 'Helvetica Neue', 'Arial', sans-serif;
}

.light.active .light-status {
    color: #212529;
    font-weight: 700;
}

.light.required .light-status {
    color: #495057;
    font-weight: 600;
}

.light-emoji {
    font-size: clamp(1.2em, 3vmin, 2.3em);
    line-height: 1;
    user-select: none;
    cursor: pointer;
    filter: grayscale(50%);
    transition: filter 0.2s ease;
}

.light.active .light-emoji {
    filter: grayscale(0%);
}

.light.required .light-emoji {
    filter: grayscale(50%);
}

.emoji-picker {
    position: fixed;
    background: #ffffff;
    border: 2px solid #212529;
    border-radius: 0;
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(8, 36px);
    gap: 6px;
    z-index: 10000;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    max-height: 360px;
    overflow-y: auto;
    width: fit-content;
    box-sizing: border-box;
}

/* Scrollbar styling for emoji picker */
.emoji-picker::-webkit-scrollbar {
    width: 6px;
}

.emoji-picker::-webkit-scrollbar-track {
    background: #f8f9fa;
}

.emoji-picker::-webkit-scrollbar-thumb {
    background: #dee2e6;
    border-radius: 0;
}

.emoji-picker::-webkit-scrollbar-thumb:hover {
    background: #adb5bd;
}

.emoji-option {
    width: 36px;
    height: 36px;
    border: 1px solid #dee2e6;
    border-radius: 0;
    background: #f8f9fa;
    font-size: 1.4em;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
}

.emoji-option:hover {
    background: #007bff;
    border-color: #007bff;
    transform: scale(1.1);
}

.canvas-container {
    position: relative;
    flex: 0 0 auto;
    width: fit-content;
    height: fit-content;
    min-width: 0;
    min-height: 0;
    max-width: 800px;
    max-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#gameCanvas {
    background: #ffffff;
    border: 3px solid #212529;
    border-radius: 0;
    cursor: crosshair;
    display: block;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    max-width: 100%;
    max-height: 100%;
}

#gameCanvas.grid-mode {
    aspect-ratio: 1 / 1;
    max-width: min(100%, 100vh - 200px);
    max-height: min(100%, 100vw - 200px);
    width: auto !important;
    height: auto !important;
}

.controls {
    display: flex;
    justify-content: center;
    gap: clamp(10px, 2vmin, 20px);
    margin-top: clamp(10px, 2vmin, 30px);
    flex-shrink: 0;
}

.btn {
    background: #212529;
    color: #ffffff;
    border: none;
    padding: clamp(10px, 2vmin, 16px) clamp(20px, 4vmin, 40px);
    font-size: clamp(0.7em, 1.5vmin, 0.9em);
    font-family: 'Helvetica Neue', 'Arial', sans-serif;
    letter-spacing: 1px;
    cursor: pointer;
    border-radius: 0;
    transition: all 0.2s ease;
    box-shadow: none;
    font-weight: 700;
    text-transform: uppercase;
}

.btn:hover {
    background: #000000;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.btn.hidden {
    display: none;
}

.btn-next {
    background: #007bff;
}

.btn-next:hover {
    background: #0056b3;
}

/* Tablet and smaller screens */
@media (max-width: 900px) {
    .game-area {
        flex-direction: column;
        max-width: 100%;
    }

    .lights-panel {
        width: 100%;
        order: 1;
        max-height: none;
        padding: clamp(10px, 2vmin, 15px);
    }

    .canvas-container {
        order: 2;
        flex: 1;
        max-width: 100%;
    }

    .level-selector {
        width: 100%;
        order: 3;
    }

    .lights-container {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }

    .level-selector-grid {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }

    .level-selector-btn {
        width: auto;
        flex: 0 0 calc(33.333% - 7px);
        min-width: 80px;
    }
}

/* Mobile screens */
@media (max-width: 600px) {
    .container {
        padding: 10px;
    }

    header {
        margin-bottom: 10px;
    }

    .game-area {
        gap: 10px;
    }

    .controls {
        margin-top: 10px;
    }

    .light-circle {
        width: 50px;
        height: 50px;
    }

    .light-emoji {
        font-size: 1.5em;
    }
}

/* Landscape mobile */
@media (max-height: 500px) {
    .container {
        padding: 5px 10px;
    }

    header {
        margin-bottom: 5px;
    }

    .level-name {
        font-size: 1.5em;
    }

    .game-area {
        gap: 10px;
    }

    .controls {
        margin-top: 5px;
    }

    .btn {
        padding: 8px 20px;
    }
}

/* Completion View */
.completion-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 20px;
    text-align: center;
}

.completion-title {
    font-size: clamp(1.5em, 4vmin, 2.5em);
    font-weight: 700;
    color: #212529;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.completion-subtitle {
    font-size: clamp(0.9em, 2vmin, 1.2em);
    color: #6c757d;
    margin-bottom: 20px;
}

.completion-solutions {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 10px;
    max-width: 500px;
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
    width: 100%;
}

.completion-solution-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.completion-solution-canvas {
    background: #ffffff;
    border: 2px solid #dee2e6;
    border-radius: 0;
}

.completion-solution-label {
    font-size: 0.75em;
    color: #6c757d;
    font-weight: 600;
}
