/* Styles generated using AI, some fixed by me */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background-color: #1a1a1a;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    position: relative;
    margin: 0;
    padding: 0;
}

#webgpu-canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: grab;
    position: relative;
    z-index: 1;
    pointer-events: auto;
}

/* Disable canvas interactions when overlay screens are visible */
body.menu-visible #webgpu-canvas,
body.loading-visible #webgpu-canvas,
body.game-over-visible #webgpu-canvas {
    pointer-events: none;
}

#webgpu-canvas:active {
    cursor: grabbing;
}

/* Controls Overlay */
.controls-overlay {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 15000;
    /* Higher than score display but lower than screen overlays */
    pointer-events: none;
    width: auto;
    height: auto;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    visibility: visible;
    opacity: 1;
}

.overlay-toggle {
    background: rgba(15, 15, 20, 0.98);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    pointer-events: all;
    transition: all 0.3s ease;
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    color: rgba(255, 255, 255, 0.8);
    font-size: 18px;
    position: relative;
    z-index: 10001;
}

.overlay-toggle:hover {
    background: rgba(25, 25, 30, 0.98);
    transform: scale(1.05);
    box-shadow:
        0 6px 20px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

.overlay-toggle:active {
    transform: scale(0.95);
}

.overlay-toggle #toggle-icon {
    transition: transform 0.3s ease;
    display: inline-block;
}

.controls-overlay.collapsed .overlay-toggle #toggle-icon {
    transform: rotate(180deg);
}

#controls-panel {
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
}

.controls-overlay.collapsed #controls-panel {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    pointer-events: none;
    height: 0;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

.controls-panel {
    background: rgba(15, 15, 20, 0.98);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 16px;
    min-width: 220px;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset,
        0 2px 8px rgba(0, 0, 0, 0.3);
    pointer-events: all;
    animation: slideIn 0.3s ease-out;
    position: relative;
    isolation: isolate;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.controls-header {
    display: flex;
    flex-direction: column;
    color: white;
    gap: 4;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#lock-toggle {
    color: white;
}

.header-buttons {
    display: flex;
    gap: 8px;
    color: white;
    align-items: center;
}

.controls-header h3 {
    color: #ffffff;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.icon-button {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 16px;
}

.icon-button:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.icon-button:active {
    transform: scale(0.95);
}

.icon-button.locked {
    background: rgba(255, 100, 100, 0.2);
    border-color: rgba(255, 100, 100, 0.4);
}

.controls-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.control-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 13px;
}

.control-key {
    background: rgba(100, 150, 255, 0.2);
    border: 1px solid rgba(100, 150, 255, 0.3);
    border-radius: 4px;
    padding: 4px 8px;
    color: #a0c4ff;
    font-weight: 500;
    font-family: 'Courier New', monospace;
    min-width: 80px;
    text-align: center;
}

.control-desc {
    color: rgba(255, 255, 255, 0.7);
    font-weight: 400;
}

.controls-footer {
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.action-button {
    width: 100%;
    background: linear-gradient(135deg, rgba(100, 150, 255, 0.3), rgba(150, 100, 255, 0.3));
    border: 1px solid rgba(100, 150, 255, 0.4);
    border-radius: 6px;
    padding: 10px 16px;
    color: #ffffff;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.3px;
}

.action-button:hover {
    background: linear-gradient(135deg, rgba(100, 150, 255, 0.4), rgba(150, 100, 255, 0.4));
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(100, 150, 255, 0.3);
}

.action-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(100, 150, 255, 0.2);
}

/* Ensure overlay is always on top */
.controls-overlay * {
    position: relative;
    z-index: inherit;
}


/* Screen Overlays */
.screen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 15, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: all;
    /* Ensure menu can receive clicks */
}

.screen-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Menu Screen */
.menu-container {
    background: rgba(20, 20, 25, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 40px;
    max-width: 600px;
    width: 90%;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
    text-align: center;
}

.game-title {
    font-size: 48px;
    font-weight: 700;
    background: linear-gradient(135deg, #64a0ff, #a064ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
    letter-spacing: 2px;
}

.game-subtitle {
    color: rgba(255, 255, 255, 0.7);
    font-size: 18px;
    margin-bottom: 32px;
}


.primary-button {
    background: linear-gradient(135deg, rgba(100, 150, 255, 0.4), rgba(150, 100, 255, 0.4));
    border: 1px solid rgba(100, 150, 255, 0.5);
    border-radius: 8px;
    padding: 14px 32px;
    color: #ffffff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 200px;
}

.primary-button:hover {
    background: linear-gradient(135deg, rgba(100, 150, 255, 0.5), rgba(150, 100, 255, 0.5));
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(100, 150, 255, 0.3);
}

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

.secondary-button {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 14px 32px;
    color: #ffffff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 200px;
}

.secondary-button:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.menu-actions {
    margin: 32px 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
}

.map-selection {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    width: 100%;
}

.map-label {
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    font-weight: 500;
}

.map-select {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    padding: 10px 16px;
    color: #ffffff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 200px;
    font-family: inherit;
}

.map-select:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(100, 150, 255, 0.5);
}

.map-select:focus {
    outline: none;
    border-color: rgba(100, 150, 255, 0.7);
    box-shadow: 0 0 0 2px rgba(100, 150, 255, 0.2);
}

/* Score Display */
.score-display {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 10000;
    background: rgba(15, 15, 20, 0.98);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 16px;
    min-width: 200px;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    display: none;
    pointer-events: all;
}

.score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 13px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.score-item:last-child {
    border-bottom: none;
}

.score-label {
    color: rgba(255, 255, 255, 0.7);
    font-weight: 400;
}

.score-value {
    color: #ffffff;
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

.menu-instructions {
    margin-top: 32px;
    padding-top: 32px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: left;
}

.menu-instructions h4 {
    color: rgba(255, 255, 255, 0.9);
    font-size: 16px;
    margin-bottom: 12px;
}

.instruction-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.instruction-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.instruction-key {
    background: rgba(100, 150, 255, 0.2);
    border: 1px solid rgba(100, 150, 255, 0.3);
    border-radius: 4px;
    padding: 4px 12px;
    color: #a0c4ff;
    font-weight: 500;
    font-family: 'Courier New', monospace;
    font-size: 12px;
}

.instruction-desc {
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
}

/* Loading Screen */
.loading-container {
    text-align: center;
    color: #ffffff;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: #64a0ff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 24px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-container h2 {
    font-size: 28px;
    margin-bottom: 12px;
}

.loading-container p {
    color: rgba(255, 255, 255, 0.7);
    font-size: 16px;
    margin-bottom: 24px;
}

.loading-progress {
    width: 300px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin: 0 auto;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #64a0ff, #a064ff);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 2px;
}

/* Game Over Screen */
.game-over-container {
    background: rgba(20, 20, 25, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 40px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
    text-align: center;
}

.game-over-container h2 {
    font-size: 36px;
    margin-bottom: 16px;
    background: linear-gradient(135deg, #64ff64, #64a0ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.game-over-stats {
    color: rgba(255, 255, 255, 0.7);
    font-size: 18px;
    margin-bottom: 32px;
    font-family: 'Courier New', monospace;
}

.game-over-actions {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 32px;
}

.map-select option {
    background-color: #1a1a1a;
    color: white;
}