/* ============================================================
   Visual identity: "campfire in the dark". Deep near-black
   backdrop, warm ember-gold as the one accent, a serif display
   face for the phase label (like a carved sign), monospace for
   readouts (numbers, resources) since it feels tool-like/utilitarian,
   fitting a survival-crafting game.
   ============================================================ */

:root {
  --bg-void: #0c0d0f;
  --ink: #eae6da;
  --ink-dim: #9b968a;
  --ember: #d97757;
  --ember-soft: rgba(217, 119, 87, 0.18);
  --gold: #d9b34a;
  --danger: #c0503f;
  --panel: rgba(18, 19, 20, 0.82);
  --panel-border: rgba(234, 230, 218, 0.1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-void);
  overflow: hidden;
  font-family: 'IBM Plex Mono', monospace;
  color: var(--ink);
}

#game-canvas {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
}

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

.hidden { display: none !important; }

/* ---------- Top bar: resources + phase ---------- */

#top-bar {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.resource-pill {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.02em;
  backdrop-filter: blur(4px);
}

.res-icon {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}
.wood-icon { background: #8a5c37; }
.stone-icon { background: #8a8a86; }

#phase-block {
  margin-left: auto;
  text-align: right;
  min-width: 220px;
}

#phase-label {
  font-family: 'Spectral', serif;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.02em;
  color: var(--gold);
  text-shadow: 0 0 14px var(--ember-soft);
  margin-bottom: 6px;
}

#phase-bar-track, .bar-track {
  height: 6px;
  border-radius: 3px;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--panel-border);
  overflow: hidden;
}

#phase-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--ember), var(--gold));
  transition: width 0.15s linear;
}

/* ---------- Health blocks ---------- */

#base-health-block, #player-health-block {
  position: absolute;
  bottom: 20px;
  width: 220px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 8px 12px;
  backdrop-filter: blur(4px);
}

#base-health-block { left: 16px; }
#player-health-block { left: 254px; }

.label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-dim);
  margin-bottom: 5px;
}

.bar-fill {
  height: 100%;
  background: #7fbf6a;
  transition: width 0.2s ease-out;
}

/* ---------- Minimap ---------- */

#minimap-wrap {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 4px;
  backdrop-filter: blur(4px);
  flex-shrink: 0;
}

#minimap {
  display: block;
  border-radius: 3px;
}

/* ---------- Build menu ---------- */

#build-menu {
  position: absolute;
  bottom: 20px;
  right: 16px;
  background: var(--panel);
  border: 1px solid var(--ember-soft);
  border-radius: 6px;
  padding: 12px 16px;
  backdrop-filter: blur(4px);
  min-width: 300px;
  max-width: 340px;
}

.build-menu-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-dim);
  margin-bottom: 8px;
}

.build-option {
  font-size: 14px;
  padding: 4px 0;
}

.build-option .hint {
  color: var(--ink-dim);
  font-size: 12px;
}

.build-option .key {
  display: inline-block;
  width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  margin-right: 8px;
  font-weight: 600;
  color: var(--gold);
}

/* ---------- Misc ---------- */

#controls-hint {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: var(--ink-dim);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 5px 12px;
  white-space: nowrap;
}

#event-banner {
  position: absolute;
  top: 90px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Spectral', serif;
  font-weight: 700;
  font-size: 28px;
  color: var(--ember);
  text-shadow: 0 0 20px var(--ember-soft);
  animation: fadeInOut 2.4s ease-in-out forwards;
  pointer-events: none;
}

@keyframes fadeInOut {
  0% { opacity: 0; transform: translate(-50%, -8px); }
  15% { opacity: 1; transform: translate(-50%, 0); }
  75% { opacity: 1; }
  100% { opacity: 0; }
}

/* ---------- Game over ---------- */

#game-over-overlay {
  position: absolute;
  inset: 0;
  background: rgba(5,5,6,0.86);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.game-over-box {
  text-align: center;
  padding: 40px 56px;
  border: 1px solid var(--ember-soft);
  border-radius: 10px;
  background: var(--panel);
}

.game-over-box h1 {
  font-family: 'Spectral', serif;
  color: var(--danger);
  font-size: 32px;
  margin: 0 0 12px;
}

.game-over-box p {
  color: var(--ink-dim);
  margin: 0 0 20px;
  font-size: 14px;
}

#restart-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.04em;
  padding: 10px 24px;
  background: var(--ember);
  color: #1a1210;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  pointer-events: all;
}
#restart-btn:hover { background: var(--gold); }
