/* ============================================================
   style.css  –  VoxelCraft UI
============================================================ */

/* ── Reset & base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --clr-primary:   #4ade80;
  --clr-accent:    #f59e0b;
  --clr-bg:        #0f1117;
  --clr-card:      rgba(15,17,23,0.88);
  --clr-border:    rgba(74,222,128,0.25);
  --clr-text:      #e2e8f0;
  --clr-muted:     #94a3b8;
  --font-pixel:    'Press Start 2P', monospace;
  --font-ui:       'Rajdhani', sans-serif;
  --radius:        6px;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--clr-bg);
  color: var(--clr-text);
  font-family: var(--font-ui);
}

/* ── Screens ──────────────────────────────────────────── */
.screen {
  position: absolute; inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.game-screen { padding: 0; }

/* ── Animated grid background ─────────────────────────── */
.menu-bg-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(74,222,128,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(74,222,128,0.05) 1px, transparent 1px);
  background-size: 48px 48px;
  animation: gridScroll 20s linear infinite;
  pointer-events: none;
}
@keyframes gridScroll {
  from { background-position: 0 0; }
  to   { background-position: 48px 48px; }
}

/* ── Menu header ──────────────────────────────────────── */
.menu-header { text-align: center; margin-bottom: 2rem; }

.logo {
  font-family: var(--font-pixel);
  font-size: clamp(1.6rem, 5vw, 2.8rem);
  color: #fff;
  text-shadow: 0 0 20px rgba(74,222,128,0.6), 4px 4px 0 rgba(0,0,0,0.5);
  letter-spacing: 2px;
}
.logo span { color: var(--clr-primary); }

.tagline {
  font-size: 1rem;
  color: var(--clr-muted);
  margin-top: .5rem;
  letter-spacing: 1px;
}

/* ── Menu card ────────────────────────────────────────── */
.menu-card {
  background: var(--clr-card);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  padding: 2rem;
  width: min(420px, 90vw);
  display: flex;
  flex-direction: column;
  gap: .85rem;
  backdrop-filter: blur(12px);
}

/* ── Buttons ──────────────────────────────────────────── */
.btn {
  display: block;
  width: 100%;
  padding: .65rem 1.2rem;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.05);
  color: var(--clr-text);
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: .5px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .08s;
}
.btn:hover  { background: rgba(255,255,255,0.12); border-color: var(--clr-primary); }
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--clr-primary);
  border-color: var(--clr-primary);
  color: #0f1117;
  font-weight: 700;
}
.btn-primary:hover { background: #22c55e; border-color: #22c55e; }

.btn-large { padding: .9rem; font-size: 1.1rem; }

.auth-row { display: flex; gap: .5rem; }
.auth-row .btn { flex: 1; }

/* ── Login panel ──────────────────────────────────────── */
.login-panel {
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  padding: 1.2rem;
}

.form-row {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-bottom: .6rem;
}
.form-row label {
  min-width: 80px;
  font-size: .85rem;
  color: var(--clr-muted);
}
.form-input {
  flex: 1;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--clr-border);
  border-radius: 4px;
  color: var(--clr-text);
  padding: .4rem .6rem;
  font-family: var(--font-ui);
  font-size: .9rem;
}
.form-input:focus { outline: none; border-color: var(--clr-primary); }

.auth-msg {
  font-size: .85rem;
  color: var(--clr-accent);
  margin-top: .4rem;
  min-height: 1.2em;
}

/* ── Controls hint ────────────────────────────────────── */
.controls-hint {
  font-size: .78rem;
  color: var(--clr-muted);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .3rem .6rem;
  border-top: 1px solid var(--clr-border);
  padding-top: .75rem;
}
.controls-hint b {
  grid-column: 1 / -1;
  color: var(--clr-text);
  font-size: .8rem;
  margin-bottom: .2rem;
}

/* ── User info ────────────────────────────────────────── */
.user-info {
  font-size: .82rem;
  color: var(--clr-muted);
  text-align: center;
}

/* ── Menu footer ──────────────────────────────────────── */
.menu-footer {
  position: absolute; bottom: 1rem;
  font-size: .75rem;
  color: var(--clr-muted);
}
.menu-footer a { color: var(--clr-primary); text-decoration: none; }

/* ── Loading screen ───────────────────────────────────── */
.loading-inner {
  text-align: center;
  width: min(360px, 80vw);
}
.logo-sm {
  font-family: var(--font-pixel);
  font-size: 1.1rem;
  color: var(--clr-primary);
  margin-bottom: 1.5rem;
  text-shadow: 0 0 12px rgba(74,222,128,0.5);
}
.load-msg {
  color: var(--clr-muted);
  font-size: .9rem;
  margin-bottom: .8rem;
  min-height: 1.3em;
}
.load-track {
  height: 8px;
  background: rgba(255,255,255,0.08);
  border-radius: 4px;
  overflow: hidden;
}
.load-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--clr-primary), var(--clr-accent));
  border-radius: 4px;
  transition: width .3s ease;
}

/* ── Canvas ───────────────────────────────────────────── */
#game-canvas {
  position: absolute; inset: 0;
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* ── Pointer-lock overlay ─────────────────────────────── */
.lock-overlay {
  position: absolute; inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.72);
  z-index: 50;
}
.lock-box {
  text-align: center;
  padding: 2rem 3rem;
  background: var(--clr-card);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
}
.lock-icon { font-size: 2.5rem; margin-bottom: .8rem; }
.lock-box p  { font-size: 1rem; margin-bottom: .4rem; }
.lock-box small { font-size: .8rem; color: var(--clr-muted); }
.lock-box kbd {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 3px;
  padding: 0 .4em;
}

/* ── HUD ──────────────────────────────────────────────── */
#hud {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 10;
}

/* Top info bar */
.hud-top {
  position: absolute;
  top: 10px; left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: .5rem;
}
.hud-badge {
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 4px;
  padding: .2rem .55rem;
  font-size: .75rem;
  color: var(--clr-text);
  font-family: var(--font-ui);
  white-space: nowrap;
}

/* Crosshair */
.crosshair {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  width: 20px; height: 20px;
}
.ch-h, .ch-v {
  position: absolute;
  background: rgba(255,255,255,0.85);
}
.ch-h { top: 50%; left: 0; right: 0; height: 2px; margin-top: -1px; }
.ch-v { left: 50%; top: 0; bottom: 0; width: 2px; margin-left: -1px; }

/* Block tooltip */
.block-tooltip {
  position: absolute;
  bottom: 130px;
  left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.65);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  padding: .25rem .75rem;
  font-size: .8rem;
  color: #fff;
  opacity: 0;
  transition: opacity .3s;
  pointer-events: none;
}

/* Notification toast */
.notification {
  position: absolute;
  top: 52px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.7);
  border: 1px solid var(--clr-border);
  border-radius: 4px;
  padding: .35rem 1rem;
  font-size: .82rem;
  color: var(--clr-primary);
  opacity: 0;
  transition: opacity .35s;
  pointer-events: none;
  white-space: nowrap;
}
.notification.visible { opacity: 1; }

/* Vitals */
.vitals {
  position: absolute;
  bottom: 80px;
  left: 50%; transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: center;
}
.pip-row {
  display: flex;
  gap: 2px;
}
.pip {
  font-size: .78rem;
  line-height: 1;
}

/* Hotbar */
.hotbar {
  position: absolute;
  bottom: 12px;
  left: 50%; transform: translateX(-50%);
  display: flex;
  gap: 4px;
  pointer-events: auto;
}
.hotbar-slot {
  width: 52px; height: 52px;
  background: rgba(0,0,0,0.6);
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 4px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color .1s;
}
.hotbar-slot.active {
  border-color: var(--clr-primary);
  box-shadow: 0 0 8px rgba(74,222,128,0.4);
}
.hotbar-slot .slot-num {
  position: absolute;
  top: 2px; left: 4px;
  font-size: .55rem;
  color: rgba(255,255,255,0.5);
  line-height: 1;
}
.slot-icon {
  image-rendering: pixelated;
}

/* ── Overlay menus (pause) ────────────────────────────── */
.overlay-menu {
  position: absolute; inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.6);
  z-index: 30;
  pointer-events: auto;
}
.overlay-card {
  background: var(--clr-card);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 260px;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  backdrop-filter: blur(12px);
}
.overlay-title {
  font-family: var(--font-pixel);
  font-size: .9rem;
  color: var(--clr-primary);
  text-align: center;
  margin-bottom: .5rem;
}

/* ── Debug panel ──────────────────────────────────────── */
.debug-panel {
  position: absolute;
  top: 10px; left: 10px;
  background: rgba(0,0,0,0.72);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 4px;
  padding: .6rem .9rem;
  font-family: monospace;
  font-size: .72rem;
  line-height: 1.6;
  color: #fff;
  pointer-events: none;
  z-index: 20;
  min-width: 220px;
}
.debug-panel b {
  color: var(--clr-primary);
  display: block;
  margin-bottom: .2rem;
}

/* ── Scrollbar ────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); }
::-webkit-scrollbar-thumb { background: var(--clr-border); border-radius: 3px; }

/* ═══════════════════════════════════════════════════════
   SURVIVAL UI ADDITIONS
═══════════════════════════════════════════════════════ */

/* ── Damage flash ──────────────────────────────────── */
.damage-flash {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(200,0,0,0.8) 100%);
  opacity: 0;
  pointer-events: none;
  z-index: 25;
  transition: opacity 0.08s;
}

/* ── Spawn protection shield ───────────────────────── */
.spawn-shield {
  position: absolute;
  top: 52px; right: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,120,255,0.25);
  border: 1px solid rgba(100,160,255,0.5);
  border-radius: 6px;
  padding: 4px 10px;
  color: #a0d0ff;
  font-size: 0.78rem;
  pointer-events: none;
  z-index: 15;
  transition: opacity 0.1s;
}
.shield-icon { font-size: 1rem; }
.shield-timer { font-family: var(--font-pixel); font-size: 0.55rem; }

/* ── Break progress bar ────────────────────────────── */
.break-bar-wrap {
  position: absolute;
  top: calc(50% + 18px);
  left: 50%; transform: translateX(-50%);
  width: 120px;
  height: 6px;
  background: rgba(0,0,0,0.5);
  border-radius: 3px;
  overflow: hidden;
  pointer-events: none;
  transition: opacity 0.1s;
  z-index: 15;
  border: 1px solid rgba(255,255,255,0.2);
}
.break-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  transition: background 0.1s;
}

/* ── Hotbar slot count badge ───────────────────────── */
.slot-count {
  position: absolute;
  bottom: 3px; right: 5px;
  font-size: 0.6rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 1px 1px 0 #000, -1px -1px 0 #000;
  pointer-events: none;
  line-height: 1;
}

/* Enlarged slot icons for survival (was 28px, now 36px) */
.slot-icon {
  image-rendering: pixelated;
  width: 36px;
  height: 36px;
}

/* Hotbar slot sizing update for larger icons */
.hotbar-slot {
  width: 56px;
  height: 56px;
}

/* Health pip colours */
.pip-health.full  { color: #e03030; }
.pip-health.half  { color: #e07070; }
.pip-health.empty { color: #444; }
.pip-hunger.full  { color: #d4a020; }
.pip-hunger.empty { color: #444; }

/* ═══════════════════════════════════════════════════════
   INVENTORY / CRAFTING / FURNACE UI
═══════════════════════════════════════════════════════ */

.inv-overlay {
  position: fixed; inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  font-family: var(--font-ui);
}
.inv-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(3px);
}
.inv-window {
  position: relative;
  display: flex;
  gap: 16px;
  background: #1a1d24;
  border: 2px solid rgba(74,222,128,0.3);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.8);
  user-select: none;
}
.inv-left { display: flex; flex-direction: column; gap: 6px; }
.inv-right {
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-left: 1px solid rgba(255,255,255,0.1);
  padding-left: 16px;
}
.inv-section-label {
  font-size: 0.7rem;
  color: var(--clr-muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 4px;
}

/* ── Slot grids ──────────────────────────────────────── */
.inv-bag-grid {
  display: grid;
  grid-template-columns: repeat(9, 46px);
  gap: 3px;
}
.inv-hotbar-row {
  display: grid;
  grid-template-columns: repeat(9, 46px);
  gap: 3px;
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 6px;
  margin-top: 2px;
}
.inv-slot {
  width: 46px; height: 46px;
  background: rgba(255,255,255,0.05);
  border: 2px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.1s, background 0.1s;
  box-sizing: border-box;
}
.inv-slot:hover { border-color: var(--clr-primary); background: rgba(74,222,128,0.08); }
.inv-slot.active { border-color: var(--clr-primary); box-shadow: 0 0 8px rgba(74,222,128,0.4); }
.inv-slot.has-result { border-color: var(--clr-accent); animation: pulse-slot 0.8s ease-in-out infinite alternate; }
@keyframes pulse-slot { from { box-shadow: 0 0 4px rgba(245,158,11,0.3); } to { box-shadow: 0 0 12px rgba(245,158,11,0.6); } }
.inv-slot-canvas { image-rendering: pixelated; width: 40px; height: 40px; }
.inv-slot-count {
  position: absolute; bottom: 2px; right: 4px;
  font-size: 0.6rem; font-weight: 700; color: #fff;
  text-shadow: 1px 1px 0 #000, -1px -1px 0 #000;
  pointer-events: none;
}

/* ── Crafting area ───────────────────────────────────── */
.craft-area {
  display: flex; align-items: center; gap: 10px;
  margin-top: 8px;
}
.craft-grid { display: grid; gap: 3px; }
.craft-grid-2 { grid-template-columns: repeat(2, 46px); }
.craft-grid-3 { grid-template-columns: repeat(3, 46px); }
.craft-arrow { font-size: 1.5rem; color: var(--clr-muted); }
.craft-output { display: flex; align-items: center; }
.craft-output-slot { width: 54px; height: 54px; }

/* ── Furnace area ────────────────────────────────────── */
.furnace-area {
  display: flex; align-items: center; gap: 16px; margin-top: 8px;
}
.furnace-col { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.furnace-middle { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.furnace-flame { font-size: 1.8rem; filter: drop-shadow(0 0 6px #f97316); transition: opacity 0.5s; }
.furnace-progress-wrap {
  width: 46px; height: 8px;
  background: rgba(255,255,255,0.1);
  border-radius: 4px; overflow: hidden;
  border: 1px solid rgba(255,255,255,0.15);
}
.furnace-progress-bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #f97316, #fbbf24);
  border-radius: 4px;
  transition: width 0.3s;
}

/* ── Drag ghost ──────────────────────────────────────── */
.inv-drag-ghost {
  position: fixed;
  width: 46px; height: 46px;
  pointer-events: none;
  z-index: 200;
  transform: translate(-50%,-50%);
  opacity: 0.9;
}
.inv-drag-ghost canvas { image-rendering: pixelated; }