:root {
    --bg-gradient: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%);
    --primary-pastel: #ffafbd;
    --secondary-pastel: #ffc3a0;
    --accent-blue: #a0e6ff;
    --accent-green: #c9ffbf;
    --glass-bg: rgba(255, 255, 255, 0.25);
    --glass-border: rgba(255, 255, 255, 0.5);
    --text-dark: #4a4a4a;
    --text-light: #7a7a7a;
    --font-heading: 'Playfair Display', serif;
    --font-body: 'Outfit', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    /* Prevent selection during clicking */
}

body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    font-family: var(--font-body);
    color: var(--text-dark);
    background: var(--bg-gradient);
}

#canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    background: radial-gradient(circle at center, #fdfbfb 0%, #e6e9f0 100%);
    /* Soft background for the 3D scene */
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    /* Let clicks pass through to the canvas */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2rem;
}

/* Enable pointer events for UI elements */
#ui-layer>* {
    pointer-events: auto;
}

header {
    text-align: center;
    margin-bottom: 1rem;
    text-shadow: 0 2px 10px rgba(255, 255, 255, 0.8);
}

h1 {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    background: -webkit-linear-gradient(45deg, var(--primary-pastel), var(--secondary-pastel));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 700;
}

.subtitle {
    font-size: 1rem;
    color: var(--text-light);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    padding: 1.5rem;
    transition: transform 0.3s ease;
}

#resources-panel {
    position: absolute;
    top: 2rem;
    left: 2rem;
    min-width: 250px;
}

.resource-item {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.resource-item .icon {
    font-size: 1.5rem;
}

.resource-info {
    display: flex;
    flex-direction: column;
}

#essence-amount {
    font-size: 1.8rem;
    font-weight: 600;
    font-family: var(--font-heading);
}

.resource-name {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-light);
}

.resource-rate {
    margin-left: auto;
    font-size: 0.9rem;
    color: var(--text-light);
}

#controls-panel {
    position: absolute;
    top: 2rem;
    right: 2rem;
    bottom: 2rem;
    width: 350px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding-bottom: 0.5rem;
}

.tab-btn {
    background: transparent;
    border: none;
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--text-light);
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.2s;
}

.tab-btn.active {
    background: rgba(255, 255, 255, 0.5);
    color: var(--text-dark);
    font-weight: 600;
}

.tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.tab-content.active {
    display: block;
}

/* Scrollbar styling */
.tab-content::-webkit-scrollbar {
    width: 6px;
}

.tab-content::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

/* Generator Items */
.generator-item {
    background: rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.generator-item:hover {
    background: rgba(255, 255, 255, 0.7);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.generator-item.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    filter: grayscale(0.5);
}

.gen-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.2rem;
}

.gen-name {
    font-weight: 600;
    font-size: 1rem;
}

.gen-count {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-light);
}

.gen-cost {
    font-size: 0.9rem;
    color: var(--primary-pastel);
    font-weight: 600;
}

.gen-desc {
    font-size: 0.8rem;
    color: var(--text-light);
    font-style: italic;
}

/* Floating Text */
.floating-text {
    position: absolute;
    color: var(--text-dark);
    font-weight: bold;
    pointer-events: none;
    animation: floatUp 1.5s ease-out forwards;
    font-family: var(--font-heading);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}

@keyframes floatUp {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }

    100% {
        transform: translateY(-50px) scale(1.2);
        opacity: 0;
    }
}

.action-btn {
    width: 100%;
    padding: 1rem;
    margin-bottom: 0.5rem;
    border: none;
    border-radius: 8px;
    background: white;
    font-family: var(--font-body);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.action-btn:hover {
    background: #f0f0f0;
}

.action-btn.danger {
    color: #ff6b6b;
}

.action-btn.is-on {
    background: linear-gradient(135deg, rgba(168, 230, 207, 0.8), rgba(220, 237, 193, 0.9));
    color: #2f5d62;
    box-shadow: 0 6px 15px rgba(168, 230, 207, 0.45);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.placeholder-text {
    text-align: center;
    color: var(--text-light);
    margin-top: 2rem;
    font-style: italic;
}