* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  overflow: hidden;
  background: #000;
  font-family: 'Inter', sans-serif;
  color: #fff;
  user-select: none;
}

#bw-app {
  width: 100vw;
  height: 100vh;
  position: relative;
}

#bw-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: none;
}

/* ── Crosshair (CSS lines) ── */
#bw-crosshair {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 10;
  opacity: 0.7;
  mix-blend-mode: difference;
}
.bw-ch-h, .bw-ch-v {
  position: absolute;
  background: #fff;
  border-radius: 1px;
}
.bw-ch-h {
  width: 100%;
  height: 2px;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
}
.bw-ch-v {
  width: 2px;
  height: 100%;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
}

/* ── Hurt overlay ── */
#bw-hurt-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 15;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(180, 10, 10, 0.55) 100%);
  opacity: 0;
  transition: opacity 0.08s;
}
#bw-hurt-overlay.bw-flash {
  opacity: 1;
  animation: bw-hurt-fade 0.45s ease-out forwards;
}
@keyframes bw-hurt-fade {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

/* ── Block info tooltip ── */
#bw-block-info {
  position: fixed;
  bottom: 160px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.65);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.15s;
  white-space: nowrap;
}
#bw-block-info.bw-visible {
  opacity: 1;
}

/* ── Break progress ring ── */
#bw-break-ring {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 9;
  opacity: 0;
  transition: opacity 0.1s;
}
#bw-break-ring.bw-active {
  opacity: 1;
}
.bw-ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.12);
  stroke-width: 2.5;
}
.bw-ring-fg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.85);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 113;
  stroke-dashoffset: 113;
  transform: rotate(-90deg);
  transform-origin: center;
  transition: stroke-dashoffset 0.05s linear;
}

/* ── HUD ── */
#bw-hud {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

#bw-selected-name {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.55);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  letter-spacing: 0.5px;
  min-height: 16px;
}

#bw-health {
  display: flex;
  gap: 2px;
}

.bw-heart {
  width: 14px;
  height: 14px;
  background: #c0392b;
  clip-path: polygon(50% 85%, 5% 35%, 25% 5%, 50% 20%, 75% 5%, 95% 35%);
  transition: background 0.15s, transform 0.15s;
}
.bw-heart.bw-empty {
  background: rgba(60, 60, 60, 0.6);
}
.bw-heart.bw-half {
  background: linear-gradient(90deg, #c0392b 50%, rgba(60, 60, 60, 0.6) 50%);
}
.bw-heart.bw-bounce {
  animation: bw-heart-bounce 0.3s ease;
}
@keyframes bw-heart-bounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.35); }
}

#bw-hotbar {
  display: flex;
  gap: 2px;
  background: rgba(0, 0, 0, 0.6);
  border: 2px solid rgba(100, 100, 100, 0.4);
  border-radius: 6px;
  padding: 3px;
  backdrop-filter: blur(4px);
}

.bw-slot {
  width: 46px;
  height: 46px;
  border: 2px solid rgba(80, 80, 80, 0.35);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  pointer-events: auto;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.bw-slot:hover {
  border-color: rgba(200, 200, 200, 0.4);
}
.bw-slot.bw-selected {
  border-color: #fff;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.25), inset 0 0 6px rgba(255, 255, 255, 0.08);
}

.bw-slot-block {
  width: 30px;
  height: 30px;
  border-radius: 3px;
  box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.3), inset 0 2px 4px rgba(255, 255, 255, 0.1);
}

.bw-slot-count {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  text-shadow: 1px 1px 1px #000, -1px -1px 1px #000, 0 0 3px rgba(0,0,0,0.6);
  line-height: 1;
}

#bw-hotbar-labels {
  display: flex;
  gap: 2px;
  padding: 0 3px;
}
.bw-slot-label {
  width: 50px;
  text-align: center;
  font-size: 9px;
  color: rgba(255, 255, 255, 0.3);
}

/* ── Debug ── */
#bw-debug {
  position: fixed;
  top: 8px;
  left: 10px;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.55);
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.9);
  background: rgba(0, 0, 0, 0.2);
  padding: 4px 8px;
  border-radius: 4px;
}

/* ── Night warning ── */
#bw-night-warn {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  font-weight: 700;
  color: #e8a040;
  text-shadow: 0 0 12px rgba(200, 120, 40, 0.5);
  pointer-events: none;
  z-index: 12;
  animation: bw-warn-pulse 2s ease-in-out infinite;
}
@keyframes bw-warn-pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* ── Click-to-lock prompt ── */
#bw-lock-prompt {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 16px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  z-index: 11;
  background: rgba(0, 0, 0, 0.35);
  padding: 12px 24px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(4px);
}

/* ── Loading screen ── */
#bw-loading {
  position: fixed;
  inset: 0;
  z-index: 105;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: linear-gradient(180deg, #0a0a12 0%, #1a1a2e 40%, #0d0d1a 100%);
}
.bw-load-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(126, 200, 80, 0.2);
  border-top-color: #7ec850;
  border-radius: 50%;
  animation: bw-spin 0.7s linear infinite;
}
@keyframes bw-spin {
  to { transform: rotate(360deg); }
}
.bw-load-text {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 1px;
}

/* ── Title Screen ── */
#bw-title {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #0a0a12 0%, #1a1a2e 40%, #0d0d1a 100%);
}
#bw-title h1 {
  font-size: clamp(36px, 8vw, 72px);
  font-weight: 900;
  letter-spacing: 6px;
  color: #7ec850;
  text-shadow: 0 0 30px rgba(126, 200, 80, 0.4), 0 4px 8px rgba(0, 0, 0, 0.6);
  margin-bottom: 8px;
}
.bw-tagline {
  font-size: 16px;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 36px;
  letter-spacing: 3px;
}
#bw-play-btn, #bw-respawn-btn, #bw-resume-btn {
  padding: 14px 52px;
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 3px;
  color: #fff;
  background: #2d7a1e;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 4px 12px rgba(45, 122, 30, 0.3);
}
#bw-play-btn:hover, #bw-respawn-btn:hover, #bw-resume-btn:hover {
  background: #3a9e28;
  transform: scale(1.04);
  box-shadow: 0 6px 20px rgba(58, 158, 40, 0.4);
}
#bw-play-btn:active, #bw-respawn-btn:active, #bw-resume-btn:active {
  transform: scale(0.98);
}
.bw-controls {
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}
.bw-ctrl-row {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.35);
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
}
.bw-ctrl-row kbd {
  display: inline-block;
  padding: 2px 7px;
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
}

/* ── Overlays (death/pause) ── */
.bw-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(10, 0, 0, 0.82);
  backdrop-filter: blur(4px);
  animation: bw-overlay-in 0.3s ease;
}
@keyframes bw-overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.bw-overlay h2 {
  font-size: 48px;
  font-weight: 900;
  letter-spacing: 4px;
  margin-bottom: 8px;
}
#bw-death h2 { color: #c0392b; }
#bw-pause h2 { color: #ccc; }
#bw-death-msg {
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 6px;
  font-size: 14px;
}
#bw-death-stats, #bw-pause-stats {
  color: rgba(255, 255, 255, 0.35);
  margin-bottom: 24px;
  font-size: 12px;
  letter-spacing: 0.5px;
}
.bw-hidden { display: none !important; }

/* ── Exit ── */
.bw-exit {
  position: fixed;
  top: 8px;
  right: 12px;
  z-index: 110;
  color: rgba(255, 255, 255, 0.45);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 4px 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.bw-exit:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.05);
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .bw-slot { width: 38px; height: 38px; }
  .bw-slot-block { width: 24px; height: 24px; }
  .bw-slot-label { width: 42px; }
  #bw-debug { font-size: 10px; }
  .bw-ctrl-row { font-size: 11px; }
}
