/* PRESERVE: Do NOT replace this file with write_file. Use edit_file to ADD your styles below the CUSTOM STYLES marker. */
/* This file contains essential 3D-shell classes: hud, hud-pill, overlay, overlay-card, overlay-stat, overlay-hint, */
/* primary-btn, and the shared --color-* / --gradient-* neon token palette (canvas is rendered by three.js). */
/* Overwriting these will break your game's HUD/overlay foundation. Add new styles at the bottom. */

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

:root {
  /* Neon-arcade palette on the shared --color-* / --gradient-* vocabulary. */
  --color-bg: #000;
  --color-text: #fff;
  --color-primary: #4af;
  --color-accent-2: #a78bfa;
  --color-accent-3: #f472b6;
  --color-danger: #f87171;
  --color-muted: rgba(255, 255, 255, 0.55);
  --color-faint: rgba(255, 255, 255, 0.3);
  --color-panel: rgba(10, 12, 24, 0.55);
  --color-border: rgba(255, 255, 255, 0.08);
  /* Gradient tokens — the title/hero neon gradient. */
  --gradient-from: #4af;
  --gradient-via: #a78bfa;
  --gradient-to: #f472b6;
  /* Motion tokens. */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --duration-fast: 150ms;
  --duration-base: 250ms;
  --duration-slow: 450ms;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--color-bg);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--color-text);
}

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

/* HUD */
#hud {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  z-index: 10;
  pointer-events: none;
}
#hud.hidden { display: none; }

.hud-pill {
  background: var(--color-panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-muted);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}
.hud-pill span {
  color: #fff;
  margin-left: 6px;
  font-variant-numeric: tabular-nums;
}

/* Overlay */
#overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  background: radial-gradient(ellipse at center, rgba(10, 10, 30, 0.85) 0%, rgba(0, 0, 0, 0.95) 100%);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: opacity 0.25s ease;
}
#overlay.hidden { opacity: 0; pointer-events: none; }

.overlay-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 40px 56px;
  text-align: center;
  animation: overlay-rise 0.4s var(--ease-out);
}

@keyframes overlay-rise {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

#overlay h1 {
  font-size: 56px;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--gradient-from) 0%, var(--gradient-via) 50%, var(--gradient-to) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 24px rgba(167, 139, 250, 0.35));
}

#overlay[data-screen="gameover"] h1 {
  background: linear-gradient(135deg, var(--color-danger) 0%, var(--color-accent-3) 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

#overlay p {
  font-size: 16px;
  color: var(--color-muted);
  letter-spacing: 0.04em;
}

.overlay-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 24px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--color-border);
  margin: 8px 0;
}
.overlay-stat span {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-faint);
}
.overlay-stat strong {
  font-size: 32px;
  font-weight: 800;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

#primary-btn {
  margin-top: 8px;
  padding: 14px 44px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent-2));
  color: #fff;
  cursor: pointer;
  box-shadow:
    0 0 30px rgba(74, 175, 255, 0.35),
    0 6px 24px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
#primary-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
  box-shadow:
    0 0 40px rgba(74, 175, 255, 0.55),
    0 10px 30px rgba(0, 0, 0, 0.5);
}
#primary-btn:active { transform: translateY(0) scale(0.98); }

.overlay-hint {
  margin-top: 16px;
  font-size: 12px;
  color: var(--color-faint);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* === CUSTOM STYLES: Add your game-specific styles below this line === */

body { cursor: default; }
canvas { cursor: crosshair; }

.hidden { display: none !important; }

/* ---------- Loading ---------- */
.spinner {
  width: 36px; height: 36px;
  border: 4px solid rgba(255,255,255,0.15);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 8px 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.secondary-btn {
  margin-top: 4px;
  padding: 10px 32px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
  color: #fff;
  cursor: pointer;
}
.secondary-btn:hover { background: rgba(255,255,255,0.12); }
.death-title { background: linear-gradient(135deg, var(--color-danger), var(--color-accent-3)) !important; -webkit-background-clip: text; background-clip: text; }

/* ---------- Crosshair ---------- */
#crosshair { position: fixed; left: 50%; top: 50%; width: 18px; height: 18px; transform: translate(-50%,-50%); z-index: 15; pointer-events: none; }
#crosshair .cross-h, #crosshair .cross-v { position: absolute; background: rgba(255,255,255,0.85); box-shadow: 0 0 2px rgba(0,0,0,0.8); }
#crosshair .cross-h { left: 0; top: 8px; width: 18px; height: 2px; }
#crosshair .cross-v { left: 8px; top: 0; width: 2px; height: 18px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; top: 70px; left: 50%; transform: translateX(-50%);
  background: rgba(10,12,24,0.75); border: 1px solid var(--color-border);
  padding: 8px 18px; border-radius: 8px; font-size: 13px; letter-spacing: 0.03em;
  opacity: 0; transition: opacity 0.25s ease; pointer-events: none; z-index: 30;
}

/* ---------- HUD bars ---------- */
#bars { position: fixed; left: 16px; bottom: 74px; z-index: 10; pointer-events: none; }
.bar-row { display: flex; gap: 2px; margin-bottom: 3px; }
.heart, .food {
  width: 16px; height: 16px;
  background: #b91c1c;
  clip-path: polygon(50% 15%, 61% 5%, 75% 5%, 88% 18%, 88% 32%, 50% 70%, 12% 32%, 12% 18%, 25% 5%, 39% 5%);
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.8));
}
.food { background: #c98a3a; clip-path: none; border-radius: 3px; }
.heart.empty { background: #3a1414; }
.heart.half { background: linear-gradient(90deg, #b91c1c 50%, #3a1414 50%); }
.food.empty { background: #3a2a14; }
.food.half { background: linear-gradient(90deg, #c98a3a 50%, #3a2a14 50%); }

/* ---------- Debug panel ---------- */
#debug-panel {
  position: fixed; top: 16px; left: 16px; z-index: 10;
  background: rgba(0,0,0,0.5); color: #baffb0; font-family: monospace; font-size: 12px;
  padding: 8px 10px; border-radius: 6px; white-space: pre; line-height: 1.5; pointer-events: none;
}

/* ---------- Break progress ---------- */
#break-bar-wrap {
  position: fixed; left: 50%; top: calc(50% + 22px); transform: translateX(-50%);
  width: 60px; height: 6px; background: rgba(0,0,0,0.4); border-radius: 3px; overflow: hidden;
  opacity: 0; transition: opacity 0.1s; z-index: 14; pointer-events: none;
}
#break-bar { height: 100%; width: 0%; background: #fff; }

/* ---------- Hotbar ---------- */
#hotbar {
  position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%);
  display: flex; gap: 4px; z-index: 10; background: rgba(0,0,0,0.25); padding: 4px; border-radius: 8px;
}
.slot {
  width: 44px; height: 44px; background: rgba(255,255,255,0.08);
  border: 2px solid rgba(255,255,255,0.15); border-radius: 4px; position: relative;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.slot.selected { border-color: #fff; box-shadow: 0 0 8px rgba(255,255,255,0.6); background: rgba(255,255,255,0.18); }
.slot-icon { width: 32px; height: 32px; background-repeat: no-repeat; }
.slot-count { position: absolute; right: 3px; bottom: 1px; font-size: 11px; font-weight: 700; text-shadow: 1px 1px 1px #000; }

/* ---------- Inventory screen ---------- */
.inv-card {
  background: rgba(15,15,25,0.92); border: 1px solid var(--color-border); border-radius: 14px;
  padding: 24px 28px; display: flex; flex-direction: column; align-items: center; gap: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.inv-card h2 { font-size: 20px; letter-spacing: 0.05em; margin-bottom: 4px; }
.craft-area { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 44px); gap: 4px; }
.craft-arrow { font-size: 22px; color: var(--color-muted); }
.output-slot-wrap .slot { border-color: rgba(255,215,120,0.5); }
.grid9 { display: grid; grid-template-columns: repeat(9, 44px); gap: 4px; margin-top: 4px; }
.hotbar-mirror { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--color-border); }
.cursor-item {
  position: fixed; width: 40px; height: 40px; pointer-events: none; z-index: 60;
  transform: translate(-20px,-20px); display: none; background-repeat: no-repeat;
}
.cursor-item .slot-count { position: absolute; right: -2px; bottom: -4px; font-size: 12px; font-weight: 700; color: #fff; text-shadow: 1px 1px 1px #000; }

/* ---------- Multiplayer: name input, status, online pill, remote nametags ---------- */
.name-input {
  width: 220px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  border-radius: 10px;
  border: 1px solid var(--color-border);
  background: rgba(255,255,255,0.06);
  color: #fff;
  text-align: center;
  outline: none;
}
.name-input:focus { border-color: var(--color-primary); background: rgba(255,255,255,0.1); }
.name-input::placeholder { color: var(--color-faint); }

.mp-status {
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--color-muted);
  min-height: 14px;
}
.mp-status.online { color: #6ee7a0; }
.mp-status.offline { color: var(--color-faint); }
.mp-status.connecting { color: #f1c40f; }

#online-pill {
  position: fixed; top: 16px; right: 16px; z-index: 10;
  background: rgba(0,0,0,0.5); border: 1px solid var(--color-border); border-radius: 999px;
  padding: 6px 14px; font-size: 12px; font-weight: 700; letter-spacing: 0.06em;
  color: #6ee7a0; pointer-events: none;
}
#online-pill.hidden { display: none; }

/* ---------- Furnace screen ---------- */
.furnace-area { display: flex; align-items: center; gap: 18px; margin-bottom: 10px; }
.furnace-io { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.furnace-progress-wrap { width: 44px; height: 8px; background: rgba(255,255,255,0.1); border-radius: 4px; overflow: hidden; }
.furnace-progress { height: 100%; width: 0%; background: linear-gradient(90deg, #ffb347, #ff7043); transition: width 0.1s linear; }
.furnace-fuel-row { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.furnace-flame { width: 18px; height: 22px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; background: #3a2416; opacity: 0.4; transition: opacity 0.15s, background 0.15s; }
.furnace-flame.lit { background: radial-gradient(circle at 50% 70%, #fff3c4, #ffb347 60%, #ff7043); opacity: 1; box-shadow: 0 0 12px rgba(255,150,50,0.7); }
.furnace-slot-wrap .slot { border-color: rgba(255,150,50,0.4); }

