:root {
  --bg: #eaf2ff;
  --bg-accent: #fce4ec;
  --ink: #2b2540;
  --ink-soft: #6a6587;
  --accent: #ff7eb6;
  --accent-2: #6cc6ff;
  --accent-3: #ffd166;
  --panel-bg: #ffffff;
  --panel-border: #e3e7ee;
  --shadow: 0 10px 32px rgba(43, 37, 64, 0.12);
  --shadow-soft: 0 4px 14px rgba(43, 37, 64, 0.06);
  --topbar-h: 76px;
  --panel-w: 340px;
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 20%, var(--bg-accent) 0%, transparent 45%),
    radial-gradient(circle at 85% 80%, #c8e6ff 0%, transparent 50%),
    var(--bg);
}

#topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-h);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 24px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--panel-border);
  z-index: 10;
  box-shadow: var(--shadow-soft);
}

#topbar h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.2px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

#topbar .hint {
  margin: 4px 0 0 0;
  font-size: 13px;
  color: var(--ink-soft);
  font-weight: 500;
}

#stage {
  position: absolute;
  top: var(--topbar-h);
  left: 0;
  right: 0;
  bottom: 0;
}

#canvas-root {
  position: absolute;
  inset: 0;
}

#canvas-root canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  cursor: grab;
}

#canvas-root canvas:active {
  cursor: grabbing;
}

#panel {
  position: fixed;
  top: calc(var(--topbar-h) + 12px);
  right: 12px;
  width: var(--panel-w);
  height: calc(100vh - var(--topbar-h) - 24px);
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transform: translateX(calc(100% + 24px));
  transition: transform 0.3s cubic-bezier(0.34, 1.2, 0.64, 1);
  padding: 24px 24px 20px 24px;
  z-index: 20;
  overflow-y: auto;
}

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

#panel-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: var(--bg);
  border: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--ink-soft);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

#panel-close:hover,
#panel-close:focus {
  color: var(--ink);
  background: var(--bg-accent);
  transform: scale(1.05);
  outline: none;
}

#panel h2 {
  margin: 0 0 10px 0;
  font-size: 22px;
  font-weight: 800;
  color: var(--ink);
  padding-right: 40px;
  line-height: 1.2;
}

#panel-short {
  font-style: italic;
  color: var(--ink-soft);
  margin: 0 0 16px 0;
  font-size: 14px;
  line-height: 1.45;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: 12px;
  border-left: 3px solid var(--accent-2);
}

#panel-detail {
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
  margin: 0;
}

#panel-sections h3 {
  margin: 18px 0 6px 0;
  font-size: 12px;
  font-weight: 800;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-top: 1px solid var(--panel-border);
  padding-top: 14px;
}

#panel-sections h3:first-child {
  border-top: none;
  margin-top: 16px;
  padding-top: 0;
}

#panel-sections p {
  margin: 0 0 14px 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink);
}

#legend {
  position: fixed;
  left: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  box-shadow: var(--shadow-soft);
  z-index: 15;
  font-size: 12px;
  color: var(--ink-soft);
  max-width: 200px;
  pointer-events: none;
}

#legend strong {
  display: block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--ink);
  margin-bottom: 2px;
}

#legend span {
  display: flex;
  align-items: center;
  gap: 8px;
}

#legend i {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
