* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: #000;
  padding-top: 55px;
  height: 100vh;
  overflow: hidden;
}

#mcApp {
  position: relative;
  width: 100%;
  height: calc(100vh - 55px);
  overflow: hidden;
  background: #88c5ff;
}

#mcCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

#crosshair {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font: bold 22px monospace;
  text-shadow: 0 0 3px #000, 0 0 3px #000;
  pointer-events: none;
  display: none;
  z-index: 5;
}

#hotbar {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  gap: 4px;
  background: rgba(0,0,0,0.4);
  padding: 4px;
  border-radius: 6px;
  z-index: 5;
}
#hotbar .slot {
  position: relative;
  width: 42px;
  height: 42px;
  border: 2px solid rgba(255,255,255,0.25);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.3);
}
#hotbar .slot.active {
  border-color: #ffe66d;
  box-shadow: 0 0 8px rgba(255,230,109,0.6);
}
#hotbar .swatch {
  width: 32px; height: 32px;
  background-size: cover;
  background-repeat: no-repeat;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border: 1px solid rgba(0,0,0,0.4);
  border-radius: 2px;
}
#hotbar .num {
  position: absolute;
  bottom: 1px; left: 3px;
  font: 10px monospace;
  color: rgba(255,255,255,0.8);
  text-shadow: 1px 1px 0 #000;
}
#hotbar .cnt {
  position: absolute;
  bottom: 1px; right: 3px;
  font: bold 12px monospace;
  color: #fff;
  text-shadow: 1px 1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, -1px -1px 0 #000;
}

#hudInfo {
  position: absolute;
  top: 8px;
  left: 8px;
  display: none;
  font-family: monospace;
  font-size: 12px;
  color: #fff;
  z-index: 5;
}
#roomBadge, #onlineBadge {
  background: rgba(0,0,0,0.55);
  padding: 4px 10px;
  border-radius: 4px;
  margin-bottom: 4px;
  display: inline-block;
}
#roomBadge { color: #ffe66d; font-weight: bold; }

#nameTags {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}
.name-tag {
  position: absolute;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.6);
  color: #fff;
  font: bold 11px monospace;
  padding: 2px 6px;
  border-radius: 3px;
  white-space: nowrap;
}

#underwaterOverlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 40, 130, 0.45);
  pointer-events: none;
  display: none;
  z-index: 3;
}

.lock-hint {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.7);
  color: #fff;
  padding: 8px 16px;
  border-radius: 6px;
  font: 13px sans-serif;
  z-index: 5;
}

/* Overlay panels */
.mc-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.7);
  z-index: 10;
}
.mc-panel {
  background: linear-gradient(160deg,#2d3a7b,#1e2a5a);
  border: 1px solid rgba(255,255,255,0.13);
  padding: 2.4rem;
  border-radius: 18px;
  text-align: center;
  max-width: 440px;
  width: 92%;
  box-shadow: 0 16px 60px rgba(0,0,0,0.65);
}
.mc-panel h1 {
  font-family: 'Trebuchet MS', system-ui, sans-serif;
  font-size: 2.2rem;
  color: #ffe66d;
  margin-bottom: 0.4rem;
  letter-spacing: 1px;
}
.mc-sub {
  font-family: system-ui, sans-serif;
  color: rgba(255,255,255,0.65);
  font-size: 0.92rem;
  margin-bottom: 1.6rem;
}
.mc-panel > button {
  display: block;
  width: 100%;
  max-width: 240px;
  margin: 0 auto 0.7rem;
  padding: 13px;
  font: bold 1.05rem 'Trebuchet MS', system-ui, sans-serif;
  background: #ffe66d;
  color: #1a1a2e;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.1s;
}
.mc-panel > button:hover { transform: translateY(-2px); }
.mc-or {
  font-family: system-ui, sans-serif;
  color: rgba(255,255,255,0.3);
  margin: 0.6rem 0;
  font-size: 0.82rem;
}
.mc-join {
  display: flex;
  gap: 8px;
  width: fit-content;
  margin: 0 auto 1.2rem;
}
.mc-join input {
  width: 115px;
  padding: 11px 6px;
  font-size: 1.15rem;
  font-weight: bold;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 6px;
  background: rgba(255,255,255,0.1);
  border: 2px solid rgba(255,255,255,0.22);
  border-radius: 8px;
  color: #fff;
  outline: none;
}
.mc-join input:focus { border-color: #ffe66d; }
.mc-join input::placeholder { letter-spacing: 2px; opacity: 0.4; font-size: 0.82rem; }
.mc-join button {
  padding: 11px 14px;
  font: bold 0.95rem 'Trebuchet MS', system-ui, sans-serif;
  background: #5ec9ff;
  color: #0a0a2e;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
.mc-hint {
  font-family: system-ui, sans-serif;
  font-size: 0.76rem;
  color: rgba(255,255,255,0.42);
  line-height: 1.55;
  margin-top: 0.5rem;
}
.mc-code {
  font-family: monospace;
  font-size: 1.6rem;
  color: #ffe66d;
  letter-spacing: 8px;
  margin: 0.6rem 0;
}

/* ── Inventory overlay ── */
#invPanel {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  font-family: system-ui, sans-serif;
  color: #fff;
}
.inv-frame {
  background: #2d3a7b;
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 12px;
  padding: 18px 22px;
  max-width: 680px;
  width: 96%;
  max-height: 88vh;
  overflow-y: auto;
  overflow-x: auto;
  box-sizing: border-box;
}
.inv-frame h2 { color: #ffe66d; font-size: 1.4rem; margin-bottom: 8px; }
.inv-frame h3 { color: #ffe66d; font-size: 1rem; margin: 14px 0 6px; }
.inv-grid {
  display: grid;
  grid-template-columns: repeat(9, 38px);
  gap: 3px;
  background: rgba(0,0,0,0.35);
  padding: 4px;
  border-radius: 6px;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
}
.iv-slot {
  position: relative;
  width: 38px; height: 38px;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 3px;
}
.iv-slot.filled { background: rgba(255,255,255,0.06); }
.iv-swatch {
  width: 100%; height: 100%;
  background-size: cover; background-repeat: no-repeat;
  image-rendering: pixelated;
}
.iv-slot .cnt {
  position: absolute; bottom: 1px; right: 3px;
  font: bold 11px monospace; color: #fff;
  text-shadow: 1px 1px 0 #000, -1px 1px 0 #000, 1px -1px 0 #000, -1px -1px 0 #000;
}
.craft-area {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 10px 0 4px;
  padding: 10px;
  background: rgba(0,0,0,0.25);
  border-radius: 6px;
}
.craft-grid {
  display: grid;
  gap: 3px;
  background: rgba(0,0,0,0.4);
  padding: 3px;
  border-radius: 4px;
}
.craft-arrow {
  font: bold 22px monospace;
  color: rgba(255,255,255,0.6);
}
.craft-result {
  background: rgba(0,0,0,0.35);
  padding: 3px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.18);
}
.craft-out { width: 44px; height: 44px; }
.craft-out.can { box-shadow: 0 0 6px rgba(94,255,138,0.6); cursor: pointer; }
.iv-slot { cursor: pointer; user-select: none; }
.iv-slot:hover { background: rgba(255,255,255,0.12); }
.dur-bar {
  position: absolute;
  bottom: 2px;
  left: 2px;
  height: 2px;
  border-radius: 1px;
  pointer-events: none;
}

#invCursor {
  position: fixed;
  pointer-events: none;
  z-index: 100;
  display: none;
}
.cursor-slot {
  width: 38px; height: 38px;
}

.inv-hint { margin-top: 12px; font-size: 0.78rem; opacity: 0.6; text-align: center; }

/* ── Damage flash ── */
#damageFlash {
  position: absolute;
  inset: 0;
  background: rgba(200,0,0,0);
  pointer-events: none;
  z-index: 6;
  transition: background 0.4s ease-out;
}
#damageFlash.hit {
  background: rgba(200,0,0,0.45);
  transition: none;
}

/* ── Death screen ── */
#deathScreen {
  position: absolute;
  inset: 0;
  background: rgba(100,0,0,0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 25;
  font-family: 'Trebuchet MS', system-ui, sans-serif;
}
.death-msg {
  font-size: 2.4rem;
  color: #fff;
  text-shadow: 0 0 20px #f00, 0 0 50px #800;
  margin-bottom: 1.6rem;
  letter-spacing: 1px;
}
#deathScreen button {
  padding: 12px 30px;
  font: bold 1rem 'Trebuchet MS', system-ui, sans-serif;
  background: #ffe66d;
  color: #1a1a2e;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.1s;
}
#deathScreen button:hover { transform: translateY(-2px); }

/* ── Health / Hunger HUD ── */
#healthHungerHud {
  position: absolute;
  bottom: 68px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  z-index: 5;
  pointer-events: none;
}
#airRow, #healthRow, #hungerRow {
  display: flex;
  gap: 1px;
}
.hud-heart, .hud-food, .hud-air {
  font-size: 15px;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.9));
  user-select: none;
}

/* ── Game mode badge in HUD ── */
#gameModeTag {
  background: rgba(0,0,0,0.6);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: bold;
  margin-top: 4px;
  display: inline-block;
  letter-spacing: 0.5px;
}

/* ── Lobby wizard ── */
.mc-big-btn {
  display: block;
  width: 100%;
  max-width: 240px;
  margin: 0 auto 0.7rem;
  padding: 13px;
  font: bold 1.05rem 'Trebuchet MS', system-ui, sans-serif;
  background: #ffe66d;
  color: #1a1a2e;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.1s;
}
.mc-big-btn:hover { transform: translateY(-2px); }
.mc-pvp-btn { background: linear-gradient(135deg, #ff5e5e, #b91c1c); color: #fff; }
.mc-pvp-btn:hover { filter: brightness(1.1); transform: translateY(-2px); }

.back-btn {
  display: block;
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.4);
  font: 0.85rem 'Trebuchet MS', system-ui, sans-serif;
  cursor: pointer;
  padding: 0 0 1rem 0;
  text-align: left;
  transition: color 0.15s;
}
.back-btn:hover { color: rgba(255,255,255,0.8); }

.step-title {
  font: bold 1.35rem 'Trebuchet MS', system-ui, sans-serif;
  color: #ffe66d;
  margin-bottom: 1rem;
  text-align: center;
}

.lobby-choices {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-bottom: 0.5rem;
}
.choice-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: rgba(255,255,255,0.05);
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: all 0.15s;
  color: #fff;
  font-family: 'Trebuchet MS', system-ui, sans-serif;
}
.choice-btn:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.3);
  transform: translateY(-1px);
}
.choice-btn.choice-pvp:hover {
  border-color: #ff5e5e;
  background: rgba(255,94,94,0.1);
}
.choice-icon { font-size: 1.9rem; flex-shrink: 0; line-height: 1; }
.choice-text { display: flex; flex-direction: column; }
.choice-title { font: bold 1rem 'Trebuchet MS', system-ui, sans-serif; color: #f1f5f9; }
.choice-desc  { font: 0.76rem system-ui, sans-serif; color: rgba(255,255,255,0.38); margin-top: 2px; }

/* Saved worlds */
.saved-worlds-label {
  font: 0.72rem system-ui, sans-serif;
  color: rgba(255,255,255,0.3);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 0.9rem 0 0.5rem;
  text-align: left;
}
.saved-world-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  margin-bottom: 5px;
}
.saved-world-code {
  font: bold 0.92rem monospace;
  color: #ffe66d;
  letter-spacing: 3px;
  flex: 1;
  text-align: left;
}
.saved-world-meta {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.3);
  white-space: nowrap;
}
.saved-cont-btn {
  padding: 4px 10px;
  font: 0.8rem 'Trebuchet MS', system-ui, sans-serif;
  background: #5ec9ff;
  color: #0a0a2e;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.saved-del-btn {
  padding: 4px 8px;
  font: 0.8rem monospace;
  background: rgba(239,68,68,0.1);
  color: #f87171;
  border: 1px solid rgba(239,68,68,0.22);
  border-radius: 6px;
  cursor: pointer;
}

/* ── Creative inventory palette ── */
.creative-palette-grid {
  display: grid;
  grid-template-columns: repeat(6, 38px);
  gap: 3px;
  background: rgba(0,0,0,0.35);
  padding: 4px;
  border-radius: 6px;
  overflow-y: auto;
  overflow-x: hidden;
}
.creative-palette-grid .iv-slot { cursor: pointer; }
.creative-palette-grid .iv-slot:hover {
  background: rgba(255,220,50,0.18);
  border-color: #ffe66d;
}

/* ── Furnace UI ── */
.furnace-area {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin: 14px 0;
  padding: 12px;
  background: rgba(0,0,0,0.25);
  border-radius: 8px;
}
.furnace-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.furnace-row-label {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.furnace-slot {
  position: relative;
  width: 52px; height: 52px;
  background: rgba(0,0,0,0.4);
  border: 2px solid rgba(255,255,255,0.18);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
}
.furnace-slot:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.4); }
.furnace-slot.filled { background: rgba(255,255,255,0.07); border-color: rgba(255,255,255,0.3); }
.furnace-slot.can    { border-color: #5eff8a; box-shadow: 0 0 6px rgba(94,255,138,0.5); }
.furnace-slot .iv-swatch { width: 42px; height: 42px; }
.furnace-slot .cnt {
  position: absolute; bottom: 2px; right: 4px;
  font: bold 11px monospace; color: #fff;
  text-shadow: 1px 1px 0 #000, -1px 1px 0 #000;
}
.furnace-slot-label {
  font-size: 0.62rem;
  color: rgba(255,255,255,0.3);
  text-align: center;
  line-height: 1.3;
  padding: 4px;
}
.furnace-arrow {
  font: bold 26px monospace;
  color: rgba(255,180,50,0.8);
  padding-bottom: 18px; /* align with mid-slot */
}
