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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0c1220;
  font-family: 'Avenir Next', 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: #eef2f7;
}

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

.hidden {
  display: none !important;
}

.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 22px;
  height: 22px;
  opacity: 0.85;
}

.ch-v,
.ch-h {
  position: absolute;
  background: #fff;
  mix-blend-mode: difference;
}

.ch-v {
  left: 50%;
  top: 0;
  width: 2px;
  height: 100%;
  transform: translateX(-50%);
}

.ch-h {
  top: 50%;
  left: 0;
  height: 2px;
  width: 100%;
  transform: translateY(-50%);
}

.hotbar {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 5px;
  padding: 6px;
  background: rgba(12, 16, 28, 0.55);
  border-radius: 14px;
  backdrop-filter: blur(6px);
  border: 2px solid rgba(255, 255, 255, 0.12);
}

.slot {
  position: relative;
  width: 50px;
  height: 50px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.07);
  border: 2px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.slot-icon {
  width: 40px;
  height: 40px;
  image-rendering: pixelated;
  pointer-events: none;
}

.slot-count {
  position: absolute;
  right: 4px;
  bottom: 2px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px #000, 0 0 4px #000;
  pointer-events: none;
}

.hb-slot.selected {
  border-color: #ffd257;
  background: rgba(255, 210, 87, 0.14);
  box-shadow: 0 0 10px rgba(255, 210, 87, 0.35);
}

.status {
  position: absolute;
  bottom: 82px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.hearts-bar,
.armor-bar {
  display: flex;
  gap: 2px;
  height: 20px;
}

.hearts-bar img,
.armor-bar img {
  width: 18px;
  height: 18px;
  image-rendering: pixelated;
}

.toast {
  position: absolute;
  bottom: 130px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 4px #000;
  opacity: 0;
  transition: opacity 0.25s;
}

.toast.show {
  opacity: 1;
}

.hint {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
  text-shadow: 0 1px 2px #000;
  letter-spacing: 0.4px;
}

.debug {
  position: absolute;
  top: 10px;
  left: 10px;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 12px;
  line-height: 1.5;
  color: #cfe6ff;
  background: rgba(8, 10, 18, 0.65);
  padding: 8px 10px;
  border-radius: 8px;
  white-space: pre;
}

.damage-overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(200, 20, 30, 0.55) 100%);
  opacity: 0;
  pointer-events: none;
}

.damage-overlay.flash {
  animation: dmg 0.45s ease-out;
}

@keyframes dmg {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.water-overlay {
  position: absolute;
  inset: 0;
  background: rgba(24, 80, 160, 0.32);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.water-overlay.show {
  opacity: 1;
}

.screens {
  position: fixed;
  inset: 0;
  z-index: 20;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 12, 24, 0.62);
  backdrop-filter: blur(7px);
  z-index: 20;
}

#inv-screen {
  background: rgba(8, 12, 24, 0.45);
}

.title-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 42px 56px;
  border-radius: 24px;
  background: rgba(14, 20, 36, 0.82);
  border: 2px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  max-width: 92vw;
}

.title-card.small {
  padding: 32px 48px;
}

.game-title {
  font-size: 58px;
  letter-spacing: 4px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 4px 0 #2c6e31, 0 8px 24px rgba(0, 0, 0, 0.6);
}

.game-title span {
  color: #8ae651;
}

.subtitle {
  color: rgba(255, 255, 255, 0.6);
  font-size: 15px;
  margin-top: -8px;
  letter-spacing: 1px;
}

.btn {
  pointer-events: auto;
  font-family: inherit;
  font-size: 17px;
  font-weight: 700;
  padding: 12px 34px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  transition: transform 0.08s, background 0.15s;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.16);
  transform: translateY(-1px);
}

.btn.primary {
  background: #43b649;
  border-color: #2c8a32;
  box-shadow: 0 6px 0 #2c6e31, 0 10px 24px rgba(0, 0, 0, 0.35);
}

.btn.primary:hover {
  background: #4ec955;
}

.btn.danger {
  background: rgba(220, 60, 60, 0.16);
  border-color: rgba(220, 60, 60, 0.4);
  font-size: 13px;
  padding: 8px 20px;
}

.btn.small {
  font-size: 13px;
  padding: 8px 20px;
}

.controls-grid {
  display: grid;
  grid-template-columns: auto auto;
  gap: 4px 18px;
  font-size: 13.5px;
  color: rgba(255, 255, 255, 0.78);
}

.controls-grid span:nth-child(odd) {
  font-weight: 700;
  color: #ffd257;
  text-align: right;
}

.danger-text {
  color: #ff6b6b;
}

.progress {
  width: 320px;
  height: 14px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #43b649, #8ae651);
  transition: width 0.15s;
}

.inv-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 22px 26px;
  border-radius: 18px;
  background: rgba(14, 20, 36, 0.9);
  border: 2px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

.inv-title {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #ffd257;
}

.inv-top {
  display: flex;
  align-items: center;
  gap: 28px;
  min-height: 120px;
}

.armor-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.armor-slot {
  width: 46px;
  height: 46px;
}

.armor-slot .slot-icon {
  width: 36px;
  height: 36px;
}

.craft-area {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
}

.craft-grid {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.craft-row {
  display: flex;
  gap: 5px;
}

.craft-arrow {
  font-size: 30px;
  color: rgba(255, 255, 255, 0.5);
  font-weight: 300;
}

.result-slot {
  width: 58px;
  height: 58px;
  border-color: rgba(255, 210, 87, 0.5);
}

.result-slot .slot-icon {
  width: 46px;
  height: 46px;
}

.inv-main {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.inv-row,
.inv-hotrow {
  display: flex;
  gap: 5px;
}

.inv-hotrow {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 2px solid rgba(255, 255, 255, 0.12);
}

#inv-screen .slot {
  pointer-events: auto;
  cursor: pointer;
}

#inv-screen .slot:hover {
  background: rgba(255, 255, 255, 0.16);
}

.cursor-item {
  position: fixed;
  z-index: 40;
  pointer-events: none;
  width: 40px;
  height: 40px;
}

.cursor-item img {
  width: 40px;
  height: 40px;
  image-rendering: pixelated;
}

.cursor-count {
  position: absolute;
  right: 0;
  bottom: -2px;
  font-size: 13px;
  font-weight: 700;
  text-shadow: 0 1px 2px #000;
}

.tooltip {
  position: fixed;
  z-index: 41;
  pointer-events: none;
  background: rgba(10, 14, 26, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13.5px;
  max-width: 240px;
  line-height: 1.45;
}

.tooltip b {
  color: #fff;
}

.tooltip .dim {
  color: rgba(255, 255, 255, 0.6);
}

.death-tint {
  background: rgba(80, 8, 12, 0.55);
}
