/* Blockverse — pixel game UI */
@font-face {
  font-family: 'BVPixel';
  src: local('Courier New');
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; background: #0b0e1a; }
body {
  font-family: 'BVPixel', 'Courier New', monospace;
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
#game { position: fixed; inset: 0; display: block; }

/* ---------- screens ---------- */
.screen {
  position: fixed; inset: 0; z-index: 30;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #1a2340 0%, #0d1122 60%, #070a14 100%);
}
.screen.hidden { display: none; }
.logo {
  font-size: clamp(42px, 9vw, 84px);
  font-weight: bold;
  letter-spacing: 0.06em;
  color: #8ee06a;
  text-shadow: 0 4px 0 #3d6631, 0 8px 18px rgba(0,0,0,0.6);
  margin-bottom: 6px;
}
.tagline { color: #9fb4d8; margin-bottom: 34px; font-size: 15px; letter-spacing: 0.12em; }
.menu-col { display: flex; flex-direction: column; gap: 14px; width: min(86vw, 340px); }
.btn {
  font-family: inherit;
  font-size: 18px;
  padding: 14px 22px;
  color: #fff;
  background: linear-gradient(180deg, #7c8794 0%, #5c6672 55%, #4a525c 100%);
  border: 2px solid #2c3138;
  border-bottom-width: 4px;
  border-radius: 4px;
  cursor: pointer;
  text-shadow: 0 2px 0 rgba(0,0,0,0.45);
  transition: filter 0.08s;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: translateY(2px); border-bottom-width: 2px; }
.btn.primary { background: linear-gradient(180deg, #83c95e 0%, #5da43d 55%, #4c8a30 100%); border-color: #2d5218; }
.btn.danger { background: linear-gradient(180deg, #d95f5f 0%, #b04343 60%, #8f3535 100%); border-color: #5c2020; }
.btn.small { font-size: 14px; padding: 9px 14px; }
.seedrow { display: flex; gap: 10px; width: min(86vw, 340px); }
.seedrow input {
  flex: 1; font-family: inherit; font-size: 16px; padding: 12px;
  background: #10141f; color: #fff; border: 2px solid #2c3138; border-radius: 4px;
}
.worldlist { display: flex; flex-direction: column; gap: 10px; width: min(86vw, 400px); max-height: 46vh; overflow-y: auto; }
.worlditem {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,0.06); border: 2px solid #2c3138; border-radius: 6px;
  padding: 12px 14px; cursor: pointer;
}
.worlditem:hover { border-color: #83c95e; }
.worlditem .wname { font-size: 16px; }
.worlditem .wmeta { font-size: 12px; color: #8296b8; }
.hint { font-size: 11px; color: #8296b8; font-weight: normal; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 20; }
#crosshair {
  position: absolute; left: 50%; top: 50%; width: 22px; height: 22px;
  transform: translate(-50%, -50%); opacity: 0.85;
}
#crosshair::before, #crosshair::after {
  content: ''; position: absolute; background: #fff; mix-blend-mode: difference;
}
#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%); }
#hearts { position: absolute; left: 50%; bottom: 92px; transform: translateX(-50%); display: flex; gap: 3px; align-items: center; }
.heart { width: 18px; height: 18px; display: inline-block; position: relative; }
.heart.full::before, .heart.half::before {
  content: ''; position: absolute; inset: 0;
  background: #e63b3b; clip-path: path('M9 17 C2 11 0 7 0 4.5 A4.5 4.5 0 0 1 9 3 A4.5 4.5 0 0 1 18 4.5 C18 7 16 11 9 17 Z');
  box-shadow: inset -2px -2px 0 rgba(0,0,0,0.25);
}
.heart.half::before { clip-path: path('M9 17 C2 11 0 7 0 4.5 A4.5 4.5 0 0 1 9 3 Z'); }
.heart.empty { opacity: 0.25; background: #333; clip-path: path('M9 17 C2 11 0 7 0 4.5 A4.5 4.5 0 0 1 9 3 A4.5 4.5 0 0 1 18 4.5 C18 7 16 11 9 17 Z'); }
.heart .air { font-size: 14px; }
#hotbar {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  display: flex; gap: 4px; pointer-events: auto;
  background: rgba(10, 12, 20, 0.55); padding: 5px; border-radius: 8px;
  border: 2px solid rgba(255,255,255,0.14);
}
.slot {
  width: 46px; height: 46px; position: relative;
  background: rgba(0,0,0,0.35);
  border: 2px solid rgba(255,255,255,0.18); border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.slot.sel { border-color: #fff; box-shadow: 0 0 0 2px rgba(255,255,255,0.35); background: rgba(255,255,255,0.12); }
.slot .cnt { position: absolute; right: 3px; bottom: 1px; font-size: 13px; font-weight: bold; text-shadow: 0 2px 2px #000; }
#bname {
  position: absolute; left: 50%; bottom: 74px; transform: translateX(-50%);
  font-size: 14px; text-shadow: 0 2px 2px #000; opacity: 0; transition: opacity 0.4s;
}
#toast {
  position: absolute; left: 50%; top: 14%; transform: translateX(-50%);
  background: rgba(12, 16, 26, 0.85); border: 2px solid rgba(255,255,255,0.2);
  padding: 10px 18px; border-radius: 6px; font-size: 15px;
  opacity: 0; transition: opacity 0.25s; pointer-events: none;
}
#toast.show { opacity: 1; }
#dmgflash {
  position: absolute; inset: 0; background: radial-gradient(ellipse at center, rgba(220,20,20,0.0) 40%, rgba(220,20,20,0.55) 100%);
  opacity: 0; transition: opacity 0.12s;
}
#debug { position: absolute; left: 10px; top: 10px; font-size: 12px; color: #b7f7a1; text-shadow: 0 1px 2px #000; display: none; line-height: 1.5; }

/* ---------- touch UI ---------- */
#touchui { position: fixed; inset: 0; z-index: 22; pointer-events: none; display: none; }
#joy {
  position: absolute; left: 26px; bottom: 96px; width: 124px; height: 124px;
  border-radius: 50%; background: rgba(255,255,255,0.09);
  border: 2px solid rgba(255,255,255,0.25);
  pointer-events: auto; touch-action: none;
}
#joyknob {
  position: absolute; left: 50%; top: 50%; width: 54px; height: 54px;
  margin: -27px 0 0 -27px; border-radius: 50%;
  background: rgba(255,255,255,0.35); border: 2px solid rgba(255,255,255,0.5);
  transition: transform 0.06s;
}
#lookpad {
  position: absolute; right: 0; top: 0; width: 55%; height: 62%;
  pointer-events: auto; touch-action: none;
}
#btns { position: absolute; right: 18px; bottom: 88px; display: grid; grid-template-columns: repeat(3, auto); gap: 10px; align-items: end; }
.tbtn {
  width: 64px; height: 64px; font-size: 26px;
  border-radius: 50%; border: 2px solid rgba(255,255,255,0.35);
  background: rgba(20, 26, 40, 0.55); color: #fff;
  pointer-events: auto; touch-action: none;
}
.tbtn:active { background: rgba(255,255,255,0.3); }
.tbtn.small { width: 46px; height: 46px; font-size: 19px; }
.tbtn.small:nth-child(-n+3) { grid-column: span 1; }

/* ---------- inventory ---------- */
#invscreen {
  position: fixed; inset: 0; z-index: 25; display: none;
  align-items: center; justify-content: center;
  background: rgba(8, 10, 18, 0.72);
}
#invscreen.show { display: flex; }
.invbox {
  width: min(92vw, 560px); max-height: 88vh;
  background: #1b2130; border: 3px solid #3a4356; border-radius: 10px;
  display: flex; flex-direction: column;
}
.invbox h3 { margin: 10px 18px 8px; font-size: 17px; color: #cfe3b8; }
.invscroll { overflow-y: auto; padding: 0 18px; min-height: 0; }
.invgrid { display: grid; grid-template-columns: repeat(auto-fill, 50px); gap: 5px; }
.craftlist { display: flex; flex-direction: column; gap: 6px; padding-bottom: 10px; }
.invfoot { padding: 10px 18px 14px; }
.recipe {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,0.05); border: 2px solid #333c4e; border-radius: 6px;
  padding: 6px 10px; cursor: pointer; opacity: 0.55;
}
.recipe.ok { opacity: 1; border-color: #83c95e; }
.recipe small { display: block; color: #93a7c9; font-size: 12px; }
#invclose { width: 100%; }

/* block catalog tabs */
.cattabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0; }
.cattab {
  background: rgba(255,255,255,0.07); color: #cfe3b8;
  border: 2px solid #333c4e; border-radius: 6px;
  padding: 3px 9px; font: inherit; font-size: 12px; cursor: pointer;
}
.cattab.on { border-color: #83c95e; background: rgba(131,201,94,0.18); }
#catalog { margin-bottom: 8px; }
.slot.cat { cursor: pointer; }

/* settings panel */
.settingspanel {
  margin-top: 14px; padding: 14px 18px;
  background: rgba(10, 16, 28, 0.72); border: 2px solid #3a4a63; border-radius: 10px;
  min-width: 260px; max-width: 88vw;
}
.settingspanel.hidden { display: none; }
.settingspanel h3 { margin: 0 0 10px; color: #f2d06b; }
.setrow { display: flex; align-items: center; gap: 10px; margin: 10px 0; font-size: 14px; }
.setrow input[type="range"] { flex: 1; min-width: 120px; }
#sensVal { min-width: 42px; color: #83c95e; font-weight: bold; }
.setrow input[type="checkbox"] { width: 18px; height: 18px; }

/* pause menu overlay */
#pausescreen { z-index: 40; }
.overlay-title { font-size: 30px; margin-bottom: 20px; text-shadow: 0 3px 0 rgba(0,0,0,0.5); }
