:root {
  --bg-a: #111827;
  --bg-b: #0a1020;
  --panel: rgba(15, 23, 36, 0.82);
  --panel-border: rgba(180, 198, 224, 0.18);
  --ink: #edf2fb;
  --muted: #b5c0d2;
  --accent: #1967d2;
  --accent-soft: rgba(25, 103, 210, 0.14);
  --shadow: 0 8px 30px rgba(2, 8, 20, 0.42);
  --r: #ec4d4d;
  --g: #43a75e;
  --b: #4382f2;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
}

body {
  color: var(--ink);
  font-family: "Avenir Next", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", sans-serif;
  background:
    radial-gradient(circle at 15% 15%, rgba(255, 173, 96, 0.17), transparent 32%),
    radial-gradient(circle at 80% 75%, rgba(78, 152, 255, 0.2), transparent 38%),
    linear-gradient(140deg, var(--bg-a), var(--bg-b));
}

.app-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

.app-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  min-height: 70px;
  border-bottom: 1px solid var(--panel-border);
  background: var(--panel);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  z-index: 3;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: rgba(22, 33, 52, 0.84);
}

.control-group.hidden {
  display: none;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 10px;
  background: rgba(245, 248, 255, 0.95);
  color: var(--muted);
  cursor: pointer;
  transition: transform 0.12s ease, color 0.16s ease, border-color 0.16s ease;
}

.icon-btn:hover {
  transform: translateY(-1px);
  color: var(--ink);
  border-color: rgba(25, 103, 210, 0.2);
}

.icon-btn:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

.icon-btn.is-active {
  color: var(--accent);
  border-color: rgba(25, 103, 210, 0.45);
  background: var(--accent-soft);
}

.icon-btn svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.small-icon {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.color-dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 0 0 1px rgba(27, 40, 56, 0.25);
}

.dot-r {
  background: var(--r);
}

.dot-g {
  background: var(--g);
}

.dot-b {
  background: var(--b);
}

.slider-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
}

#tps-slider {
  width: min(220px, 24vw);
  accent-color: var(--accent);
}

.metric {
  min-width: 1.8em;
  text-align: right;
  font-size: 0.85rem;
  color: var(--ink);
}

.metric-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 9px;
  height: 32px;
  border-radius: 999px;
  background: rgba(23, 36, 56, 0.88);
  border: 1px solid rgba(184, 205, 239, 0.18);
  color: var(--ink);
  font-size: 0.86rem;
}

.canvas-stage {
  position: relative;
  flex: 1;
  min-height: 0;
}

#hex-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

#hex-canvas.is-panning {
  cursor: grabbing;
}

.context-menu {
  position: absolute;
  z-index: 8;
  width: 0;
  height: 0;
  overflow: visible;
  pointer-events: none;
  transform-origin: top left;
  animation: pop-in 130ms ease;
}

.context-menu.hidden {
  display: none;
}

.menu-btn {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(171, 198, 235, 0.22);
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: rgba(245, 248, 255, 0.94);
  color: #45566f;
  cursor: pointer;
  pointer-events: auto;
}

.menu-btn.radial-btn {
  position: absolute;
  transform: translate(-50%, -50%);
}

.menu-btn:hover {
  color: var(--ink);
  border-color: rgba(25, 103, 210, 0.35);
}

.menu-btn.danger {
  color: #c44545;
}

.menu-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.menu-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(27, 40, 56, 0.22);
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (max-width: 980px) {
  .app-header {
    padding: 8px;
    gap: 7px;
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .control-group {
    padding: 4px;
    gap: 6px;
  }

  .icon-btn {
    width: 34px;
    height: 34px;
  }

  #tps-slider {
    width: 130px;
  }
}
