html, body { margin: 0; padding: 0; overflow: hidden; background: #1a1f16; font-family: 'Segoe UI', Arial, sans-serif; }
#game { display: block; cursor: crosshair; }
.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: fixed; top: 12px; left: 12px; color: #fff; z-index: 10; text-shadow: 0 1px 3px rgba(0,0,0,.8); user-select: none; }
#hud .bar { width: 200px; height: 18px; background: rgba(0,0,0,.5); border-radius: 9px; overflow: hidden; margin-bottom: 8px; border: 1px solid rgba(255,255,255,.25); }
#hud .bar > div { height: 100%; transition: width .15s; }
#hpFill { background: linear-gradient(90deg, #e74c3c, #ff7b6b); width: 100%; }
#hud .row { display: flex; gap: 14px; font-size: 15px; margin-top: 4px; }
#biome { position: fixed; top: 12px; right: 12px; color: #fff; z-index: 10; font-size: 15px; text-shadow: 0 1px 3px rgba(0,0,0,.8); background: rgba(0,0,0,.35); padding: 6px 12px; border-radius: 10px; }
#netstatus { position: fixed; top: 48px; right: 12px; z-index: 10; font-size: 13px; padding: 5px 10px; border-radius: 8px; background: rgba(231,76,60,.85); color: #fff; }

/* ---------- Inventory ---------- */
#craftBtn { position: fixed; bottom: 80px; right: 14px; z-index: 15; width: 58px; height: 58px; border-radius: 14px; background: #4a5d3a; border: 2px solid #6b8a52; color: #fff; font-size: 28px; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 0 3px 10px rgba(0,0,0,.4); transition: transform .1s, background .1s; }
#craftBtn:hover { background: #5d7a48; transform: scale(1.06); }
#craftBtn:active { transform: scale(0.96); }
#craftBtn .key { position: absolute; bottom: -6px; right: -6px; background: #2b3324; border: 1px solid #6b8a52; border-radius: 6px; font-size: 11px; padding: 1px 5px; }
#inv { position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; z-index: 10; }
.slot { width: 56px; height: 56px; border-radius: 8px; position: relative; background: rgba(0,0,0,.45); border: 2px solid rgba(255,255,255,.2); display: flex; align-items: center; justify-content: center; font-size: 30px; cursor: pointer; user-select: none; transition: border-color .1s, transform .05s; }
.slot:hover { border-color: rgba(255,255,255,.5); }
.slot.selected { border-color: #ffd166; box-shadow: 0 0 12px rgba(255,209,102,.6); }
.slot .num { position: absolute; top: 2px; left: 5px; font-size: 11px; color: rgba(255,255,255,.6); }
.slot .cnt { position: absolute; bottom: 2px; right: 5px; font-size: 13px; color: #fff; font-weight: bold; text-shadow: 0 1px 2px #000; }
.slot .dur { position: absolute; bottom: 0; left: 0; right: 0; height: 4px; background: rgba(0,0,0,.5); border-radius: 0 0 6px 6px; overflow: hidden; }
.slot .dur > div { height: 100%; background: #7bed9f; }
.slot.empty { opacity: .55; }
.slot.drag-over { border-color: #7bed9f; background: rgba(123,237,159,.15); }
#dragItem { position: fixed; z-index: 50; pointer-events: none; font-size: 34px; transform: translate(-50%, -50%); filter: drop-shadow(0 2px 4px rgba(0,0,0,.6)); }

/* ---------- Crafting ---------- */
#craftMenu { position: fixed; inset: 0; z-index: 40; display: none; align-items: center; justify-content: center; background: rgba(0,0,0,.55); }
#craftMenu.open { display: flex; }
#craftBox { width: 560px; max-width: 92vw; max-height: 80vh; overflow-y: auto; background: #2b3324; border: 2px solid #6b8a52; border-radius: 14px; padding: 18px 20px; color: #fff; }
#craftBox h2 { margin: 0 0 4px; font-size: 26px; }
#craftBox .sub { color: #b8c9a8; font-size: 13px; margin-bottom: 14px; }
.recipe { display: flex; align-items: center; gap: 12px; padding: 10px; background: rgba(0,0,0,.25); border-radius: 10px; margin-bottom: 8px; }
.recipe .icon { font-size: 34px; width: 44px; text-align: center; }
.recipe .info { flex: 1; }
.recipe .info .name { font-size: 16px; font-weight: bold; }
.recipe .info .desc { font-size: 12px; color: #b8c9a8; }
.recipe .cost { font-size: 13px; color: #ffd166; }
.recipe button { background: #4a5d3a; color: #fff; border: 1px solid #6b8a52; border-radius: 8px; padding: 8px 14px; cursor: pointer; font-size: 14px; }
.recipe button:disabled { opacity: .4; cursor: default; }
.recipe button:not(:disabled):hover { background: #5d7a48; }
.recipe.owned button { background: #3a4a30; }
#closeCraft { margin-top: 10px; width: 100%; padding: 10px; font-size: 16px; background: #556b45; color: #fff; border: none; border-radius: 8px; cursor: pointer; }

/* ---------- Chat ---------- */
#chatLog { position: fixed; left: 12px; bottom: 82px; z-index: 12; max-width: 380px; display: flex; flex-direction: column; gap: 2px; pointer-events: none; font-size: 14px; }
#chatLog div { background: rgba(0,0,0,.45); padding: 3px 8px; border-radius: 6px; color: #eee; width: fit-content; }
#chatLog div b { color: #ffd166; }
#chatLog div.sys { color: #9fd6a0; font-style: italic; }
#chatInput { position: fixed; left: 12px; bottom: 82px; z-index: 14; width: 360px; padding: 8px 10px; font-size: 14px; border-radius: 8px; border: 2px solid #6b8a52; background: rgba(20,26,16,.95); color: #fff; outline: none; }
#chatHint { position: fixed; left: 12px; bottom: 82px; z-index: 11; width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; border-radius: 8px; background: rgba(0,0,0,.45); cursor: pointer; user-select: none; }
#chatHint:hover { background: rgba(0,0,0,.65); }

/* ---------- Scoreboard ---------- */
#scoreboard { position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); z-index: 30; background: rgba(30,38,25,.95); border: 2px solid #6b8a52; border-radius: 12px; padding: 16px 20px; color: #fff; min-width: 280px; }
#scoreboard h3 { margin: 0 0 10px; font-size: 20px; }
#scoreboard .row { display: flex; justify-content: space-between; gap: 18px; padding: 3px 0; font-size: 14px; border-bottom: 1px solid rgba(255,255,255,.07); }
#scoreboard .row.me { color: #ffd166; font-weight: bold; }
#scoreboard .row .nm { display: flex; align-items: center; gap: 7px; }
#scoreboard .dot { width: 11px; height: 11px; border-radius: 50%; border: 1px solid rgba(0,0,0,.4); }

/* ---------- Messages & overlay ---------- */
#msg { position: fixed; top: 38%; width: 100%; text-align: center; color: #fff; font-size: 40px; font-weight: bold; text-shadow: 0 2px 8px rgba(0,0,0,.9); z-index: 20; pointer-events: none; opacity: 0; transition: opacity .4s; }
#overlay { position: fixed; inset: 0; background: rgba(0,0,0,.72); z-index: 30; display: flex; align-items: center; justify-content: center; color: #fff; text-align: center; overflow-y: auto; }
#menu { background: #2b3324; border: 2px solid #6b8a52; border-radius: 16px; padding: 26px 32px; max-width: 620px; width: 92vw; margin: 20px 0; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
#menu h1 { font-size: 54px; margin: 0 0 6px; }
#menu .tagline { font-size: 14px; color: #b8c9a8; margin: 0 0 20px; line-height: 1.5; }
#menu label { display: block; text-align: left; font-size: 13px; color: #b8c9a8; margin-bottom: 6px; }
#menu input { width: 100%; padding: 12px 14px; font-size: 18px; border-radius: 10px; border: 2px solid #6b8a52; background: #1d2417; color: #fff; outline: none; margin-bottom: 14px; }
#menu input:focus { border-color: #ffd166; }
#menu button { width: 100%; font-size: 20px; padding: 13px; border-radius: 10px; border: none; background: #6b8a52; color: #fff; cursor: pointer; }
#menu button:hover:not(:disabled) { background: #7fa361; }
#menu button:disabled { opacity: .45; cursor: default; }
#menuStatus { font-size: 13px; color: #b8c9a8; margin-top: 10px; min-height: 18px; }
#menuStatus.err { color: #ff8b7b; }
#menu .controls { margin-top: 20px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.12); font-size: 13px; color: #cfe0bd; line-height: 1.7; text-align: left; }
#overlay.dead h1 { font-size: 44px; }
