/* UI overlays only — all game logic lives in JS. */

:root {
  --hud-bg: rgba(0, 0, 0, 0.45);
  --hud-border: rgba(255, 255, 255, 0.25);
  --accent: #7fd24d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: "Lucida Console", Monaco, monospace;
  user-select: none;
  -webkit-user-select: none;
}

#game-canvas { display: block; width: 100vw; height: 100vh; }

button {
  font-family: inherit;
  font-size: 13px;
  padding: 7px 14px;
  background: #3a3f46;
  color: #eee;
  border: 2px solid #565d66;
  border-radius: 4px;
  cursor: pointer;
}
button:hover { background: #4a525c; }
button:disabled { opacity: 0.4; cursor: default; }

/* ---------- crosshair ---------- */
#crosshair {
  position: fixed; left: 50%; top: 50%;
  width: 20px; height: 20px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  mix-blend-mode: difference;
  z-index: 3;
}
#crosshair .h, #crosshair .v { position: absolute; background: #fff; }
#crosshair .h { left: 0; top: 9px; width: 20px; height: 2px; }
#crosshair .v { left: 9px; top: 0; width: 2px; height: 20px; }

/* ---------- damage vignette / underwater ---------- */
#vignette {
  position: fixed; inset: 0; pointer-events: none; opacity: 0; z-index: 4;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(200, 20, 20, 0.55) 100%);
}
#vignette.flash { animation: dmg 0.5s ease-out; }
@keyframes dmg { 0% { opacity: 1; } 100% { opacity: 0; } }

#underwater {
  position: fixed; inset: 0;
  background: rgba(20, 60, 160, 0.35);
  pointer-events: none; display: none; z-index: 2;
}
#underwater.active { display: block; }

/* ---------- clock & toasts ---------- */
#clock {
  position: fixed; top: 8px; right: 10px;
  color: #fff; font-size: 13px; text-shadow: 1px 1px 0 #000;
  background: var(--hud-bg); padding: 5px 9px; border-radius: 4px;
  z-index: 3;
}
#toasts {
  position: fixed; top: 44px; right: 10px;
  display: flex; flex-direction: column; gap: 6px;
  z-index: 8; pointer-events: none;
}
.toast {
  background: rgba(20, 24, 18, 0.92);
  border: 2px solid var(--accent);
  border-radius: 6px;
  padding: 8px 14px;
  color: #fff; font-size: 12px;
  transform: translateX(120%);
  transition: transform 0.35s ease;
  max-width: 260px;
}
.toast.show { transform: translateX(0); }
.toast b { color: var(--accent); display: block; margin-bottom: 2px; }
.toast span { color: #bbb; font-size: 11px; }

/* ---------- HUD ---------- */
#hud { pointer-events: none; }
#debug {
  position: fixed; top: 8px; left: 8px;
  padding: 6px 8px;
  background: var(--hud-bg);
  color: #e8e8e8; font-size: 11px; line-height: 1.5;
  white-space: pre; border-radius: 4px;
  z-index: 3;
}
#hud-bottom {
  position: fixed; left: 50%; bottom: 12px;
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  z-index: 3;
}
#selected-name { color: #fff; font-size: 13px; text-shadow: 1px 1px 0 #000; min-height: 16px; }
#health { font-size: 16px; letter-spacing: 2px; text-shadow: 1px 1px 0 #000; }
#health .full { color: #e83b3b; }
#health .empty { color: #3a3a3a; }
#breath { font-size: 11px; letter-spacing: 3px; min-height: 13px; }
#breath .bubble { color: #6db9f7; }
#breath .bubble.popped { color: transparent; }

#hotbar {
  display: flex; gap: 4px; padding: 4px;
  background: var(--hud-bg);
  border: 2px solid var(--hud-border);
  border-radius: 6px;
  pointer-events: auto;
}
.slot {
  position: relative; width: 48px; height: 48px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.35);
  cursor: pointer;
}
.slot.selected { border-color: #fff; box-shadow: 0 0 6px rgba(255, 255, 255, 0.6); }
.slot.empty-item .icon { opacity: 0.25; }
.slot .icon, .slot canvas {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  image-rendering: pixelated;
}
.slot .count {
  position: absolute; right: 3px; bottom: 1px;
  color: #fff; font-size: 12px; font-weight: bold;
  text-shadow: 1px 1px 0 #000;
}
.slot .key {
  position: absolute; left: 3px; top: 1px;
  color: rgba(255, 255, 255, 0.55); font-size: 9px;
}
.slot .durability {
  position: absolute; left: 4px; right: 4px; bottom: 3px;
  height: 3px; background: #222; display: none;
}
.slot .durability div { height: 100%; width: 100%; }

/* ---------- inventory / crafting / furnace panel ---------- */
#panel {
  position: fixed; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, 92vw); max-height: 78vh;
  overflow-y: auto;
  background: rgba(18, 22, 28, 0.95);
  border: 2px solid var(--hud-border);
  border-radius: 10px;
  padding: 18px 22px;
  color: #ddd;
  z-index: 6;
}
#panel.hidden { display: none; }
#panel h2 { margin: 0 0 6px; color: var(--accent); font-size: 18px; letter-spacing: 1px; }
#panel .hint { color: #999; font-size: 11px; margin: 0 0 12px; }
#panel .hint b { color: #ffb74d; }

.inv-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.inv-cell {
  position: relative; aspect-ratio: 1;
  background: rgba(0, 0, 0, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.inv-cell:hover { border-color: var(--accent); }
.inv-cell canvas { image-rendering: pixelated; }
.inv-cell .count {
  position: absolute; right: 3px; bottom: 1px;
  color: #fff; font-size: 12px; font-weight: bold; text-shadow: 1px 1px 0 #000;
}

.recipe-list { display: flex; flex-direction: column; gap: 6px; }
.recipe {
  display: flex; align-items: center; gap: 10px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 5px; padding: 6px 10px;
}
.recipe.needs-table { opacity: 0.45; }
.recipe canvas { image-rendering: pixelated; flex-shrink: 0; }
.recipe .rname { font-size: 13px; color: #fff; min-width: 130px; }
.recipe .ring { flex: 1; font-size: 11px; color: #999; }
.recipe .ring .ok { color: #8bc34a; font-weight: normal; }
.recipe .ring .missing { color: #e0563c; font-weight: normal; }
.recipe button { padding: 4px 12px; font-size: 12px; }

/* ---------- overlays (pause + death) ---------- */
#overlay, #death {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10, 14, 20, 0.65);
  backdrop-filter: blur(2px);
  cursor: pointer; z-index: 10;
}
#overlay.hidden, #death.hidden { display: none; }
#death { background: rgba(120, 10, 10, 0.5); cursor: default; }

.panel-box {
  text-align: center; color: #eee;
  background: rgba(0, 0, 0, 0.6);
  border: 2px solid var(--hud-border);
  border-radius: 10px;
  padding: 24px 40px;
  max-width: min(620px, 94vw);
  max-height: 90vh; overflow-y: auto;
}
.panel-box h1 {
  margin: 0 0 4px; font-size: 38px; letter-spacing: 6px;
  color: var(--accent); text-shadow: 3px 3px 0 #1c3a10;
}
#death .panel-box h1 { color: #ff5544; text-shadow: 3px 3px 0 #401008; }
.panel-box .sub { margin: 0 0 14px; color: #aaa; font-size: 12px; }
.panel-box ul {
  list-style: none; margin: 0 0 16px; padding: 0;
  font-size: 12px; line-height: 2; color: #ccc;
}
.panel-box b { color: #fff; }
.btn-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 14px; }

#achievements-list {
  display: flex; flex-wrap: wrap; gap: 5px; justify-content: center;
  margin-bottom: 14px;
}
.ach {
  font-size: 10px; padding: 3px 8px; border-radius: 10px;
  background: #2a2d33; color: #777;
  border: 1px solid #3a3f46;
}
.ach.earned { background: #2c4a1e; color: #aef08c; border-color: var(--accent); }

.panel-box .cta {
  margin: 0; font-size: 15px; color: #fff;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
