* {
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
}

body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background-color: #1a1714;
    color: #dbccb0;
    font-family: Georgia, 'Times New Roman', Times, serif;
    overflow: hidden;
    touch-action: none;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    outline: none;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: none;
}

.menu-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle, #28231ef2 0%, #0f0c0afa 100%);
    z-index: 100;
}

.main-title {
    font-size: 56px;
    font-weight: bold;
    margin-bottom: 40px;
    color: #dbccb0;
    text-shadow: 3px 3px 0px #1a110a;
    letter-spacing: 4px;
    border-bottom: 3px dashed #3d2817;
    padding-bottom: 10px;
}

.main-btn-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 320px;
}

.ds-btn {
    background: #3d2817;
    color: #dbccb0;
    border: 2px solid #1a110a;
    padding: 14px 20px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 18px;
    font-family: inherit;
    border-radius: 6px;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5), 0 4px 6px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.ds-btn:hover:not(:disabled) {
    background: #5c3c22;
    transform: translateY(-2px);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3), 0 6px 8px rgba(0, 0, 0, 0.4);
}

.ds-btn:disabled {
    background: #4a4540;
    color: #888;
    border-color: #333;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.ds-panel {
    background: #dbccb0;
    color: #3d2817;
    border: 4px solid #271a0f;
    border-radius: 8px;
    background-image: repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(0, 0, 0, 0.03) 10px, rgba(0, 0, 0, 0.03) 20px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
}

.world-selection-panel {
    width: 650px;
    height: 450px;
    max-width: 95%;
}

.panel-header {
    text-align: center;
    font-size: 24px;
    padding: 15px 0;
    margin: 0;
    font-weight: bold;
    border-bottom: 2px dashed #3d2817;
    position: relative;
}

.world-list-container {
    flex-grow: 1;
    overflow-y: auto;
    background: #ebdcc2;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-bottom: 2px dashed #3d2817;
}

.world-item {
    background: #ebdcc2;
    border: 2px dashed #775a40;
    padding: 12px;
    cursor: pointer;
    color: #3d2817;
    display: flex;
    flex-direction: column;
    border-radius: 4px;
    transition: background 0.1s;
}

.world-item:hover {
    background: #d4c2a3;
}

.world-item.selected {
    background: #3d2817;
    color: #dbccb0;
    border-color: #1a110a;
}

.world-item-name {
    font-weight: bold;
    font-size: 18px;
    margin-bottom: 4px;
}

.world-item-date {
    font-size: 13px;
    opacity: 0.8;
}

.world-actions {
    display: flex;
    justify-content: space-between;
    padding: 15px;
    gap: 10px;
    background: rgba(0, 0, 0, 0.05);
}

.world-actions .ds-btn {
    flex: 1;
    font-size: 15px;
    padding: 10px;
}

.create-panel {
    width: 450px;
    padding: 25px;
    text-align: center;
    max-height: 90vh;
    overflow-y: auto;
}

.ds-input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    background: #ebdcc2;
    border: 2px solid #3d2817;
    color: #3d2817;
    font-family: inherit;
    font-size: 16px;
    font-weight: bold;
    border-radius: 4px;
}

.create-actions {
    display: flex;
    gap: 10px;
}

.create-actions .ds-btn {
    flex: 1;
}

.slider-container {
    margin-bottom: 15px;
    text-align: left;
}

.slider-label {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 5px;
    display: block;
}

input[type=range] {
    width: 100%;
    accent-color: #3d2817;
}

.flex-row {
    display: flex;
    gap: 10px;
    width: 100%;
}

.server-item {
    background: #ebdcc2;
    border: 2px dashed #775a40;
    padding: 12px;
    margin-bottom: 8px;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.server-info {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.server-name {
    font-weight: bold;
    font-size: 16px;
}

.server-ip {
    font-size: 12px;
    opacity: 0.8;
}

.server-actions {
    display: flex;
    gap: 5px;
}

.btn-icon {
    padding: 6px 10px;
    font-size: 14px;
}

.account-section {
    border: 2px dashed #775a40;
    padding: 15px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.03);
    margin-bottom: 15px;
    text-align: left;
}

.account-section-title {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 10px;
    border-bottom: 1px solid #775a40;
    padding-bottom: 5px;
}

.account-info-text {
    font-size: 15px;
    margin-bottom: 8px;
    font-weight: bold;
}

@media screen and (max-width: 768px) {
    .main-btn-group {
        flex-direction: row;
        flex-wrap: wrap;
        width: 95%;
        max-width: 600px;
        justify-content: center;
    }

    .main-btn-group .ds-btn {
        flex: 1 1 calc(50% - 15px);
        font-size: 15px;
        padding: 10px;
    }
}

@media screen and (max-height: 500px) and (orientation: landscape) {
    .main-btn-group {
        flex-direction: row;
        flex-wrap: nowrap;
        width: 95%;
    }

    .main-btn-group .ds-btn {
        flex: 1;
        font-size: 14px;
        padding: 10px 5px;
    }
}

#time-display {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(40, 35, 30, 0.9);
    border: 2px solid #dbccb0;
    padding: 10px;
    border-radius: 8px;
    font-weight: bold;
    font-size: 20px;
    text-shadow: 2px 2px 0 #000;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
    width: 110px;
    font-family: monospace;
    cursor: help;
}

#hud-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 10;
}

.hud-btn {
    background: rgba(39, 26, 15, 0.9);
    border: 2px solid #dbccb0;
    color: #dbccb0;
    width: 50px;
    height: 50px;
    font-size: 22px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
    transition: transform 0.1s;
    position: relative;
}

.hud-btn:hover {
    transform: scale(1.05);
    background: rgba(92, 60, 34, 1);
}

.chat-notify {
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid #271a0f;
    z-index: 15;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.chat-notify-global {
    top: -4px;
    left: -4px;
    background-color: #e74c3c;
}

.chat-notify-clan {
    top: -4px;
    right: -4px;
    background-color: #2ecc71;
}

.side-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(26, 23, 20, 0.98);
    border: none;
    border-radius: 0;
    padding: 60px 5% 40px 5%;
    display: none;
    overflow-y: auto;
    color: #dbccb0;
    z-index: 200;
    box-shadow: none;
    pointer-events: auto;
}

.wide-panel {
    width: 100%;
    left: 0;
    transform: none;
}

#panel-inventory,
#panel-crafting,
#panel-station,
#panel-skills,
#panel-clan {
    right: auto;
}

#panel-chest {
    display: none;
    flex-direction: column;
    gap: 10px;
}

.chest-container-row {
    display: flex;
    flex-direction: row;
    gap: 40px;
    width: 100%;
    flex-wrap: wrap;
}

.chest-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 300px;
}

.panel-title {
    font-size: 24px;
    text-transform: uppercase;
    border-bottom: 2px dashed #dbccb0;
    padding-bottom: 15px;
    margin-top: 0;
    margin-bottom: 25px;
    text-align: center;
    position: relative;
}

.close-panel-btn {
    position: fixed;
    right: 25px;
    top: 25px;
    background: #e74c3c;
    color: #fff;
    border: 2px solid #c0392b;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    width: 45px;
    height: 45px;
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 201;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
    transition: background 0.2s;
}

.close-panel-btn:hover {
    background: #c0392b;
}

.equipment-section {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    justify-content: center;
    border-bottom: 2px dashed #775a40;
    padding-bottom: 20px;
}

.equip-slot {
    width: 60px;
    height: 60px;
    background: rgba(40, 35, 30, 0.95);
    border: 2px dashed #775a40;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
}

.equip-label {
    position: absolute;
    top: -20px;
    font-size: 12px;
    color: #a39581;
    font-weight: bold;
}

.inv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 15px;
}

.inv-item {
    aspect-ratio: 1;
    background: rgba(20, 15, 10, 0.8);
    border: 2px solid #775a40;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: grab;
    overflow: hidden;
    transition: all 0.2s;
}

.inv-item:hover {
    border-color: #dbccb0;
    background: rgba(40, 25, 15, 0.9);
    transform: scale(1.05);
    z-index: 2;
}

#crafting-list,
#station-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
    align-items: start;
}

.recipe-item {
    background: rgba(20, 15, 10, 0.7);
    border: 2px solid #775a40;
    padding: 15px;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
}

.recipe-name {
    font-weight: bold;
    margin-bottom: 10px;
    font-size: 18px;
    color: #f0e6d2;
    border-bottom: 1px solid #775a40;
    padding-bottom: 5px;
}

.recipe-req {
    font-size: 14px;
    color: #a39581;
    line-height: 1.6;
}

.recipe-req.has {
    color: #81c784;
}

.recipe-req.lack {
    color: #e57373;
}

.craft-btn {
    margin-top: 15px;
    width: 100%;
    background: #3d2817;
    border: 2px solid #dbccb0;
    color: #dbccb0;
    padding: 10px;
    cursor: pointer;
    font-family: inherit;
    font-weight: bold;
    font-size: 16px;
    border-radius: 6px;
    transition: background 0.2s;
}

.craft-btn:hover:not(:disabled) {
    background: #5c3c22;
}

.craft-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.demolish-btn {
    background: #78231a;
    border-color: #dbccb0;
}

#hud-bottom {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
    z-index: 5;
}

#stats-container {
    display: flex;
    justify-content: center;
    width: 100%;
    margin-bottom: 12px;
    gap: 20px;
}

.stat-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100px;
}

.stat-label {
    font-size: 13px;
    font-weight: bold;
    text-shadow: 1px 1px 2px #000;
    margin-bottom: 5px;
    color: #dbccb0;
}

.stat-bar {
    width: 100%;
    height: 16px;
    background: rgba(20, 15, 10, 0.9);
    border: 2px solid #dbccb0;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

.stat-fill {
    height: 100%;
    transition: width 0.1s linear;
}

.fill-hp {
    background: #c0392b;
}

.fill-hunger {
    background: #d35400;
}

.fill-stamina {
    background: #2980b9;
}

#hotbar {
    display: flex;
    gap: 8px;
    pointer-events: auto;
    background: rgba(20, 15, 10, 0.8);
    padding: 10px;
    border-radius: 10px;
    border: 3px solid #5c3c22;
}

.slot {
    width: 55px;
    height: 55px;
    background: rgba(40, 35, 30, 0.95);
    border: 2px solid #775a40;
    border-radius: 6px;
    position: relative;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.slot.active {
    border-color: #f1c40f;
    box-shadow: 0 0 12px rgba(241, 196, 15, 0.6);
}

.slot-index {
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: 12px;
    color: #dbccb0;
    font-weight: bold;
    text-shadow: 1px 1px 0 #000;
    pointer-events: none;
    z-index: 2;
}

.item-count {
    position: absolute;
    bottom: 3px;
    right: 5px;
    font-size: 14px;
    font-weight: bold;
    text-shadow: 1px 1px 0 #000;
    color: #fff;
    pointer-events: none;
    z-index: 2;
}

.item-icon {
    width: 100%;
    height: 100%;
    border-radius: 4px;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

.durability-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 4px;
    background: #2ecc71;
    width: 100%;
    pointer-events: none;
    opacity: 0.8;
    z-index: 3;
}

#build-mode-warning {
    position: absolute;
    top: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(26, 17, 10, 0.9);
    border: 2px solid #f1c40f;
    color: #f1c40f;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 15px;
    font-weight: bold;
    display: none;
    z-index: 5;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    align-items: center;
    gap: 15px;
    pointer-events: auto;
}

.cancel-build-btn {
    padding: 4px 10px;
    background: #e74c3c;
    color: #fff;
    border: 1px solid #c0392b;
    cursor: pointer;
    border-radius: 4px;
    font-weight: bold;
    font-family: inherit;
}

.context-menu {
    position: absolute;
    background: #ebdcc2;
    border: 2px solid #3d2817;
    border-radius: 4px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    padding: 5px;
    gap: 5px;
    box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.5);
}

.ctx-btn {
    background: #3d2817;
    color: #dbccb0;
    border: none;
    padding: 8px 15px;
    cursor: pointer;
    font-weight: bold;
    font-family: inherit;
    border-radius: 2px;
}

.ctx-btn:hover:not(:disabled) {
    background: #5c3c22;
}

.ctx-btn:disabled {
    background: #888;
    color: #ccc;
    cursor: not-allowed;
    display: none;
}

.custom-tooltip {
    position: absolute;
    background: rgba(20, 15, 10, 0.95);
    border: 1px solid #dbccb0;
    color: #dbccb0;
    padding: 8px;
    border-radius: 4px;
    pointer-events: none;
    font-size: 12px;
    z-index: 1000;
    display: none;
    white-space: pre-line;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
    line-height: 1.4;
}

#skills-display {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
}

.skill-item {
    background: rgba(20, 15, 10, 0.8);
    padding: 15px;
    border: 2px solid #5c3c22;
    border-radius: 6px;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
}

.skill-header {
    display: flex;
    justify-content: space-between;
    font-weight: bold;
    margin-bottom: 10px;
    color: #dbccb0;
    font-size: 16px;
}

.skill-bar-bg {
    width: 100%;
    height: 12px;
    background: #1a110a;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid #3d2817;
    margin-bottom: 8px;
    position: relative;
}

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

.skill-xp-text {
    font-size: 13px;
    color: #a39581;
    text-align: right;
    font-family: monospace;
    font-weight: bold;
}

#chat-container {
    position: absolute;
    bottom: 120px;
    left: 20px;
    width: 300px;
    height: 200px;
    display: flex;
    flex-direction: column;
    background: rgba(20, 15, 10, 0.6);
    border-radius: 6px;
    z-index: 10;
    pointer-events: none;
}

#chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 8px;
    font-size: 13px;
    color: #fff;
    text-shadow: 1px 1px 0 #000;
    display: flex;
    flex-direction: column;
    gap: 4px;
    pointer-events: auto;
}

#chat-input-wrapper {
    display: none;
    padding: 5px;
    background: rgba(0, 0, 0, 0.8);
    border-top: 1px solid #5c3c22;
    pointer-events: auto;
    align-items: center;
}

#chat-channel-btn {
    background: #3d2817;
    color: #dbccb0;
    border: 1px solid #5c3c22;
    padding: 4px 8px;
    font-size: 11px;
    cursor: pointer;
    margin-right: 5px;
}

#chat-input {
    flex-grow: 1;
    background: transparent;
    border: none;
    color: #fff;
    padding: 4px;
    outline: none;
    font-family: inherit;
    font-size: 13px;
}

#chat-send-btn {
    background: #2ecc71;
    color: #fff;
    border: 1px solid #27ae60;
    padding: 4px 8px;
    font-size: 11px;
    cursor: pointer;
    margin-left: 5px;
    border-radius: 3px;
    font-weight: bold;
}

.msg-global {
    color: #fff;
}

.msg-team {
    color: #3498db;
}

.msg-system {
    color: #f1c40f;
    font-style: italic;
}

#clan-content {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

.clan-section {
    background: rgba(20, 15, 10, 0.7);
    border: 2px solid #5c3c22;
    padding: 15px;
    border-radius: 6px;
}

.clan-input-group {
    display: flex;
    gap: 5px;
    margin-top: 10px;
}

.clan-input {
    flex: 1;
    background: #ebdcc2;
    border: 1px solid #3d2817;
    padding: 8px;
    font-family: inherit;
    font-weight: bold;
    border-radius: 4px;
}

.clan-member-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(20, 15, 10, 0.5);
    padding: 8px;
    margin-bottom: 6px;
    border: 1px solid #5c3c22;
    border-radius: 4px;
}

.clan-invite-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(52, 152, 219, 0.2);
    padding: 8px;
    margin-bottom: 6px;
    border: 1px solid #3498db;
    border-radius: 4px;
    font-size: 13px;
}

.btn-small {
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    background: #3d2817;
    color: #dbccb0;
    border: 1px solid #1a110a;
    font-family: inherit;
    border-radius: 4px;
}

.btn-small:hover {
    background: #5c3c22;
}

#mobile-controls {
    display: none;
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    pointer-events: none;
    z-index: 100;
    justify-content: space-between;
    align-items: flex-end;
}

#joystick-base {
    width: 120px;
    height: 120px;
    background: rgba(40, 35, 30, 0.5);
    border: 2px solid rgba(219, 204, 176, 0.5);
    border-radius: 50%;
    position: relative;
    pointer-events: auto;
}

#joystick-stick {
    width: 50px;
    height: 50px;
    background: rgba(219, 204, 176, 0.8);
    border-radius: 50%;
    position: absolute;
    top: 35px;
    left: 35px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
}

.mobile-btn {
    width: 60px;
    height: 60px;
    background: rgba(40, 35, 30, 0.8);
    border: 2px solid rgba(219, 204, 176, 0.8);
    color: #dbccb0;
    font-size: 24px;
    border-radius: 50%;
    pointer-events: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
    user-select: none;
    cursor: pointer;
}

.mobile-btn:active {
    background: rgba(92, 60, 34, 1);
    transform: scale(0.95);
}

.action-btns {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

@media (max-height: 500px) and (orientation: landscape) {
    #chat-container {
        bottom: auto;
        top: 70px;
        left: 20px;
        height: 120px;
        width: 250px;
        z-index: 1000;
    }

    #mobile-controls {
        bottom: 5px;
    }
}
#Intro {
    position: fixed;
    top: 0px;
    left: 0px;
    height: 100%;
    width: 100%;
    background-color: black;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    animation: fadeOut 1s 1s forwards;
}

#Intro img {
    width: 50%;
    transform: scale(0.95);
    animation: popUp 0.25s ease-out forwards;
}

@keyframes popUp {
    to {
        transform: scale(1);
    }
}

@keyframes fadeOut {
    0% {
        opacity: 1;
    }

    90% {
        opacity: 0;
    }

    100% {
        opacity: 0;
        pointer-events: none;
        visibility: hidden;
    }
}

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

                    100% {
                        transform: rotate(360deg);
                    }
                }

                #connection-spinner {
                    margin: 10px auto 20px auto;
                    width: 40px;
                    height: 40px;
                    border: 4px solid #3d2817;
                    border-top: 4px solid transparent;
                    border-radius: 50%;
                    animation: spin 1s linear infinite;
                }