* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; color: #fff; font-family: "Courier New", Consolas, monospace; user-select: none; }
#app, #ui { position: fixed; inset: 0; }
#ui { pointer-events: none; }
#game-canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; }

.hud { position: absolute; inset: 0; }
.crosshair { position: absolute; left: 50%; top: 50%; width: 20px; height: 20px; transform: translate(-50%, -50%); mix-blend-mode: difference; }
.crosshair::before, .crosshair::after { content: ""; position: absolute; background: #fff; }
.crosshair::before { left: 9px; top: 0; width: 2px; height: 20px; }
.crosshair::after { top: 9px; left: 0; height: 2px; width: 20px; }

.hotbar { position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%); display: flex; padding: 2px; background: rgba(20, 20, 20, 0.55); border: 2px solid #111; box-shadow: inset 0 0 0 2px #6d6d6d; }
.slot { position: relative; width: 40px; height: 40px; border: 2px solid #3a3a3a; box-shadow: inset 0 0 0 1px #8b8b8b; }
.slot img { position: absolute; left: 4px; top: 4px; width: 28px; height: 28px; image-rendering: pixelated; }
.slot .count { position: absolute; right: 2px; bottom: 0; font-weight: bold; font-size: 14px; text-shadow: 2px 2px 0 #3f3f3f; }
.slot .durability { position: absolute; left: 5px; right: 5px; bottom: 4px; height: 3px; background: #000; display: none; }
.slot .durability div { height: 2px; }
.selector { position: absolute; left: 0; top: 0; width: 44px; height: 44px; border: 3px solid #fff; outline: 2px solid #000; transition: transform 40ms linear; }
.item-name { position: absolute; bottom: 64px; left: 50%; transform: translateX(-50%); font-weight: bold; font-size: 16px; text-shadow: 2px 2px 0 #3f3f3f; white-space: nowrap; }
.mode-label { position: absolute; top: 6px; left: 50%; transform: translateX(-50%); font-size: 12px; opacity: 0.6; text-shadow: 1px 1px 0 #000; }
.water-overlay { position: absolute; inset: 0; background: radial-gradient(ellipse at center, rgba(20, 60, 160, 0.15), rgba(10, 30, 90, 0.45)); display: none; }

.debug { position: absolute; inset: 0; font-size: 13px; line-height: 1.25; }
.debug pre { position: absolute; top: 4px; left: 4px; margin: 0; padding: 2px 4px; background: rgba(0, 0, 0, 0.45); white-space: pre; font-family: inherit; }
.debug pre.right { left: auto; right: 4px; text-align: right; }

.screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: auto; background: rgba(0, 0, 0, 0.55); }
.main-menu { background: linear-gradient(#3b6fb5, #7fb2e5 55%, #5a8a3a 55.2%, #4a3524 70%, #2d2d2d); }
.logo { font-size: 72px; font-weight: 900; letter-spacing: 6px; color: #d8d8d8; text-shadow: 4px 4px 0 #3c3c3c, 8px 8px 0 #1c1c1c; }
.subtitle { color: #ffea3a; font-size: 18px; margin-bottom: 20px; text-shadow: 2px 2px 0 #3f3f00; transform: rotate(-4deg); }
.title { font-size: 28px; margin-bottom: 16px; text-shadow: 3px 3px 0 #3f3f3f; }
.panel { display: flex; flex-direction: column; gap: 10px; width: 400px; max-width: 92vw; padding: 16px; background: rgba(0, 0, 0, 0.35); border: 2px solid #000; box-shadow: inset 0 0 0 2px #555; }
.panel.wide { width: 520px; max-height: 78vh; overflow-y: auto; }
.panel label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: #ddd; }
.panel label.check { flex-direction: row; align-items: center; gap: 8px; }
.field { font-family: inherit; font-size: 16px; padding: 8px; background: #000; color: #fff; border: 2px solid #a0a0a0; outline: none; }
.field:focus { border-color: #fff; }
.btn { font-family: inherit; font-size: 18px; padding: 10px; color: #e0e0e0; cursor: pointer; background: linear-gradient(#8a8a8a, #6c6c6c); border: 2px solid #000; box-shadow: inset 2px 2px 0 #b8b8b8, inset -2px -2px 0 #4a4a4a; text-shadow: 2px 2px 0 #3a3a3a; }
.btn:hover { background: linear-gradient(#8e97c8, #6a73a8); color: #ffffa0; }
.footer { position: absolute; bottom: 10px; left: 10px; right: 10px; text-align: center; font-size: 12px; color: #ddd; text-shadow: 1px 1px 0 #000; }
input[type=range] { width: 100%; accent-color: #9aa; }
.gui-overlay { position: absolute; inset: 0; pointer-events: auto; background: rgba(16, 16, 16, 0.55); display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: default; }
.gui-panel { position: relative; background: #c6c6c6; border-radius: calc(var(--s) * 2); box-shadow: 0 0 0 var(--s) #000, inset var(--s) var(--s) 0 var(--s) #fff, inset calc(var(--s) * -1) calc(var(--s) * -1) 0 var(--s) #555; image-rendering: pixelated; }
.gui-slot { position: absolute; box-sizing: border-box; background: #8b8b8b; border-style: solid; border-width: var(--s); border-color: #373737 #fff #fff #373737; }
.gui-slot img { position: absolute; left: 0; top: 0; width: 100%; height: 100%; image-rendering: pixelated; pointer-events: none; }
.gui-slot .count, .gui-cursor .count { position: absolute; right: calc(var(--s) * -0.5); bottom: calc(var(--s) * -1.5); font-weight: bold; font-size: calc(var(--s) * 8); line-height: 1; color: #fff; text-shadow: calc(var(--s) * 0.8) calc(var(--s) * 0.8) 0 #3f3f3f; pointer-events: none; }
.gui-slot.hover::after { content: ""; position: absolute; inset: 0; background: rgba(255, 255, 255, 0.45); pointer-events: none; }
.gui-slot.drag { background: #a8a8a8; }
.gui-slot .durability { position: absolute; left: calc(var(--s) * 1.5); right: calc(var(--s) * 1.5); bottom: calc(var(--s) * 1.5); height: calc(var(--s) * 2); background: #000; display: none; pointer-events: none; }
.gui-slot .durability div { height: var(--s); }
.gui-slot.empty-icon[data-icon]::before { content: ""; position: absolute; inset: calc(var(--s) * 2); border: var(--s) dashed rgba(55, 55, 55, 0.35); }
.gui-slot[data-icon="trash"] { background: #8b5a5a; }
.gui-slot[data-icon="trash"]::before { content: "✕"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #ddd; font-size: calc(var(--s) * 10); }
.gui-cursor { position: fixed; left: 0; top: 0; pointer-events: none; z-index: 10; }
.gui-cursor img { width: 100%; height: 100%; image-rendering: pixelated; }
.gui-tooltip { position: fixed; left: 0; top: 0; z-index: 11; pointer-events: none; display: none; padding: 4px 7px; background: rgba(16, 0, 16, 0.94); border: 2px solid #2b0a5a; border-radius: 3px; font-size: 15px; line-height: 1.3; white-space: nowrap; text-shadow: 2px 2px 0 #3f3f3f; }
.tt-name { color: #fff; }
.tt-ench, .tt-info { color: #aaa; }
.tt-blue { color: #5555ff; }
.tt-id { color: #555; }
.gui-decor { position: absolute; pointer-events: none; }
.gui-label { color: #404040; font-size: calc(var(--s) * 8); line-height: 1; white-space: nowrap; }
.gui-arrow { width: calc(var(--s) * 22); height: calc(var(--s) * 15); }
.gui-arrow::before { content: ""; position: absolute; left: 0; top: calc(var(--s) * 5); width: calc(var(--s) * 14); height: calc(var(--s) * 5); background: #8b8b8b; }
.gui-arrow::after { content: ""; position: absolute; left: calc(var(--s) * 14); top: 0; border-style: solid; border-width: calc(var(--s) * 7.5) 0 calc(var(--s) * 7.5) calc(var(--s) * 8); border-color: transparent transparent transparent #8b8b8b; }
.gui-furnaceArrow { width: calc(var(--s) * 24); height: calc(var(--s) * 17); background: #8b8b8b; clip-path: polygon(0 35%, 62% 35%, 62% 0, 100% 50%, 62% 100%, 62% 65%, 0 65%); }
.gui-furnaceArrow .fill { height: 100%; width: 0; background: #fff; }
.gui-flame { width: calc(var(--s) * 14); height: calc(var(--s) * 14); background: #8b8b8b; clip-path: polygon(50% 0, 80% 35%, 100% 60%, 85% 100%, 15% 100%, 0 60%, 20% 35%); display: flex; align-items: flex-end; }
.gui-flame .fill { width: 100%; height: 0; background: linear-gradient(#ffe066, #ff7a00 60%, #c02000); }
.gui-player { background: #000; border: var(--s) solid #373737; border-right-color: #fff; border-bottom-color: #fff; overflow: hidden; pointer-events: auto; cursor: grab; }
.gui-player:active { cursor: grabbing; }
.gui-player-canvas { display: block; width: 100%; height: 100%; }
.gui-tabs { display: flex; gap: 2px; margin-bottom: -2px; }
.gui-tab { position: relative; background: #a0a0a0; border: 2px solid #000; border-bottom: none; border-radius: 4px 4px 0 0; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: inset 2px 2px 0 #d8d8d8; }
.gui-tab img { width: 70%; height: 70%; image-rendering: pixelated; pointer-events: none; }
.gui-tab.active { background: #c6c6c6; z-index: 1; }
.gui-tab:hover { background: #b8b8d0; }
.gui-search { position: absolute; box-sizing: border-box; font-family: inherit; font-size: calc(var(--s) * 7); background: #000; color: #fff; border: var(--s) solid #a0a0a0; padding: 0 calc(var(--s) * 2); outline: none; }
.gui-scrollbar { position: absolute; background: #8b8b8b; border-style: solid; border-width: var(--s); border-color: #373737 #fff #fff #373737; box-sizing: border-box; cursor: pointer; }
.gui-scrollbar .thumb { width: 100%; background: #c6c6c6; box-shadow: inset var(--s) var(--s) 0 #fff, inset calc(var(--s) * -1) calc(var(--s) * -1) 0 #555; }
.gui-scrollbar.disabled .thumb { background: #999; }
.chat { position: absolute; left: 4px; bottom: 60px; width: min(640px, 70vw); pointer-events: none; }
.chat.open { pointer-events: auto; }
.chat-log { max-height: 45vh; overflow: hidden; display: flex; flex-direction: column; }
.chat.open .chat-log { overflow-y: auto; background: rgba(0, 0, 0, 0.35); }
.chat-line { padding: 1px 6px; font-size: 15px; line-height: 1.35; background: rgba(0, 0, 0, 0.4); text-shadow: 2px 2px 0 #3f3f3f; word-break: break-word; }
.chat.open .chat-line { background: transparent; }
.chat-line.system { color: #ffff55; }
.chat-line.error { color: #ff5555; }
.chat-line.info { color: #aaaaaa; }
.chat-input { width: 100%; margin-top: 4px; font-family: inherit; font-size: 15px; padding: 5px 6px; background: rgba(0, 0, 0, 0.6); color: #fff; border: none; outline: none; }
.player-list { position: absolute; top: 30px; left: 50%; transform: translateX(-50%); background: rgba(0, 0, 0, 0.55); padding: 6px 14px; font-size: 15px; min-width: 200px; text-align: center; display: none; }
.player-list b { display: block; color: #ffff55; margin-bottom: 4px; }
.mp-status { color: #ff8080; min-height: 18px; font-size: 14px; text-align: center; }
.mp-hint { font-size: 12px; color: #bbb; line-height: 1.4; }
.menu-row { display: flex; gap: 18px; align-items: stretch; justify-content: center; flex-wrap: wrap; max-width: 96vw; }
.skin-box { width: 200px; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px; background: rgba(0, 0, 0, 0.35); border: 2px solid #000; box-shadow: inset 0 0 0 2px #555; }
.skin-title { font-size: 16px; color: #ddd; text-shadow: 2px 2px 0 #3f3f3f; }
.skin-canvas { width: 180px; height: 270px; cursor: grab; touch-action: none; background: radial-gradient(ellipse at 50% 60%, rgba(255, 255, 255, 0.12), rgba(0, 0, 0, 0) 70%); }
.skin-canvas:active { cursor: grabbing; }
.skin-controls { display: flex; align-items: center; gap: 6px; width: 100%; }
.skin-controls .btn { padding: 4px 10px; font-size: 16px; }
.skin-name { flex: 1; text-align: center; font-size: 13px; color: #fff; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.skin-hint { font-size: 11px; color: #aaa; text-align: center; }
@media (max-height: 640px) { .skin-canvas { height: 200px; width: 133px; } .logo { font-size: 48px; } }
.stats { position: absolute; bottom: 56px; left: 50%; width: 364px; transform: translateX(-50%); display: grid; grid-template-columns: 1fr 1fr; row-gap: 2px; column-gap: 4px; pointer-events: none; }
.stat-row { display: flex; height: 18px; }
.armor-row, .heart-row { justify-content: flex-start; }
.air-row, .food-row { justify-content: flex-end; }
.stat-row img { width: 18px; height: 18px; image-rendering: pixelated; margin-right: -1px; }
.hurt-overlay { position: absolute; inset: 0; opacity: 0; background: radial-gradient(ellipse at center, rgba(255, 0, 0, 0) 35%, rgba(200, 0, 0, 0.85) 100%); pointer-events: none; }
.fire-overlay { position: absolute; left: 0; right: 0; bottom: 0; height: 38%; display: none; pointer-events: none; background: linear-gradient(rgba(255, 120, 0, 0), rgba(255, 110, 0, 0.35) 50%, rgba(255, 60, 0, 0.55)); animation: fireflicker 0.25s infinite alternate; }
@keyframes fireflicker { from { opacity: 0.75; } to { opacity: 1; } }
.death-screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; pointer-events: auto; background: linear-gradient(rgba(80, 0, 0, 0.45), rgba(160, 0, 0, 0.6)); }
.death-title { font-size: 46px; font-weight: 900; color: #fff; text-shadow: 4px 4px 0 #3f0000; }
.death-cause { font-size: 17px; color: #eee; text-shadow: 2px 2px 0 #300; }
.death-score { font-size: 15px; color: #ffff55; text-shadow: 2px 2px 0 #300; }
.death-screen .btn { width: 320px; }
.death-screen .btn[disabled] { opacity: 0.5; pointer-events: none; }
.loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 22px; background: #2b1d12; text-shadow: 2px 2px 0 #000; pointer-events: auto; }
