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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
}

body {
  font-family: 'Trebuchet MS', sans-serif;
  background: #0d0e10;
  color: #f4ecd8;
}

.hidden { display: none !important; }

:root {
  --gold:   #f5c542;
  --accent: #f0a040;
  --panel:  rgba(0, 0, 0, 0.55);
  --border: rgba(245, 197, 66, 0.4);
  --text:   #f4ecd8;
  --muted:  rgba(244, 236, 216, 0.6);
  --danger: #c44;
}

/* ============ Character creation ============ */
.char-creation {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cc-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 20%, rgba(245,197,66,0.18), transparent 50%),
    linear-gradient(180deg, #1a3a4a 0%, #2a5a3a 50%, #3a4a2a 100%);
  z-index: 0;
}
.cc-content {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 24px;
  max-width: 560px;
  width: 100%;
}
.cc-title {
  font-family: 'Impact', 'Arial Black', sans-serif;
  font-size: clamp(40px, 7vw, 56px);
  letter-spacing: 4px;
  color: var(--gold);
  text-shadow: 2px 2px 0 #000, -2px 2px 0 #000, 0 4px 0 #5a3a10, 0 8px 16px rgba(0,0,0,0.6);
  margin-bottom: 6px;
}
.cc-subtitle {
  font-size: 14px;
  color: var(--muted);
  letter-spacing: 0.5px;
  margin-bottom: 22px;
  font-style: italic;
}

.cc-stage {
  position: relative;
  width: 100%;
  height: clamp(280px, 45vh, 400px);
  background: rgba(0,0,0,0.35);
  border: 2px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 18px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
#cc-canvas { display: block; width: 100%; height: 100%; }
.cc-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.5);
  border: 2px solid var(--border);
  color: var(--gold);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 28px;
  cursor: pointer;
  font-family: inherit;
  line-height: 1;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.cc-arrow:hover { background: rgba(0,0,0,0.85); border-color: var(--gold); }
.cc-arrow:active { transform: translateY(-50%) scale(0.95); }
.cc-prev { left: 14px; }
.cc-next { right: 14px; }
.cc-char-name {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.65);
  color: var(--gold);
  padding: 6px 16px;
  border-radius: 6px;
  font-size: 14px;
  letter-spacing: 1px;
  pointer-events: none;
  font-weight: bold;
  border: 1px solid var(--border);
}

.cc-customize {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
  align-items: center;
}
.cc-pick-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.cc-pick-label {
  font-size: 12px;
  color: var(--muted);
  width: 50px;
  text-align: right;
  letter-spacing: 0.5px;
  font-weight: bold;
}
.cc-swatches {
  display: flex;
  gap: 6px;
}
.cc-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.45);
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  transition: transform 0.1s, border-color 0.1s, box-shadow 0.1s;
}
.cc-swatch:hover { transform: scale(1.15); }
.cc-swatch.selected {
  border-color: var(--gold);
  transform: scale(1.18);
  box-shadow: 0 0 0 2px rgba(245, 197, 66, 0.4);
}
.cc-style-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.cc-style {
  font-family: inherit;
  font-size: 11px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: rgba(0,0,0,0.25);
  color: var(--text);
  cursor: pointer;
}
.cc-style:hover { border-color: var(--gold); }
.cc-style.selected { border-color: var(--gold); color: var(--gold); }

.cc-name-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
  justify-content: center;
}
.cc-name-row label {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.5px;
}
.cc-name-row input {
  background: rgba(0,0,0,0.4);
  border: 2px solid var(--border);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 6px;
  font-size: 16px;
  font-family: inherit;
  min-width: 220px;
}
.cc-name-row input:focus {
  outline: none;
  border-color: var(--gold);
}

.cc-start {
  padding: 14px 32px;
  background: var(--accent);
  color: #fff;
  border: 2px solid #1a1a1a;
  border-radius: 8px;
  font-weight: bold;
  font-size: 18px;
  letter-spacing: 1.5px;
  cursor: pointer;
  text-shadow: 0 1px 0 rgba(0,0,0,0.4);
  box-shadow: 0 4px 0 rgba(0,0,0,0.4), 0 8px 16px rgba(0,0,0,0.3);
  font-family: inherit;
  transition: transform 0.1s, box-shadow 0.1s;
}
.cc-start:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(0,0,0,0.4);
}

.cc-lang {
  position: fixed;
  top: 16px;
  right: 16px;
  background: rgba(0,0,0,0.5);
  border: 1px solid var(--border);
  color: var(--gold);
  padding: 7px 14px;
  border-radius: 6px;
  font-weight: bold;
  font-size: 13px;
  letter-spacing: 1px;
  cursor: pointer;
  font-family: inherit;
  min-width: 44px;
}
.cc-lang:hover { background: rgba(0,0,0,0.8); }

/* ============ Game ============ */
.game { position: fixed; inset: 0; z-index: 1; }
#world-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}
#world-canvas:active { cursor: grabbing; }

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

.hud-minimap {
  position: absolute;
  top: 44px;
  right: 12px;
  width: 180px;
  height: 180px;
  background: rgba(20, 25, 35, 0.55);
  border: 1px solid var(--border);
  border-radius: 50%;
  pointer-events: none;
  z-index: 12;
}

.hud-compass {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 280px;
  height: 26px;
  background: rgba(20, 25, 35, 0.55);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  pointer-events: none;
  z-index: 12;
}
.hud-compass-strip {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 1120px;          /* 4× width so we can scroll N..E..S..W..N */
  font-size: 13px;
  color: #e0e6ed;
  font-weight: 600;
  letter-spacing: 1px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
.hud-compass-strip span {
  position: absolute;
  transform: translateX(-50%);
  top: 50%;
  margin-top: -8px;
}
.hud-compass-strip span.cardinal { color: var(--gold); }
.hud-compass-needle {
  position: absolute;
  top: 0;
  left: 50%;
  width: 1px;
  height: 100%;
  background: var(--gold);
  box-shadow: 0 0 4px var(--gold);
}

.damage-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s linear;
  background: radial-gradient(ellipse at center,
    rgba(255,0,0,0) 35%,
    rgba(180,0,0,0.55) 70%,
    rgba(120,0,0,0.85) 100%);
  z-index: 11;
}

.hud-corner-tl {
  position: absolute;
  top: 14px;
  left: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  pointer-events: auto;
  min-width: 130px;
}
.hud-name {
  font-family: 'Impact', 'Arial Black', sans-serif;
  font-size: 16px;
  color: var(--gold);
  letter-spacing: 1px;
  text-shadow: 1px 1px 0 #000;
}
.hud-stat-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 2px;
}
.hud-coords, .hud-fps {
  font-size: 11px;
  color: var(--muted);
  font-family: monospace;
}
.hud-fps  { color: rgba(245, 197, 66, 0.85); }
.hud-time { font-size: 14px; line-height: 1; margin-left: auto; }
.hud-debug {
  font-size: 10px;
  color: rgba(180, 200, 130, 0.65);
  font-family: monospace;
  margin-top: 2px;
}

.hud-controls-hint {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 12px;
  letter-spacing: 0.3px;
  pointer-events: none;
  text-align: center;
  max-width: 92%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.4s 1.5s;
}
.hud-controls-hint.fade { opacity: 0; }

/* ---------- Inventory ---------- */
/* ---------- Mobile virtual joysticks ---------- */
.mobile-controls {
  position: fixed;
  inset: 0;
  z-index: 250;
  pointer-events: none;
}
.mobile-controls.hidden { display: none; }
.joystick {
  position: absolute;
  width: 130px;
  height: 130px;
  bottom: 30px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.32);
  border: 2px solid rgba(255, 255, 255, 0.35);
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.joystick-left  { left: 30px; }
.joystick-right { right: 30px; }
.js-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 56px;
  height: 56px;
  margin: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(0, 0, 0, 0.3);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.mobile-actions {
  position: absolute;
  right: 30px;
  bottom: 180px;     /* above the right joystick */
  display: grid;
  grid-template-columns: repeat(2, 56px);
  grid-auto-rows: 56px;
  gap: 8px;
  pointer-events: auto;
}
.ma-btn {
  background: rgba(0, 0, 0, 0.45);
  border: 2px solid rgba(255, 255, 255, 0.4);
  color: #fff;
  border-radius: 50%;
  font-size: 18px;
  font-family: monospace;
  text-shadow: 1px 1px 0 #000;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
}
.ma-btn:active { background: rgba(180, 200, 130, 0.5); transform: scale(0.95); }

/* ---------- Toolbar (active-tool hotbar) ---------- */
.hud-toolbar {
  position: absolute;
  bottom: 110px;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(5, 50px);
  grid-auto-rows: 50px;
  gap: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  pointer-events: auto;
}
.hud-toolbar .bag-slot {
  width: 50px;
  height: 50px;
  border-width: 2px;
}
.hud-toolbar .bag-slot::before {
  content: attr(data-key);
  position: absolute;
  top: 1px;
  left: 4px;
  font-size: 10px;
  color: var(--muted);
  font-family: monospace;
}
.hud-toolbar .bag-slot .bag-icon { font-size: 26px; }
.hud-toolbar .bag-slot.active {
  border-color: #f5d76e;
  box-shadow: 0 0 8px rgba(245, 215, 110, 0.5);
}

/* ---------- Chat ---------- */
.chat-wrap {
  position: absolute;
  left: 16px;
  bottom: 84px;
  width: 320px;
  max-width: 50vw;
  pointer-events: none;
  z-index: 140;
}
.chat-log {
  display: flex;
  flex-direction: column-reverse;
  gap: 2px;
  font-family: monospace;
  font-size: 12px;
  color: #f0e8c8;
  text-shadow: 1px 1px 0 #000;
  max-height: 180px;
  overflow: hidden;
  padding-bottom: 4px;
}
.chat-line {
  background: rgba(0, 0, 0, 0.45);
  padding: 2px 8px;
  border-radius: 3px;
  word-wrap: break-word;
  animation: chatFade 8s linear forwards;
}
.chat-line.system { color: #b3d967; font-style: italic; }
.chat-line .chat-name { color: #f5d76e; font-weight: bold; margin-right: 6px; }
@keyframes chatFade {
  0%   { opacity: 1; }
  80%  { opacity: 1; }
  100% { opacity: 0.15; }
}
.chat-input {
  display: block;
  width: 100%;
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(180, 200, 130, 0.45);
  color: #f0e8c8;
  font-family: monospace;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 4px;
  outline: none;
  margin-top: 4px;
}
.chat-input.hidden { display: none; }

/* ---------- Bag (slot inventory) HUD ---------- */
.hud-bag-wrap {
  position: absolute;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  pointer-events: auto;
}
.hud-dinos-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: monospace;
  font-size: 14px;
  color: var(--gold);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
}
.hud-bag {
  display: grid;
  grid-template-columns: repeat(4, 36px);
  grid-auto-rows: 36px;
  gap: 3px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
}
.bag-slot {
  position: relative;
  background: rgba(20, 26, 18, 0.6);
  border: 1px solid rgba(180, 200, 130, 0.18);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: monospace;
}
.bag-slot.filled {
  background: rgba(50, 60, 35, 0.85);
  border-color: rgba(180, 200, 130, 0.45);
}
.bag-icon {
  font-size: 20px;
  line-height: 1;
}
.bag-count {
  position: absolute;
  bottom: 1px;
  right: 3px;
  font-size: 10px;
  font-weight: bold;
  color: var(--gold);
  text-shadow: 1px 1px 0 #000;
}
.bag-wear {
  position: absolute;
  bottom: 1px;
  left: 2px;
  right: 2px;
  height: 3px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 2px;
  overflow: hidden;
}
.bag-wear i {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #e87b3a, #f5d76e, #b3d967);
}
.hud-bag-row {
  display: flex;
  gap: 6px;
  align-items: center;
  width: 100%;
  justify-content: flex-end;
}
.hud-bag-toggle {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 16px;
  padding: 4px 8px;
  cursor: pointer;
  color: var(--gold);
  line-height: 1;
}
.hud-bag-toggle:hover { background: rgba(180, 200, 130, 0.2); }
.hud-quick-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 16px;
  padding: 4px 8px;
  cursor: pointer;
  color: var(--gold);
  line-height: 1;
  pointer-events: auto;
}
.hud-quick-btn:hover { background: rgba(180, 200, 130, 0.2); }
.hud-bag.hidden { display: none; }
.hud-bag-hint {
  font-family: monospace;
  font-size: 10px;
  color: var(--muted);
  opacity: 0.75;
  text-align: right;
}
.hud-bag-hint.hidden { display: none; }
/* Drag-and-drop visual states */
.bag-slot.dragging { opacity: 0.35; }
.bag-slot.drop-target {
  border-color: #b3d967;
  background: rgba(120, 200, 100, 0.25);
}
.bag-drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 9000;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(50, 60, 35, 0.92);
  border: 1px solid #b3d967;
  border-radius: 4px;
  font-family: monospace;
}
.bag-drag-ghost .bag-icon  { font-size: 20px; line-height: 1; }
.bag-drag-ghost .bag-count {
  position: absolute;
  bottom: 1px;
  right: 3px;
  font-size: 10px;
  font-weight: bold;
  color: var(--gold);
  text-shadow: 1px 1px 0 #000;
}

/* ---------- Craft panel ---------- */
.craft-panel {
  position: absolute;
  top: 60px;
  right: 270px;
  width: 280px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  pointer-events: auto;
  color: var(--gold);
  font-family: monospace;
  font-size: 13px;
  z-index: 150;
}
.craft-panel.hidden { display: none; }
.cp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.cp-title { font-size: 14px; }
.cp-close {
  background: transparent;
  border: none;
  color: var(--gold);
  cursor: pointer;
  font-size: 18px;
  padding: 0 4px;
  line-height: 1;
}
.cp-grid { display: flex; flex-direction: column; gap: 6px; }
.cp-recipe {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  background: rgba(20, 26, 18, 0.6);
  border: 1px solid rgba(180, 200, 130, 0.18);
  border-radius: 5px;
}
.cp-icon { font-size: 22px; }
.cp-info { flex: 1; min-width: 0; }
.cp-name { font-weight: bold; }
.cp-cost { font-size: 11px; opacity: 0.85; }
.cp-craft {
  background: #2a2f23;
  border: 1px solid var(--border);
  color: var(--gold);
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
  font-family: monospace;
}
.cp-craft:hover:not(:disabled) { background: #3a4030; border-color: #b3d967; }
.cp-craft:disabled { opacity: 0.35; cursor: default; }
.cp-hint { margin-top: 10px; font-size: 11px; opacity: 0.6; text-align: center; }

/* ---------- Storage transfer panel ---------- */
.storage-panel {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  z-index: 300;
}
.storage-panel.hidden { display: none; }
.storage-content {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  min-width: 480px;
  max-width: 92vw;
  pointer-events: auto;
}
.storage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.storage-title {
  font-family: monospace;
  font-size: 16px;
  color: var(--gold);
}
.storage-close {
  background: transparent;
  border: none;
  color: var(--gold);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}
.storage-grids {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.storage-side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.storage-side h3 {
  margin: 0;
  font-family: monospace;
  font-size: 13px;
  color: var(--gold);
  font-weight: normal;
  opacity: 0.9;
}
.storage-bulk {
  background: #2a2f23;
  border: 1px solid var(--border);
  color: var(--gold);
  border-radius: 4px;
  font-family: monospace;
  font-size: 11px;
  padding: 4px 10px;
  cursor: pointer;
}
.storage-bulk:hover { background: #3a4030; }
.bag-drag-ghost.split::after {
  content: '½';
  position: absolute;
  top: 1px;
  left: 3px;
  font-size: 11px;
  font-weight: bold;
  color: #f5d76e;
  text-shadow: 1px 1px 0 #000;
}
.storage-hint {
  margin-top: 12px;
  font-family: monospace;
  font-size: 11px;
  color: var(--muted);
  opacity: 0.75;
  text-align: center;
}

/* ---------- Boot loader ---------- */
.boot-loader {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #1a221a;
  color: #e0d8c0;
  font-family: monospace;
  z-index: 9999;
}
.boot-loader.hidden { display: none; }
.bl-title { font-size: 56px; font-weight: bold; letter-spacing: 6px; margin-bottom: 8px; color: #b3d967; }
.bl-msg   { font-size: 13px; opacity: 0.75; margin-bottom: 22px; }
.bl-bar   { width: 320px; height: 8px; background: #303a30; border-radius: 4px; overflow: hidden; }
.bl-bar > i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #b3d967, #5e8c44);
  transition: width 0.18s ease-out;
}
.bl-pct   { margin-top: 10px; font-size: 13px; opacity: 0.7; }

/* ---------- Tame progress bar (over wild dinos being fed) ---------- */
.tame-bar {
  position: absolute;
  width: 60px;
  height: 7px;
  margin-left: -30px;     /* centered at projected screen point */
  margin-top: -4px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(0, 0, 0, 0.75);
  border-radius: 3px;
  overflow: hidden;
  pointer-events: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}
.tame-bar > i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #f5d76e, #e87b3a);
  transition: width 0.18s ease-out;
}

/* ---------- Dino hover tooltip ---------- */
.dino-tooltip {
  position: fixed;
  background: rgba(20, 28, 18, 0.92);
  border: 1px solid rgba(180, 200, 130, 0.4);
  border-radius: 4px;
  padding: 4px 8px;
  font-family: monospace;
  font-size: 12px;
  color: #e0e8c8;
  pointer-events: none;
  z-index: 200;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}
.dino-tooltip.hidden { display: none; }

/* ---------- Dino info / management panel ---------- */
.dino-panel {
  position: absolute;
  top: 60px;
  right: 16px;
  width: 240px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  pointer-events: auto;
  color: var(--gold);
  font-family: monospace;
  font-size: 13px;
  z-index: 150;
}
.dino-panel.hidden { display: none; }
.dp-header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.dp-emoji  { font-size: 22px; }
#dp-name {
  flex: 1;
  padding: 4px 6px;
  background: #2a2f23;
  border: 1px solid var(--border);
  color: var(--gold);
  border-radius: 4px;
  font-family: monospace;
  font-size: 13px;
}
.dp-close {
  background: transparent;
  border: none;
  color: var(--gold);
  cursor: pointer;
  font-size: 18px;
  padding: 0 4px;
  line-height: 1;
}
.dp-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-top: 1px solid rgba(180, 200, 130, 0.18);
}
.dp-row:first-of-type { border-top: none; }
.dp-label { opacity: 0.7; }
.dp-value { font-weight: bold; }
.dp-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(180, 200, 130, 0.18);
}
/* Label gets its own row so the four task buttons can share the panel width
   without overflowing past the right edge. */
.dp-actions .dp-label {
  flex-basis: 100%;
  margin: 0 0 2px 0;
}
.dp-btn {
  background: #2a2f23;
  border: 1px solid var(--border);
  color: var(--gold);
  border-radius: 4px;
  padding: 4px 0;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  flex: 1 1 0;
  min-width: 0;
}
.dp-btn:hover { background: #3a4030; }
.dp-btn.active {
  background: #5e8c44;
  border-color: #b3d967;
}
.dp-row-xp { gap: 8px; align-items: center; }
.dp-stats { margin-top: 6px; padding-top: 6px; border-top: 1px solid rgba(180, 200, 130, 0.18); }
.dp-stats-points { font-size: 11px; color: var(--gold); margin-bottom: 4px; }
.dp-stat {
  display: grid; grid-template-columns: 18px 1fr auto auto; gap: 6px; align-items: center;
  padding: 2px 0; font-size: 12px;
}
.dp-stat-icon { text-align: center; }
.dp-stat-name { opacity: 0.85; }
.dp-stat-val { color: var(--gold); font-family: monospace; min-width: 18px; text-align: right; }
.dp-stat-add {
  background: #2a4030; border: 1px solid var(--border); color: var(--gold);
  border-radius: 4px; padding: 1px 8px; cursor: pointer; font-size: 14px;
}
.dp-stat-add:disabled { opacity: 0.25; cursor: default; }
.dp-stat-add:hover:not(:disabled) { background: #3a5040; }
.dp-carry-slot { display: inline-flex; }
.dp-carry-slot .bag-slot { width: 38px; height: 38px; }
.dp-xp-bar {
  flex: 1;
  height: 8px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(180, 200, 130, 0.25);
  border-radius: 4px;
  overflow: hidden;
}
.dp-xp-bar > i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #f5d76e, #5e8c44);
  transition: width 0.25s ease-out;
}
.dp-xp-text { font-family: monospace; font-size: 11px; opacity: 0.85; }

.dp-breed-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(180, 200, 130, 0.18);
}
.dp-breed {
  background: #2a2f23;
  border: 1px solid var(--border);
  color: var(--gold);
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
  font-family: monospace;
  font-size: 12px;
}
.dp-breed:hover:not(:disabled) { background: #4a3030; border-color: #e87b9a; }
.dp-breed:disabled { opacity: 0.4; cursor: default; }
.dp-breed-status {
  font-family: monospace;
  font-size: 11px;
  opacity: 0.85;
  flex: 1;
  text-align: right;
}

/* ---------- Worker badge (over tamed dinos with a job) ---------- */
.worker-badge {
  position: absolute;
  width: 28px;
  height: 28px;
  margin-left: -14px;
  margin-top: -14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(0, 0, 0, 0.75);
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* ---------- FX layer (floating gains) ---------- */
.fx-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 5;
}
.fx-float {
  position: absolute;
  font-family: 'Impact', 'Arial Black', sans-serif;
  font-size: 22px;
  color: var(--gold);
  text-shadow: 2px 2px 0 #000, -2px 2px 0 #000, 2px -2px 0 #000, -2px -2px 0 #000;
  letter-spacing: 1px;
  pointer-events: none;
  white-space: nowrap;
  transform: translate(-50%, -50%);
  animation: fxFloatUp 1.2s ease-out forwards;
}
@keyframes fxFloatUp {
  0%   { opacity: 0; transform: translate(-50%, -30%) scale(0.7); }
  20%  { opacity: 1; transform: translate(-50%, -55%) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -180%) scale(1.0); }
}

/* ---------- Build panel ---------- */
.build-panel {
  position: absolute;
  bottom: 64px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  pointer-events: auto;
  min-width: 320px;
}
.build-panel.hidden { display: none; }
.build-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: 'Impact', 'Arial Black', sans-serif;
  font-size: 14px;
  color: var(--gold);
  letter-spacing: 1.5px;
  margin-bottom: 8px;
}
.build-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 20px;
  width: 24px;
  height: 24px;
  cursor: pointer;
  line-height: 1;
}
.build-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 6px;
}
.build-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(245,197,66,0.30);
  border-radius: 8px;
  padding: 8px 4px 6px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  transition: background 0.1s, border-color 0.1s;
}
.build-item:hover { background: rgba(0,0,0,0.55); border-color: var(--gold); }
.build-item.active {
  background: rgba(245,197,66,0.18);
  border-color: var(--gold);
  box-shadow: 0 0 0 1px rgba(245,197,66,0.4);
}
.bi-icon { font-size: 22px; line-height: 1; margin-bottom: 2px; }
.bi-name { font-size: 11px; font-weight: bold; color: var(--gold); }
.bi-cost { font-size: 10px; color: var(--muted); margin-top: 1px; font-family: monospace; }
.build-hint {
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  letter-spacing: 0.3px;
}

.hud-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  pointer-events: auto;
  font-family: inherit;
  transition: background 0.15s;
}
.hud-btn:hover { background: rgba(0,0,0,0.75); border-color: var(--gold); }
.hud-btn-lang {
  font-size: 13px;
  font-weight: bold;
  color: var(--gold);
  letter-spacing: 1px;
  width: auto;
  min-width: 44px;
  padding: 0 12px;
}

#lang-btn     { position: absolute; top: 14px; right: 164px; }
#skills-btn   { position: absolute; top: 14px; right: 114px; }
#players-btn  { position: absolute; top: 14px; right: 64px; }
#settings-btn { position: absolute; top: 14px; right: 14px; }

/* ---------- Skills panel ---------- */
.skills-panel {
  position: absolute;
  top: 64px;
  right: 14px;
  width: 280px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  z-index: 30;
  pointer-events: auto;
}
.skills-panel.hidden { display: none; }

.equip-panel {
  position: absolute;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  width: 320px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  z-index: 30;
  pointer-events: auto;
}
.equip-panel.hidden { display: none; }
.ep-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.ep-title { font-weight: bold; color: var(--gold); }
.ep-close {
  background: transparent; border: none; color: var(--text); font-size: 18px; cursor: pointer;
}
.ep-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}
.ep-slot {
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 4px;
  text-align: center;
  cursor: pointer;
  font-size: 22px;
  min-height: 50px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.ep-slot:hover { border-color: var(--gold); }
.ep-slot .ep-slot-name {
  font-size: 9px;
  color: #aaa;
  margin-top: 2px;
}
.ep-slot.empty { opacity: 0.45; }
.ep-stats {
  background: rgba(0,0,0,0.20);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12px;
  color: var(--text);
  margin-bottom: 8px;
  white-space: pre-line;
  line-height: 1.5;
}
.ep-hint { font-size: 11px; color: #aaa; }
.sp-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sp-title { font-weight: bold; color: var(--gold); }
.sp-close {
  background: none; border: none; color: var(--text);
  font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.sp-close:hover { color: var(--gold); }
.sp-row {
  display: grid;
  grid-template-columns: 28px 1fr 70px;
  gap: 6px; align-items: center;
  padding: 4px 0;
  border-top: 1px solid rgba(180, 200, 130, 0.18);
}
.sp-row:first-child { border-top: none; }
.sp-row .sp-icon { font-size: 18px; text-align: center; }
.sp-row .sp-name { font-size: 12px; }
.sp-row .sp-name small { display: block; opacity: 0.55; font-size: 10px; }
.sp-row .sp-bar {
  position: relative; height: 14px;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(180, 200, 130, 0.25);
  border-radius: 4px; overflow: hidden;
  grid-column: 1 / -1;
}
.sp-row .sp-bar i {
  display: block; height: 100%;
  background: linear-gradient(90deg, #5e8c44, #b3d967);
}
.sp-row .sp-bar span {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-family: monospace; color: #fff;
  text-shadow: 1px 1px 0 #000;
}
.sp-row .sp-level { color: var(--gold); font-family: monospace; font-size: 13px; text-align: right; }
.sp-hint { margin-top: 10px; font-size: 11px; opacity: 0.6; text-align: center; }

/* ============ Player list panel ============ */
.players-panel {
  position: absolute;
  top: 64px;
  right: 14px;
  width: 240px;
  max-height: 60vh;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  pointer-events: auto;
  z-index: 30;
  display: flex;
  flex-direction: column;
  font-size: 13px;
}
.players-panel.hidden { display: none; }
.pp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.pp-title { font-weight: bold; color: var(--gold); }
.pp-close {
  background: none;
  border: none;
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.pp-close:hover { color: var(--gold); }
.pp-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  flex: 1 1 auto;
}
.pp-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(0,0,0,0.25);
}
.pp-row.self { background: rgba(245, 215, 110, 0.12); }
.pp-dot { width: 8px; height: 8px; border-radius: 50%; background: #6dd45a; flex-shrink: 0; }
.pp-name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp-tag  { color: var(--gold); font-size: 11px; opacity: 0.85; }
.pp-empty { padding: 12px; text-align: center; opacity: 0.6; font-style: italic; }
.pp-hint { margin-top: 10px; font-size: 11px; opacity: 0.6; text-align: center; }

/* ============ Modal ============ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal.hidden { display: none; }
.modal-content {
  background: rgba(40, 30, 20, 0.95);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 24px 22px;
  max-width: 380px;
  width: 100%;
  position: relative;
  pointer-events: auto;
}
.modal-close {
  position: absolute;
  top: 6px;
  right: 6px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  line-height: 1;
}
.modal h2 {
  font-family: 'Impact', 'Arial Black', sans-serif;
  color: var(--gold);
  letter-spacing: 1px;
  margin-bottom: 16px;
  text-align: center;
}
.settings-row {
  display: flex;
  gap: 10px;
  margin: 10px 0;
}
.settings-row button {
  flex: 1;
  padding: 10px;
  background: var(--accent);
  color: #fff;
  border: 2px solid #1a1a1a;
  border-radius: 6px;
  font-weight: bold;
  cursor: pointer;
  text-shadow: 0 1px 0 rgba(0,0,0,0.4);
  font-family: inherit;
}
.settings-row button.danger { background: var(--danger); }
.settings-help {
  font-size: 12px;
  color: var(--muted);
  margin-top: 12px;
  text-align: center;
}

/* ---------- Health bar ---------- */
.hud-hp {
  position: relative;
  width: 160px;
  height: 12px;
  margin-top: 6px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.hud-hp-fill {
  position: absolute;
  inset: 0;
  width: 100%;
  background: linear-gradient(90deg, #d83838, #f25656);
  transition: width 0.18s linear;
}
.hud-hp-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: monospace;
  font-size: 10px;
  color: #fff;
  text-shadow: 1px 1px 0 #000;
  pointer-events: none;
}

/* ============ Mobile / touch — bigger hit targets, repositioned panels ============ */
@media (pointer: coarse) {
  /* Bigger action buttons in a 2-column grid above the right joystick */
  .mobile-actions {
    bottom: 175px;
    right: 14px;
    grid-template-columns: repeat(2, 60px);
    grid-auto-rows: 60px;
    gap: 8px;
  }
  .ma-btn {
    width: 60px;
    height: 60px;
    font-size: 22px;
  }

  /* Inventory: top-right under the lang/players/settings row so the right
     joystick can't cover it. Smaller cells to fit a phone screen. */
  .hud-bag-wrap {
    top: 58px;
    right: 14px;
    bottom: auto;
  }
  .hud-bag {
    grid-template-columns: repeat(4, 30px);
    grid-auto-rows: 30px;
    gap: 2px;
    padding: 4px;
  }
  .hud-bag-row { gap: 4px; }
  .hud-dinos-badge { font-size: 12px; padding: 3px 6px; }
  .hud-bag-toggle { width: 32px; height: 32px; font-size: 16px; }
  .hud-bag-hint { display: none; }

  /* Toolbar: just below the top-left HUD instead of bottom-centre, where
     the joysticks would have covered it. */
  .hud-toolbar {
    top: 100px;
    left: 14px;
    bottom: auto;
    transform: none;
    grid-template-columns: repeat(5, 38px);
    grid-auto-rows: 38px;
    gap: 3px;
    padding: 4px;
  }
  .hud-toolbar .bag-slot {
    width: 38px;
    height: 38px;
  }
  .hud-toolbar .bag-slot .bag-icon { font-size: 19px; }

  /* Top-left HUD chip smaller on phones */
  .hud-corner-tl { font-size: 11px; padding: 4px 6px; }
  .hud-name { font-size: 13px; }

  /* Hide the desktop "drag here · right-click deletes" hint and keyboard
     hint text — neither apply to touch input. */
  .hud-controls-hint { display: none; }
}

