:root {
  /* color system */
  --bg: #0d0f17;
  --bg-elev: #141723;
  --panel: rgba(20, 23, 35, 0.72);
  --panel-strong: rgba(20, 23, 35, 0.88);
  --panel-border: rgba(148, 163, 184, 0.14);
  --panel-border-strong: rgba(148, 163, 184, 0.22);

  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-faint: #64748b;

  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --accent-soft: rgba(56, 189, 248, 0.16);
  --accent-glow: rgba(56, 189, 248, 0.35);

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 14px 40px -16px rgba(0, 0, 0, 0.7);

  --font: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

#canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#canvas:active {
  cursor: grabbing;
}

/* ---- glass panels ---- */
.topbar,
.statusbar,
.hint {
  position: absolute;
  z-index: 10;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  box-shadow: var(--shadow);
}

.topbar,
.hint {
  animation: rise 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* statusbar is horizontally centered via transform, so its entrance
   animates the individual `translate` property to avoid clobbering it */
.statusbar {
  animation: rise-center 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes rise-center {
  from {
    opacity: 0;
    translate: 0 -8px;
  }
  to {
    opacity: 1;
    translate: 0 0;
  }
}

/* ---- top bar (brand) ---- */
.topbar {
  top: 16px;
  left: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px 9px 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
}
.brand-mark {
  width: 22px;
  height: 22px;
  color: var(--accent);
  filter: drop-shadow(0 0 6px var(--accent-glow));
}
.brand-name {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.02em;
  color: var(--text);
}
.brand-accent {
  color: var(--accent);
}
.topbar-tag {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.1);
  border: 1px solid var(--panel-border);
}

/* ---- hint (desktop, top-right) ---- */
.hint {
  top: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 14px;
  font-size: 12px;
  color: var(--text-muted);
}
.hint span {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
.hint kbd {
  font-family: var(--mono);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(148, 163, 184, 0.12);
  border: 1px solid var(--panel-border);
  color: var(--text);
  margin-right: 6px;
  line-height: 1;
}

/* ---- bottom control bar ----
   Desktop: a centered pill. Mobile: full-width, coordinates on the left,
   zoom stepper + reset on the right for one-thumb reach. */
.statusbar {
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 14px;
}

.coord-group {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.coord {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.coord-label {
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 10px;
  font-weight: 600;
}
.coord-value {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  min-width: 44px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sb-divider {
  width: 1px;
  height: 22px;
  background: var(--panel-border);
  flex: none;
}

.controls-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

.zoom-group {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: rgba(148, 163, 184, 0.07);
}

.zoom-readout {
  min-width: 52px;
  text-align: center;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  user-select: none;
  padding: 0 4px;
}

/* ---- control buttons ---- */
.ctrl-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.18s ease, background 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
}
.ctrl-btn svg {
  width: 18px;
  height: 18px;
}
.ctrl-btn:hover {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--panel-border-strong);
}
.ctrl-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.ctrl-btn:active {
  transform: scale(0.9);
}

/* ---- responsive ---- */
@media (max-width: 720px) {
  .hint {
    display: none;
  }
  .topbar-tag {
    display: none;
  }

  .statusbar {
    left: 10px;
    right: 10px;
    bottom: 10px;
    transform: none;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 10px;
  }
  .sb-divider {
    display: none;
  }
  .coord-group {
    gap: 10px;
  }
  .coord-value {
    min-width: 30px;
    font-size: 11.5px;
  }
  .coord-label {
    font-size: 9px;
  }
  .controls-group {
    gap: 8px;
  }
  .zoom-group {
    padding: 2px;
  }
  .zoom-readout {
    min-width: 42px;
    font-size: 11.5px;
  }
  .ctrl-btn {
    width: 32px;
    height: 32px;
  }
  .ctrl-btn svg {
    width: 16px;
    height: 16px;
  }
}

@media (max-width: 380px) {
  .topbar {
    top: 10px;
    left: 10px;
    padding: 8px 11px 8px 9px;
  }
  .statusbar {
    gap: 6px;
    padding: 6px 8px;
  }
  .coord-group {
    gap: 8px;
  }
  .coord-value {
    min-width: 26px;
  }
  .zoom-readout {
    min-width: 38px;
  }
  .ctrl-btn {
    width: 30px;
    height: 30px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
