* { margin:0; padding:0; box-sizing:border-box; }
html,body { width:100%; height:100%; overflow:hidden; background:#87CEEB;
  font-family:'Courier New', monospace; color:#fff; user-select:none; }
canvas { display:block; }
#game-canvas { width:100vw; height:100vh; cursor:none; }
.hidden { display:none !important; }

/* Crosshair */
#crosshair { position:fixed; top:50%; left:50%; transform:translate(-50%,-50%);
  width:22px; height:22px; pointer-events:none; z-index:10; }
#crosshair::before,#crosshair::after { content:''; position:absolute; background:#fff;
  box-shadow:0 0 2px #000; mix-blend-mode:difference; }
#crosshair::before { left:10px; top:0; width:2px; height:22px; }
#crosshair::after  { top:10px; left:0; height:2px; width:22px; }

/* Mining progress ring */
#mining-ring { position:fixed; top:50%; left:50%; transform:translate(-50%,-50%);
  width:42px; height:42px; border-radius:50%; pointer-events:none; z-index:10; display:none; }

/* Hotbar */
#hotbar { position:fixed; bottom:16px; left:50%; transform:translateX(-50%);
  display:flex; gap:4px; padding:4px; background:rgba(0,0,0,.55);
  border:2px solid #222; border-radius:6px; z-index:10; }
.slot { width:54px; height:54px; border:2px solid #555; background:rgba(0,0,0,.45);
  display:flex; align-items:center; justify-content:center; position:relative;
  border-radius:3px; overflow:hidden; }
.slot.active { border-color:#fff; box-shadow:0 0 12px #fff inset; }
.slot .num { position:absolute; top:1px; left:4px; font-size:10px; color:#ffe;
  text-shadow:1px 1px 1px #000; z-index:2; }
.slot .count { position:absolute; bottom:0; right:3px; font-size:11px; color:#fff;
  font-weight:bold; text-shadow:1px 1px 2px #000; z-index:2; }
.slot img { width:40px; height:40px; image-rendering:pixelated; pointer-events:none; }
.slot .durab { position:absolute; bottom:2px; left:2px; right:2px; height:3px;
  background:#222; border:1px solid #000; }
.slot .durab > div { height:100%; }

/* Hearts & hunger */
#hearts { position:fixed; bottom:80px; left:20px; display:flex; gap:2px; z-index:10; }
#hunger { position:fixed; bottom:80px; right:20px; display:flex; gap:2px;
  flex-direction:row-reverse; z-index:10; }
.heart,.hunger { width:20px; height:20px; background-size:contain; background-repeat:no-repeat; }

/* Info panels */
#info-panel { position:fixed; top:10px; left:10px; background:rgba(0,0,0,.5);
  padding:8px 12px; border-radius:4px; font-size:12px; z-index:10; line-height:1.6;
  min-width:200px; }
#peer-panel { position:fixed; top:10px; right:10px; background:rgba(0,0,0,.5);
  padding:8px 12px; border-radius:4px; font-size:12px; z-index:10; text-align:right;
  line-height:1.6; }
#peer-panel .rid { font-family:monospace; color:#5fa; background:rgba(0,0,0,.4);
  padding:2px 4px; border-radius:2px; }
#peer-panel button { margin-left:4px; padding:2px 6px; font-size:10px;
  cursor:pointer; vertical-align:middle; }
#selected-info { position:fixed; top:10px; left:50%; transform:translateX(-50%);
  background:rgba(0,0,0,.6); padding:6px 14px; border-radius:4px; font-size:13px;
  z-index:10; display:none; }
#toast { position:fixed; top:110px; left:50%; transform:translateX(-50%);
  background:rgba(0,0,0,.7); padding:6px 14px; border-radius:4px; font-size:12px;
  z-index:10; display:none; }

/* Menu */
#menu { position:fixed; inset:0; display:flex; align-items:center; justify-content:center;
  background:linear-gradient(180deg,#6ab7ff 0%,#a6dfff 60%,#7dc96f 60%,#4f9a3c 100%);
  z-index:20; }
#menu.hidden { display:none; }
.menu-box { background:rgba(10,15,30,.95); padding:28px 32px; border-radius:12px;
  width:420px; border:2px solid #5af; text-align:center;
  box-shadow:0 0 50px rgba(80,170,255,.5); }
.menu-box h1 { font-size:32px; margin-bottom:4px; color:#ffd; text-shadow:2px 2px 0 #000; }
.menu-box .sub { font-size:12px; margin-bottom:16px; color:#aac; }
.menu-box input { width:100%; padding:10px; margin:5px 0; border:1px solid #5af;
  background:#0a1020; color:#fff; border-radius:4px; font-family:inherit; font-size:13px; }
.menu-box button { width:100%; padding:11px; margin:4px 0; border:none; border-radius:4px;
  color:#fff; cursor:pointer; font-weight:bold; font-family:inherit; font-size:14px; }
.menu-box button.primary { background:#2e7d32; }
.menu-box button.secondary { background:#1565c0; }
.menu-box button:hover { filter:brightness(1.25); }
.hint { color:#bcf; font-size:11px; margin-top:12px; line-height:1.5; text-align:left;
  background:rgba(0,0,0,.3); padding:8px; border-radius:4px; }
.connecting { margin-top:10px; color:#ffb; }

/* Loading screen */
#loading { position:fixed; inset:0; background:#1a3a5c; z-index:100;
  display:flex; align-items:center; justify-content:center; font-size:22px; color:#fff;
  text-shadow:2px 2px 0 #000; flex-direction:column; text-align:center; }
.loading-inner > div:first-child { font-size:26px; margin-bottom:6px; }
#loading-phase { font-size:14px; color:#dfd; text-shadow:1px 1px 0 #000; margin-top:6px;
  min-height:18px; }
#loading-pct { font-size:13px; margin-top:4px; font-variant-numeric: tabular-nums; }
.bar { width:360px; height:22px; background:#222; border:2px solid #000; margin-top:12px;
  overflow:hidden; border-radius:3px; }
.bar div { width:0%; height:100%; background:linear-gradient(90deg,#4caf50,#8bc34a);
  /* No transition — we set width directly from JS on each chunk and want instant update */
  transition: width 0.05s linear; }

/* Chat */
#chat { position:fixed; bottom:100px; left:10px; width:300px; max-height:150px;
  overflow-y:auto; font-size:12px; z-index:10; pointer-events:none; }
#chat .msg { background:rgba(0,0,0,.5); padding:4px 8px; margin-top:2px; border-radius:3px;
  text-shadow:1px 1px 1px #000; }
#chat-input { position:fixed; bottom:95px; left:10px; width:300px; padding:7px;
  background:rgba(0,0,0,.8); border:1px solid #5af; color:#fff; border-radius:3px;
  font-family:inherit; display:none; z-index:11; }

/* Inventory */
#inv-screen { position:fixed; inset:0; background:rgba(0,0,0,.7); z-index:12;
  display:flex; align-items:center; justify-content:center; }
.inv-panel { background:#c6c6c6; border:3px solid #373737; padding:12px; border-radius:4px;
  image-rendering:pixelated; color:#3f3f3f; }
.inv-title { font-weight:bold; text-shadow:1px 1px 0 #fff; margin-bottom:8px; font-size:14px; }
.craft-area { display:flex; gap:10px; align-items:flex-start; margin-bottom:10px;
  padding:8px; background:#8b8b8b; border:2px solid #373737; }
.craft-grid { display:grid; grid-template-columns:repeat(3,42px); gap:3px; }
.craft-arrow { font-size:30px; color:#3f3f3f; align-self:center; text-shadow:1px 1px 0 #fff; }
.craft-result { width:52px; height:52px; background:#555; border:2px solid #373737;
  display:flex; align-items:center; justify-content:center; align-self:center; cursor:pointer; }
.inv-grid { display:grid; grid-template-columns:repeat(9,42px); gap:3px; }
.inv-slot { width:42px; height:42px; background:#8b8b8b; border:2px solid #373737;
  display:flex; align-items:center; justify-content:center; position:relative; cursor:pointer; }
.inv-slot:hover { border-color:#fff; }
.inv-slot img { width:32px; height:32px; image-rendering:pixelated; pointer-events:none; }
.inv-slot .cnt { position:absolute; bottom:0; right:2px; font-size:11px; color:#fff; font-weight:bold;
  text-shadow:1px 1px 1px #000; }
.inv-close { position:relative; top:6px; color:#3f3f3f; font-size:11px; text-shadow:1px 1px 0 #fff; }

/* Death screen */
#death-screen { position:fixed; inset:0; background:rgba(80,0,0,.6); z-index:15;
  display:flex; align-items:center; justify-content:center; flex-direction:column; }
#death-screen h1 { font-size:64px; color:#f44; text-shadow:3px 3px 0 #000; letter-spacing:4px; }
#death-screen #death-msg { margin-top:10px; }
#death-screen button { margin-top:20px; padding:12px 24px; font-size:18px; background:#a00;
  border:2px solid #fff; color:#fff; border-radius:4px; cursor:pointer; font-family:inherit;
  font-weight:bold; }
