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

/* ---------- overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center; flex-direction: column;
}
.overlay.dark { background: rgba(0, 0, 0, 0.55); }
.overlay.red { background: rgba(120, 0, 0, 0.45); }

/* ---------- main menu ---------- */
#main-menu { background: #1b2a1b; z-index: 100; }
#menu-bg { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; opacity: 0.55; }
.menu-inner { position: relative; text-align: center; }
.title {
  font-size: 72px; letter-spacing: 6px; color: #e8e8e8;
  text-shadow: 4px 4px 0 #222, 0 0 24px rgba(120, 255, 120, 0.25);
}
.title span { color: #7ec850; }
.subtitle { margin: 4px 0 30px; color: #aaa; letter-spacing: 3px; }
.menu-buttons { display: flex; flex-direction: column; gap: 14px; align-items: center; }
.version { position: fixed; left: 10px; bottom: 8px; color: #777; font-size: 12px; }

.mc-btn {
  font-family: inherit; font-size: 18px; padding: 10px 26px; min-width: 240px;
  color: #eee; cursor: pointer;
  background: linear-gradient(#7a7a7a, #5c5c5c 40%, #4a4a4a);
  border: 2px solid #1a1a1a; outline: 2px solid #a8a8a8; outline-offset: -4px;
  box-shadow: 0 4px 0 #222;
}
.mc-btn:hover { background: linear-gradient(#8a9a6a, #6a7a4a 40%, #55663a); color: #fff; }
.mc-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #222; }
.mc-btn.big { font-size: 22px; padding: 14px 30px; min-width: 320px; }
.mc-btn.square {
  position: relative; min-width: 0; width: 56px; height: 56px; padding: 0;
  font-size: 28px; margin-top: 18px;
}
.mc-btn.back { margin-top: 18px; }

.panel {
  position: absolute; z-index: 110; background: rgba(20, 26, 18, 0.96);
  border: 3px solid #555; padding: 28px 36px; text-align: center;
  display: flex; flex-direction: column; gap: 12px; align-items: center;
  max-width: 92vw;
}
.panel.transparent { background: transparent; border: none; }
.panel h2 { margin-bottom: 8px; letter-spacing: 2px; }
.panel .row { display: flex; gap: 8px; }
.hint { color: #9a9; font-size: 13px; max-width: 360px; }
.mc-input {
  font-family: inherit; font-size: 16px; padding: 9px 12px;
  background: #111; color: #eee; border: 2px solid #555; min-width: 180px;
}
.mc-input:focus { border-color: #7ec850; outline: none; }

.custom-row { display: flex; gap: 24px; align-items: center; }
#custom-preview { background: #243024; border: 2px solid #555; }
.custom-opts { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.custom-opts label { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
input[type="color"] { width: 48px; height: 28px; border: 2px solid #555; background: #111; cursor: pointer; }

label.slider { display: flex; flex-direction: column; width: 320px; text-align: left; gap: 4px; }
label.slider input { width: 100%; }
label.chk { display: flex; gap: 10px; align-items: center; }

/* ---------- loading ---------- */
#loading-overlay { background: #101810; z-index: 90; gap: 18px; }
.loadbar { width: 320px; height: 18px; border: 2px solid #666; background: #0a0a0a; }
#loadbar-fill { height: 100%; width: 0%; background: #7ec850; transition: width 0.15s; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
#crosshair {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font-size: 22px; color: rgba(255, 255, 255, 0.85); text-shadow: 0 0 2px #000;
}
#hotbar {
  position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%);
  display: flex; gap: 2px; background: rgba(0, 0, 0, 0.45); padding: 3px; border: 2px solid #222;
}
#hearts {
  position: absolute; left: 50%; bottom: 66px; transform: translateX(-50%);
  display: flex; gap: 2px; font-size: 18px; text-shadow: 1px 1px 0 #000;
}
#coords {
  position: absolute; left: 10px; top: 10px; font-size: 13px; color: #cfc;
  text-shadow: 1px 1px 0 #000; white-space: pre-line;
}
#hud-tip {
  position: absolute; left: 50%; bottom: 110px; transform: translateX(-50%);
  font-size: 16px; color: #fff; text-shadow: 1px 1px 0 #000; opacity: 0; transition: opacity 0.5s;
}
#mount-tip {
  position: absolute; left: 50%; top: 58%; transform: translateX(-50%);
  font-size: 14px; color: #ffd; text-shadow: 1px 1px 0 #000;
}
#damage-flash {
  position: absolute; inset: 0; background: rgba(255, 0, 0, 0.35); opacity: 0; pointer-events: none;
}
#water-overlay {
  position: absolute; inset: 0; background: rgba(20, 60, 180, 0.3); opacity: 0; pointer-events: none;
}
#chat-log {
  position: absolute; left: 10px; bottom: 100px; max-width: 45vw; font-size: 14px;
  text-shadow: 1px 1px 0 #000; display: flex; flex-direction: column; gap: 2px;
}
#chat-log .msg { background: rgba(0,0,0,0.35); padding: 2px 6px; }
#chat-input {
  position: absolute; left: 10px; bottom: 60px; width: 45vw; pointer-events: auto;
}

/* ---------- slots & grids ---------- */
.grid { display: grid; gap: 3px; }
#inv-grid, #chest-grid { grid-template-columns: repeat(9, 46px); }
#inv-hotbar { grid-template-columns: repeat(9, 46px); margin-top: 10px; }
#craft-grid.three { grid-template-columns: repeat(3, 46px); }
#craft-grid.two { grid-template-columns: repeat(2, 46px); }
#craft-result, #fu-in, #fu-fuel, #fu-out { grid-template-columns: 46px; }

.slot {
  width: 46px; height: 46px; background: #2e2e2e; border: 2px solid #1a1a1a;
  outline: 1px solid #555; outline-offset: -3px; position: relative; cursor: pointer;
  image-rendering: pixelated; background-size: 38px 38px; background-repeat: no-repeat; background-position: center;
}
.slot:hover { outline-color: #fff; }
.slot .count {
  position: absolute; right: 2px; bottom: 0; font-size: 14px; font-weight: bold;
  color: #fff; text-shadow: 1px 1px 0 #000; pointer-events: none;
}
.slot .durbar {
  position: absolute; left: 3px; bottom: 3px; height: 3px; background: #4f4;
  pointer-events: none;
}
#hotbar .slot { width: 50px; height: 50px; background-color: rgba(40, 40, 40, 0.7); background-size: 40px 40px; background-repeat: no-repeat; background-position: center; }
#hotbar .slot.sel { outline: 3px solid #fff; outline-offset: -2px; }

/* ---------- ui window ---------- */
.ui-window {
  background: #c6c6c6; color: #2a2a2a; border: 3px solid #555;
  box-shadow: inset 3px 3px 0 #fff, inset -3px -3px 0 #8a8a8a, 0 10px 40px rgba(0,0,0,0.6);
  padding: 18px 22px; display: flex; flex-direction: column; gap: 12px;
}
.ui-window h3 { color: #3a3a3a; }
.ui-window .slot { background-color: #8b8b8b; border-color: #373737; outline-color: #fff; }
.craft-wrap, .furnace-wrap { display: flex; align-items: center; gap: 18px; }
.craft-arrow { font-size: 30px; color: #555; }
.fu-col { display: flex; flex-direction: column; gap: 6px; align-items: center; }
#fu-flame { font-size: 22px; filter: grayscale(1); }
#fu-flame.lit { filter: none; }
.fu-arrow { width: 70px; height: 14px; background: #8b8b8b; border: 2px solid #373737; }
#fu-progress { height: 100%; width: 0%; background: #e8e8e8; }

#trade-list { display: flex; flex-direction: column; gap: 8px; max-height: 300px; overflow-y: auto; }
.trade-row {
  display: flex; align-items: center; gap: 10px; background: #9a9a9a; padding: 6px 10px;
  border: 2px solid #555; cursor: pointer;
}
.trade-row:hover { background: #b0c89a; }
.trade-row.cant { opacity: 0.45; cursor: not-allowed; }
.trade-row img { width: 34px; height: 34px; image-rendering: pixelated; }
.trade-row .tcount { font-weight: bold; margin-left: -6px; }
.trade-row .tarrow { font-size: 20px; color: #444; }

#cursor-stack {
  position: fixed; z-index: 200; width: 40px; height: 40px; pointer-events: none;
  background-size: contain; image-rendering: pixelated;
}
#cursor-stack .count {
  position: absolute; right: 0; bottom: -2px; font-size: 14px; font-weight: bold;
  color: #fff; text-shadow: 1px 1px 0 #000;
}
#slot-tip {
  position: fixed; z-index: 210; background: rgba(20, 10, 40, 0.92); color: #fff;
  padding: 4px 10px; font-size: 14px; border: 1px solid #7050a0; pointer-events: none;
}

/* ---------- world slots ---------- */
#world-slots { display: flex; flex-direction: column; gap: 10px; min-width: 420px; }
.world-slot {
  display: flex; align-items: center; gap: 12px; background: #14201a;
  border: 2px solid #555; padding: 10px 14px; text-align: left;
}
.world-slot .ws-info { flex: 1; }
.world-slot .ws-name { font-weight: bold; font-size: 17px; }
.world-slot .ws-meta { font-size: 12px; color: #9a9; }
.world-slot .mc-btn { min-width: 0; padding: 6px 14px; font-size: 14px; }
.mc-btn.danger:hover { background: linear-gradient(#a05a5a, #804040 40%, #663434); }
.mc-btn.small { min-width: 0; padding: 6px 12px; font-size: 13px; }
#new-world-form { display: flex; flex-direction: column; gap: 10px; align-items: center;
  border: 2px solid #555; padding: 14px 20px; background: #101a14; }
select.mc-input { min-width: 140px; }

/* ---------- creative inventory ---------- */
#creative-area { display: flex; flex-direction: column; gap: 8px; }
#creative-search { width: 100%; background: #fff; color: #222; border-color: #373737; }
#creative-grid {
  grid-template-columns: repeat(9, 46px);
  max-height: 240px; overflow-y: auto; padding-right: 4px;
}

/* ---------- keybinds ---------- */
.settings-sub { margin-top: 6px; color: #cdc; }
#keybind-list {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px;
  max-height: 220px; overflow-y: auto; min-width: 420px;
}
.kb-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.kb-row .kb-name { font-size: 14px; }
.kb-key {
  font-family: inherit; font-size: 13px; min-width: 110px; padding: 5px 8px;
  background: #111; color: #cfc; border: 2px solid #555; cursor: pointer;
}
.kb-key.listening { border-color: #f0d030; color: #f0d030; }

/* ---------- skin editor ---------- */
.skin-editor-col { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
#skin-editor { background: #15201a; border: 2px solid #555; cursor: crosshair; image-rendering: pixelated; }
#skin-palette { display: flex; gap: 3px; flex-wrap: wrap; max-width: 320px; }
#skin-palette .pal {
  width: 22px; height: 22px; border: 2px solid #444; cursor: pointer;
}
#skin-palette .pal:hover { border-color: #fff; }
#panel-custom { max-height: 92vh; overflow-y: auto; }
