:root {
    --bg-color: #050508;
    --card-bg: rgba(15, 15, 25, 0.8);
    --primary: #00f2ff;
    --secondary: #7000ff;
    --accent: #ff007a;
    --text: #e0e0ff;
    --text-dim: #9090b0;
    --success: #00ff95;
    --danger: #ff4d4d;
    --border: rgba(255, 255, 255, 0.1);
    --glow: 0 0 15px rgba(0, 242, 255, 0.4);
}

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

body {
    background-color: var(--bg-color);
    color: var(--text);
    font-family: 'Outfit', 'Pretendard', sans-serif;
    overflow: hidden;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Input Styles */
.input-group {
    margin-bottom: 2rem;
}

#player-name-input {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid var(--primary);
    padding: 1rem 1.5rem;
    color: var(--text);
    font-size: 1.2rem;
    font-family: 'JetBrains Mono', monospace;
    border-radius: 8px;
    text-align: center;
    outline: none;
    transition: all 0.3s;
}

#player-name-input:focus {
    box-shadow: var(--glow);
    background: rgba(255, 255, 255, 0.1);
}

.control-hint {
    margin-top: 2rem;
    color: var(--text-dim);
    font-size: 0.9rem;
    letter-spacing: 1px;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at center, #1a1a2e 0%, #050508 100%);
}

#game-canvas {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

#ui-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    pointer-events: none;
    padding: 2rem;
}

#ui-overlay > * {
    pointer-events: auto;
}

/* Screen Management */
.screen {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease;
    opacity: 0;
}

.screen.active {
    display: flex;
    opacity: 1;
}

/* Typography */
.glitch-text {
    font-size: 6rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5rem;
    color: var(--text);
    position: relative;
    text-shadow: 0.05em 0 0 rgba(255, 0, 0, 0.75),
                -0.025em -0.05em 0 rgba(0, 255, 0, 0.75),
                0.025em 0.05em 0 rgba(0, 0, 255, 0.75);
    animation: glitch 500ms infinite;
}

@keyframes glitch {
    0% { text-shadow: 0.05em 0 0 rgba(255, 0, 0, 0.75), -0.05em -0.025em 0 rgba(0, 255, 0, 0.75), -0.025em 0.05em 0 rgba(0, 0, 255, 0.75); }
    14% { text-shadow: 0.05em 0 0 rgba(255, 0, 0, 0.75), -0.05em -0.025em 0 rgba(0, 255, 0, 0.75), -0.025em 0.05em 0 rgba(0, 0, 255, 0.75); }
    15% { text-shadow: -0.05em -0.025em 0 rgba(255, 0, 0, 0.75), 0.025em 0.025em 0 rgba(0, 255, 0, 0.75), -0.05em -0.05em 0 rgba(0, 0, 255, 0.75); }
    49% { text-shadow: -0.05em -0.025em 0 rgba(255, 0, 0, 0.75), 0.025em 0.025em 0 rgba(0, 255, 0, 0.75), -0.05em -0.05em 0 rgba(0, 0, 255, 0.75); }
    50% { text-shadow: 0.025em 0.05em 0 rgba(255, 0, 0, 0.75), 0.05em 0 0 rgba(0, 255, 0, 0.75), 0 -0.05em 0 rgba(0, 0, 255, 0.75); }
    99% { text-shadow: 0.025em 0.05em 0 rgba(255, 0, 0, 0.75), 0.05em 0 0 rgba(0, 255, 0, 0.75), 0 -0.05em 0 rgba(0, 0, 255, 0.75); }
    100% { text-shadow: -0.025em 0 0 rgba(255, 0, 0, 0.75), -0.025em -0.025em 0 rgba(0, 255, 0, 0.75), -0.025em -0.05em 0 rgba(0, 0, 255, 0.75); }
}

.subtitle {
    font-size: 1.2rem;
    color: var(--primary);
    letter-spacing: 0.2rem;
    margin-bottom: 2rem;
    text-shadow: var(--glow);
}

/* Upgrade Screen Styles */
.glass-panel {
    background: rgba(10, 10, 20, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid var(--primary);
    padding: 3rem;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 0 50px rgba(0, 242, 255, 0.2);
    width: 90%;
    max-width: 900px;
}

.neon-text {
    font-size: 2.2rem;
    color: var(--primary);
    text-shadow: 0 0 20px var(--primary);
    margin-bottom: 0.5rem;
}

.upgrade-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-top: 2rem;
}

.upgrade-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    padding: 1.5rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
}

.upgrade-card:hover {
    background: rgba(0, 242, 255, 0.1);
    border-color: var(--primary);
    transform: translateY(-8px);
    box-shadow: 0 10px 30px rgba(0, 242, 255, 0.2);
}

.upgrade-icon {
    font-size: 2rem;
}

.upgrade-name {
    font-weight: 800;
    font-size: 1.1rem;
    color: #fff;
}

.upgrade-desc {
    font-size: 0.85rem;
    color: var(--text-dim);
    line-height: 1.4;
}

/* Buttons */
.primary-btn {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
    padding: 1rem 3rem;
    font-family: 'JetBrains Mono', monospace;
    font-weight: bold;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
    clip-path: polygon(10% 0, 100% 0, 100% 70%, 90% 100%, 0 100%, 0 30%);
}

.primary-btn:hover {
    background: var(--primary);
    color: var(--bg-color);
    box-shadow: var(--glow);
}

/* Battle UI Components */
#battle-ui {
    justify-content: space-between;
    padding: 3rem;
}

.card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
}

.player-stats {
    width: 250px;
    position: absolute;
    bottom: 3rem;
    left: 3rem;
}

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

.entity-name {
    font-weight: 800;
}

.level-badge {
    background: var(--secondary);
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
}

.bar-group {
    margin-bottom: 0.4rem;
}

.bar-label {
    font-size: 0.6rem;
    color: var(--text-dim);
    margin-bottom: 2px;
}

.bar-bg {
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    transition: width 0.3s ease-out;
}

.bar-fill.hp { background: linear-gradient(90deg, #ff416c, #ff4b2b); }
.bar-fill.energy { background: linear-gradient(90deg, #12c2e9, #c471ed, #f64f59); }

.log-container {
    position: absolute;
    top: 3rem;
    right: 3rem;
    width: 300px;
    height: 120px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    padding: 0.8rem;
    font-size: 0.8rem;
    overflow-y: hidden;
    font-family: 'JetBrains Mono', monospace;
}

#battle-log div {
    margin-bottom: 0.3rem;
    border-left: 2px solid var(--primary);
    padding-left: 0.5rem;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateX(10px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Lab Screen */
.lab-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin: 2rem 0;
}

.lab-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    padding: 1.5rem;
    border-radius: 12px;
    cursor: pointer;
    transition: 0.3s;
    text-align: center;
}

.lab-item:hover {
    border-color: var(--primary);
    background: rgba(0, 242, 255, 0.05);
    transform: translateY(-5px);
}

.lab-icon { font-size: 2rem; display: block; margin-bottom: 0.5rem; }
.lab-name { font-weight: 800; color: #fff; display: block; }
.lab-desc { font-size: 0.75rem; color: var(--text-dim); display: block; margin-bottom: 0.8rem; }
.lab-cost { 
    background: var(--secondary); 
    padding: 4px 10px; 
    border-radius: 20px; 
    font-size: 0.8rem;
    font-weight: bold;
}

/* Mobile Controls */
.mobile-only { display: none; }

@media (pointer: coarse) {
    .mobile-only {
        display: block;
        position: absolute;
        inset: 0;
        z-index: 100;
        pointer-events: none;
    }
    
    #joystick-base {
        position: absolute;
        bottom: 50px;
        left: 50px;
        width: 120px;
        height: 120px;
        background: rgba(255,255,255,0.1);
        border: 2px solid rgba(255,255,255,0.2);
        border-radius: 50%;
        pointer-events: auto;
    }
    
    #joystick-stick {
        position: absolute;
        left: 35px;
        top: 35px;
        width: 50px;
        height: 50px;
        background: var(--primary);
        border-radius: 50%;
        box-shadow: var(--glow);
    }
    
    .mobile-actions {
        position: absolute;
        bottom: 50px;
        right: 50px;
        display: flex;
        gap: 1rem;
        pointer-events: auto;
    }
    
    .mobile-btn {
        width: 80px;
        height: 80px;
        border-radius: 50%;
        border: 2px solid var(--primary);
        background: rgba(0,242,255,0.1);
        color: #fff;
        font-weight: bold;
        backdrop-filter: blur(5px);
    }
}

/* Device Optimization */
@media (max-width: 768px) {
    .glitch-text { font-size: 3rem; }
    .glass-panel { padding: 1.5rem; }
    .upgrade-grid, .lab-grid { grid-template-columns: 1fr; }
    .player-stats { left: 1rem; bottom: 1rem; transform: scale(0.8); }
    .log-container { display: none; }
}


/* Bottom Guide HUD */
#bottom-guide {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 3rem;
    padding: 1rem 2rem;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid var(--border);
    border-radius: 12px;
    backdrop-filter: blur(10px);
    pointer-events: none;
    z-index: 100;
}

.skill-guide, .key-guide {
    display: flex;
    gap: 1.5rem;
}

.guide-item {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.guide-item span {
    background: var(--primary);
    color: var(--bg-color);
    padding: 2px 6px;
    font-weight: bold;
    border-radius: 4px;
}

/* Difficulty Selector */
.difficulty-container {
    margin: 1.5rem 0;
    text-align: center;
}

.section-label {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-bottom: 0.8rem;
    letter-spacing: 2px;
}

.difficulty-grid {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.diff-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    transition: 0.3s;
    font-size: 0.75rem;
    font-weight: bold;
}

.diff-btn.active {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(0, 242, 255, 0.1);
    box-shadow: 0 0 15px rgba(0, 242, 255, 0.3);
}

.diff-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.1);
}

/* Responsive fix */
@media (max-width: 900px) {
    #bottom-guide { display: none; }
}


/* Pause Screen */
#pause-screen.active {
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 5, 10, 0.85);
    backdrop-filter: blur(15px);
}

.pause-content {
    text-align: center;
    animation: pulseGlow 2s infinite;
}

@keyframes pulseGlow {
    0%, 100% { filter: drop-shadow(0 0 10px var(--primary)); }
    50% { filter: drop-shadow(0 0 25px var(--primary)); }
}

/* Upgrade Card Animation */
.upgrade-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    padding: 2rem;
    border-radius: 15px;
    cursor: pointer;
    transition: 0.3s;
    text-align: center;
}

.upgrade-card:hover {
    transform: scale(1.05);
    border-color: var(--primary);
    background: rgba(0, 242, 255, 0.1);
}

