/* Phone first: one pane at a time. From 900px wide the list and editor sit side by side. */
:root {
  color-scheme: dark;
  --bg: #14151a;
  --panel: #1e2027;
  --line: #363944;
  --text: #e8e9ee;
  --muted: #a3a7b4;
  --accent: #6fd6ff;
  --danger: #ff8a80;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1, h2 { margin: 0; font-size: 1.15rem; min-width: 0; overflow-wrap: anywhere; }

/* 16px text keeps iOS from zooming in on focus; 44px targets suit a thumb. */
button, input, select, textarea {
  font: inherit;
  color: inherit;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 44px;
  padding: 8px 12px;
}

textarea { width: 100%; resize: vertical; }
input[type="text"], input[type="search"], input[type="password"], select { width: 100%; min-width: 0; }
input[type="checkbox"] { min-height: 0; width: 22px; height: 22px; accent-color: var(--accent); }
button { cursor: pointer; }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #06222e; font-weight: 600; }
button.danger { color: var(--danger); }
button.selected { border-color: var(--accent); color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.invalid { border-color: var(--danger); }
.error { color: var(--danger); }
.note, .empty, .loading { color: var(--muted); }
.loading, .empty { padding: 24px; }

.row { display: flex; gap: 8px; align-items: center; }
.grow { flex: 1; min-width: 0; }

.sign-in { display: flex; flex-direction: column; gap: 12px; max-width: 420px; margin: 0 auto; padding: 24px 16px; }
.sign-in a { color: var(--accent); }

.layout { min-height: 100dvh; }
.layout.browsing .editor-pane, .layout.editing .list-pane { display: none; }

.list-pane, .editor-pane { display: flex; flex-direction: column; gap: 10px; padding: 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); min-width: 0; }
.list-pane header, .editor-pane header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.editor-pane header h2 { flex: 1; }

.banner { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border: 1px solid var(--accent); border-radius: 8px; }

.pattern-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.pattern-list button { width: 100%; text-align: left; overflow-wrap: anywhere; }

.levels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.levels button { padding: 8px 2px; }

.status-row { display: flex; justify-content: space-between; gap: 8px; min-height: 1.4em; color: var(--muted); font-size: 0.9rem; }

/* The game field is 3:4. Held to about a third of the screen so the fields stay reachable. */
.preview-box { display: flex; flex-direction: column; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 1; padding: 4px 0; background: var(--bg); }
.preview { display: block; aspect-ratio: 3 / 4; height: 36dvh; max-width: 100%; border: 1px solid var(--line); border-radius: 8px; }

.crumbs { display: flex; flex-wrap: wrap; gap: 6px; }
.crumbs button { min-height: 36px; padding: 4px 10px; font-size: 0.9rem; }

.tabs { display: flex; flex-direction: column; gap: 10px; }
.tab-bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.tab-bar button { padding: 8px 2px; font-size: 0.85rem; }

fieldset { margin: 0; border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
legend { color: var(--accent); padding: 0 6px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.field span { color: var(--muted); font-size: 0.9rem; }
.check { display: flex; align-items: center; gap: 8px; white-space: nowrap; }

.phases, .subs { display: flex; flex-direction: column; gap: 8px; }
.phase { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.phase .row { align-self: stretch; align-items: flex-end; }
.sub { flex-wrap: wrap; }
.sub .grow { flex-basis: 100%; text-align: left; overflow-wrap: anywhere; }
.actions { justify-content: flex-end; }

@media (min-width: 900px) {
  .layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); }
  .layout.browsing .editor-pane, .layout.editing .list-pane { display: flex; }
  .list-pane { height: 100dvh; overflow-y: auto; position: sticky; top: 0; border-right: 1px solid var(--line); }
  .back { display: none; }
}
