@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');

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

:root {
  --font: 'VT323', 'Courier New', monospace;
}

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

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

.hidden { display: none !important; }

/* ================= Screens ================= */
.screen {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 24px; overflow-y: auto;
}
.menu-bg {
  background:
    linear-gradient(rgba(16, 14, 26, 0.55), rgba(16, 14, 26, 0.75)),
    repeating-conic-gradient(#3e2f23 0% 25%, #46362a 0% 50%) 0 0 / 96px 96px;
  image-rendering: pixelated;
}
.overlay { background: rgba(20, 20, 20, 0.65); z-index: 60; }
.overlay.death { background: rgba(120, 0, 0, 0.55); }

.title-wrap { text-align: center; margin-bottom: 10px; }
.game-title {
  font-size: 84px; letter-spacing: 6px; color: #e8e8e8;
  text-shadow: 4px 4px 0 #3f3f3f, 8px 8px 0 rgba(0,0,0,0.5);
}
.game-subtitle { font-size: 28px; color: #ffff55; text-shadow: 2px 2px 0 #3f3f00; margin-top: -8px; }
.splash {
  display: inline-block; margin-top: 8px; color: #ffff55; font-size: 22px;
  text-shadow: 2px 2px 0 #3f3f00; transform: rotate(-6deg);
  animation: splash-pulse 0.8s ease-in-out infinite alternate;
}
@keyframes splash-pulse { from { transform: rotate(-6deg) scale(1); } to { transform: rotate(-6deg) scale(1.08); } }

.screen-title { color: #fff; font-size: 40px; text-shadow: 2px 2px 0 #383838; }
.death-title { color: #fff; font-size: 64px; text-shadow: 3px 3px 0 #550000; }
.death-info { color: #ffdddd; font-size: 24px; }

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

.btn {
  font-family: var(--font); font-size: 24px; color: #e0e0e0; cursor: pointer;
  background: linear-gradient(#8d8d8d, #6f6f6f 45%, #5a5a5a);
  border: 2px solid #000; box-shadow: inset 2px 2px 0 rgba(255,255,255,0.35), inset -2px -2px 0 rgba(0,0,0,0.35);
  padding: 8px 18px; text-shadow: 2px 2px 0 rgba(0,0,0,0.5);
}
.btn:hover { background: linear-gradient(#9fa4c4, #7d84b0 45%, #666da0); color: #ffffa0; }
.btn:active { transform: translateY(1px); }
.btn-wide { width: 380px; max-width: 90vw; }
.btn-mode { flex: 1; font-size: 20px; }
.btn-mode.selected { background: linear-gradient(#5f8f4f, #4a7a3c 45%, #3b6330); color: #fff; }
.btn-mode.hardcore.selected { background: linear-gradient(#a04040, #8a3030 45%, #702424); }

.panel {
  background: rgba(0, 0, 0, 0.55); border: 2px solid #000;
  box-shadow: inset 2px 2px 0 rgba(255,255,255,0.12);
  padding: 16px 20px; width: 520px; max-width: 92vw;
  display: flex; flex-direction: column; gap: 10px;
}
.panel-title { color: #ffff88; font-size: 24px; }
.form-row { display: flex; align-items: center; gap: 12px; }
.form-row label { color: #ccc; font-size: 22px; width: 120px; }
.form-row input[type=text] {
  flex: 1; font-family: var(--font); font-size: 22px; color: #eee;
  background: #111; border: 2px solid #555; padding: 4px 8px; outline: none;
}
.form-row input[type=text]:focus { border-color: #aaa; }
.mode-select { display: flex; gap: 8px; flex: 1; }
.mode-desc { color: #999; font-size: 19px; min-height: 22px; }

.world-list { display: flex; flex-direction: column; gap: 8px; width: 520px; max-width: 92vw; max-height: 30vh; overflow-y: auto; }
.world-entry {
  display: flex; align-items: center; gap: 10px;
  background: rgba(0,0,0,0.5); border: 2px solid #333; padding: 8px 12px;
}
.world-entry .w-info { flex: 1; }
.world-entry .w-name { color: #fff; font-size: 24px; }
.world-entry .w-meta { color: #999; font-size: 18px; }
.world-entry .w-meta .hc { color: #ff5555; }
.world-empty { color: #888; font-size: 22px; text-align: center; }

.settings-panel .setting-row { display: flex; align-items: center; gap: 12px; }
.setting-row label { color: #ccc; font-size: 22px; width: 200px; }
.setting-row input[type=range] { flex: 1; accent-color: #7d84b0; }
.setting-row span { color: #ffff88; font-size: 22px; width: 60px; text-align: right; }

.controls-panel { gap: 4px; }
.controls-grid { display: grid; grid-template-columns: 140px 1fr; gap: 2px 14px; }
.controls-grid span { color: #aaa; font-size: 19px; }
.controls-grid span:nth-child(odd) { color: #ffff88; }

.footer-text { position: absolute; bottom: 8px; left: 10px; color: rgba(255,255,255,0.45); font-size: 18px; }
.footer-text.right { left: auto; right: 10px; color: #ff8888; }

.progress-outer { width: 420px; max-width: 80vw; height: 26px; border: 2px solid #fff; background: #222; }
.progress-inner { height: 100%; width: 0%; background: #4a7a3c; transition: width 0.1s linear; }

/* ================= HUD ================= */
#hud { position: fixed; inset: 0; z-index: 20; pointer-events: none; }

#crosshair {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -52%);
  color: rgba(255,255,255,0.85); font-size: 30px; text-shadow: 1px 1px 0 rgba(0,0,0,0.6);
}

#break-bar-wrap {
  position: absolute; left: 50%; top: 55%; transform: translateX(-50%);
  width: 80px; height: 8px; background: rgba(0,0,0,0.5); border: 1px solid #000;
}
#break-bar { height: 100%; width: 0%; background: #ddd; }

#hotbar {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 0;
}
#status-bars {
  position: absolute; bottom: 62px; left: 50%; transform: translateX(-50%);
  width: 424px; display: flex; justify-content: space-between;
}
.icon-row { display: flex; gap: 1px; }
.icon-row img { width: 18px; height: 18px; image-rendering: pixelated; }
#hunger { flex-direction: row-reverse; }

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

#toasts { position: absolute; bottom: 120px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.toast { color: #ffff88; font-size: 21px; text-shadow: 2px 2px 0 rgba(0,0,0,0.7); animation: toast-fade 2.5s forwards; }
@keyframes toast-fade { 0% { opacity: 0; transform: translateY(8px); } 10% { opacity: 1; transform: none; } 75% { opacity: 1; } 100% { opacity: 0; } }

#overlay-damage {
  position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 40%, rgba(200,0,0,0.55));
  opacity: 0; transition: opacity 0.12s;
}
#overlay-water { position: absolute; inset: 0; background: rgba(20, 60, 180, 0.35); opacity: 0; }

/* ================= Slots / Inventory ================= */
.slot {
  width: 44px; height: 44px; position: relative;
  background: #8b8b8b;
  border: 2px solid; border-color: #373737 #ffffff #ffffff #373737;
  display: flex; align-items: center; justify-content: center;
  pointer-events: auto; cursor: pointer;
}
.slot img { width: 34px; height: 34px; image-rendering: pixelated; pointer-events: none; }
.slot .cnt {
  position: absolute; right: 2px; bottom: 0; color: #fff; font-size: 19px;
  text-shadow: 1px 1px 0 #000; pointer-events: none;
}
.slot .dur { position: absolute; left: 3px; bottom: 3px; height: 3px; background: #3f3; pointer-events: none; }
.slot.selected { outline: 3px solid #fff; z-index: 2; }
.slot.result { width: 52px; height: 52px; }

#hotbar .slot { background: rgba(90, 90, 90, 0.8); border-color: #222 #aaa #aaa #222; }

#ui-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 30; }
#ui-window {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 35;
  background: #c6c6c6; border: 3px solid; border-color: #fff #555 #555 #fff;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
}
#ui-window .win-title { color: #3f3f3f; font-size: 24px; }
.grid-row { display: flex; gap: 2px; }
.grid-col { display: flex; flex-direction: column; gap: 2px; }
.craft-area { display: flex; align-items: center; gap: 14px; }
.craft-arrow { color: #555; font-size: 36px; }
.furnace-col { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.furnace-flame { font-size: 26px; }
.inv-section-label { color: #3f3f3f; font-size: 20px; margin-top: 2px; }
.creative-grid {
  display: grid; grid-template-columns: repeat(9, 44px); gap: 2px;
  max-height: 240px; overflow-y: auto; padding-right: 4px;
}

#cursor-item { position: fixed; z-index: 40; pointer-events: none; width: 36px; height: 36px; }
#cursor-item img { width: 36px; height: 36px; image-rendering: pixelated; }
#cursor-item .cnt { position: absolute; right: -2px; bottom: -4px; color: #fff; font-size: 19px; text-shadow: 1px 1px 0 #000; }

#hearts.hardcore img { filter: hue-rotate(-45deg) saturate(1.6) brightness(0.9); }
