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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #080c14;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: #f1f5f9;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
}

.game-container {
    position: fixed;
    inset: 0;
    background: #080c14;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

.hud {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: max(12px, 2vh) max(16px, 2.5vw);
    z-index: 5;
    pointer-events: none;
}

.hud-left, .hud-right {
    display: flex;
    align-items: flex-start;
    gap: max(12px, 2vw);
}

.hud-item {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.hud-label {
    font-size: clamp(8px, 1.2vh, 14px);
    font-weight: 700;
    letter-spacing: 0.12em;
    color: #64748b;
    text-transform: uppercase;
}

.hud-value {
    font-size: clamp(16px, 3vh, 32px);
    font-weight: 800;
    color: #f1f5f9;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: opacity 0.35s ease, transform 0.35s ease, visibility 0.35s ease;
}

.overlay.hidden {
    visibility: hidden;
    opacity: 0;
    transform: scale(0.92);
}

.overlay-bg {
    position: absolute;
    inset: 0;
    background: rgba(8, 12, 20, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.overlay-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(10px, 1.6vh, 20px);
    padding: clamp(28px, 4.5vh, 52px) clamp(24px, 5vw, 48px);
    text-align: center;
    width: min(370px, 86vw);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    box-shadow:
        0 24px 80px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.title-icon {
    font-size: clamp(48px, 10vh, 72px);
    line-height: 1;
    margin-bottom: 2px;
    animation: float 3s ease-in-out infinite;
    filter: drop-shadow(0 4px 24px rgba(16, 185, 129, 0.25));
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.game-title {
    font-size: clamp(24px, 4.8vh, 40px);
    font-weight: 900;
    letter-spacing: 0.15em;
    background: linear-gradient(135deg, #10b981, #34d399, #6ee7b7, #10b981);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 4s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.game-subtitle {
    font-size: clamp(13px, 1.8vh, 16px);
    color: #64748b;
    margin-bottom: 2px;
}

.controls-hint {
    display: none;
    align-items: center;
    gap: clamp(6px, 1vw, 10px);
    flex-wrap: wrap;
    justify-content: center;
    margin: 1px 0;
}

.key-badge {
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: clamp(3px, 0.5vh, 6px) clamp(8px, 1.5vw, 14px);
    border-radius: 6px;
    font-size: clamp(10px, 1.4vh, 13px);
    font-weight: 700;
    color: #94a3b8;
}

.hint-text {
    font-size: clamp(10px, 1.4vh, 13px);
    color: #475569;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: clamp(10px, 1.5vh, 14px);
    width: 100%;
    margin-top: 4px;
}

.btn-modern {
    background: linear-gradient(135deg, #059669, #10b981);
    color: white;
    border: none;
    width: 100%;
    padding: clamp(14px, 2.2vh, 18px) clamp(28px, 5vw, 48px);
    font-size: clamp(14px, 2vh, 17px);
    font-weight: 700;
    letter-spacing: 0.1em;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 24px rgba(16, 185, 129, 0.3);
    pointer-events: auto;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn-modern:active {
    transform: scale(0.96);
    box-shadow: 0 2px 12px rgba(16, 185, 129, 0.15);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    box-shadow: none;
    color: rgba(255, 255, 255, 0.65);
    font-size: clamp(12px, 1.6vh, 14px);
    padding: clamp(12px, 1.8vh, 16px) clamp(24px, 4vw, 40px);
}

.btn-secondary:active {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(0.96);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    box-shadow: none;
    color: #ef4444;
}

.btn-danger:active {
    background: rgba(239, 68, 68, 0.25);
}

.gameover-icon {
    font-size: clamp(40px, 7vh, 56px);
    line-height: 1;
    animation: pulse-icon 1.5s ease-in-out infinite;
    filter: drop-shadow(0 4px 20px rgba(239, 68, 68, 0.25));
}

@keyframes pulse-icon {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: 0.75; }
}

.gameover-title {
    font-size: clamp(20px, 3.5vh, 30px);
    font-weight: 800;
    letter-spacing: 0.12em;
    color: #ef4444;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(8px, 1.2vh, 12px);
    width: 100%;
}

.stat-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    padding: clamp(10px, 1.5vh, 16px) clamp(8px, 1.2vw, 14px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.stat-card:first-child {
    border-color: rgba(16, 185, 129, 0.2);
    background: rgba(16, 185, 129, 0.06);
}

.stat-icon {
    font-size: clamp(16px, 2.5vh, 24px);
    margin-bottom: 2px;
}

.stat-label {
    font-size: clamp(8px, 1vh, 11px);
    font-weight: 600;
    color: #64748b;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.stat-value {
    font-size: clamp(18px, 3vh, 28px);
    font-weight: 800;
    color: #f1f5f9;
    font-variant-numeric: tabular-nums;
}

.settings-icon {
    font-size: clamp(32px, 5vh, 44px);
    line-height: 1;
}

.settings-title {
    font-size: clamp(20px, 3vh, 28px);
    font-weight: 800;
    letter-spacing: 0.08em;
    color: #f1f5f9;
}

.settings-list {
    display: flex;
    flex-direction: column;
    gap: clamp(10px, 1.5vh, 18px);
    width: 100%;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: clamp(12px, 1.8vh, 16px) clamp(14px, 2vw, 20px);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    gap: 12px;
}

.setting-label {
    font-size: clamp(14px, 1.8vh, 16px);
    font-weight: 600;
    color: #e2e8f0;
}

.toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.toggle input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.toggle-track {
    position: relative;
    width: 48px;
    height: 26px;
    border-radius: 13px;
    background: rgba(255, 255, 255, 0.12);
    transition: background 0.25s ease;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle input:checked + .toggle-track {
    background: linear-gradient(135deg, #059669, #10b981);
}

.toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #f1f5f9;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle input:checked + .toggle-track .toggle-thumb {
    transform: translateX(22px);
}

.color-trigger {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.15);
    background: transparent;
    cursor: pointer;
    padding: 2px;
    touch-action: manipulation;
    transition: border-color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.color-trigger:active {
    border-color: rgba(255, 255, 255, 0.3);
    transform: scale(0.92);
}

.color-swatch-preview {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: #34d399;
    transition: background 0.2s ease;
}

.color-picker-icon {
    font-size: clamp(32px, 5vh, 44px);
    line-height: 1;
}

.color-picker-title {
    font-size: clamp(18px, 3vh, 26px);
    font-weight: 800;
    letter-spacing: 0.06em;
    color: #f1f5f9;
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: clamp(8px, 1.2vh, 14px);
    width: 100%;
    padding: clamp(8px, 1vh, 16px) 0;
}

.color-swatch-btn {
    aspect-ratio: 1;
    width: 100%;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    padding: 0;
    touch-action: manipulation;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

.color-swatch-btn:active {
    transform: scale(0.88);
    border-color: rgba(255, 255, 255, 0.4);
}

.color-swatch-btn.selected {
    border-color: #f1f5f9;
    box-shadow: 0 0 16px rgba(255, 255, 255, 0.2);
    transform: scale(1.08);
}

@media (hover: hover) and (pointer: fine) {
    .controls-hint {
        display: flex;
    }

    .btn-modern:hover {
        transform: translateY(-2px) scale(1.02);
        box-shadow: 0 8px 30px rgba(16, 185, 129, 0.4);
    }

    .btn-secondary:hover {
        background: rgba(255, 255, 255, 0.1);
        transform: translateY(-1px);
        box-shadow: none;
    }

    .btn-danger:hover {
        background: rgba(239, 68, 68, 0.25);
        box-shadow: 0 4px 20px rgba(239, 68, 68, 0.15);
    }

    .mobile-controls {
        display: none !important;
    }
}

.mobile-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: max(18px, 3vh) max(20px, 4vw);
    z-index: 20;
    pointer-events: none;
}

.mobile-controls.hidden {
    display: none;
}

.ctrl-group {
    display: flex;
    gap: max(14px, 2.5vw);
}

.ctrl-btn {
    pointer-events: auto;
    width: max(56px, 8vh);
    height: max(56px, 8vh);
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.04));
    box-shadow:
        0 6px 24px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.15),
        inset 0 -1px 0 rgba(0, 0, 0, 0.1);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    color: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    cursor: pointer;
    transition: all 0.12s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

.ctrl-btn:active,
.ctrl-btn.pressed {
    transform: scale(0.84);
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.08));
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.ctrl-btn svg {
    display: block;
    width: max(22px, 3vh);
    height: max(22px, 3vh);
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

.ctrl-jump-btn {
    width: max(72px, 10vh);
    height: max(72px, 10vh);
    border-color: rgba(16, 185, 129, 0.25);
    background: linear-gradient(145deg, rgba(16, 185, 129, 0.3), rgba(16, 185, 129, 0.1));
    box-shadow:
        0 6px 28px rgba(16, 185, 129, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
    color: #34d399;
}

.ctrl-jump-btn:active,
.ctrl-jump-btn.pressed {
    transform: scale(0.84);
    background: linear-gradient(145deg, rgba(16, 185, 129, 0.4), rgba(16, 185, 129, 0.15));
    box-shadow:
        0 2px 12px rgba(16, 185, 129, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.ctrl-jump-btn svg {
    width: max(26px, 3.8vh);
    height: max(26px, 3.8vh);
}

.btn-install-app {
    background: rgba(16, 185, 129, 0.12) !important;
    color: #34d399 !important;
    font-size: clamp(12px, 1.6vh, 14px) !important;
}

.btn-install-app:active {
    background: rgba(16, 185, 129, 0.25) !important;
}
