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

body {
    overflow: hidden;
    background: #0a0a1a;
    font-family: 'IBM Plex Mono', monospace;
    color: #ecf0f1;
    user-select: none;
    -webkit-user-select: none;
}

#scene-container {
    width: 100vw;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
}

#scene-container canvas {
    display: block;
}

/* ==================== WELCOME SCREEN ==================== */

#welcome-screen {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: linear-gradient(135deg, #0a0a1a 0%, #1a1a2e 40%, #16213e 100%);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.welcome-bg-gears {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    overflow: hidden;
    pointer-events: none;
}

.gear {
    position: absolute;
    font-size: 120px;
    opacity: 0.06;
    color: #f39c12;
}

.gear-1 {
    top: 10%; left: 5%;
    animation: spin 20s linear infinite;
}

.gear-2 {
    bottom: 15%; right: 8%;
    font-size: 180px;
    animation: spin 30s linear infinite reverse;
}

.gear-3 {
    top: 50%; left: 60%;
    font-size: 90px;
    animation: spin 15s linear infinite;
}

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

.welcome-content {
    text-align: center;
    z-index: 10;
    animation: fadeInUp 0.8s ease-out;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.welcome-title {
    font-family: 'Oswald', sans-serif;
    font-size: clamp(48px, 10vw, 96px);
    font-weight: 700;
    letter-spacing: 6px;
    color: #f39c12;
    text-shadow: 0 0 40px rgba(243, 156, 18, 0.4), 0 4px 0 #c47f17, 0 6px 0 #a06810;
    margin-bottom: 12px;
}

.welcome-subtitle {
    font-size: clamp(12px, 2vw, 18px);
    color: #7f8c8d;
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-bottom: 48px;
}

.welcome-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-primary, .btn-secondary {
    font-family: 'Oswald', sans-serif;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 2px;
    padding: 16px 36px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-primary {
    background: linear-gradient(180deg, #f39c12 0%, #e67e22 100%);
    color: #1a1a2e;
    box-shadow: 0 4px 0 #c47f17, 0 6px 20px rgba(243, 156, 18, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #c47f17, 0 8px 30px rgba(243, 156, 18, 0.5);
}

.btn-primary:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #c47f17;
}

.btn-secondary {
    background: linear-gradient(180deg, #34495e 0%, #2c3e50 100%);
    color: #ecf0f1;
    box-shadow: 0 4px 0 #1a252f, 0 6px 20px rgba(0,0,0,0.3);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #1a252f, 0 8px 30px rgba(0,0,0,0.4);
}

.btn-secondary:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #1a252f;
}

.btn-icon {
    font-size: 22px;
}

/* ==================== HUD ==================== */

#top-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 44px;
    background: linear-gradient(180deg, rgba(26,26,46,0.9) 0%, rgba(26,26,46,0.6) 100%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 100;
    border-bottom: 1px solid rgba(243, 156, 18, 0.15);
}

#game-title {
    font-family: 'Oswald', sans-serif;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 3px;
    color: #f39c12;
}

#top-stats {
    display: flex;
    gap: 20px;
    font-size: 12px;
    color: #95a5a6;
}

#block-count { color: #3498db; }
#fps-counter { color: #7f8c8d; font-variant-numeric: tabular-nums; }

/* Crosshair */
#crosshair {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    color: rgba(255,255,255,0.7);
    pointer-events: none;
    z-index: 99;
    text-shadow: 0 0 4px rgba(0,0,0,0.8);
    font-weight: 100;
    line-height: 1;
}

/* Left Panel */
#left-panel {
    position: fixed;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(26,26,46,0.88);
    border: 1px solid rgba(243,156,18,0.15);
    border-radius: 8px;
    padding: 12px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    backdrop-filter: blur(8px);
}

.panel-btn {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    font-weight: 600;
    padding: 8px 12px;
    border: 1px solid rgba(243,156,18,0.3);
    border-radius: 4px;
    background: rgba(44,62,80,0.8);
    color: #ecf0f1;
    cursor: pointer;
    transition: all 0.15s ease;
    width: 100%;
    text-align: center;
}

.panel-btn:hover {
    background: rgba(243,156,18,0.2);
    border-color: #f39c12;
}

.mode-btn {
    background: rgba(46,204,113,0.2);
    border-color: rgba(46,204,113,0.4);
    color: #2ecc71;
}

.mode-btn.play-mode {
    background: rgba(243,156,18,0.2);
    border-color: rgba(243,156,18,0.4);
    color: #f39c12;
}

.panel-divider {
    width: 80%;
    height: 1px;
    background: rgba(255,255,255,0.08);
    margin: 4px 0;
}

.panel-label {
    font-size: 9px;
    letter-spacing: 2px;
    color: #7f8c8d;
    text-transform: uppercase;
}

.rotation-btns {
    display: flex;
    gap: 4px;
}

.rot-btn {
    width: 32px !important;
    padding: 6px !important;
    font-size: 10px !important;
    text-align: center;
}

#color-palette {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 3px;
}

.color-swatch {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
}

.color-swatch:hover {
    transform: scale(1.2);
}

.color-swatch.active {
    border-color: #fff;
    box-shadow: 0 0 8px rgba(255,255,255,0.4);
}

/* Right Panel */
#right-panel {
    position: fixed;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(26,26,46,0.88);
    border: 1px solid rgba(243,156,18,0.15);
    border-radius: 8px;
    padding: 12px;
    z-index: 100;
    backdrop-filter: blur(8px);
}

.control-hint {
    font-size: 10px;
    color: #7f8c8d;
    margin: 4px 0;
    display: flex;
    gap: 6px;
    align-items: center;
}

.control-hint kbd {
    font-family: 'IBM Plex Mono', monospace;
    background: rgba(255,255,255,0.08);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 9px;
    color: #bdc3c7;
    min-width: 40px;
    text-align: center;
    border: 1px solid rgba(255,255,255,0.1);
}

/* Hotbar */
#hotbar {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 4px;
    padding: 6px;
    background: rgba(26,26,46,0.92);
    border: 1px solid rgba(243,156,18,0.2);
    border-radius: 10px;
    z-index: 100;
    backdrop-filter: blur(8px);
}

.hotbar-slot {
    width: 56px;
    height: 56px;
    border-radius: 6px;
    border: 2px solid rgba(255,255,255,0.08);
    background: rgba(44,62,80,0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
}

.hotbar-slot:hover {
    background: rgba(44,62,80,0.9);
    border-color: rgba(255,255,255,0.2);
}

.hotbar-slot.active {
    border-color: #f39c12;
    box-shadow: 0 0 12px rgba(243,156,18,0.4), inset 0 0 12px rgba(243,156,18,0.1);
}

.hotbar-slot .slot-icon {
    font-size: 22px;
    line-height: 1;
}

.hotbar-slot .slot-name {
    font-size: 7px;
    color: #95a5a6;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.hotbar-slot .slot-key {
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: 8px;
    color: rgba(255,255,255,0.3);
}

/* Achievement */
#achievement {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, rgba(243,156,18,0.95), rgba(230,126,34,0.95));
    color: #1a1a2e;
    padding: 14px 28px;
    border-radius: 8px;
    font-family: 'Oswald', sans-serif;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 2px;
    z-index: 200;
    animation: achievePop 0.4s ease-out;
    box-shadow: 0 4px 30px rgba(243,156,18,0.5);
}

@keyframes achievePop {
    0% { transform: translateX(-50%) scale(0.5); opacity: 0; }
    60% { transform: translateX(-50%) scale(1.1); }
    100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* ==================== MODALS ==================== */

.pause-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(10,10,26,0.75);
    backdrop-filter: blur(4px);
}

.pause-modal {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
    border: 1px solid rgba(243,156,18,0.3);
    border-radius: 12px;
    padding: 32px 40px;
    min-width: 320px;
    z-index: 1001;
    text-align: center;
}

.pause-modal h2 {
    font-family: 'Oswald', sans-serif;
    font-size: 28px;
    letter-spacing: 4px;
    color: #f39c12;
    margin-bottom: 24px;
}

.pause-btn {
    display: block;
    width: 100%;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 14px;
    font-weight: 600;
    padding: 12px 20px;
    margin: 8px 0;
    border: 1px solid rgba(243,156,18,0.2);
    border-radius: 6px;
    background: rgba(44,62,80,0.8);
    color: #ecf0f1;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
}

.pause-btn:hover {
    background: rgba(243,156,18,0.15);
    border-color: #f39c12;
    transform: translateX(4px);
}

.btn-danger {
    border-color: rgba(231,76,60,0.4) !important;
    color: #e74c3c !important;
}

.btn-danger:hover {
    background: rgba(231,76,60,0.2) !important;
    border-color: #e74c3c !important;
}

.save-slot-btn {
    text-align: left !important;
}

.save-slot-info {
    font-size: 10px;
    color: #7f8c8d;
    margin-top: 2px;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.setting-row label {
    font-size: 13px;
    color: #bdc3c7;
}

.setting-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #f39c12;
}

.setting-row input[type="range"] {
    width: 120px;
    accent-color: #f39c12;
}

#confirm-modal p {
    color: #bdc3c7;
    margin-bottom: 20px;
    font-size: 14px;
}

/* Footer */
#footer-link {
    position: fixed;
    bottom: 6px;
    right: 12px;
    z-index: 50;
}

#footer-link a {
    font-size: 10px;
    color: rgba(255,255,255,0.2);
    text-decoration: none;
    font-family: 'IBM Plex Mono', monospace;
    transition: color 0.2s;
}

#footer-link a:hover {
    color: rgba(243,156,18,0.6);
}

/* Responsive */
@media (max-width: 768px) {
    #right-panel { display: none; }
    #left-panel { 
        left: 6px;
        padding: 8px;
        transform: translateY(-50%) scale(0.85);
        transform-origin: left center;
    }
    .hotbar-slot {
        width: 44px;
        height: 44px;
    }
    .hotbar-slot .slot-icon { font-size: 18px; }
    .hotbar-slot .slot-name { display: none; }
}