/* ============================================================
   Minecraft Two — UI styling (Minecraft-flavored chrome)
   ============================================================ */

:root {
  --pixel-font: 'VT323', 'Courier New', monospace;
  --logo-font: 'Press Start 2P', 'VT323', monospace;
}

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

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

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hidden { display: none !important; }

/* ======================= overlays ======================= */

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

#pause-menu, #options-menu, #controls-menu, #online-menu {
  background: rgba(16, 16, 16, 0.62);
  backdrop-filter: blur(1px);
}

#title-screen { background: transparent; pointer-events: auto; }

/* ======================= MC buttons ======================= */

.mc-button {
  font-family: var(--pixel-font);
  font-size: 22px;
  letter-spacing: 1px;
  color: #fff;
  text-shadow: 2px 2px 0 #3f3f3f;
  background: linear-gradient(#828282, #6a6a6a 45%, #5a5a5a);
  border: 2px solid #000;
  box-shadow: inset 2px 2px 0 rgba(255,255,255,0.45), inset -2px -2px 0 rgba(0,0,0,0.45);
  padding: 8px 18px;
  min-width: 300px;
  cursor: pointer;
  image-rendering: pixelated;
}
.mc-button:hover {
  background: linear-gradient(#8f9ad1, #707bb4 45%, #5e69a3);
  border-color: #fff;
}
.mc-button:active { transform: translateY(1px); }
.mc-button.small { min-width: 0; font-size: 18px; padding: 6px 12px; }
.mc-button.toggle { min-width: 230px; }

/* ======================= title screen ======================= */

.title-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
}

.mc-logo {
  font-family: var(--logo-font);
  font-size: clamp(38px, 8vw, 84px);
  color: #d8d8d8;
  letter-spacing: 4px;
  text-shadow:
    3px 3px 0 #3a3a3a,
    6px 6px 0 rgba(0,0,0,0.55);
  -webkit-text-stroke: 2px #1f1f1f;
  filter: drop-shadow(0 4px 0 rgba(0,0,0,0.3));
}

.mc-sublogo {
  font-family: var(--pixel-font);
  font-size: 24px;
  color: #ffce3d;
  text-shadow: 2px 2px 0 #3e2e00;
  margin-top: -10px;
  letter-spacing: 6px;
}

.splash {
  position: relative;
  color: #ffff00;
  font-size: 26px;
  text-shadow: 2px 2px 0 #3f3f00;
  transform: rotate(-12deg);
  animation: splash-pulse 0.9s ease-in-out infinite;
  margin-top: -28px;
  margin-left: 280px;
  pointer-events: none;
}
@keyframes splash-pulse {
  0%, 100% { scale: 1; }
  50% { scale: 1.08; }
}

.menu-buttons {
  margin-top: 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.seed-row { display: flex; gap: 8px; }

#seed-input {
  font-family: var(--pixel-font);
  font-size: 18px;
  width: 190px;
  background: #000;
  color: #e0e0e0;
  border: 2px solid #a0a0a0;
  padding: 6px 8px;
  outline: none;
}
#seed-input:focus { border-color: #fff; }

.title-footer {
  position: fixed;
  bottom: 8px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  color: #fff;
  font-size: 18px;
  text-shadow: 2px 2px 0 #3f3f3f;
  pointer-events: none;
}

/* ======================= menus ======================= */

.menu-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.menu-stack.wide { width: min(560px, 92vw); }

.menu-title {
  font-size: 30px;
  color: #fff;
  text-shadow: 2px 2px 0 #3f3f3f;
  margin-bottom: 12px;
}

.opt-row {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: #e8e8e8;
  font-size: 20px;
  text-shadow: 1px 1px 0 #303030;
}
.opt-row input[type="range"] {
  width: 100%;
  accent-color: #7fbf4f;
  cursor: pointer;
}
.opt-row.checks {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 8px 0;
}

.controls-grid {
  display: grid;
  grid-template-columns: auto auto;
  gap: 4px 28px;
  color: #e8e8e8;
  font-size: 20px;
  text-shadow: 1px 1px 0 #303030;
  background: rgba(0,0,0,0.35);
  border: 2px solid #555;
  padding: 14px 20px;
}
.controls-grid span:nth-child(odd) { color: #a8d08f; }
.controls-note { color: #ffd75e; font-size: 18px; text-shadow: 1px 1px 0 #303030; }

/* ======================= multiplayer ======================= */

#online-menu { pointer-events: auto; }

.online-window {
  width: min(920px, 94vw);
  max-height: 92vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.online-layout {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.9fr);
  gap: 14px;
}

.online-section {
  min-height: 250px;
  background: rgba(0,0,0,0.42);
  border: 2px solid #555;
  box-shadow: inset 2px 2px 0 rgba(255,255,255,0.12), inset -2px -2px 0 rgba(0,0,0,0.4);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.online-heading {
  color: #a8d08f;
  font-size: 22px;
  text-shadow: 2px 2px 0 #202020;
}

.online-name-row {
  display: flex;
  gap: 8px;
  width: 100%;
}

#online-player-name,
#host-lobby-name,
#host-seed-input,
#host-max-players {
  min-width: 0;
  width: 100%;
  font-family: var(--pixel-font);
  font-size: 20px;
  color: #e8e8e8;
  background: #080808;
  border: 2px solid #8a8a8a;
  outline: none;
  padding: 7px 9px;
}

#host-max-players { width: 76px; flex: 0 0 76px; }

.mc-select {
  font-family: var(--pixel-font);
  font-size: 18px;
  color: #e8e8e8;
  background: #080808;
  border: 2px solid #8a8a8a;
  outline: none;
  padding: 7px 9px;
  flex: 0 0 auto;
}
.mc-select:focus { border-color: #fff; }

#online-player-name:focus,
#host-lobby-name:focus,
#host-seed-input:focus,
#host-max-players:focus {
  border-color: #fff;
}

.server-list {
  min-height: 178px;
  max-height: 46vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.server-row {
  width: 100%;
  min-height: 68px;
  border: 2px solid #2a2a2a;
  background: rgba(70,70,70,0.75);
  box-shadow: inset 2px 2px 0 rgba(255,255,255,0.18), inset -2px -2px 0 rgba(0,0,0,0.35);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
}

.server-row:hover {
  border-color: #fff;
  background: rgba(90,98,142,0.82);
}

.server-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.server-name {
  color: #fff;
  font-size: 23px;
  text-shadow: 2px 2px 0 #202020;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.server-meta {
  color: #cfcfcf;
  font-size: 18px;
  text-shadow: 1px 1px 0 #202020;
}

.server-empty {
  color: #cfcfcf;
  font-size: 20px;
  text-align: center;
  padding: 34px 10px;
  border: 2px dashed rgba(255,255,255,0.24);
}

.online-status {
  width: 100%;
  min-height: 28px;
  color: #d8d8d8;
  font-size: 20px;
  text-align: center;
  text-shadow: 1px 1px 0 #202020;
}

.online-status.error { color: #ff7777; }
.online-status.warn { color: #ffd75e; }
.online-status.ok { color: #a8d08f; }

.online-note {
  color: #cfcfcf;
  font-size: 18px;
  line-height: 1.15;
  text-shadow: 1px 1px 0 #202020;
}

@media (max-width: 760px) {
  .online-layout { grid-template-columns: 1fr; }
  .online-window { max-height: 96vh; overflow-y: auto; }
  .server-row { grid-template-columns: 1fr; }
  .online-name-row { flex-wrap: wrap; }
  .online-name-row .mc-button { width: 100%; }
}

/* ======================= loading ======================= */

#loading-screen { background: #2c2156; background: linear-gradient(#1c1633, #3a2d6b); }

.loading-stack { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.loading-text { color: #fff; font-size: 28px; text-shadow: 2px 2px 0 #1a1a1a; }
.loading-bar {
  width: min(420px, 80vw);
  height: 12px;
  border: 2px solid #fff;
  background: #000;
  padding: 2px;
}
#loading-fill { height: 100%; width: 0%; background: #6ec24a; transition: width 0.15s linear; }
.loading-tip { color: #b9b9d8; font-size: 20px; }

/* ======================= HUD ======================= */

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }

#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%);
  mix-blend-mode: difference;
}
#crosshair::before, #crosshair::after {
  content: '';
  position: absolute;
  background: #ddd;
}
#crosshair::before { left: 50%; top: 0; width: 2px; height: 100%; transform: translateX(-50%); }
#crosshair::after { top: 50%; left: 0; height: 2px; width: 100%; transform: translateY(-50%); }

/* --------- hotbar --------- */

#hotbar {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  background: rgba(12, 12, 12, 0.55);
  border: 2px solid rgba(0, 0, 0, 0.8);
  outline: 2px solid rgba(255, 255, 255, 0.25);
}

.hotbar-slot {
  width: 54px;
  height: 54px;
  border: 2px solid rgba(255,255,255,0.18);
  border-right-width: 1px;
  border-left-width: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.hotbar-slot img { width: 44px; height: 44px; image-rendering: auto; }
.hotbar-slot .slot-num {
  position: absolute;
  top: 1px;
  left: 3px;
  font-size: 14px;
  color: rgba(255,255,255,0.6);
  text-shadow: 1px 1px 0 #000;
}
.hotbar-slot .slot-count {
  position: absolute;
  right: 3px;
  bottom: 1px;
  font-size: 18px;
  font-weight: bold;
  color: #fff;
  text-shadow: 2px 2px 0 #000;
  pointer-events: none;
  z-index: 3;
}
.hotbar-slot.selected {
  border: 3px solid #fff;
  outline: 2px solid #999;
  z-index: 2;
}

#item-name {
  position: absolute;
  bottom: 76px;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 24px;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.7);
  opacity: 0;
  transition: opacity 0.4s ease;
}

/* --------- health hearts --------- */

#hearts {
  position: absolute;
  bottom: 72px;
  left: 50%;
  transform: translateX(-50%);
  width: 490px;
  max-width: 96vw;
  display: flex;
  gap: 1px;
  pointer-events: none;
}
#hearts img {
  width: 22px;
  height: 22px;
  image-rendering: pixelated;
  filter: drop-shadow(1px 1px 0 rgba(0, 0, 0, 0.6));
}

.death-title { color: #ff5555; }

/* --------- debug (F3) --------- */

#debug {
  position: absolute;
  top: 6px;
  left: 6px;
  color: #fff;
  font-size: 17px;
  line-height: 1.25;
  text-shadow: 1px 1px 0 #000;
  background: rgba(16,16,16,0.35);
  padding: 6px 10px;
  white-space: pre;
}

/* --------- water / effects --------- */

#underwater-overlay {
  position: absolute;
  inset: 0;
  background: rgba(20, 60, 160, 0.28);
  opacity: 0;
  transition: opacity 0.2s;
}

/* ======================= chat (8-bit, bottom-left) ======================= */
#chat-log {
  position: absolute;
  left: 10px;
  bottom: 92px;
  max-width: 46vw;
  display: flex;
  flex-direction: column;
  gap: 3px;
  pointer-events: none;
  z-index: 12;
}
#chat-log .chat-line {
  font-family: var(--logo-font);
  font-size: 10px;
  line-height: 1.5;
  color: #ffffff;
  text-shadow: 2px 2px 0 #000;
  background: rgba(0, 0, 0, 0.35);
  padding: 3px 6px;
  width: fit-content;
  max-width: 100%;
  word-break: break-word;
  image-rendering: pixelated;
  transition: opacity 0.6s;
}
#chat-log .chat-line .chat-name { color: #f7d23b; }       /* sender name, gold */
#chat-log .chat-line.whisper { color: #d77bff; }          /* private messages, purple */
#chat-log .chat-line.system { color: #8fd3ff; }           /* system/server notices */
#chat-input {
  position: absolute;
  left: 10px;
  bottom: 66px;
  width: 46vw;
  font-family: var(--logo-font);
  font-size: 10px;
  color: #fff;
  background: rgba(0, 0, 0, 0.6);
  border: 2px solid #555;
  padding: 6px 8px;
  outline: none;
  z-index: 13;
  image-rendering: pixelated;
}
#chat-tip {
  position: absolute;
  left: 10px;
  bottom: 50px;
  font-family: var(--logo-font);
  font-size: 7px;
  color: #bdbdbd;
  text-shadow: 1px 1px 0 #000;
  z-index: 13;
}

/* submerged in lava: dense, hot orange murk (like the underwater tint, redder) */
#lava-overlay {
  position: absolute;
  inset: 0;
  background: rgba(210, 70, 10, 0.82);
  opacity: 0;
  transition: opacity 0.15s;
}

#damage-vignette {
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 120px rgba(255, 40, 20, 0.85);
  opacity: 0;
  transition: opacity 0.1s;
}

/* on-fire overlay: flames licking up from the bottom of the screen */
#fire-overlay {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 70% at 50% 115%, rgba(255, 150, 30, 0.85), rgba(255, 90, 10, 0.35) 40%, transparent 70%),
    linear-gradient(to top, rgba(255, 110, 20, 0.6), transparent 45%);
  box-shadow: inset 0 0 140px rgba(255, 90, 10, 0.6);
  transition: opacity 0.08s;
}

/* ======================= picker ======================= */

#picker { background: rgba(16, 16, 16, 0.55); pointer-events: auto; }

/* --------- survival inventory --------- */

.inv-window {
  background: #c6c6c6;
  border: 3px solid #000;
  box-shadow: inset 3px 3px 0 #ffffff, inset -3px -3px 0 #555555, 0 10px 30px rgba(0,0,0,0.5);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.inv-window .menu-title { color: #3f3f3f; font-size: 24px; }
.inv-grid {
  display: grid;
  grid-template-columns: repeat(9, 52px);
  gap: 4px;
}
.inv-hotbar-row { margin-top: 6px; }
.inv-slot {
  width: 52px;
  height: 52px;
  background: #8b8b8b;
  border: 2px solid #373737;
  box-shadow: inset 2px 2px 0 #313131, inset -2px -2px 0 #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
}
.inv-slot:hover { background: #a8a8c0; }
.inv-slot img { width: 42px; height: 42px; image-rendering: auto; pointer-events: none; }
.inv-slot .slot-count {
  position: absolute;
  right: 3px;
  bottom: 0;
  font-size: 18px;
  font-weight: bold;
  color: #fff;
  text-shadow: 2px 2px 0 #000;
  pointer-events: none;
}
/* durability bar (tools) — shown on hotbar + inventory slots */
.dur-bar {
  position: absolute;
  left: 5px; right: 5px; bottom: 4px;
  height: 4px;
  background: #1a1a1a;
  pointer-events: none;
  z-index: 2;
}
.dur-bar i { display: block; height: 100%; width: 100%; }

.inv-hint { font-size: 14px; color: #555; }
.inv-craft-row { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.inv-craft-label { color: #3f3f3f; font-size: 16px; width: 70px; text-align: right; }
.inv-craft-grid { grid-template-columns: repeat(3, 52px); }
.inv-chest-grid { margin-bottom: 10px; border-bottom: 2px solid #8b8b8b; padding-bottom: 10px; }
.inv-arrow { color: #5a5a5a; font-size: 30px; }
.inv-result { display: flex; }
.inv-result .inv-slot { width: 60px; height: 60px; background: #9a9a9a; }

/* recipe book */
#recipe-book { z-index: 60; }
.recipe-window { background: #c6c6c6; border: 4px solid #373737; padding: 16px; width: min(640px, 90vw); max-height: 80vh; display: flex; flex-direction: column; box-shadow: 0 0 0 2px #fff inset; }
.recipe-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.recipe-list { display: grid; grid-template-columns: repeat(auto-fill, 48px); gap: 6px; overflow-y: auto; padding: 4px; }
.recipe-item { width: 48px; height: 48px; background: #8b8b8b; border: 2px solid #555; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.recipe-item:hover { background: #a8a8c0; }
.recipe-item img { width: 40px; height: 40px; image-rendering: auto; pointer-events: none; }
.recipe-detail { overflow-y: auto; padding: 6px; }
.recipe-name { font-size: 20px; color: #2a2a2a; margin-bottom: 12px; text-align: center; }
.recipe-craft { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; justify-content: center; }
.recipe-grid { display: grid; gap: 3px; }
.recipe-cell { width: 40px; height: 40px; background: #8b8b8b; border: 2px solid #555; display: flex; align-items: center; justify-content: center; position: relative; }
.recipe-cell img { width: 34px; height: 34px; image-rendering: auto; }
.recipe-cell.result { width: 52px; height: 52px; background: #9a9a9a; }
.recipe-cell.result img { width: 44px; height: 44px; }
.recipe-cell.result span { position: absolute; right: 2px; bottom: 0; color: #fff; font-size: 16px; text-shadow: 1px 1px #000; }
.recipe-arrow { color: #5a5a5a; font-size: 28px; }
.recipe-arrow-fire { font-size: 22px; }
.recipe-tag { color: #5a5a5a; font-size: 13px; font-style: italic; }
.recipe-tag-fire { color: #c8531a; font-weight: bold; font-style: normal; }

/* furnace panel */
.inv-furnace-row { display: flex; align-items: center; gap: 18px; margin-bottom: 10px; padding-bottom: 10px; border-bottom: 2px solid #8b8b8b; justify-content: center; }
.inv-furnace-col { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.inv-flame { width: 26px; height: 26px; background: #3a3a3a; border: 2px solid #555; position: relative; }
.inv-flame-fill { position: absolute; left: 0; bottom: 0; width: 100%; height: 0%; background: linear-gradient(#ffd24a, #ff7a18); }
.inv-furnace-arrow { width: 70px; height: 16px; background: #3a3a3a; border: 2px solid #555; position: relative; }
.inv-furnace-arrow-fill { position: absolute; left: 0; top: 0; height: 100%; width: 0%; background: #c8b86a; }
.inv-cursor {
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 48px;
  height: 48px;
  margin: -24px 0 0 -24px; /* center on the pointer */
  pointer-events: none;
  display: none;
}
.inv-cursor img { width: 44px; height: 44px; image-rendering: auto; }
.inv-cursor .slot-count {
  position: absolute;
  right: 2px;
  bottom: -2px;
  font-size: 18px;
  font-weight: bold;
  color: #fff;
  text-shadow: 2px 2px 0 #000;
}

.picker-window {
  background: #c6c6c6;
  border: 3px solid #000;
  box-shadow:
    inset 3px 3px 0 #ffffff,
    inset -3px -3px 0 #555555,
    0 10px 30px rgba(0,0,0,0.5);
  padding: 14px 16px;
  max-width: min(640px, 94vw);
}

.picker-title {
  font-size: 22px;
  color: #3f3f3f;
  margin-bottom: 10px;
}
.picker-hint { font-size: 16px; color: #6e6e6e; }

#picker-grid {
  display: grid;
  grid-template-columns: repeat(9, 52px);
  gap: 4px;
  max-height: 52vh;
  overflow-y: auto;
  padding: 6px;
  background: #8b8b8b;
  border: 2px solid #373737;
  box-shadow: inset 2px 2px 0 #313131, inset -2px -2px 0 #ffffff;
}

.picker-cell {
  width: 52px;
  height: 52px;
  background: #8b8b8b;
  border: 1px solid #6f6f6f;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
}
.picker-cell:hover { background: #a8a8c0; }
.picker-cell img { width: 42px; height: 42px; }

.picker-hotbar {
  margin-top: 12px;
  display: flex;
  justify-content: center;
  gap: 4px;
}
.picker-hotbar .hotbar-slot {
  background: #8b8b8b;
  border: 2px solid #373737;
  cursor: pointer;
}
.picker-hotbar .hotbar-slot.selected { border-color: #fff; background: #a8a8c0; }

/* tooltip */
.picker-cell::after {
  content: attr(data-name);
  position: absolute;
  bottom: 105%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(16, 0, 32, 0.92);
  border: 1px solid #4a2a7a;
  color: #fff;
  font-size: 17px;
  padding: 2px 8px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  z-index: 5;
}
.picker-cell:hover::after { opacity: 1; }

/* scrollbars */
#picker-grid::-webkit-scrollbar { width: 12px; }
#picker-grid::-webkit-scrollbar-track { background: #6f6f6f; }
#picker-grid::-webkit-scrollbar-thumb { background: #c6c6c6; border: 2px solid #373737; }
