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

body {
    overflow: hidden;
    background: #000;
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    color: #fff;
}

canvas {
    display: block;
}

/* Blocker / Instructions Overlay */
#blocker {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    cursor: pointer;
}

#blocker.hidden {
    display: none;
}

#instructions {
    text-align: center;
    max-width: 420px;
    padding: 40px;
    background: rgba(30, 30, 30, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

#instructions h1 {
    font-size: 2.4rem;
    font-weight: 700;
    margin-bottom: 4px;
    background: linear-gradient(135deg, #4ade80, #22d3ee);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

#instructions .subtitle {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 28px;
}

.controls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 28px;
}

.control-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.control-item kbd {
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    color: #4ade80;
    background: rgba(74, 222, 128, 0.1);
    padding: 4px 10px;
    border-radius: 6px;
}

.control-item span {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
}

.click-hint {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.7);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.7;
    }

    50% {
        opacity: 1;
    }
}

/* Crosshair */
#crosshair {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    color: rgba(255, 255, 255, 0.7);
    pointer-events: none;
    z-index: 50;
    text-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
    display: none;
    font-weight: 200;
    line-height: 1;
}

#crosshair.visible {
    display: block;
}

/* Debug Info */
#debug-info {
    position: fixed;
    top: 12px;
    left: 12px;
    font-size: 12px;
    font-family: 'Consolas', 'Courier New', monospace;
    color: rgba(255, 255, 255, 0.6);
    background: rgba(0, 0, 0, 0.4);
    padding: 8px 12px;
    border-radius: 8px;
    z-index: 50;
    display: none;
    line-height: 1.6;
    backdrop-filter: blur(4px);
}

#debug-info.visible {
    display: block;
}

/* Hotbar */
#hotbar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    gap: 4px;
    z-index: 50;
    padding: 6px;
    background: rgba(0, 0, 0, 0.55);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
}

#hotbar.visible {
    display: flex;
}

.hotbar-slot {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 4px 6px 3px;
    border-radius: 6px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    min-width: 48px;
}

.hotbar-slot canvas {
    border-radius: 4px;
    image-rendering: pixelated;
}

.hotbar-slot.active {
    border-color: #4ade80;
    background: rgba(74, 222, 128, 0.1);
    box-shadow: 0 0 12px rgba(74, 222, 128, 0.3);
}

.hotbar-label {
    font-size: 9px;
    color: rgba(255, 255, 255, 0.7);
    white-space: nowrap;
}

.hotbar-key {
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 9px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.35);
}

/* ============================================================
   Crafting UI
   ============================================================ */
#crafting-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

#crafting-overlay.visible {
    display: flex;
}

#crafting-window {
    background: rgba(40, 40, 40, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 24px;
    min-width: 420px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.crafting-title {
    text-align: center;
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: #e0c080;
}

.crafting-body {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.crafting-grid {
    display: grid;
    grid-template-columns: repeat(3, 56px);
    grid-template-rows: repeat(3, 56px);
    gap: 4px;
}

.craft-slot {
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
}

.craft-slot:hover {
    border-color: rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.12);
}

.crafting-arrow {
    font-size: 2rem;
    color: rgba(255, 255, 255, 0.4);
    user-select: none;
}

.crafting-result-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.result-slot {
    width: 64px;
    height: 64px;
    border-width: 3px;
}

#craft-btn {
    padding: 8px 20px;
    background: rgba(74, 222, 128, 0.2);
    border: 1px solid rgba(74, 222, 128, 0.4);
    border-radius: 8px;
    color: #4ade80;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

#craft-btn:hover:not(:disabled) {
    background: rgba(74, 222, 128, 0.35);
}

#craft-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.material-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 10px;
    margin-bottom: 16px;
    justify-content: center;
}

.palette-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 8px;
    border-radius: 8px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
}

.palette-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.palette-item.selected {
    border-color: #4ade80;
    background: rgba(74, 222, 128, 0.1);
}

.palette-item span {
    font-size: 9px;
    color: rgba(255, 255, 255, 0.6);
    white-space: nowrap;
}

.palette-swatch {
    width: 28px;
    height: 28px;
    border-radius: 4px;
}

.crafting-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.craft-hint {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.35);
}

#craft-close-btn {
    padding: 6px 16px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

#craft-close-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Craft Toast */
.craft-toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: rgba(74, 222, 128, 0.2);
    border: 1px solid rgba(74, 222, 128, 0.4);
    border-radius: 10px;
    padding: 10px 24px;
    color: #4ade80;
    font-size: 0.95rem;
    font-weight: 600;
    z-index: 300;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}

.craft-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ============================================================
   Equipment UI
   ============================================================ */
#equipment-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

#equipment-overlay.visible {
    display: flex;
}

#equipment-window {
    background: rgba(40, 40, 40, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 24px;
    min-width: 380px;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.equip-title {
    text-align: center;
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: #60a5fa;
}

.equip-body {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.equip-slots {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.equip-slot {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.equip-slot:hover {
    border-color: rgba(96, 165, 250, 0.5);
    background: rgba(96, 165, 250, 0.1);
}

.slot-label {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    min-width: 36px;
}

.slot-icon {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.equip-stats {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 10px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
}

.stat-row span:last-child {
    font-weight: 700;
    color: #60a5fa;
}

.equip-inv-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 10px;
}

.equip-inventory {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 50px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 10px;
    margin-bottom: 16px;
}

.inv-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.inv-item:hover {
    background: rgba(96, 165, 250, 0.15);
    border-color: rgba(96, 165, 250, 0.5);
}

.inv-icon {
    font-size: 20px;
}

.inv-name {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.8);
}

.inv-empty {
    width: 100%;
    text-align: center;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.3);
    padding: 8px;
}

.equip-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.equip-hint {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.35);
}

#equip-close-btn {
    padding: 6px 16px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

#equip-close-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

#multiplayer-hud {
    position: fixed;
    top: 12px;
    right: 12px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.85);
    background: rgba(0, 0, 0, 0.45);
    padding: 8px 12px;
    border-radius: 8px;
    z-index: 60;
    backdrop-filter: blur(4px);
}

.mp-join-row {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

#player-name {
    flex: 1;
    min-width: 0;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    padding: 10px 12px;
    outline: none;
}

#player-name::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

#join-btn {
    border: 1px solid rgba(74, 222, 128, 0.5);
    border-radius: 8px;
    background: rgba(74, 222, 128, 0.18);
    color: #c7ffd8;
    padding: 10px 14px;
    font-weight: 600;
    cursor: pointer;
}

#join-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
