:root {
  --bg: #1a1420;
  --panel: rgba(20, 16, 28, 0.82);
  --text: #f4e8d8;
  --muted: #c4b4a0;
  --accent: #e8a040;
  --accent-dim: #c07830;
  --ok: #7ec87e;
  --border: rgba(232, 160, 64, 0.35);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #e8dcc8;
    --panel: rgba(255, 250, 240, 0.88);
    --text: #2a2018;
    --muted: #5a4a3a;
    --accent: #c06020;
    --accent-dim: #a04818;
    --ok: #2a7a3a;
    --border: rgba(192, 96, 32, 0.4);
  }
}

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

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

#c {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

#c:active { cursor: grabbing; }

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

#hud-right {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

#fps {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  letter-spacing: 0.04em;
}

#compass {
  width: 64px;
  height: 64px;
}

#compass-rose {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--panel);
  border: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

#compass-needle {
  font-weight: 700;
  color: var(--accent);
  font-size: 16px;
  transition: transform 0.08s linear;
}

#inventory {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  min-width: 140px;
}

.inv-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 6px;
}

#inv-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}

.inv-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.inv-row span:last-child {
  color: var(--accent);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

#controls-hint {
  position: absolute;
  bottom: 20px;
  left: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--muted);
  font-size: 12px;
  max-width: 360px;
  transition: opacity 1s ease;
}

#controls-hint.fade { opacity: 0; }

#interact-hint {
  position: absolute;
  bottom: 28%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 8px 16px;
  color: var(--text);
  font-size: 13px;
}

#interact-hint.hidden { display: none; }

#crosshair {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border: 1.5px solid rgba(244, 232, 216, 0.7);
  border-radius: 50%;
  pointer-events: none;
  z-index: 9;
}

#craft-menu {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
  z-index: 20;
  pointer-events: auto;
  min-width: 300px;
  max-width: 90vw;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

#craft-menu.hidden { display: none; }

#craft-menu h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--accent);
}

.craft-sub {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 14px;
}

#recipe-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

#recipe-list li button {
  width: 100%;
  text-align: left;
  background: rgba(232, 160, 64, 0.08);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  cursor: pointer;
  font: inherit;
  transition: background 0.15s, border-color 0.15s;
}

#recipe-list li button:hover:not(:disabled),
#recipe-list li button:focus-visible {
  background: rgba(232, 160, 64, 0.18);
  border-color: var(--accent);
  outline: none;
}

#recipe-list li button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.recipe-name { font-weight: 600; display: block; margin-bottom: 2px; }
.recipe-cost { font-size: 11px; color: var(--muted); }

#craft-close {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
  font: inherit;
  width: 100%;
}

#craft-close:hover,
#craft-close:focus-visible {
  border-color: var(--accent);
  color: var(--text);
  outline: none;
}

@media (prefers-reduced-motion: reduce) {
  #controls-hint { transition: none; }
  #compass-needle { transition: none; }
}
