/* ============ NEW BLOCKS theme ============ */
:root {
  --font-pixel: "Pixelify Sans", "Trebuchet MS", system-ui, sans-serif;
  --blue: #2f8bff;
  --blue-lite: #5fa8ff;
  --blue-dark: #1f6fe0;
  --blue-deep: #14467f;
  --cyan: #5fe0ff;
  --stone: #2a2d33;
  --stone-lite: #3a3e46;
  --stone-dark: #15171b;
  --ink: #0a0d12;
  --steel: #6b7079;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #8fc7ff;
  font-family: var(--font-pixel);
  color: #fff;
  user-select: none;
}

#game canvas { display: block; }

.hidden { display: none !important; }

/* small cyan square accents in the four corners (signature block-UI look) */
.cyan-corners {
  background-image:
    linear-gradient(var(--cyan), var(--cyan)),
    linear-gradient(var(--cyan), var(--cyan)),
    linear-gradient(var(--cyan), var(--cyan)),
    linear-gradient(var(--cyan), var(--cyan));
  background-repeat: no-repeat;
  background-size: 8px 8px;
  background-position: 6px 6px, calc(100% - 6px) 6px, 6px calc(100% - 6px), calc(100% - 6px) calc(100% - 6px);
}

/* ---------- Overlays ---------- */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.overlay.click-through { background: rgba(0, 0, 0, 0.12); cursor: pointer; }

#menu {
  background: linear-gradient(180deg, #5aa6ea 0%, #79bdf2 45%, #a6d6ff 100%);
  overflow: hidden;
}
/* drifting blocky Minecraft-style clouds */
.sky-clouds {
  position: absolute;
  inset: -20% -10%;
  pointer-events: none;
  opacity: 0.9;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='200' shape-rendering='crispEdges'%3E%3Cg fill='%23ffffff' opacity='0.8'%3E%3Crect x='24' y='34' width='96' height='22'/%3E%3Crect x='42' y='20' width='60' height='16'/%3E%3Crect x='12' y='50' width='118' height='14'/%3E%3Crect x='190' y='104' width='84' height='20'/%3E%3Crect x='208' y='92' width='46' height='14'/%3E%3Crect x='178' y='120' width='102' height='12'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 360px 240px;
  animation: cloud-drift 70s linear infinite;
}
@keyframes cloud-drift { from { background-position: 0 0; } to { background-position: 360px 0; } }

.panel {
  position: relative;
  z-index: 1;
  background:
    linear-gradient(var(--cyan), var(--cyan)) 8px 8px/9px 9px no-repeat,
    linear-gradient(var(--cyan), var(--cyan)) calc(100% - 8px) 8px/9px 9px no-repeat,
    linear-gradient(var(--cyan), var(--cyan)) 8px calc(100% - 8px)/9px 9px no-repeat,
    linear-gradient(var(--cyan), var(--cyan)) calc(100% - 8px) calc(100% - 8px)/9px 9px no-repeat,
    linear-gradient(180deg, #34383f, #25282e);
  border: 4px solid var(--ink);
  box-shadow: 0 0 0 4px var(--steel), 0 0 0 7px var(--ink), 0 18px 54px rgba(0, 0, 0, 0.55);
  padding: 30px 40px 34px;
  border-radius: 4px;
  text-align: center;
  width: min(470px, 94vw);
}

.logo {
  display: block;
  width: min(360px, 84%);
  height: auto;
  margin: 2px auto 12px;
  filter: drop-shadow(0 5px 0 rgba(0, 0, 0, 0.35)) drop-shadow(0 3px 10px rgba(0, 0, 0, 0.5));
}

h1 {
  font-family: var(--font-pixel);
  letter-spacing: 4px;
  font-size: 40px;
  text-shadow: 3px 3px 0 #14467f, 0 0 18px rgba(95, 224, 255, 0.5);
  color: #fff;
}
.tag { opacity: 0.78; margin: 4px 0 18px; font-size: 14px; letter-spacing: 1px; }
.mode-tag { margin: 16px 0 6px; color: var(--cyan); font-size: 13px; letter-spacing: 2px; opacity: 1; }

#name-input {
  display: block;
  width: 100%;
  font-family: var(--font-pixel);
  font-size: 17px;
  text-align: center;
  padding: 12px 14px;
  margin: 6px 0 12px;
  color: #fff;
  background: var(--stone-dark);
  border: 3px solid var(--ink);
  box-shadow: inset 0 0 0 2px var(--stone-lite);
  outline: none;
  border-radius: 3px;
}
#name-input::placeholder { color: #7a818c; }
#name-input:focus { box-shadow: inset 0 0 0 2px var(--cyan); }

.name-row { display: flex; gap: 8px; margin: 6px 0 12px; }
.name-row #name-input { margin: 0; flex: 1 1 auto; }
#name-refresh {
  flex: 0 0 auto;
  width: 48px;
  font-family: var(--font-pixel);
  font-size: 22px;
  line-height: 1;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(180deg, var(--blue-lite), var(--blue) 55%, var(--blue-dark));
  border: 3px solid var(--ink);
  border-radius: 3px;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5), inset 0 2px 0 rgba(255, 255, 255, 0.25);
}
#name-refresh:hover { filter: brightness(1.1); }
#name-refresh:active { transform: translateY(2px); }

/* big blue block "PLAY" button */
#play-btn {
  display: block;
  width: 100%;
  cursor: pointer;
  font-family: var(--font-pixel);
  font-weight: 700;
  font-size: 24px;
  letter-spacing: 1px;
  color: #fff;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.4);
  padding: 0;
  margin: 8px 0 4px;
  border: none;
  border-radius: 4px;
  background:
    linear-gradient(var(--cyan), var(--cyan)) 6px 6px/7px 7px no-repeat,
    linear-gradient(var(--cyan), var(--cyan)) calc(100% - 6px) 6px/7px 7px no-repeat,
    linear-gradient(var(--cyan), var(--cyan)) 6px calc(100% - 6px)/7px 7px no-repeat,
    linear-gradient(var(--cyan), var(--cyan)) calc(100% - 6px) calc(100% - 6px)/7px 7px no-repeat,
    linear-gradient(180deg, var(--blue-lite) 0%, var(--blue) 52%, var(--blue-dark) 100%);
  box-shadow: 0 0 0 3px var(--ink), 0 0 0 6px rgba(255, 255, 255, 0.9), 0 8px 0 var(--blue-deep), 0 12px 18px rgba(0, 0, 0, 0.45);
  transition: filter 0.1s, transform 0.06s;
}
#play-btn span { display: block; padding: 16px 14px; }
#play-btn:hover { filter: brightness(1.08); }
#play-btn:active {
  transform: translateY(5px);
  box-shadow: 0 0 0 3px var(--ink), 0 0 0 6px rgba(255, 255, 255, 0.9), 0 3px 0 var(--blue-deep), 0 5px 10px rgba(0, 0, 0, 0.4);
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  margin-top: 20px;
  font-size: 11px;
}
.controls span {
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid var(--ink);
  border-radius: 3px;
  padding: 5px 4px;
}
.controls b { color: var(--cyan); font-weight: 700; }

#loading {
  flex-direction: column;
  gap: 22px;
  background: linear-gradient(180deg, rgba(10, 14, 22, 0.94), rgba(8, 12, 20, 0.97));
  font-family: var(--font-pixel);
  font-size: 24px;
  letter-spacing: 2px;
  color: var(--cyan);
}
.loading-logo {
  width: min(340px, 70vw);
  height: auto;
  filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.35)) drop-shadow(0 3px 10px rgba(0, 0, 0, 0.5));
  animation: loading-pulse 1.6s ease-in-out infinite;
}
@keyframes loading-pulse { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

.hint {
  font-family: var(--font-pixel);
  font-weight: 700;
  color: #fff;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.4);
  padding: 16px 40px;
  border-radius: 4px;
  font-size: 24px;
  letter-spacing: 1px;
  background:
    linear-gradient(var(--cyan), var(--cyan)) 6px 6px/7px 7px no-repeat,
    linear-gradient(var(--cyan), var(--cyan)) calc(100% - 6px) 6px/7px 7px no-repeat,
    linear-gradient(var(--cyan), var(--cyan)) 6px calc(100% - 6px)/7px 7px no-repeat,
    linear-gradient(var(--cyan), var(--cyan)) calc(100% - 6px) calc(100% - 6px)/7px 7px no-repeat,
    linear-gradient(180deg, var(--blue-lite) 0%, var(--blue) 52%, var(--blue-dark) 100%);
  box-shadow: 0 0 0 3px var(--ink), 0 0 0 6px rgba(255, 255, 255, 0.9), 0 6px 0 var(--blue-deep), 0 10px 16px rgba(0, 0, 0, 0.45);
}

/* ---------- HUD ---------- */
#underwater-overlay {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease;
  background:
    radial-gradient(circle at 50% 45%, rgba(105, 205, 235, 0.18), rgba(14, 74, 120, 0.42)),
    repeating-linear-gradient(115deg, rgba(180, 235, 255, 0.08) 0 10px, rgba(20, 90, 145, 0.06) 10px 22px);
  mix-blend-mode: screen;
}
#underwater-overlay.show {
  opacity: 1;
  animation: water-drift 5s linear infinite;
}

#rain-overlay {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.2s ease;
  background:
    radial-gradient(circle at 50% 40%, rgba(60, 76, 96, 0.04), rgba(38, 50, 68, 0.22)),
    linear-gradient(rgba(46, 58, 74, 0.12), rgba(40, 52, 68, 0.18));
}
#rain-overlay.show { opacity: 1; }

#lightning-overlay {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  background: #e3edff;
  mix-blend-mode: screen;
}

#cave-vignette {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.24s ease;
  background:
    radial-gradient(circle at 50% 48%, rgba(0, 0, 0, 0.02) 0 30%, rgba(0, 0, 0, 0.34) 72%, rgba(0, 0, 0, 0.72) 100%),
    linear-gradient(rgba(7, 10, 12, 0.12), rgba(7, 10, 12, 0.3));
}

@keyframes water-drift {
  from { background-position: 0 0, 0 0; }
  to { background-position: 0 0, 80px 36px; }
}

#crosshair {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 5;
  background:
    linear-gradient(#fff, #fff) center/3px 22px no-repeat,
    linear-gradient(#fff, #fff) center/22px 3px no-repeat;
  mix-blend-mode: difference;
}

#coords {
  position: fixed;
  top: 8px;
  left: 8px;
  font-family: monospace;
  font-size: 13px;
  background: rgba(0, 0, 0, 0.4);
  padding: 4px 8px;
  border-radius: 4px;
  z-index: 5;
  pointer-events: none;
}

#debug-metrics {
  position: fixed;
  top: 34px;
  left: 8px;
  width: min(520px, 70vw);
  font-family: "Consolas", "Menlo", monospace;
  font-size: 12px;
  line-height: 1.35;
  white-space: pre;
  color: #dfffe0;
  background: rgba(0, 0, 0, 0.62);
  border: 1px solid rgba(190, 255, 190, 0.28);
  border-radius: 4px;
  padding: 6px 8px;
  z-index: 5;
  pointer-events: none;
  text-shadow: 1px 1px 1px #000;
}

#player-list {
  position: fixed;
  top: 28px;
  left: 50%;
  width: min(360px, calc(100vw - 32px));
  transform: translateX(-50%);
  z-index: 8;
  pointer-events: none;
  padding: 10px;
  border: 2px solid rgba(210, 230, 210, 0.34);
  border-radius: 6px;
  background: rgba(12, 16, 22, 0.78);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.38);
  color: #eef8e8;
  font-family: "Consolas", "Menlo", monospace;
  text-shadow: 1px 1px 1px #000;
}
.player-list-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px 6px;
  color: #cfe8b8;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}
.player-list-rows {
  display: grid;
  gap: 4px;
}
.player-list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 28px;
  padding: 4px 7px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
}
.player-list-row.self {
  border-color: rgba(95, 224, 255, 0.4);
  background: rgba(47, 139, 255, 0.22);
}
.player-list-name {
  overflow: hidden;
  color: #fff;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player-list-meta {
  color: #d9e8cf;
  font-size: 12px;
  white-space: nowrap;
}

#chat-log {
  position: fixed;
  left: 8px;
  bottom: 96px;
  width: min(420px, 60vw);
  max-height: 30vh;
  overflow-y: auto;
  font-size: 14px;
  text-shadow: 1px 1px 2px #000;
  z-index: 5;
  pointer-events: none;
}
#chat-log div { padding: 1px 0; }
#chat-log div.chat-pending { opacity: 0.72; }
#chat-log div.chat-delayed { color: #ffe08a; }
#chat-log div.chat-rejected { color: #ff9b8f; opacity: 0.88; }

#chat-input {
  position: fixed;
  left: 8px;
  bottom: 70px;
  width: min(420px, 60vw);
  font-size: 15px;
  padding: 8px 10px;
  border: none;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  outline: none;
  z-index: 12;
}

/* ---------- Inventory ---------- */
#inventory-screen {
  position: fixed;
  inset: 0;
  z-index: 14;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.28);
}
#furnace-screen {
  position: fixed;
  inset: 0;
  z-index: 14;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.28);
}

.inventory-panel,
.furnace-panel {
  width: min(560px, 94vw);
  background:
    linear-gradient(var(--cyan), var(--cyan)) 7px 7px/8px 8px no-repeat,
    linear-gradient(var(--cyan), var(--cyan)) calc(100% - 7px) 7px/8px 8px no-repeat,
    linear-gradient(var(--cyan), var(--cyan)) 7px calc(100% - 7px)/8px 8px no-repeat,
    linear-gradient(var(--cyan), var(--cyan)) calc(100% - 7px) calc(100% - 7px)/8px 8px no-repeat,
    linear-gradient(180deg, #2f333b, #23262c);
  border: 4px solid var(--ink);
  box-shadow: 0 0 0 4px var(--steel), 0 0 0 7px var(--ink), 0 16px 48px rgba(0, 0, 0, 0.55);
  border-radius: 4px;
  padding: 20px;
}

.furnace-row {
  display: flex;
  align-items: center;
  gap: 14px;
}
.furnace-inputs {
  display: grid;
  gap: 6px;
}
.furnace-meters {
  display: grid;
  gap: 8px;
  width: 96px;
}
.furnace-bar {
  height: 10px;
  border: 2px solid #11141a;
  background: rgba(0, 0, 0, 0.38);
  border-radius: 4px;
  overflow: hidden;
}
.furnace-bar span {
  display: block;
  height: 100%;
  background: #d98a36;
}
.furnace-bar.cook span { background: #d9e8cf; }
.furnace-inventory { margin-top: 16px; }

.inventory-section + .inventory-section { margin-top: 14px; }

.inventory-label {
  font-family: var(--font-pixel);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--cyan);
  margin: 0 0 6px;
  text-shadow: 1px 1px 1px #000;
}

.craft-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.craft-grid {
  display: grid;
  grid-template-columns: repeat(2, 52px);
  gap: 4px;
}

.craft-arrow {
  width: 24px;
  text-align: center;
  font-family: monospace;
  font-size: 22px;
  color: var(--cyan);
  text-shadow: 1px 1px 1px #000;
}

.recipe-book {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.recipe-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.recipe-toolbar .inventory-label {
  margin: 0;
}

.recipe-search {
  flex: 1 1 120px;
  min-width: 0;
  height: 28px;
  padding: 0 8px;
  border: 2px solid #2a2d34;
  border-radius: 4px;
  background: rgba(10, 12, 16, 0.72);
  color: #f2ffe8;
  font-size: 12px;
  font-weight: 700;
  outline: none;
}

.recipe-toggle {
  height: 28px;
  min-width: 84px;
  padding: 0 10px;
  border: 2px solid #2a2d34;
  border-radius: 4px;
  background: rgba(46, 58, 70, 0.92);
  color: #f2ffe8;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  text-shadow: 1px 1px 1px #000;
}

.recipe-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.recipe-tab {
  height: 24px;
  padding: 0 8px;
  border: 2px solid #2a2d34;
  border-radius: 4px;
  background: rgba(30, 34, 40, 0.78);
  color: #cfe2f5;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  text-shadow: 1px 1px 1px #000;
}
.recipe-tab.active {
  background: linear-gradient(180deg, var(--blue), var(--blue-dark));
  color: #fff;
  border-color: var(--cyan);
}

.recipe-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 112px;
  overflow-y: auto;
}

.recipe-button {
  position: relative;
  width: 124px;
  height: 38px;
  padding: 2px 8px 2px 4px;
  border: 2px solid #2a2d34;
  border-radius: 4px;
  background: linear-gradient(180deg, rgba(47, 72, 104, 0.85), rgba(34, 52, 78, 0.85));
  color: #eef4ff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  text-shadow: 1px 1px 1px #000;
}
.recipe-button canvas {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  image-rendering: pixelated;
}
.recipe-button span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.recipe-button b {
  position: absolute;
  left: 26px;
  bottom: 1px;
  font-family: monospace;
  font-size: 11px;
  color: #fff;
  text-shadow: 1px 1px 0 #000;
}
.recipe-button.locked {
  opacity: 0.5;
  background: rgba(48, 52, 58, 0.72);
  cursor: default;
}
.recipe-button.search-hidden { display: none; }
.recipe-button:hover,
.recipe-toggle:hover,
.recipe-tab:hover { border-color: var(--cyan); }

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(9, 52px);
  gap: 4px;
}

.inventory-hotbar { margin-top: 10px; }

.inv-slot {
  position: relative;
  width: 52px;
  height: 52px;
  background: rgba(0, 0, 0, 0.35);
  border: 2px solid #2a2d34;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
.inv-slot:hover { border-color: var(--cyan); }
.inv-slot.selected { border-color: #fff; box-shadow: 0 0 0 2px #fff inset; }
.inv-slot canvas {
  width: 40px;
  height: 40px;
  image-rendering: pixelated;
}

#cursor-stack {
  position: fixed;
  z-index: 30;
  width: 52px;
  height: 52px;
  transform: translate(-18px, -18px);
  pointer-events: none;
}
#cursor-stack canvas {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
  filter: drop-shadow(2px 2px 0 rgba(0, 0, 0, 0.6));
}

/* ---------- Toast / hint ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 120px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 15px;
  padding: 8px 16px;
  border-radius: 6px;
  white-space: nowrap;
  z-index: 6;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s;
  text-shadow: 1px 1px 2px #000;
}
#toast.show { opacity: 1; }

/* ---------- Survival stats ---------- */
#stats {
  position: fixed;
  left: 50%;
  bottom: 76px;
  transform: translateX(-50%);
  width: 360px;
  z-index: 5;
  pointer-events: none;
}
.statrow {
  display: flex;
  justify-content: space-between;
}
.iconbar {
  display: flex;
  gap: 1px;
}
#air-bar {
  justify-content: flex-end;
  margin-bottom: 3px;
  min-height: 18px;
}
.iconbar .icon {
  width: 18px;
  height: 18px;
  background-size: contain;
  background-repeat: no-repeat;
  image-rendering: pixelated;
  filter: drop-shadow(1px 1px 0 rgba(0, 0, 0, 0.6));
}
#hunger-bar {
  flex-direction: row-reverse; /* food drains from the inside out, like Minecraft */
}
#xp-wrap {
  position: relative;
  width: 100%;
  height: 16px;
  margin-top: 3px;
}
#xp-bar {
  position: absolute;
  left: 5px;
  right: 5px;
  bottom: 0;
  height: 6px;
  border: 2px solid rgba(0, 0, 0, 0.78);
  background: #1a1b21;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12), inset 0 0 0 1px #111;
}
#xp-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(180deg, #d7ff75 0%, #7bd629 45%, #398a16 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
#xp-level {
  position: absolute;
  left: 50%;
  bottom: 5px;
  transform: translateX(-50%);
  min-width: 18px;
  text-align: center;
  color: #b8ff4f;
  font: 700 18px var(--font-pixel);
  text-shadow: 2px 2px 0 #15220b, -1px -1px 0 #15220b, 1px -1px 0 #15220b, -1px 1px 0 #15220b;
  opacity: 0;
}
#xp-level.show { opacity: 1; }

#damage-flash {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background: radial-gradient(circle, rgba(120, 0, 0, 0) 45%, rgba(160, 0, 0, 0.55) 100%);
  opacity: 0;
  transition: opacity 0.12s;
}
#damage-flash.show { opacity: 1; }

#death { background: rgba(60, 0, 0, 0.55); z-index: 20; }
#respawn-btn {
  display: block;
  width: 100%;
  font-family: var(--font-pixel);
  font-size: 18px;
  padding: 13px 14px;
  margin-top: 14px;
  border-radius: 4px;
  border: 3px solid var(--ink);
  background: linear-gradient(180deg, var(--blue-lite), var(--blue) 55%, var(--blue-dark));
  color: #fff;
  font-weight: 700;
  letter-spacing: 1px;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.4);
  cursor: pointer;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5), inset 0 2px 0 rgba(255, 255, 255, 0.25), 0 5px 0 var(--blue-deep);
}
#respawn-btn:hover { filter: brightness(1.08); }
#respawn-btn:active { transform: translateY(3px); box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5), 0 2px 0 var(--blue-deep); }

.settings-panel {
  width: min(700px, 95vw);
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ---- Tabbed settings layout ---- */
.settings-layout { display: flex; gap: 16px; text-align: left; min-height: 320px; }
.settings-tabs { display: flex; flex-direction: column; gap: 8px; flex: 0 0 154px; }
.settings-tab {
  font-family: var(--font-pixel);
  font-size: 14px;
  letter-spacing: 1px;
  text-align: left;
  padding: 12px 12px;
  color: #cfe2f5;
  cursor: pointer;
  background: linear-gradient(180deg, rgba(40, 44, 52, 0.95), rgba(28, 31, 38, 0.95));
  border: 3px solid var(--ink);
  border-radius: 4px;
}
.settings-tab:hover { border-color: var(--steel); }
.settings-tab.active {
  color: #fff;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.4);
  background: linear-gradient(180deg, var(--blue-lite), var(--blue) 55%, var(--blue-dark));
  border-color: var(--cyan);
  box-shadow: 0 0 0 1px var(--cyan), inset 0 2px 0 rgba(255, 255, 255, 0.25);
}
.settings-content { flex: 1 1 auto; min-width: 0; }
.settings-pane { display: none; }
.settings-pane.active { display: grid; gap: 12px; align-content: start; }
.settings-pane label {
  display: grid;
  grid-template-columns: 92px 1fr 60px;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  font-size: 13px;
}
.settings-pane label > span,
.settings-pane b {
  font-family: var(--font-pixel);
  color: #cfe2f5;
  text-shadow: 1px 1px 1px #000;
}
.settings-pane .setting-check { grid-template-columns: 1fr 26px; }
.settings-pane .setting-pack { grid-template-columns: 70px minmax(0, 1fr) 70px; }
.settings-pane input[type="range"] { width: 100%; accent-color: var(--blue); }
.settings-pane input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--blue); justify-self: end; }
.pause-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 0; }
.settings-actions { display: flex; gap: 12px; margin-top: 18px; }
.settings-actions button { flex: 1 1 0; }
.settings-panel::-webkit-scrollbar { width: 10px; }
.settings-panel::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.3); }
.settings-panel::-webkit-scrollbar-thumb { background: var(--steel); border-radius: 4px; }

.settings-panel h1 {
  font-size: 34px;
  letter-spacing: 4px;
}

.settings-panel button,
.settings-panel select {
  width: 100%;
  height: 42px;
  border-radius: 4px;
  border: 3px solid var(--ink);
  color: #fff;
  font-family: var(--font-pixel);
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
}

.settings-panel button {
  background: linear-gradient(180deg, var(--blue-lite), var(--blue) 55%, var(--blue-dark));
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.4);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.45), inset 0 2px 0 rgba(255, 255, 255, 0.22), 0 4px 0 var(--blue-deep);
}
.settings-panel button:hover { filter: brightness(1.08); }
.settings-panel button:active { transform: translateY(2px); }

.settings-panel input[type="text"] {
  width: 100%;
  min-width: 0;
  height: 42px;
  border-radius: 4px;
  border: 3px solid var(--ink);
  background: var(--stone-dark);
  color: #f4f7ef;
  font: 700 12px var(--font-pixel);
  padding: 0 10px;
  box-shadow: inset 0 0 0 2px var(--stone-lite);
}

.settings-panel select {
  background: var(--stone-dark);
  box-shadow: inset 0 0 0 2px var(--stone-lite);
  padding: 0 10px;
}

.settings-grid {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.settings-grid label {
  display: grid;
  grid-template-columns: 86px 1fr 78px;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  font-size: 13px;
  text-align: left;
}

.settings-grid label > span,
.settings-grid b {
  font-family: var(--font-pixel);
  color: #cfe2f5;
  text-shadow: 1px 1px 1px #000;
}

.settings-grid input[type="range"] {
  width: 100%;
  accent-color: var(--blue);
}

.settings-grid input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--blue);
}

.settings-grid .setting-check {
  grid-template-columns: 86px 1fr 78px;
}

.settings-grid .setting-pack {
  grid-template-columns: 86px minmax(0, 1fr) 78px;
}

.settings-grid .setting-pack button {
  height: 42px;
  font-size: 12px;
  padding: 0 8px;
}

.setting-pack-status {
  min-height: 28px;
  padding: 6px 8px;
  border: 1px solid rgba(217, 232, 207, 0.22);
  border-radius: 4px;
  background: rgba(10, 12, 16, 0.72);
  color: #d9e8cf;
  font: 700 12px monospace;
  line-height: 1.35;
  overflow-wrap: anywhere;
  text-shadow: 1px 1px 1px #000;
}

.pack-status-label {
  color: #b8c8ae;
  font-size: 11px;
  text-transform: uppercase;
}

.pack-status-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
  padding-top: 6px;
}

.pack-status-heading {
  display: flex;
  gap: 8px;
  align-items: baseline;
  min-width: 0;
}

.pack-status-heading strong {
  min-width: 0;
  overflow: hidden;
  color: #f4f7ef;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pack-status-heading span {
  flex: 0 0 auto;
  color: #96aa8e;
  font-size: 11px;
}

.pack-status-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.pack-status-badge {
  padding: 2px 5px;
  border: 1px solid rgba(217, 232, 207, 0.18);
  border-radius: 3px;
  background: rgba(120, 185, 87, 0.13);
  color: #d9e8cf;
  font-size: 11px;
  line-height: 1.2;
}

.pack-source-links {
  display: grid;
  gap: 4px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(217, 232, 207, 0.16);
}

.pack-source-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.pack-source-row span {
  overflow: hidden;
  color: #f4f7ef;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pack-source-actions {
  display: flex;
  gap: 6px;
}

.pack-source-actions a {
  color: #cfe8b8;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.slot-count {
  position: absolute;
  bottom: 0;
  right: 2px;
  font-size: 13px;
  font-family: monospace;
  font-weight: bold;
  color: #fff;
  text-shadow: 1px 1px 0 #000, -1px 1px 0 #000, 1px -1px 0 #000, -1px -1px 0 #000;
}

.durability {
  position: absolute;
  left: 5px;
  right: 5px;
  bottom: 4px;
  height: 4px;
  background: rgba(30, 12, 10, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.75);
  pointer-events: none;
}
.durability span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #c43d31, #e4c84b, #4fc45d);
}

#hotbar {
  --hotbar-slot-size: min(52px, calc((100vw - 36px) / 9));
  --hotbar-gap: clamp(1px, 0.7vw, 4px);
  --hotbar-pad: clamp(3px, 0.9vw, 5px);
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  display: flex;
  gap: var(--hotbar-gap);
  max-width: calc(100vw - 8px);
  padding: var(--hotbar-pad);
  background: linear-gradient(180deg, rgba(30, 33, 39, 0.82), rgba(18, 20, 25, 0.85));
  border: 2px solid var(--ink);
  box-shadow: 0 0 0 2px rgba(107, 112, 121, 0.6);
  border-radius: 4px;
  z-index: 5;
}
.slot {
  --slot-size: var(--hotbar-slot-size, 52px);
  position: relative;
  width: var(--slot-size);
  height: var(--slot-size);
  flex: 0 0 var(--slot-size);
  background: rgba(0, 0, 0, 0.35);
  border: 2px solid #2a2d34;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.slot canvas {
  width: calc(var(--slot-size) - 12px);
  height: calc(var(--slot-size) - 12px);
  image-rendering: pixelated;
}
.slot:hover { border-color: var(--cyan); }
.slot.selected { border-color: #fff; box-shadow: 0 0 0 2px #fff inset, 0 0 8px rgba(95, 224, 255, 0.5); }
.slot-num {
  position: absolute;
  bottom: 1px;
  right: 3px;
  font-size: 11px;
  font-family: monospace;
  text-shadow: 1px 1px 1px #000;
  opacity: 0.8;
}
