/* ===== Global Reset & Variables ===== */
:root {
    --primary: #8B6F47;
    --primary-light: #C4A882;
    --accent: #4A7C59;
    --accent-light: #7DB892;
    --bg-dark: #1a1612;
    --bg-overlay: rgba(26, 22, 18, 0.6);
    --text-light: #F5F0EB;
    --text-muted: #B8A99A;
    --glass-bg: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.12);
    --shadow-deep: 0 8px 32px rgba(0, 0, 0, 0.4);
    --font-main: 'Noto Sans KR', sans-serif;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-main);
    background: var(--bg-dark);
    color: var(--text-light);
    cursor: none;
}

/* ===== Loading Screen ===== */
#loading-screen {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.8s ease, visibility 0.8s ease;
}

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

.loader-content {
    text-align: center;
}

.loader-spinner {
    width: 60px;
    height: 60px;
    margin: 0 auto 20px;
    border: 4px solid var(--glass-border);
    border-top-color: var(--primary-light);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loader-text {
    font-size: 1.2rem;
    color: var(--text-muted);
    animation: pulse 1.5s ease-in-out infinite;
}

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

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* ===== Three.js Canvas ===== */
#three-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

/* ===== UI Overlay ===== */
#ui-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none; /* Let clicks pass through to 3D scene */
    z-index: 10;
}

#title {
    position: absolute;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.8rem;
    font-weight: 900;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--primary-light), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3));
    animation: titleFloat 3s ease-in-out infinite;
}

@keyframes titleFloat {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(-6px); }
}

#instructions {
    position: absolute;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 10px 24px;
    font-size: 0.9rem;
    color: var(--text-muted);
    white-space: nowrap;
    animation: fadeInDown 1s ease 0.5s both;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ===== Reaction Bubble ===== */
#reaction-bubble {
    position: absolute;
    top: 30%;
    left: 50%;
    transform: translateX(-50%) translateY(-50%) scale(1);
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 16px 32px;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-light);
    box-shadow: var(--shadow-deep);
    transition: opacity 0.4s ease, transform 0.4s ease;
    pointer-events: none;
}

#reaction-bubble.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(-50%) scale(0.7);
}

#reaction-bubble.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(-50%) scale(1);
    animation: bubblePop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes bubblePop {
    0% { transform: translateX(-50%) translateY(-50%) scale(0.3); }
    60% { transform: translateX(-50%) translateY(-50%) scale(1.1); }
    100% { transform: translateX(-50%) translateY(-50%) scale(1); }
}

/* ===== Item Tray ===== */
#item-tray {
    position: absolute;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 16px;
    padding: 16px 28px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: var(--shadow-deep);
    pointer-events: all;
    animation: traySlideUp 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s both;
}

@keyframes traySlideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(60px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.item-btn {
    width: 64px;
    height: 64px;
    border: 2px solid var(--glass-border);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.05);
    font-size: 2rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.item-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, rgba(255,255,255,0.15), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.item-btn:hover {
    transform: translateY(-8px) scale(1.1);
    border-color: var(--primary-light);
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 8px 24px rgba(139, 111, 71, 0.3);
}

.item-btn:hover::before {
    opacity: 1;
}

.item-btn:active {
    transform: translateY(-4px) scale(0.95);
    transition-duration: 0.1s;
}

.item-tray {
    display: flex;
    align-items: center;
    gap: 16px;
}

.item-group {
    display: flex;
    gap: 16px;
}

.item-group.hidden {
    display: none !important;
}

.hidden {
    display: none !important;
}

@keyframes throwPulse {
    0% { box-shadow: 0 0 0 0 rgba(125, 184, 146, 0.5); }
    70% { box-shadow: 0 0 0 16px rgba(125, 184, 146, 0); }
    100% { box-shadow: 0 0 0 0 rgba(125, 184, 146, 0); }
}

/* ===== Hand Icon ===== */
#hand-icon {
    position: fixed;
    pointer-events: none;
    z-index: 10000;
    font-size: 3rem;
    transform: translate(-50%, -50%);
    display: none;
    user-select: none;
    transition: transform 0.1s ease;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
    #title { font-size: 1.3rem; }
    #instructions { font-size: 0.75rem; padding: 8px 16px; }
    .item-btn { width: 52px; height: 52px; font-size: 1.6rem; }
    #item-tray { gap: 10px; padding: 12px 20px; bottom: 20px; }
}
