:root {
  --bg: #06060f;
  --ink: #dddddd;
  --solid: #444444;
  --safe: #55aa88;
  --hazard: #cc8844;
  --grapple: #4488cc;
  --point: #4499dd;
  --rope: #db2d2d;
  --hud-bg: rgba(15, 15, 18, 0.96);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow: hidden;
  background: #06060f;
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

.app {
  width: 100vw;
  height: 100vh;
  position: relative;
}

.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--hud-bg);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding: 8px 12px;
}

.hud__left,
.hud__right {
  display: flex;
  align-items: center;
  gap: 14px;
}

#debugInfo {
  font-size: 0.78rem;
  font-weight: 600;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

button {
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08);
  color: var(--ink);
  padding: 6px 12px;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: rgba(255,255,255,0.14);
  transform: translateY(-1px);
}

canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #06060f;
  touch-action: none;
  cursor: none;
}

.legend {
  position: absolute;
  bottom: 8px;
  left: 12px;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 0.82rem;
  opacity: 0.6;
}

.legend__swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 6px;
  vertical-align: -2px;
  border: 1px solid rgba(255,255,255,0.2);
}

.legend__swatch--solid { background: var(--solid); }
.legend__swatch--safe { background: var(--safe); }
.legend__swatch--hazard { background: var(--hazard); }
.legend__swatch--grapple { background: var(--grapple); }
.legend__swatch--point { background: var(--point); }
.legend__swatch--rope { background: var(--rope); }

/* JSON load overlay */
.json-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.55);
  justify-content: center;
  align-items: center;
}

.json-overlay.open {
  display: flex;
}

.json-dialog {
  background: #1a1a1e;
  border: 1px solid rgba(255,255,255,0.15);
  padding: 16px 20px;
  width: min(560px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.json-dialog__label {
  font-weight: 700;
  font-size: 0.95rem;
}

.json-dialog__textarea {
  width: 100%;
  resize: vertical;
  font-family: "Courier New", monospace;
  font-size: 0.82rem;
  padding: 8px;
  border: 1px solid rgba(255,255,255,0.15);
  background: #111114;
  color: var(--ink);
}

.json-dialog__textarea:focus {
  outline: none;
  border-color: var(--grapple);
}

.json-dialog__buttons {
  display: flex;
  gap: 8px;
}

.json-dialog__status {
  font-size: 0.82rem;
  min-height: 1.2em;
}

.json-dialog__status.error {
  color: #e85050;
  font-weight: 600;
}

.json-dialog__status.ok {
  color: #44cc66;
  font-weight: 600;
}

/* Tuning panel */
.tuning-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 280px;
  height: 100vh;
  background: rgba(15, 15, 18, 0.95);
  border-left: 1px solid #333;
  overflow-y: auto;
  padding: 12px;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: #aaa;
  z-index: 1000;
  transform: translateX(100%);
  transition: transform 0.2s ease;
}

.tuning-panel.open {
  transform: translateX(0);
}

.tuning-group {
  margin-bottom: 16px;
}

.tuning-group-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #666;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid #2a2a2e;
}

.tuning-row {
  margin-bottom: 10px;
}

.tuning-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 2px;
}

.tuning-name { color: #999; }
.tuning-value { color: #ddd; font-weight: bold; }

.tuning-slider {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: #333;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.tuning-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #4488cc;
  cursor: pointer;
}

.tuning-range {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: #555;
  margin-top: 1px;
}

.tuning-actions {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #2a2a2e;
}

.tuning-action-btn {
  flex: 1;
  padding: 6px;
  background: #2a2a2e;
  border: 1px solid #444;
  color: #aaa;
  font-family: inherit;
  font-size: 10px;
  cursor: pointer;
  border-radius: 2px;
  text-align: center;
}

.tuning-action-btn:hover { background: #333; color: #ddd; }

/* Volume control */
.volume-control {
  display: flex;
  align-items: center;
  gap: 6px;
}

.volume-slider {
  width: 70px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: #333;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  vertical-align: middle;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #4488cc;
  cursor: pointer;
}

#muteBtn {
  font-size: 0.75rem;
  padding: 4px 8px;
  min-width: 36px;
}

#muteBtn.muted {
  color: #666;
  border-color: rgba(255,255,255,0.1);
}

@media (max-width: 900px) {
  .hud {
    flex-direction: column;
    align-items: flex-start;
  }
}
