:root {
  --panel: rgba(18, 21, 26, 0.72);
  --panel-border: rgba(255, 255, 255, 0.12);
  --text: #f4f5f7;
  --muted: #b5bac2;
  --accent: #ffc440;
  --font: "Inter", -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0b0d10;
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

#viewer,
#viewer canvas {
  position: fixed;
  inset: 0;
  display: block;
  cursor: pointer;
  touch-action: none;
}

#viewer canvas.dragging {
  cursor: grabbing;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(10px);
}

#topbar {
  position: fixed;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
}

#title,
#mode-toggle,
#mode-banner,
#floor-selector,
#minimap,
#brand,
#hint {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

#title {
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

#mode-toggle {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  color: var(--text);
  font: 600 14px var(--font);
  cursor: pointer;
}

#mode-toggle:hover {
  border-color: rgba(255, 255, 255, 0.35);
}

.mode-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #8fa3b8;
}

body[data-mode="enhanced"] .mode-dot {
  background: var(--accent);
}

kbd {
  display: inline-block;
  min-width: 18px;
  padding: 1px 5px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 4px;
  font: 600 11px var(--font);
  color: var(--muted);
  text-align: center;
}

#mode-banner {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
}

body[data-mode="enhanced"] #mode-banner {
  border-color: rgba(255, 196, 64, 0.55);
}

.enhanced-fallback {
  margin-left: 8px;
  font-weight: 500;
  color: var(--muted);
}

.split-label .enhanced-fallback {
  display: block;
  margin: 4px 0 0;
  font-size: 14px;
}

.enhanced-fallback[hidden] {
  display: none;
}

#map-panel {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

#floor-selector {
  display: flex;
  border-radius: 10px;
  overflow: hidden;
}

#floor-selector button {
  padding: 7px 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 600 13px var(--font);
  cursor: pointer;
}

#floor-selector button.active {
  background: rgba(255, 255, 255, 0.14);
  color: var(--text);
}

#minimap {
  width: 232px;
  height: 232px;
  border-radius: 12px;
  cursor: pointer;
}

#footer {
  position: fixed;
  left: 16px;
  bottom: 16px;
  display: flex;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

#brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

#brand .mark {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: linear-gradient(135deg, #ffc440, #ff7a59);
}

#hint {
  padding: 6px 11px;
  border-radius: 9px;
  font-size: 12px;
  color: var(--muted);
}

#split-labels {
  display: none;
}

body[data-split="1"] #split-labels {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  pointer-events: none;
}

body[data-split="1"] .split-label {
  align-self: start;
  justify-self: start;
  margin: 18px;
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  font-size: 18px;
  font-weight: 650;
}

body[data-split="1"] .split-label:nth-child(2) {
  border-color: rgba(255, 196, 64, 0.55);
}

body[data-split="1"] #split-labels::after {
  content: "";
  position: fixed;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  background: rgba(255, 255, 255, 0.85);
}

body[data-split="1"] #topbar,
body[data-split="1"] #mode-banner,
body[data-split="1"] #hint,
body[data-split="1"] #floor-selector {
  display: none;
}

body[data-split="1"] #minimap {
  width: 176px;
  height: 176px;
}

#loading {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: #0b0d10;
  transition: opacity 0.4s;
}

body.loaded #loading {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

#error {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 14px 18px;
  border-radius: 10px;
  background: rgba(120, 20, 20, 0.92);
  font-size: 14px;
}

@media (max-width: 720px) {
  #hint,
  #mode-banner {
    display: none;
  }
  #minimap {
    width: 160px;
    height: 160px;
  }
}

#clip-wait {
  position: fixed;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: rgba(255, 255, 255, 0.95);
  border-radius: 50%;
  pointer-events: none;
  animation: clip-wait-spin 0.8s linear infinite;
  z-index: 5;
}
#clip-wait[hidden] {
  display: none;
}
@keyframes clip-wait-spin {
  to {
    transform: rotate(360deg);
  }
}
#help-hint {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(18, 21, 26, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 13px;
  letter-spacing: 0.01em;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.8s ease;
  z-index: 4;
}
#help-hint.visible {
  opacity: 1;
}
#clip-debug {
  position: fixed;
  left: 12px;
  bottom: 48px;
  margin: 0;
  padding: 6px 8px;
  font: 11px/1.4 ui-monospace, monospace;
  color: #cfe;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 4px;
  pointer-events: none;
  z-index: 6;
}
#clip-debug[hidden] {
  display: none;
}
