/* === Reset & Base === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #0a0a0a;
    color: #e0e0e0;
    font-family: 'Courier New', Courier, monospace;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow-y: auto;
    -webkit-tap-highlight-color: transparent;
}

/* === Background Ambient Canvas === */
#bg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.22;
}

/* === App Layout === */
#app {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: center;
    padding: 20px;
    align-items: flex-start;
    width: 100%;
}

/* === Game Area === */
#game-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

/* === Scoreboard === */
#score-board {
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding: 0 4px;
}

.score-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.score-label {
    font-size: 11px;
    color: #666;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.score-value {
    font-size: 28px;
    font-weight: bold;
    color: #00ff88;
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
    transition: transform 0.15s ease;
}

.score-value.bump {
    transform: scale(1.3);
}

/* === Canvas Wrapper === */
#canvas-wrap {
    position: relative;
    line-height: 0;
}

#game-canvas {
    border: 2px solid #00ff88;
    border-radius: 4px;
    box-shadow:
        0 0 15px rgba(0, 255, 136, 0.2),
        inset 0 0 15px rgba(0, 255, 136, 0.05);
    display: block;
    background: #0d0d0d;
}

/* === Overlay === */
#overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    z-index: 10;
    opacity: 1;
    transition: opacity 0.3s ease;
    line-height: 1.4;
}

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

#overlay-content {
    text-align: center;
    pointer-events: auto;
    line-height: 1.5;
    background: rgba(13, 13, 13, 0.88);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(0, 255, 136, 0.25);
    border-radius: 12px;
    padding: 24px 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7);
}

#overlay-title {
    font-size: 40px;
    font-weight: 800;
    color: #00ff88;
    text-shadow:
        0 0 20px rgba(0, 255, 136, 0.6),
        0 0 40px rgba(0, 255, 136, 0.3);
    letter-spacing: 6px;
    margin: 0;
    line-height: 1.2;
    animation: pulse-glow 2s ease-in-out infinite;
}

#overlay-message {
    font-size: 14px;
    color: #cccccc;
    letter-spacing: 1px;
    margin: 0;
    line-height: 1.4;
}

.sub-text {
    font-size: 11px;
    color: #777777;
    letter-spacing: 0.5px;
    margin: 0;
    line-height: 1.4;
}

@keyframes pulse-glow {
    0%, 100% { text-shadow: 0 0 20px rgba(0, 255, 136, 0.6), 0 0 40px rgba(0, 255, 136, 0.3); }
    50% { text-shadow: 0 0 30px rgba(0, 255, 136, 0.9), 0 0 60px rgba(0, 255, 136, 0.5); }
}

/* === Settings Panel === */
#settings-panel {
    position: absolute;
    right: 20px;
    top: 20px;
    background: #111;
    border: 1px solid #222;
    border-radius: 8px;
    padding: 18px;
    width: 240px;
    flex-shrink: 0;
    max-height: 90vh;
    overflow-y: auto;
}

#settings-panel::-webkit-scrollbar {
    width: 4px;
}
#settings-panel::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 2px;
}

.panel-title {
    font-size: 16px;
    color: #00ff88;
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-bottom: 16px;
    text-align: center;
    text-shadow: 0 0 8px rgba(0, 255, 136, 0.3);
}

.setting-group {
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid #1a1a1a;
}

.setting-group:last-of-type {
    border-bottom: none;
    margin-bottom: 12px;
}

.group-title {
    font-size: 10px;
    color: #555;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.setting-row label {
    font-size: 12px;
    color: #999;
}

/* Color inputs */
.setting-row input[type="color"] {
    -webkit-appearance: none;
    appearance: none;
    width: 32px;
    height: 24px;
    border: 1px solid #333;
    border-radius: 4px;
    background: none;
    cursor: pointer;
    padding: 0;
}

.setting-row input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.setting-row input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 2px;
}

/* Toggle switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 20px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: #222;
    border-radius: 20px;
    transition: background 0.2s;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    left: 2px;
    bottom: 2px;
    background: #666;
    border-radius: 50%;
    transition: transform 0.2s, background 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
    background: #00ff8844;
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(18px);
    background: #00ff88;
}

/* Range slider */
.slider-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 70px;
    height: 4px;
    background: #222;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: #00ff88;
    border-radius: 50%;
    border: none;
    cursor: pointer;
}

.range-label {
    font-size: 10px;
    color: #666;
    min-width: 36px;
    text-align: right;
}

/* Select */
select {
    background: #1a1a1a;
    color: #ccc;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 11px;
    font-family: inherit;
    cursor: pointer;
    outline: none;
}

select:focus {
    border-color: #00ff88;
}

/* Preset grid */
.preset-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
}

.preset-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    padding: 8px 4px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    font-family: inherit;
    color: #888;
    font-size: 9px;
    letter-spacing: 0.5px;
}

.preset-btn:hover {
    border-color: #444;
    background: #222;
}

.preset-btn.active {
    border-color: #00ff88;
    background: #0a1a10;
    color: #00ff88;
}

.preset-swatch {
    width: 28px;
    height: 18px;
    border-radius: 3px;
    display: block;
}

/* Reset button */
.reset-button {
    width: 100%;
    padding: 8px;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 6px;
    color: #888;
    font-family: inherit;
    font-size: 11px;
    letter-spacing: 1px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.reset-button:hover {
    background: #2a1a1a;
    color: #ff4466;
    border-color: #ff4466;
}

/* === Mobile Controls === */
#mobile-controls {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    user-select: none;
}

.ctrl-row {
    display: flex;
    gap: 4px;
}

.ctrl-btn {
    width: 56px;
    height: 56px;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 8px;
    color: #00ff88;
    font-size: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background 0.1s, border-color 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.ctrl-btn:active {
    background: #00ff88;
    color: #0a0a0a;
    border-color: #00ff88;
}

/* === Responsive === */
@media (hover: none) and (pointer: coarse) {
    #mobile-controls {
        display: flex;
    }
}

@media (max-width: 700px) {
    #app {
        flex-direction: column;
        align-items: center;
    }

    #settings-panel {
        position: static;
        width: 100%;
        max-width: 400px;
        max-height: none;
    }
}
