/* === RESET & BASE === */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: #000;
    font-family: 'Inter', sans-serif;
    color: #e2e8f0;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

#gameCanvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

/* === SCREENS === */
.screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.screen.hidden {
    display: none;
}

.menu-bg-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #0a1628 0%, #0d2137 40%, #071a0e 100%);
}

.menu-content {
    position: relative;
    z-index: 1;
    text-align: center;
}

.menu-content.compact {
    background: rgba(5, 10, 15, 0.92);
    border: 1px solid rgba(74, 222, 128, .2);
    border-radius: 16px;
    padding: 40px 48px;
    backdrop-filter: blur(20px);
}

.logo {
    margin-bottom: 48px;
}

.logo-icon {
    font-size: 64px;
    display: block;
    margin-bottom: 12px;
    filter: drop-shadow(0 0 20px #4ade80);
}

.logo h1 {
    font-size: 72px;
    font-weight: 700;
    letter-spacing: -2px;
    background: linear-gradient(135deg, #4ade80, #22d3ee, #4ade80);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: none;
}

.tagline {
    font-size: 18px;
    color: #94a3b8;
    letter-spacing: 4px;
    text-transform: uppercase;
    margin-top: 4px;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.btn {
    padding: 14px 32px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, #16a34a, #15803d);
    color: #fff;
    box-shadow: 0 0 20px rgba(74, 222, 128, .3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 30px rgba(74, 222, 128, .5);
}

.btn-secondary {
    background: rgba(255, 255, 255, .08);
    color: #e2e8f0;
    border: 1px solid rgba(255, 255, 255, .15);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, .13);
    transform: translateY(-2px);
}

.btn-danger {
    background: rgba(239, 68, 68, .15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, .3);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, .25);
}

.menu-tips {
    color: #475569;
    font-size: 13px;
    margin-top: 16px;
}

/* Loading */
.loading-content {
    text-align: center;
}

.loading-icon {
    font-size: 60px;
    animation: spin 3s linear infinite;
    display: block;
    margin-bottom: 20px;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.loading-content h2 {
    font-size: 24px;
    margin-bottom: 20px;
    color: #4ade80;
}

.loading-bar-wrap {
    width: 300px;
    height: 4px;
    background: rgba(255, 255, 255, .1);
    border-radius: 2px;
    overflow: hidden;
}

.loading-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #4ade80, #22d3ee);
    transition: width .3s;
}

.loading-content p {
    margin-top: 12px;
    color: #64748b;
    font-size: 14px;
}

/* Focus / Click to play */
.focus-box {
    text-align: center;
    background: rgba(0, 0, 0, .7);
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 12px;
    padding: 24px 40px;
    backdrop-filter: blur(10px);
}

.focus-box p {
    font-size: 20px;
    margin-bottom: 8px;
}

.focus-box small {
    color: #64748b;
}

/* Death */
.death-content {
    min-width: 320px;
}

.death-skull {
    font-size: 60px;
    margin-bottom: 16px;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1)
    }

    50% {
        transform: scale(1.1)
    }
}

.death-content h2 {
    font-size: 36px;
    color: #ef4444;
    margin-bottom: 8px;
}

.death-content p {
    color: #94a3b8;
    margin-bottom: 6px;
}

.death-content .menu-buttons {
    margin-top: 24px;
}

/* === HUD === */
#hud {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 50;
}

#hud.hidden {
    display: none;
}

#topBar {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 24px;
    background: rgba(0, 0, 0, .5);
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 20px;
    padding: 6px 20px;
    backdrop-filter: blur(10px);
    font-size: 13px;
}

#topBar>div {
    display: flex;
    align-items: center;
    gap: 6px;
}

#crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.ch-dot {
    width: 6px;
    height: 6px;
    background: rgba(255, 255, 255, .8);
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(255, 255, 255, .5);
}

#interactHint {
    position: absolute;
    top: 55%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, .7);
    border: 1px solid rgba(255, 255, 255, .15);
    border-radius: 8px;
    padding: 6px 16px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

#interactHint.hidden {
    display: none;
}

#interactHint kbd {
    background: rgba(255, 255, 255, .15);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 12px;
    font-family: inherit;
}

#bottomHud {
    position: absolute;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

#vitals {
    display: flex;
    gap: 16px;
    background: rgba(0, 0, 0, .6);
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 20px;
    padding: 6px 18px;
    backdrop-filter: blur(12px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.vbar {
    display: flex;
    align-items: center;
    gap: 8px;
}

.vtrack {
    width: 120px;
    height: 4px;
    background: rgba(255, 255, 255, .1);
    border-radius: 2px;
    overflow: hidden;
}

.vfill {
    height: 100%;
    transition: width .5s ease;
}

.vicon {
    font-size: 14px;
    filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.5));
}

.vhealth {
    background: linear-gradient(90deg, #ef4444, #f87171);
}

.vhunger {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

#hotbar {
    display: flex;
    gap: 8px;
}

.hslot {
    width: 56px;
    height: 56px;
    background: rgba(0, 0, 0, .6);
    border: 2px solid rgba(255, 255, 255, .12);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    cursor: pointer;
    position: relative;
    transition: border-color .15s;
}

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

.hslot .slot-qty {
    position: absolute;
    bottom: 2px;
    right: 4px;
    font-size: 10px;
    color: #94a3b8;
    font-weight: 600;
}

.hslot .slot-num {
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: 9px;
    color: #475569;
}

#notifications {
    position: absolute;
    top: 70px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: none;
}

.notif {
    background: rgba(0, 0, 0, .75);
    border-left: 3px solid #4ade80;
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 13px;
    animation: slideIn .3s ease;
    max-width: 280px;
}

.notif.warn {
    border-left-color: #f59e0b;
}

.notif.danger {
    border-left-color: #ef4444;
}

.notif.fadeout {
    animation: fadeOut .5s ease forwards;
}

@keyframes slideIn {
    from {
        transform: translateX(20px);
        opacity: 0
    }

    to {
        transform: translateX(0);
        opacity: 1
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateX(20px)
    }
}

#sanityOverlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 40%, rgba(80, 0, 120, 0) 100%);
    transition: opacity 1s;
    opacity: 0;
}

#hitOverlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: rgba(200, 0, 0, 0);
    transition: background .3s;
}

/* Craft progress */
#craftProgress {
    position: absolute;
    bottom: 140px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, .75);
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 8px;
    padding: 10px 20px;
    min-width: 200px;
}

#craftProgress.hidden {
    display: none;
}

.cp-label {
    text-align: center;
    font-size: 13px;
    margin-bottom: 6px;
    color: #4ade80;
}

.cp-track {
    height: 4px;
    background: rgba(255, 255, 255, .1);
    border-radius: 2px;
    overflow: hidden;
}

.cp-fill {
    height: 100%;
    background: linear-gradient(90deg, #4ade80, #22d3ee);
    width: 0%;
    transition: width .1s linear;
}

/* === PANELS === */
.panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(5, 10, 15, .95);
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 16px;
    padding: 0;
    min-width: 500px;
    max-width: 700px;
    z-index: 80;
    backdrop-filter: blur(20px);
    box-shadow: 0 25px 60px rgba(0, 0, 0, .8);
    pointer-events: all;
}

.panel.hidden {
    display: none;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.panel-head h3 {
    font-size: 16px;
    font-weight: 600;
}

.px {
    background: none;
    border: none;
    color: #64748b;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}

.px:hover {
    color: #e2e8f0;
    background: rgba(255, 255, 255, .08);
}

.panel-foot {
    padding: 10px 20px;
    border-top: 1px solid rgba(255, 255, 255, .08);
    font-size: 13px;
    color: #64748b;
}

/* Inventory Grid */
.inv-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    padding: 16px;
}

.inv-slot {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, .04);
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    cursor: pointer;
    position: relative;
    transition: border-color .15s, background .15s;
}

.inv-slot:hover {
    border-color: rgba(74, 222, 128, .4);
    background: rgba(74, 222, 128, .06);
}

.inv-slot.occupied:hover .tooltip-trigger {
    display: block;
}

.inv-slot .sq {
    font-size: 11px;
    color: #64748b;
    position: absolute;
    bottom: 3px;
    right: 5px;
    font-weight: 600;
}

.inv-slot .sname {
    font-size: 9px;
    color: #475569;
    position: absolute;
    bottom: 3px;
    left: 0;
    right: 0;
    text-align: center;
}

/* Crafting */
.craft-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 300px;
}

#recipeList {
    border-right: 1px solid rgba(255, 255, 255, .08);
    overflow-y: auto;
    max-height: 350px;
    padding: 8px;
}

.recipe-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background .15s;
    font-size: 14px;
}

.recipe-item:hover {
    background: rgba(255, 255, 255, .06);
}

.recipe-item.active {
    background: rgba(74, 222, 128, .1);
    border: 1px solid rgba(74, 222, 128, .2);
}

.recipe-item.locked {
    opacity: .4;
    cursor: not-allowed;
}

.recipe-icon {
    font-size: 22px;
}

.recipe-name {
    flex: 1;
}

.recipe-can {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
    flex-shrink: 0;
}

.recipe-can.yes {
    background: #4ade80;
}

#recipeDetail {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.hint-text {
    color: #475569;
    font-size: 13px;
    text-align: center;
    padding: 20px 0;
}

.rd-title {
    font-size: 18px;
    font-weight: 600;
}

.rd-desc {
    font-size: 13px;
    color: #64748b;
}

.rd-ings {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ing-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.ing-row .have {
    color: #4ade80;
}

.ing-row .miss {
    color: #ef4444;
}

.btn-craft {
    margin-top: auto;
    padding: 10px;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
}

.btn-craft.ready {
    background: linear-gradient(135deg, #16a34a, #15803d);
    color: #fff;
}

.btn-craft.notready {
    background: rgba(255, 255, 255, .06);
    color: #475569;
    cursor: not-allowed;
}

/* Build grid */
.build-grid-ui {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 16px;
}

.build-btn {
    background: rgba(255, 255, 255, .05);
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 10px;
    padding: 14px;
    text-align: center;
    cursor: pointer;
    transition: all .2s;
    font-size: 13px;
}

.build-btn:hover {
    background: rgba(74, 222, 128, .1);
    border-color: rgba(74, 222, 128, .3);
}

.build-btn .bi {
    font-size: 28px;
    display: block;
    margin-bottom: 6px;
}

.build-btn.active {
    background: rgba(74, 222, 128, .15);
    border-color: #4ade80;
}

/* Tooltip */
.tooltip {
    position: fixed;
    background: rgba(5, 10, 15, .95);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    max-width: 220px;
    pointer-events: none;
    z-index: 200;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .6);
}

.tooltip.hidden {
    display: none;
}

.tooltip h4 {
    font-size: 14px;
    margin-bottom: 4px;
}

.tooltip p {
    color: #64748b;
    font-size: 12px;
    line-height: 1.4;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .15);
    border-radius: 2px;
}

/* Multiplayer Menu Styles */
.server-list {
    width: 100%;
    max-width: 400px;
    max-height: 250px;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin: 15px 0;
    padding: 10px;
}

.server-item {
    padding: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.server-item.empty {
    color: var(--text-muted);
    text-align: center;
    font-size: 0.9em;
}

.multi-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.multi-input {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    color: white;
    padding: 12px;
    border-radius: 6px;
    font-family: inherit;
    outline: none;
    margin-bottom: 10px;
}

.multi-input:focus {
    border-color: var(--accent);
}