* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; background: #000; }
body { font-family: "Trebuchet MS", "Segoe UI", sans-serif; color: #fff; user-select: none; }
#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: default; }
.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#crosshair {
  position: absolute; left: 50%; top: 50%; width: 20px; height: 20px;
  transform: translate(-50%, -50%); mix-blend-mode: difference;
}
#crosshair::before, #crosshair::after {
  content: ""; position: absolute; background: #fff;
}
#crosshair::before { left: 9px; top: 0; width: 2px; height: 20px; }
#crosshair::after { top: 9px; left: 0; height: 2px; width: 20px; }

#info {
  position: absolute; left: 8px; top: 8px; font: 12px/1.45 Consolas, monospace;
  color: #fff; text-shadow: 1px 1px 0 #000; white-space: pre; opacity: .9;
}

#hotbar {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%);
  display: flex; gap: 2px; padding: 3px;
  background: rgba(0,0,0,.45); border: 2px solid rgba(0,0,0,.6); border-radius: 3px;
}
.slot {
  width: 46px; height: 46px; position: relative;
  background: rgba(120,120,120,.35); border: 2px solid rgba(60,60,60,.8);
  display: flex; align-items: center; justify-content: center;
}
.slot.sel { border-color: #fff; box-shadow: 0 0 0 2px #000 inset, 0 0 6px rgba(255,255,255,.6); background: rgba(200,200,200,.35); }
.slot canvas { width: 36px; height: 36px; image-rendering: pixelated; }
.slot .num { position: absolute; left: 2px; top: 0; font: 10px Consolas, monospace; color: #ddd; text-shadow: 1px 1px 0 #000; }

#heldname {
  position: absolute; left: 50%; bottom: 70px; transform: translateX(-50%);
  font-size: 15px; text-shadow: 2px 2px 0 #000; opacity: 0; transition: opacity .4s;
}
#heldname.show { opacity: 1; transition: none; }

#toast {
  position: absolute; left: 50%; top: 18%; transform: translateX(-50%);
  font-size: 16px; text-shadow: 2px 2px 0 #000; opacity: 0; transition: opacity .5s;
}
#toast.show { opacity: 1; transition: none; }

#vignette { position: absolute; inset: 0; box-shadow: inset 0 0 160px rgba(0,0,0,.55); }
#water-overlay { position: absolute; inset: 0; background: rgba(30,80,200,.35); opacity: 0; transition: opacity .15s; }
#water-overlay.on { opacity: 1; }

/* ---------- Screens ---------- */
.screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(10, 14, 24, .55); backdrop-filter: blur(2px);
}
#start { background: linear-gradient(180deg, #4a7fd6 0%, #86b6f0 55%, #6a9a4a 55%, #3f6a2a 100%); }
.panel {
  background: rgba(20, 20, 24, .82); border: 3px solid #000; border-radius: 4px;
  padding: 22px 28px; min-width: 380px; text-align: center;
  box-shadow: 0 0 0 3px #555 inset, 0 10px 40px rgba(0,0,0,.6);
}
.panel.wide { width: min(760px, 92vw); }
h1 { margin: 0 0 4px; font-size: 54px; letter-spacing: 2px; color: #e8e8e8;
  text-shadow: 3px 3px 0 #3a3a3a, 6px 6px 0 rgba(0,0,0,.4); }
h2 { margin: 0 0 14px; font-size: 26px; text-shadow: 2px 2px 0 #000; }
.sub { margin: 0 0 18px; color: #bbb; }
.hint { color: #aaa; font-size: 13px; margin: 14px 0 0; }
.seedrow { display: block; margin: 0 0 16px; color: #ccc; font-size: 14px; }
.seedrow input {
  margin-left: 8px; width: 200px; padding: 6px 8px; font: 14px Consolas, monospace;
  background: #111; color: #fff; border: 2px solid #555; border-radius: 2px;
}
.row { display: flex; gap: 10px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }
button {
  font: inherit; font-size: 16px; padding: 9px 18px; cursor: pointer; color: #fff;
  background: linear-gradient(#7a7a7a, #5a5a5a); border: 2px solid #000; border-radius: 3px;
  box-shadow: 0 0 0 2px #999 inset; text-shadow: 1px 1px 0 #000;
}
button:hover { background: linear-gradient(#8f9fd0, #5d6fa8); }
button:active { transform: translateY(1px); }
button.big { font-size: 20px; padding: 12px 46px; }
.controls {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 18px; text-align: left;
  margin: 18px 0 6px; font-size: 13px; color: #ccc;
}
.controls b { color: #fff; font-weight: 600; }

#pickerGrid {
  display: grid; grid-template-columns: repeat(auto-fill, 52px); gap: 4px;
  justify-content: center; max-height: 60vh; overflow-y: auto; padding: 4px;
}
.pick {
  width: 52px; height: 52px; display: flex; align-items: center; justify-content: center;
  background: rgba(120,120,120,.3); border: 2px solid #444; cursor: pointer;
}
.pick:hover { border-color: #fff; background: rgba(200,200,200,.3); }
.pick canvas { width: 40px; height: 40px; image-rendering: pixelated; }
