:root {
  color-scheme: dark;
  --bg: #0d0d10;
  --fg: #e8e6e1;
  --dim: #8a8680;
  --accent: #e0a458;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0a0e14;
  color: var(--fg);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  -webkit-user-select: none;
  user-select: none;
}

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

#crosshair {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  z-index: 5;
  display: none;
}
body.playing #crosshair { display: block; }

.toast {
  position: fixed;
  top: 3.4rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(224, 164, 88, 0.95);
  color: #1a1408;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.3rem 0.7rem;
  border-radius: 0.3rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 20;
  max-width: 90vw;
  text-align: center;
}
.toast.show { opacity: 1; }

.compass {
  position: fixed;
  top: 3.4rem;
  right: 0.8rem;
  z-index: 6;
  display: none;
  align-items: center;
  gap: 0.35rem;
  background: rgba(12, 12, 16, 0.6);
  border: 1px solid #3a3a40;
  border-radius: 1rem;
  padding: 0.25rem 0.65rem;
  font-size: 0.72rem;
  color: var(--dim);
  pointer-events: none;
}
body.playing .compass { display: flex; }
.compass-arrow {
  display: inline-block;
  color: var(--accent);
  font-size: 0.95rem;
  transition: transform 0.15s ease;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0.9rem;
  background: linear-gradient(to bottom, rgba(10, 10, 14, 0.85), transparent);
  pointer-events: none;
}

h1 {
  font-size: 1.1rem;
  letter-spacing: 0.15em;
  margin: 0;
  text-transform: lowercase;
  color: var(--accent);
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

.topstats {
  color: var(--fg);
  font-size: 0.75rem;
  display: flex;
  gap: 0.9rem;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

.panels-toggle {
  pointer-events: auto;
  background: rgba(20, 20, 24, 0.7);
  border: 1px solid #3a3a40;
  color: var(--fg);
  border-radius: 0.3rem;
  width: 2rem;
  height: 2rem;
  cursor: pointer;
  font-size: 1rem;
}

.start-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 8, 12, 0.72);
}
.start-overlay.hidden { display: none; }

.start-card {
  max-width: 30rem;
  width: 90vw;
  background: rgba(16, 16, 20, 0.96);
  border: 1px solid #3a3a40;
  border-radius: 0.6rem;
  padding: 1.6rem 1.6rem 1.4rem;
  text-align: center;
}

.start-card h2 {
  margin: 0 0 0.6rem;
  color: var(--accent);
  letter-spacing: 0.12em;
  text-transform: lowercase;
}

.start-card p {
  color: var(--dim);
  font-size: 0.85rem;
  line-height: 1.5;
  margin: 0.6rem 0;
}

.controls-list {
  color: var(--fg) !important;
  font-size: 0.8rem !important;
  line-height: 1.9 !important;
}

.enter-btn {
  font-family: inherit;
  background: var(--accent);
  color: #1a1408;
  border: none;
  border-radius: 0.4rem;
  padding: 0.6rem 1.4rem;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  margin-top: 0.4rem;
}

.mobile-note {
  font-size: 0.72rem !important;
  opacity: 0.7;
}

.hotbar {
  position: fixed;
  bottom: 0.8rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.3rem;
  z-index: 10;
  pointer-events: auto;
  max-width: 95vw;
}

.hotbar-slot {
  width: 2.3rem;
  height: 2.3rem;
  border: 2px solid #3a3a40;
  border-radius: 0.3rem;
  background-size: cover;
  background-position: center;
  background-color: #1a1a1e;
  position: relative;
  cursor: pointer;
  image-rendering: pixelated;
}
.hotbar-slot.active {
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(224, 164, 88, 0.6);
}
.hotbar-slot .num {
  position: absolute;
  top: 1px;
  left: 3px;
  font-size: 0.6rem;
  color: rgba(255,255,255,0.85);
  text-shadow: 0 1px 2px #000;
}
.hotbar-more {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  color: var(--dim);
  letter-spacing: -0.1em;
  background-image: none !important;
}
.hotbar-more:hover { color: var(--accent); }

.selected-label {
  position: fixed;
  bottom: 3.4rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  font-size: 0.72rem;
  color: var(--dim);
  text-transform: capitalize;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
}

.block-palette {
  position: fixed;
  bottom: 5.4rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  width: min(92vw, 34rem);
  max-height: 60vh;
  overflow-y: auto;
  background: rgba(12, 12, 16, 0.92);
  border: 1px solid #3a3a40;
  border-radius: 0.5rem;
  padding: 0.7rem 0.9rem;
  pointer-events: auto;
}
.block-palette.hidden { display: none; }
.block-palette h4 {
  margin: 0.6rem 0 0.35rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}
.block-palette h4:first-child { margin-top: 0; }
.palette-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.palette-close {
  position: absolute;
  top: 0.4rem;
  right: 0.5rem;
  background: none;
  border: none;
  color: var(--dim);
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
}
.palette-close:hover { color: var(--accent); }

.chat-log {
  position: fixed;
  left: 0.8rem;
  bottom: 4.2rem;
  z-index: 10;
  max-width: 22rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  pointer-events: none;
}
.chat-log .line {
  font-size: 0.78rem;
  background: rgba(10, 10, 14, 0.55);
  padding: 0.15rem 0.4rem;
  border-radius: 0.2rem;
  color: var(--fg);
  width: fit-content;
}
.chat-log .line b { color: var(--accent); }

.chat-input-wrap {
  position: fixed;
  left: 50%;
  bottom: 4.2rem;
  transform: translateX(-50%);
  z-index: 30;
  width: min(90vw, 26rem);
}
.chat-input-wrap.hidden { display: none; }
#chatInput {
  width: 100%;
  font-family: inherit;
  font-size: 0.85rem;
  background: rgba(10, 10, 14, 0.9);
  border: 1px solid var(--accent);
  color: var(--fg);
  border-radius: 0.3rem;
  padding: 0.45rem 0.6rem;
  outline: none;
}

.panels {
  position: fixed;
  top: 3.2rem;
  right: 0.8rem;
  z-index: 10;
  width: 15rem;
  max-height: 70vh;
  overflow-y: auto;
  background: rgba(12, 12, 16, 0.78);
  border: 1px solid #2a2a30;
  border-radius: 0.4rem;
  padding: 0.7rem;
  pointer-events: auto;
}
.panels.hidden { display: none; }

.panel + .panel { margin-top: 0.8rem; }

.panel h3 {
  color: var(--dim);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0 0 0.35rem;
  font-weight: 500;
}

.leaderboard {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
  font-size: 0.76rem;
}
.leaderboard li { display: flex; align-items: center; gap: 0.35rem; color: var(--fg); }
.leaderboard .swatch { width: 0.55rem; height: 0.55rem; border-radius: 50%; flex-shrink: 0; }
.leaderboard .count { color: var(--dim); margin-left: auto; }

.events { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.28rem; }
.events li { color: var(--dim); font-size: 0.72rem; line-height: 1.3; }

.panel-footer { margin-top: 0.7rem; text-align: center; }
.panel-footer a { color: var(--dim); text-decoration: none; border-bottom: 1px dotted var(--dim); font-size: 0.78rem; }
.panel-footer a:hover { color: var(--accent); border-color: var(--accent); }

.touch-controls {
  position: fixed;
  inset: 0;
  z-index: 8;
  pointer-events: none;
}
.touch-controls.hidden { display: none; }

.joystick {
  position: fixed;
  left: 1.2rem;
  bottom: 1.2rem;
  width: 6.5rem;
  height: 6.5rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.25);
  pointer-events: auto;
  touch-action: none;
}
.joystick-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2.6rem;
  height: 2.6rem;
  margin: -1.3rem 0 0 -1.3rem;
  border-radius: 50%;
  background: rgba(224, 164, 88, 0.55);
  border: 1px solid rgba(224, 164, 88, 0.9);
}

.touch-actions {
  position: fixed;
  right: 1.2rem;
  bottom: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: auto;
}
.touch-btn {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: rgba(20, 20, 24, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: var(--fg);
  font-size: 1.1rem;
}

@media (max-width: 480px) {
  h1 { font-size: 0.95rem; }
  .panels { width: 12rem; font-size: 0.9em; }
}
