.game-flow-shell {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.game-flow-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.game-flow-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.game-flow-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.game-flow-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.game-flow-mode-select {
  min-width: 180px;
}

.game-flow-saving-banner {
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(79, 70, 229, 0.08);
  color: var(--primary);
  font-size: 13px;
}

.game-flow-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
  gap: 16px;
}

.game-flow-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.game-flow-board,
.game-flow-panel,
.game-flow-inspector-card,
.game-flow-relations-graph,
.game-flow-relations-timeline,
.game-flow-attr-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.game-flow-board {
  position: relative;
  overflow: hidden;
  min-height: 500px;
  background-image: radial-gradient(circle, rgba(0,0,0,0.08) 1px, transparent 1px);
  background-size: 20px 20px;
}

.game-flow-canvas {
  position: relative;
  transform-origin: 0 0;
  transition: transform 0.1s ease;
  min-width: 100%;
  min-height: 100%;
}

.game-flow-mode-banner {
  padding: 10px 12px;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 10px;
  background: rgba(15, 118, 110, 0.06);
  color: var(--text-primary);
}

.game-flow-mode-banner-meta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}

.game-flow-rail {
  display: flex;
  align-items: flex-start;
  min-width: max-content;
  gap: 8px;
}

.game-flow-stage {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.game-flow-chapter-card {
  position: relative;
  width: 220px;
  min-height: 128px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--bg-white) 0%, var(--bg-primary) 100%);
  cursor: pointer;
  text-align: left;
}

.game-flow-port {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--bg-white);
  box-shadow: 0 0 0 1px var(--primary);
}
.game-flow-port-left { left: -5px; top: 50%; transform: translateY(-50%); }
.game-flow-port-right { right: -5px; top: 50%; transform: translateY(-50%); }

.game-flow-chapter-card.is-active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.game-flow-chapter-step {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--primary);
  letter-spacing: 0.08em;
}

.game-flow-chapter-title {
  margin-top: 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.game-flow-chapter-meta {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.game-flow-stage-notes {
  width: 220px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.game-flow-stage-characters,
.game-flow-stage-endings,
.game-flow-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.game-flow-arrow {
  color: var(--text-muted);
  font-size: 18px;
}

.game-flow-edges {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}
.game-flow-edge {
  fill: none;
  stroke: var(--border);
  stroke-width: 2;
}
.game-flow-edge-active {
  stroke: var(--primary);
  stroke-width: 2.5;
}

.game-flow-mini-node {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-white);
}
.game-flow-mini-node-danger { border-color: rgba(239,68,68,0.3); color: #b91c1c; }
.game-flow-mini-node-success { border-color: rgba(16,185,129,0.3); color: #047857; }
.game-flow-mini-node-info { border-color: rgba(79,70,229,0.3); color: #4338ca; }

.game-flow-zoom-controls {
  position: absolute;
  bottom: 12px;
  left: 12px;
  display: flex;
  gap: 4px;
  z-index: 10;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  box-shadow: var(--shadow);
}
.game-flow-zoom-controls button {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}
.game-flow-zoom-controls button:hover { background: var(--bg-primary); }
.game-flow-zoom-label {
  display: flex;
  align-items: center;
  padding: 0 6px;
  font-size: 11px;
  color: var(--text-secondary);
}

.game-flow-start-node {
  position: absolute;
  width: 80px;
  height: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: white;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(79,70,229,0.3);
  z-index: 1;
}

.game-flow-chip,
.game-flow-avatar-chip,
.game-flow-pill {
  border: 1px solid var(--border);
  background: var(--bg-white);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--text-primary);
}

.game-flow-chip-danger {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.2);
  color: #b91c1c;
}

.game-flow-chip-success {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.2);
  color: #047857;
}

.game-flow-stage-reward,
.game-flow-empty-inline,
.game-flow-attr-category,
.game-flow-relation-meta,
.game-flow-relation-affinity,
.game-flow-relation-appear,
.game-flow-curve-delta,
.game-flow-field-note {
  font-size: 12px;
  color: var(--text-secondary);
}

.game-flow-field-note {
  margin-top: 6px;
}

.game-flow-bottom-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.game-flow-panel {
  padding: 14px 16px;
}

.game-flow-panel-title,
.game-flow-editor-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
}

details.game-flow-editor-block > summary.game-flow-editor-title {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  list-style: none;
  margin-bottom: 10px;
}

details.game-flow-editor-block > summary.game-flow-editor-title::-webkit-details-marker {
  display: none;
}

details.game-flow-editor-block[open] > summary.game-flow-editor-title::after {
  content: '▾';
  font-size: 10px;
  color: var(--text-secondary);
  margin-left: 2px;
}

details.game-flow-editor-block:not([open]) > summary.game-flow-editor-title::after {
  content: '▸';
  font-size: 10px;
  color: var(--text-secondary);
  margin-left: 2px;
}

.game-flow-inspector {
  min-width: 0;
}

.game-flow-inspector-card {
  padding: 16px;
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 64px);
  overflow: auto;
}

.game-flow-inspector-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.game-flow-inspector-kicker {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  font-weight: 700;
}

.game-flow-inspector-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.game-flow-inspector-section,
.game-flow-editor-block {
  margin-top: 16px;
}

.game-flow-readonly {
  padding: 12px;
  border-radius: 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  font-size: 13px;
  white-space: pre-wrap;
}

.game-flow-inline-form,
.game-flow-editor-actions,
.game-flow-edit-grid,
.game-flow-header,
.game-flow-character-meta,
.game-flow-curve-row {
  display: flex;
  gap: 8px;
}

.game-flow-inline-form .form-control {
  max-width: 120px;
}

.game-flow-edit-card {
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 10px;
  padding: 12px;
  padding-left: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-white);
}

.game-flow-edit-card-danger {
  border-left-color: #ef4444;
}

.game-flow-edit-card-success {
  border-left-color: #10b981;
}

.game-flow-json-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 12px;
  padding: 6px 8px;
  background: var(--bg-primary);
  border-radius: 6px;
  border: 1px solid var(--border);
  min-height: 32px;
  align-items: center;
}

.game-flow-json-preview .game-flow-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  border: none;
}

.game-flow-edit-grid > label,
.game-flow-edit-card > label {
  flex: 1;
  font-size: 12px;
  color: var(--text-secondary);
}

.game-flow-inline-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.game-flow-json {
  min-height: 96px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.game-flow-relations,
.game-flow-attr-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.game-flow-relations-graph,
.game-flow-relations-timeline {
  padding: 16px;
}

.game-flow-protagonist-card {
  padding: 18px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.12), rgba(59, 130, 246, 0.06));
  border: 1px solid rgba(79, 70, 229, 0.16);
  margin-bottom: 16px;
}

.game-flow-protagonist-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  font-weight: 700;
}

.game-flow-protagonist-name {
  font-size: 22px;
  font-weight: 800;
  margin-top: 6px;
}

.game-flow-protagonist-meta {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.game-flow-relation-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.game-flow-relation-card {
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-white);
  padding: 12px;
}

.game-flow-relation-name,
.game-flow-attr-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.game-flow-timeline-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.game-flow-timeline-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
  align-items: start;
}

.game-flow-timeline-chapter {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}

.game-flow-attr-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.game-flow-attr-card {
  padding: 16px;
}

.game-flow-attr-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.game-flow-attr-threshold {
  font-size: 12px;
  color: #b91c1c;
  font-weight: 600;
}

.game-flow-curve-row {
  overflow-x: auto;
  padding-bottom: 4px;
}

.game-flow-curve-point {
  min-width: 80px;
  padding: 10px;
  border-radius: 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  text-align: center;
}

.game-flow-curve-label {
  font-size: 11px;
  color: var(--text-secondary);
}

.game-flow-curve-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
}

.game-flow-character-modal .modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.game-flow-character-desc {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.7;
}

@media (max-width: 1200px) {
  .game-flow-layout {
    grid-template-columns: 1fr;
  }

  .game-flow-inspector-card {
    position: static;
    max-height: none;
  }
}

@media (max-width: 768px) {
  .game-flow-header,
  .game-flow-attr-header,
  .game-flow-edit-grid,
  .game-flow-bottom-grid {
    flex-direction: column;
    grid-template-columns: 1fr;
  }

  .game-flow-toolbar {
    width: 100%;
  }

  .game-flow-chapter-card,
  .game-flow-stage-notes {
    width: 190px;
  }
}

/* ── Fullscreen ── */
.game-flow-shell.is-fullscreen,
.game-flow-shell:fullscreen,
.game-flow-shell:-webkit-full-screen {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 9999;
  background: var(--bg-primary);
  overflow: auto;
  padding: 16px;
}
.game-flow-shell.is-fullscreen .game-flow-board,
.game-flow-shell:fullscreen .game-flow-board,
.game-flow-shell:-webkit-full-screen .game-flow-board { min-height: calc(100vh - 200px); }

/* ── Branch edge styles ── */
.game-flow-edge-svg { position: absolute; top: 0; left: 0; pointer-events: none; overflow: visible; }
.game-flow-edge-danger { stroke: #ef4444; stroke-width: 1.5; stroke-dasharray: 6 3; fill: none; }
.game-flow-edge-warn { stroke: #f59e0b; stroke-width: 1.5; stroke-dasharray: 6 3; fill: none; }
.game-flow-edge-success { stroke: #10b981; stroke-width: 2; fill: none; }

/* ── Branch nodes ── */
.game-flow-branch-node {
  position: absolute;
  display: flex; align-items: center; gap: 4px;
  padding: 4px 8px; border-radius: 6px; font-size: 11px;
  cursor: pointer; white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  transition: box-shadow 0.15s, transform 0.15s;
}
.game-flow-branch-node:hover { transform: translateY(-1px); box-shadow: 0 3px 8px rgba(0,0,0,0.12); }
.game-flow-branch-fail { background: rgba(239,68,68,0.06); border: 1px solid rgba(239,68,68,0.25); color: #b91c1c; }
.game-flow-branch-ending { background: rgba(16,185,129,0.06); border: 1px solid rgba(16,185,129,0.25); color: #047857; }
