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

body {
    overflow: hidden;
    background: #111;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: #eee;
}

/* Canvas */
#game-canvas {
    display: block;
    width: 100vw;
    height: 100vh;
}

/* ── Login Screen ── */
#login-screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0a0e1a 0%, #1a1e2e 50%, #0a0e1a 100%);
    z-index: 100;
}

.login-title {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(90deg, #7289DA, #99AAF0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-subtitle {
    font-size: 1.1rem;
    color: #888;
    margin-bottom: 2rem;
}

#btn-login {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 32px;
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
    background: #5865F2;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

#btn-login:hover {
    background: #4752C4;
    transform: translateY(-1px);
}

#btn-login:active {
    transform: translateY(0);
}

/* ── Loading Screen ── */
#loading-screen {
    position: fixed;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #0a0e1a;
    z-index: 99;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #333;
    border-top-color: #7289DA;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 1rem;
}

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

/* ── HUD ── */
#hud {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 10;
    display: none;
}

#hud > * {
    pointer-events: auto;
}

/* Health bar */
.health-bar {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 220px;
    height: 24px;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    overflow: hidden;
}

#health-fill {
    height: 100%;
    background: #44cc44;
    border-radius: 10px;
    transition: width 0.3s, background 0.3s;
}

#health-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

/* Interact prompt */
#interact-prompt {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    padding: 8px 20px;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    font-size: 0.9rem;
}

/* Dialogue box */
#dialogue-box {
    position: absolute;
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    width: 500px;
    max-width: 90vw;
    padding: 16px 20px;
    background: rgba(10, 14, 26, 0.9);
    border: 1px solid rgba(114, 137, 218, 0.4);
    border-radius: 10px;
}

#dialogue-name {
    font-weight: 700;
    color: #7289DA;
    margin-bottom: 6px;
}

#dialogue-text {
    line-height: 1.5;
    color: #ccc;
}

/* ── Pause Menu ── */
#menu-overlay {
    position: fixed;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    z-index: 50;
    gap: 12px;
}

.menu-btn {
    padding: 12px 40px;
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    background: rgba(88, 101, 242, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    cursor: pointer;
    min-width: 200px;
    transition: background 0.2s;
}

.menu-btn:hover {
    background: rgba(88, 101, 242, 1);
}

.menu-btn.danger {
    background: rgba(200, 50, 50, 0.7);
}

.menu-btn.danger:hover {
    background: rgba(200, 50, 50, 1);
}

/* ── Chat ── */
#chat-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 320px;
    z-index: 20;
    pointer-events: none;
}

#chat-container.active {
    pointer-events: auto;
}

#chat-messages {
    max-height: 180px;
    overflow-y: auto;
    padding: 8px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 6px 6px 0 0;
    font-size: 0.85rem;
    scrollbar-width: thin;
}

.chat-msg {
    margin-bottom: 4px;
    line-height: 1.4;
}

.chat-sender {
    font-weight: 600;
}

.chat-system .chat-sender { color: #FFD700; }
.chat-player .chat-sender { color: #7289DA; }

#chat-input {
    width: 100%;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 0 0 6px 6px;
    color: #eee;
    font-size: 0.85rem;
    outline: none;
    display: none;
}

#chat-container.active #chat-input {
    display: block;
}

/* ── Hotbar ── */
#hotbar {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 4px;
}

.hotbar-slot {
    position: relative;
    width: 60px;
    height: 60px;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.hotbar-slot.active {
    border-color: rgba(114, 137, 218, 0.8);
    box-shadow: 0 0 8px rgba(114, 137, 218, 0.4);
}

.slot-key {
    position: absolute;
    top: 2px;
    left: 5px;
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.4);
    pointer-events: none;
}

.item-icon {
    width: 32px;
    height: 32px;
    border-radius: 4px;
}

.item-label {
    font-size: 0.55rem;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    margin-top: 2px;
    max-width: 56px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.item-qty {
    position: absolute;
    bottom: 2px;
    right: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* ── Inventory Panel ── */
#inventory-panel {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    z-index: 40;
}

.inventory-window {
    background: rgba(15, 20, 35, 0.95);
    border: 1px solid rgba(114, 137, 218, 0.3);
    border-radius: 12px;
    padding: 20px;
    min-width: 340px;
}

.inventory-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.inventory-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
    color: #ccc;
}

#inventory-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}

#inventory-close:hover {
    color: #fff;
}

#inventory-grid {
    display: grid;
    grid-template-columns: repeat(4, 60px);
    gap: 4px;
}

.grid-slot {
    position: relative;
    width: 60px;
    height: 60px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.grid-slot:hover {
    border-color: rgba(114, 137, 218, 0.5);
}

/* ── Damage Flash ── */
#damage-flash {
    position: fixed;
    inset: 0;
    background: rgba(200, 0, 0, 0.3);
    pointer-events: none;
    z-index: 30;
    opacity: 0;
    transition: opacity 0.3s;
}

#damage-flash.active {
    opacity: 1;
    transition: none;
}

/* ── Death Screen ── */
#death-screen {
    position: fixed;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.8);
    z-index: 55;
}

#death-screen h2 {
    font-size: 2.5rem;
    color: #cc3333;
    margin-bottom: 12px;
}

#death-screen p {
    font-size: 1.1rem;
    color: #999;
}

/* Crosshair */
.crosshair {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 4px;
    height: 4px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 10;
}
