:root {
  --ink: #f4f7f2;
  --ink-dim: #b9c6c3;
  --panel: rgba(14, 20, 28, 0.72);
  --panel-line: rgba(233, 245, 240, 0.16);
  --mint: #8fd0a4;
  --teal: #4fb7cf;
  --coral: #ef7a5a;
  --sand: #e8d5a8;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #0b1023;
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

#scene-wrap { position: fixed; inset: 0; }
#scene { display: block; width: 100%; height: 100%; }

body.locked #scene { cursor: none; }

/* crosshair */
#crosshair {
  position: fixed; left: 50%; top: 50%;
  width: 22px; height: 22px; margin: -11px 0 0 -11px;
  pointer-events: none;
  transition: transform 120ms ease;
}
#crosshair i {
  position: absolute; background: rgba(247, 244, 236, 0.92);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.55);
}
#crosshair i:nth-child(1) { left: 10px; top: 0; width: 2px; height: 7px; }
#crosshair i:nth-child(2) { left: 10px; bottom: 0; width: 2px; height: 7px; }
#crosshair i:nth-child(3) { top: 10px; left: 0; height: 2px; width: 7px; }
#crosshair i:nth-child(4) { top: 10px; right: 0; height: 2px; width: 7px; }
#crosshair.pop { transform: scale(1.35); }

/* hud */
.hud-panel {
  position: fixed; z-index: 6;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  backdrop-filter: blur(8px);
  font-size: 13px;
}
#hud-top { left: 12px; top: 12px; max-width: min(92vw, 720px); }
.brand {
  font-weight: 800; letter-spacing: 0.18em; color: var(--mint);
  font-size: 13px;
}
.hud-chip {
  padding: 3px 9px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink-dim); font-variant-numeric: tabular-nums;
}
.ui-button {
  font: inherit; font-weight: 700; color: #14201b;
  background: linear-gradient(160deg, var(--mint), var(--teal));
  border: 0; border-radius: 999px; padding: 7px 14px; cursor: pointer;
}
.ui-button:hover { filter: brightness(1.08); }
.ui-button.big { font-size: 17px; padding: 12px 26px; }

#hud-hint {
  position: fixed; z-index: 5; right: 12px; bottom: 14px;
  margin: 0; max-width: 340px; text-align: right;
  font-size: 11.5px; line-height: 1.6; color: var(--ink-dim);
  background: var(--panel); border: 1px solid var(--panel-line);
  border-radius: 12px; padding: 8px 12px;
}
#hud-hint strong { color: var(--sand); font-weight: 700; }

/* hotbar */
#hotbar {
  position: fixed; z-index: 7; left: 50%; bottom: 16px; transform: translateX(-50%);
  display: flex; gap: 6px; padding: 8px;
  background: var(--panel); border: 1px solid var(--panel-line);
  border-radius: 14px; backdrop-filter: blur(8px);
}
.slot {
  position: relative; width: 62px; height: 62px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px; cursor: pointer;
  background: rgba(255, 255, 255, 0.05);
  padding: 4px 2px 6px; overflow: hidden;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}
.slot img { display: block; width: 100%; height: 42px; object-fit: contain; image-rendering: pixelated; }
.slot .slot-key {
  position: absolute; left: 5px; top: 3px; font-size: 10px;
  color: rgba(255, 255, 255, 0.6);
}
.slot .slot-name {
  display: block; font-size: 9.5px; letter-spacing: 0.03em;
  color: var(--ink-dim); text-align: center;
}
.slot:hover { transform: translateY(-3px); }
.slot[aria-selected="true"] {
  border-color: var(--coral);
  background: rgba(239, 122, 90, 0.22);
  transform: translateY(-6px);
  box-shadow: 0 8px 20px rgba(239, 122, 90, 0.28);
}

/* toast */
#toast {
  position: fixed; z-index: 9; left: 50%; top: 70px; transform: translateX(-50%) translateY(-10px);
  padding: 8px 16px; border-radius: 999px;
  background: var(--coral); color: #1b1210; font-weight: 700; font-size: 13px;
  opacity: 0; pointer-events: none; transition: opacity 220ms ease, transform 220ms ease;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* start screen */
#start-screen {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center;
  background: radial-gradient(120% 90% at 50% 20%, rgba(20, 34, 46, 0.72), rgba(8, 12, 22, 0.94));
  cursor: pointer;
}
#start-screen.hidden { display: none; }
.start-card {
  max-width: min(90vw, 560px); text-align: center; padding: 28px;
  border: 1px solid var(--panel-line); border-radius: 20px;
  background: rgba(11, 16, 35, 0.6); backdrop-filter: blur(10px);
}
.start-card h1 {
  margin: 0 0 8px; font-size: clamp(28px, 7vw, 46px); letter-spacing: 0.22em;
  color: var(--mint); font-weight: 800;
}
.start-card p { color: var(--ink-dim); margin: 0 0 18px; }
.start-keys { list-style: none; margin: 18px 0 0; padding: 0; display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; font-size: 12px; color: var(--ink-dim); }
.start-keys b { color: var(--sand); }

/* touch controls */
#touch-controls { display: none; }
body.touch #touch-controls { display: block; }
body.touch #hud-hint { display: none; }
.touch-pad {
  position: fixed; z-index: 8; left: 22px; bottom: 110px;
  width: 128px; height: 128px; border-radius: 50%;
  background: rgba(11, 16, 35, 0.42); border: 1px solid var(--panel-line);
  touch-action: none;
}
.touch-pad .knob {
  position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px;
  border-radius: 50%; background: linear-gradient(160deg, var(--mint), var(--teal));
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}
.touch-actions { position: fixed; z-index: 8; right: 18px; bottom: 110px; display: grid; gap: 10px; }
.touch-btn {
  width: 84px; padding: 12px 0; border: 1px solid var(--panel-line); border-radius: 14px;
  background: rgba(11, 16, 35, 0.55); color: var(--ink); font: inherit; font-weight: 700;
  touch-action: none;
}
.touch-btn:active { background: var(--coral); color: #17110e; }

@media (max-width: 700px) {
  .slot { width: 44px; height: 52px; }
  .slot img { height: 30px; }
  .slot .slot-name { display: none; }
  #hud-hint { display: none; }
  #hud-top { font-size: 11px; }
}
