* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
    user-select: none;
}

body {
    background-color: #0d1117;
    color: white;
    overflow: hidden;
}

canvas {
    display: block;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at center, #1f242e 0%, #0d1117 100%);
    position: fixed;
    top: 0;
    left: 0;
    z-index: -1;
}

#ui-layer {
    position: relative;
    width: 100%;
    height: 100vh;
    pointer-events: none;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    padding-bottom: 30px;
}

#login-screen {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 350px;
    z-index: 2000;
}

.panel {
    pointer-events: auto;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    padding: 20px;
}

#hud {
    width: 400px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.hud-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-group {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.label {
    font-size: 0.8rem;
    color: #9ca3af;
    letter-spacing: 1px;
}

.value {
    font-size: 1.5rem;
    font-weight: 800;
}

.text-blue { color: #60a5fa; }
.text-red { color: #f87171; }

.bars-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bar-bg {
    position: relative;
    width: 100%;
    height: 24px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.bar-fill {
    height: 100%;
    width: 100%; /* controlled by JS */
    border-radius: 12px;
    transition: width 0.2s ease-out;
}

.hp-fill { background: linear-gradient(90deg, #ef4444, #f87171); }
.exp-fill { background: linear-gradient(90deg, #3b82f6, #60a5fa); }

.bar-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.8rem;
    font-weight: 800;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

.stats-grid {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #d1d5db;
    font-weight: 600;
}

#level-up-banner {
    position: absolute;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    pointer-events: none;
    animation: popInOut 2s ease-in-out forwards;
}

#level-up-banner h1 {
    font-size: 3rem;
    font-weight: 800;
    text-shadow: 0 0 20px rgba(59, 130, 246, 0.8);
    margin-bottom: 5px;
}

#level-up-banner p {
    font-size: 1.2rem;
    color: white;
    font-weight: 600;
}

@keyframes popInOut {
    0% { opacity: 0; transform: translate(-50%, 20px) scale(0.8); }
    15% { opacity: 1; transform: translate(-50%, 0) scale(1.1); }
    30% { opacity: 1; transform: translate(-50%, 0) scale(1); }
    80% { opacity: 1; transform: translate(-50%, 0) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -20px) scale(0.9); }
}

#death-screen {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 40px 60px;
    z-index: 999;
}

#death-screen h1 {
    font-size: 4rem;
    text-shadow: 0 0 30px rgba(239, 68, 68, 0.8);
}

#death-screen p {
    font-size: 1.2rem;
    color: #e2e8f0;
}

#restart-btn {
    background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.2rem;
    font-weight: 800;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(239, 68, 68, 0.3);
    transition: all 0.2s ease;
}

#restart-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 25px rgba(239, 68, 68, 0.5);
}

.back-link {
    color: #9ca3af;
    text-decoration: none;
    font-size: 0.9rem;
}

.back-link:hover { color: white; }

.hidden { display: none !important; }

/* Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(255,255,255,0.2);
  transition: .4s;
}
.slider:before {
  position: absolute;
  content: "";
  height: 20px; width: 20px;
  left: 4px; bottom: 4px;
  background-color: white;
  transition: .4s;
}
input:checked + .slider { background-color: #10b981; }
input:checked + .slider:before { transform: translateX(22px); }
.slider.round { border-radius: 34px; }
.slider.round:before { border-radius: 50%; }

/* Mobile Joysticks */
#mobile-controls {
    position: absolute;
    bottom: 0; left: 0; width: 100%; height: 50%;
    pointer-events: none;
    z-index: 1500;
}
.joystick-zone {
    position: absolute;
    width: 50%; height: 100%;
    pointer-events: auto;
}
#joystick-left { left: 0; }
#joystick-right { right: 0; }
.joystick-base {
    position: absolute;
    width: 120px; height: 120px;
    background: rgba(255,255,255,0.1);
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 50%;
    bottom: 40px;
    transform: translateX(-50%);
    display: none;
    pointer-events: none;
}
#joystick-left .joystick-base { left: 30%; }
#joystick-right .joystick-base { left: 70%; }
.joystick-stick {
    position: absolute;
    width: 50px; height: 50px;
    background: rgba(255,255,255,0.5);
    border-radius: 50%;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
}
