:root {
  --ui: #e8eef6;
  --ui-dim: #9fb0c3;
  --accent: #6bd4ff;
  --panel: rgba(13, 18, 26, 0.82);
  --slot: rgba(255, 255, 255, 0.06);
  --slot-sel: #ffd95e;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #05070a;
  color: var(--ui);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#gl {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

/* ---- crosshair ---- */
#crosshair {
  position: fixed;
  left: 50%; top: 50%;
  width: 22px; height: 22px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  mix-blend-mode: difference;
  opacity: 0.85;
  z-index: 5;
}
#crosshair::before, #crosshair::after {
  content: "";
  position: absolute;
  background: #fff;
}
#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%); }

/* ---- underwater tint ---- */
#watertint {
  position: fixed; inset: 0;
  background: radial-gradient(circle at 50% 60%, rgba(40,110,200,0.20), rgba(20,60,140,0.55));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
  z-index: 6;
}
#watertint.on { opacity: 1; }

/* ---- hurt vignette ---- */
#damage {
  position: fixed; inset: 0;
  background: radial-gradient(ellipse at center, rgba(170,0,0,0) 42%, rgba(150,0,0,0.9) 100%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.06s linear;
  z-index: 7;
}

/* ---- survival HUD: breath bar + hearts (stacked above the hotbar) ---- */
#breath {
  position: fixed; left: 50%; bottom: 86px;
  transform: translateX(-50%);
  width: 188px; height: 6px;
  background: rgba(255,255,255,0.14);
  border-radius: 3px;
  opacity: 0;
  transition: opacity 0.2s ease;
  overflow: hidden;
  z-index: 5; pointer-events: none;
}
#breath.on { opacity: 1; }
#breathfill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, #2bd6ff, #7fe6ff);
  border-radius: 3px;
}
#hearts {
  position: fixed; left: 50%; bottom: 64px;
  transform: translateX(-50%);
  display: flex; gap: 2px;
  z-index: 5; pointer-events: none;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.85));
}
.heart {
  position: relative;
  width: 18px; height: 16px;
  font-size: 17px; line-height: 16px;
  text-align: center;
  color: #4a1414;                 /* empty heart */
}
.heart::after { content: "\2665"; }   /* ♥ */
.heart .full {
  position: absolute; inset: 0;
  width: 100%; overflow: hidden;
  color: #ff3b3b;                 /* full heart */
  text-align: center;
}
.heart .full::after { content: "\2665"; }

/* ---- HUD stats ---- */
#hud {
  position: fixed;
  top: 12px; left: 12px;
  font-size: 12px;
  line-height: 1.55;
  letter-spacing: 0.4px;
  color: var(--ui);
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  pointer-events: none;
  z-index: 5;
}
#hud .lbl { color: var(--ui-dim); }

/* ---- hotbar ---- */
#hotbar {
  position: fixed;
  left: 50%; bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 12px;
  backdrop-filter: blur(6px);
  z-index: 5;
}
.slot {
  width: 52px; height: 52px;
  border-radius: 8px;
  background: var(--slot);
  border: 2px solid transparent;
  position: relative;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.08s ease, border-color 0.1s ease;
}
.slot .icon {
  width: 38px; height: 38px;
  image-rendering: pixelated;
  border-radius: 4px;
}
.slot .num {
  position: absolute;
  top: 2px; left: 4px;
  font-size: 10px;
  color: var(--ui-dim);
}
.slot.sel {
  border-color: var(--slot-sel);
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 6px 16px rgba(255, 217, 94, 0.25);
}
.slot.sel .num { color: var(--slot-sel); }

/* ---- loading ---- */
#loading {
  position: fixed; inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  background: linear-gradient(160deg, #0b1622, #16243a);
  z-index: 30;
  transition: opacity 0.4s ease;
}
#loading.hide { opacity: 0; pointer-events: none; }
.brand { font-size: 44px; letter-spacing: 3px; font-weight: 700; }
.sub { margin-top: 10px; color: var(--ui-dim); letter-spacing: 1px; }

/* ---- overlay (start / pause) ---- */
#overlay {
  position: fixed; inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  background: rgba(5, 8, 12, 0.62);
  backdrop-filter: blur(3px);
  z-index: 20;
  transition: opacity 0.25s ease;
}
#overlay.hide { opacity: 0; pointer-events: none; }
.panel {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 16px;
  padding: 28px 36px;
  max-width: 540px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.panel .brand { font-size: 34px; }
.tagline { color: var(--ui-dim); margin: 6px 0 18px; font-size: 12px; letter-spacing: 0.5px; }
.controls {
  font-size: 12px;
  color: var(--ui-dim);
  line-height: 1.9;
  text-align: left;
  margin: 16px auto;
  max-width: 440px;
  border-top: 1px solid rgba(255,255,255,0.08);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  padding: 10px 0;
}
.controls b { color: var(--ui); font-weight: 600; }
.muted-note { color: var(--ui-dim); font-size: 11px; opacity: 0.75; margin-top: 4px; }
button {
  font-family: inherit;
  font-size: 16px;
  letter-spacing: 1px;
  color: #06121c;
  background: linear-gradient(180deg, #8fe6ff, var(--accent));
  border: none;
  border-radius: 10px;
  padding: 12px 30px;
  cursor: pointer;
  font-weight: 700;
  box-shadow: 0 6px 16px rgba(107,212,255,0.3);
  transition: transform 0.08s ease, filter 0.1s ease;
}
button:hover { filter: brightness(1.06); }
button:active { transform: translateY(1px); }
button.ghost {
  background: transparent;
  color: var(--ui-dim);
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: none;
  font-size: 12px;
  padding: 8px 16px;
  margin-top: 10px;
}
button.ghost:hover { color: #ff8a8a; border-color: rgba(255,138,138,0.4); }

/* ---- fatal ---- */
#fatal {
  position: fixed; inset: 0;
  display: grid; place-content: center;
  text-align: center;
  background: #1a0c0c;
  color: #ffb4b4;
  font-size: 14px;
  padding: 40px;
  z-index: 50;
  white-space: pre-line;
}

/* ---- death screen ---- */
#death {
  position: fixed; inset: 0;
  display: grid; place-content: center;
  text-align: center;
  background: rgba(22,4,4,0.78);
  backdrop-filter: blur(4px);
  z-index: 40;
  transition: opacity 0.25s ease;
}
#death.hide { opacity: 0; pointer-events: none; }
.death-panel { border-color: rgba(255,80,80,0.28); }
.panel .brand.death { font-size: 30px; color: #ff7a7a; }
#respawn-btn {
  background: linear-gradient(180deg, #ff9a9a, #ff5a5a);
  box-shadow: 0 6px 16px rgba(255,90,90,0.3);
  color: #1a0606;
}
