:root {
  color-scheme: dark;
  --bg: #151719;
  --panel: #202428;
  --panel-2: #2b3035;
  --ink: #f3f0e8;
  --muted: #aeb7bd;
  --line: #3d454b;
  --accent: #f04f90;
  --green: #38d166;
  --sand: #d9ae5b;
  --blue: #5db8ff;
}

* {
  box-sizing: border-box;
}

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

.app {
  display: grid;
  grid-template-columns: 310px minmax(360px, 1fr) 320px;
  min-height: 100vh;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
  background: var(--panel);
  border-color: var(--line);
}

.left-panel {
  border-right: 1px solid var(--line);
}

.right-panel {
  border-left: 1px solid var(--line);
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h1,
h2 {
  margin: 0;
  font-weight: 750;
}

h1 {
  font-size: 24px;
}

h2 {
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
}

#saveStatus {
  min-width: 72px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

input,
textarea,
select,
button {
  font: inherit;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #15181b;
  color: var(--ink);
  padding: 9px 10px;
  outline: none;
}

textarea {
  min-height: 420px;
  resize: vertical;
  font: 12px/1.45 Consolas, "Cascadia Mono", monospace;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--blue);
}

.grid-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 7px;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--ink);
  cursor: pointer;
}

button:hover {
  border-color: var(--blue);
}

button.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 700;
}

button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.tool-grid button[data-tool="player"] {
  color: var(--accent);
}

.tool-grid button[data-tool="enemy"] {
  color: var(--green);
}

.tool-grid button[data-tool="boulder"] {
  color: #b7bcc0;
}

.tool-grid button[data-tool="clear"] {
  color: var(--sand);
}

.object-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.object-form .wide {
  grid-column: 1 / -1;
}

.actions {
  display: grid;
  gap: 8px;
}

.file-label {
  min-height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--ink);
  cursor: pointer;
}

.file-label input {
  display: none;
}

.stage-wrap {
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 22px;
  overflow: auto;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255,255,255,0.03) 1px, transparent 1px),
    #111416;
  background-size: 32px 32px;
}

#stage {
  width: min(100%, 72vh);
  max-width: 900px;
  aspect-ratio: 3 / 4;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f1214;
  cursor: crosshair;
  touch-action: none;
}

#stage[data-tool="select"] {
  cursor: default;
}

#stage[data-tool="select"].is-dragging {
  cursor: grabbing;
}

#stage[data-tool="clear"] {
  cursor: cell;
}

.stats {
  display: grid;
  gap: 8px;
  margin: 0;
}

.stats div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 32px;
  border-bottom: 1px solid var(--line);
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  font-weight: 700;
}

@media (max-width: 1000px) {
  .app {
    grid-template-columns: 1fr;
  }

  .panel {
    border: 0;
  }

  .stage-wrap {
    min-height: 70vh;
    order: -1;
  }
}
