:root {
  --bg: #f7f7f5;
  --panel: #ffffff;
  --text: #1f1f1f;
  --muted: #636363;
  --edge: #c8c8c8;
  --node: #6a6a6a;
  --start: #2d9c6a;
  --end: #da4b4b;
  --food: #f2b635;
  --selected: #3a7afe;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.page {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.header h1 {
  margin: 0 0 6px;
}

.header p {
  margin: 0 0 8px;
  color: var(--muted);
}

.footer {
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 14px;
  align-items: start;
}

.panel,
.board-wrap {
  background: var(--panel);
  border: 1px solid #e8e8e8;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.03);
}

.board-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.board-toolbar {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--panel);
  border: 1px solid #e8e8e8;
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.03);
}

.import-group {
  flex: 1;
  min-width: 0;
}

.import-group textarea {
  width: 100%;
  font-family: monospace;
  font-size: 0.85rem;
  resize: none;
  min-height: 36px;
  margin-bottom: 6px;
}

.import-group .row {
  gap: 6px;
}

#import-error {
  margin: 4px 0 0;
}

.board-toolbar #playtest-level {
  margin-top: 0;
  white-space: nowrap;
  border-color: #bad8ff;
  background: #edf4ff;
  color: #1a56db;
  font-weight: 600;
  align-self: flex-start;
}

.panel {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section {
  border-top: 1px solid #ececec;
  padding-top: 10px;
}

.section h2 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
  font-size: 0.92rem;
}

select,
button,
textarea,
input {
  border: 1px solid #d8d8d8;
  border-radius: 8px;
  padding: 8px;
  font: inherit;
}

button {
  cursor: pointer;
  background: #fff;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 120px;
}

.row {
  display: flex;
  gap: 8px;
}

.row input {
  flex: 1;
  min-width: 0;
}

.board-wrap {
  padding: 10px;
}

.board {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
  background: #fcfcfc;
}

.edge {
  stroke: var(--edge);
  stroke-width: 3;
  stroke-linecap: round;
}

.node {
  fill: var(--node);
  stroke: #ffffff;
  stroke-width: 2;
  cursor: pointer;
}

.node-start {
  fill: var(--start);
}

.node-end {
  fill: var(--end);
}

.node-food {
  fill: var(--food);
}

.node-selected {
  stroke: var(--selected);
  stroke-width: 4;
}

.node-label {
  font-size: 12px;
  fill: #8a8a8a;
  text-anchor: middle;
  pointer-events: none;
}

.node-second-selected {
  stroke: #f97316;
  stroke-width: 4;
}

.context-menu {
  position: fixed;
  z-index: 1000;
  background: #fff;
  border: 1px solid #d8d8d8;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  padding: 4px 0;
  min-width: 140px;
  font-size: 0.9rem;
}

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

.context-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 14px;
  border: none;
  background: none;
  cursor: pointer;
  font: inherit;
  color: var(--text);
  border-radius: 0;
}

.context-menu-item:hover {
  background: #f0f0f0;
}

.context-menu-separator {
  height: 1px;
  background: #ececec;
  margin: 4px 0;
}

#playtest-level {
  width: 100%;
  border-color: #bad8ff;
  background: #edf4ff;
  color: #1a56db;
  font-weight: 600;
}

.file-label {
  display: inline-block;
  border: 1px solid #d8d8d8;
  background: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  text-align: center;
}

.file-label:hover {
  background: #f5f5f5;
}

.file-label input[type="file"] {
  display: none;
}

.import-error {
  color: #da4b4b;
  font-size: 0.85rem;
  min-height: 1.2em;
}
