:root {
  --ui-bg: rgba(12, 14, 18, 0.78);
  --ui-border: rgba(255, 255, 255, 0.22);
  --ui-text: #f2f5f8;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0d1117;
  color: var(--ui-text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  cursor: default;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* --- crosshair ------------------------------------------------------- */
#crosshair {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 20px;
  height: 20px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  mix-blend-mode: difference;
  opacity: 0.85;
  z-index: 5;
}

#crosshair::before,
#crosshair::after {
  content: '';
  position: absolute;
  background: #ffffff;
}

#crosshair::before {
  left: 9px;
  top: 0;
  width: 2px;
  height: 20px;
}

#crosshair::after {
  left: 0;
  top: 9px;
  width: 20px;
  height: 2px;
}

/* --- debug readout ---------------------------------------------------- */
#debug {
  position: fixed;
  left: 12px;
  top: 12px;
  padding: 8px 10px;
  background: var(--ui-bg);
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.5;
  letter-spacing: 0.02em;
  pointer-events: none;
  z-index: 6;
  min-width: 180px;
}

#debug.error {
  background: rgba(120, 20, 20, 0.85);
  border-color: #ff8080;
  max-width: 60ch;
  white-space: pre-wrap;
}

/* --- hotbar ----------------------------------------------------------- */
#hotbar {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 6px;
  background: var(--ui-bg);
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  z-index: 6;
}

.slot {
  position: relative;
  width: 46px;
  height: 46px;
  border: 2px solid transparent;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: border-color 0.12s ease, transform 0.12s ease;
}

.slot canvas {
  width: 40px;
  height: 40px;
  image-rendering: pixelated;
  border-radius: 3px;
}

.slot:hover {
  border-color: rgba(255, 255, 255, 0.45);
  transform: translateY(-2px);
}

.slot.active {
  border-color: #ffe08a;
  box-shadow: 0 0 0 2px rgba(255, 224, 138, 0.35) inset;
}

.slot-label {
  position: absolute;
  right: 3px;
  bottom: 1px;
  font-size: 9px;
  opacity: 0.65;
}

/* --- toast ------------------------------------------------------------ */
#toast {
  position: fixed;
  left: 50%;
  bottom: 78px;
  transform: translateX(-50%) translateY(8px);
  padding: 6px 14px;
  background: var(--ui-bg);
  border: 1px solid var(--ui-border);
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 7;
}

#toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --- pause / start panel --------------------------------------------- */
#panel {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: radial-gradient(circle at 50% 40%, rgba(10, 14, 20, 0.55), rgba(6, 8, 12, 0.85));
  z-index: 8;
  cursor: pointer;
}

/* Clicks must reach the overlay itself (which requests pointer lock). */
#panel > * {
  pointer-events: none;
}

#panel h1 {
  margin: 0 0 4px;
  font-size: 34px;
  letter-spacing: 0.08em;
}

#panel .sub {
  margin: 0 0 22px;
  opacity: 0.75;
  font-size: 13px;
}

#panel .keys {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 6px 22px;
  font-size: 13px;
  padding: 14px 20px;
  background: var(--ui-bg);
  border: 1px solid var(--ui-border);
  border-radius: 10px;
}

#panel .keys div {
  text-align: left;
  opacity: 0.9;
}

kbd {
  display: inline-block;
  min-width: 18px;
  padding: 1px 5px;
  margin-right: 2px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 11px;
}
