:root {
  --ink: #0a0f26;
  --ink-2: #131a44;
  --ink-3: #0d1230;
  --line: #2b3470;
  --line-2: #3b4690;
  --text: #e8ecff;
  --muted: #8d95c3;
  --accent: var(--jp-gold);
  --danger: #ff6b6b;
}
.editor {
  background: var(--ink);
  color: var(--text);
  font: 14px/1.45 "Inter","Helvetica Neue",Arial,sans-serif;
  min-height: 100vh;
  margin: 0;
}

/* ---------- Top bar ---------- */
.ed-top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: var(--ink-2);
  border-bottom: 1px solid var(--line);
  gap: 12px;
  flex-wrap: wrap;
}
.top-left, .top-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.brand-sm {
  font-family: "Impact","Arial Black",sans-serif;
  color: var(--accent);
  font-size: 1.2rem;
  letter-spacing: 1px;
}
.chip {
  display: inline-block;
  padding: 3px 10px;
  background: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.75rem;
  letter-spacing: 0.3px;
}
#dirty_chip { background: var(--accent); color: #1a1500; border-color: var(--accent); }

.btn {
  background: var(--ink-3);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 8px 12px;
  border-radius: 7px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
}
.btn:hover { background: #1a2258; }
.btn.primary { background: var(--accent); color: #1a1500; border-color: var(--accent); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
.btn.danger:not(:disabled):hover {
  background: var(--danger);
  color: #1a0000;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.link-btn {
  background: var(--ink-3);
  color: var(--text);
  text-decoration: none;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 0.9rem;
  font-weight: 600;
}

/* ---------- Layout ---------- */
.ed-main {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 16px;
  padding: 16px;
  max-width: 1200px;
  margin: 0 auto;
}
@media (max-width: 820px) {
  .ed-main { grid-template-columns: 1fr; }
}
.col h2 { font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); margin: 0 0 10px; }

.games-list { align-self: start; position: sticky; top: 70px; }
.games { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-direction: column; gap: 6px; max-height: 400px; overflow-y: auto; }
.games li {
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  position: relative;
}
.games li:hover { border-color: var(--line-2); }
.games li.active { border-color: var(--accent); }
.games li .gname { font-weight: 600; }
.games li .gid { font-size: 0.75rem; color: var(--muted); font-family: "SF Mono", Menlo, monospace; }
.games li .gmeta { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.games li .gdel {
  position: absolute; top: 8px; right: 8px;
  background: transparent; color: var(--muted); border: none; cursor: pointer; font-size: 0.9rem;
  padding: 2px 6px;
}
.games li .gdel:hover { color: var(--danger); }

.draft-badge {
  display: inline-block;
  background: var(--accent);
  color: #1a1500;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  letter-spacing: 0.4px;
  margin-left: 6px;
  vertical-align: middle;
  text-transform: uppercase;
}

.muted { color: var(--muted); }
.small { font-size: 0.8rem; }

/* ---------- Work area ---------- */
.ed-work { display: flex; flex-direction: column; gap: 16px; }
.card {
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}
.card h2 { margin: 0 0 12px; }

.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.meta-grid .full { grid-column: 1 / -1; }
label { display: grid; gap: 4px; }
label > span { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.3px; }
label.check { grid-template-columns: auto 1fr; align-items: center; gap: 8px; }
label.check > span { text-transform: none; font-size: 0.9rem; color: var(--text); letter-spacing: 0; }
input, textarea {
  background: var(--ink-3);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 0.95rem;
  font-family: inherit;
  width: 100%;
  box-sizing: border-box;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; }

/* ---------- Board grids ---------- */
.board {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
}
.board .head, .board .cell {
  background: #060a1f;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-align: center;
  padding: 8px 4px;
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
}
.board .head {
  background: #06173d;
  color: var(--jp-gold, #d4af37);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 2px;
  cursor: text;
  transition: background 0.1s, border-color 0.1s;
}
.board .head:hover { background: #09265a; border-color: var(--line-2); }
.board .head:focus-within { background: var(--ink-3); border-color: var(--accent); }
.board .head input {
  display: block;
  width: 100%;
  min-height: 46px;
  background: transparent;
  border: none;
  color: var(--jp-gold, #d4af37);
  text-align: center;
  text-transform: uppercase;
  font-family: "Impact","Arial Black",sans-serif;
  font-weight: 400;
  font-size: 1rem;
  letter-spacing: 1.5px;
  padding: 4px;
  box-sizing: border-box;
  cursor: text;
}
.board .head input::placeholder {
  color: #5a6aa8;
  font-weight: 400;
  letter-spacing: 1px;
  text-transform: none;
  font-family: "Inter","Helvetica Neue",Arial,sans-serif;
  font-size: 0.85rem;
}
.board .head input:focus {
  outline: none;
  background: transparent;
}
.board .cell {
  cursor: pointer;
  color: var(--jp-gold, #d4af37);
  font-family: "Impact","Arial Black",sans-serif;
  font-size: 1.4rem;
  letter-spacing: 1px;
}
.board .cell:hover { background: #0a1538; }
.board .cell.filled {
  background: #0f1a46;
  color: var(--text);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.3;
  padding: 6px;
  text-align: left;
  align-items: flex-start;
  justify-content: flex-start;
}
.board .cell.filled .val {
  font-family: "Impact","Arial Black",sans-serif;
  color: var(--jp-gold, #d4af37);
  font-size: 0.85rem;
  margin-bottom: 2px;
}
.board .cell.filled .preview {
  color: var(--text);
  font-size: 0.75rem;
  line-height: 1.2;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  text-overflow: ellipsis;
  max-width: 100%;
}
.board .cell.dd::after {
  content: "DD";
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 0.65rem;
  color: var(--accent);
  background: rgba(0,0,0,0.5);
  padding: 1px 4px;
  border-radius: 3px;
  font-family: "SF Mono", Menlo, monospace;
}
.board .cell { position: relative; }

/* ---------- Final card ---------- */
.final-card label { margin-bottom: 10px; }

/* ---------- Drawer (clue editor) ---------- */
.drawer {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(10, 15, 38, 0.6);
  display: flex;
  justify-content: flex-end;
}
.drawer.hidden { display: none; }
.drawer-panel {
  width: min(480px, 100%);
  background: var(--ink-2);
  border-left: 1px solid var(--line);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}
.drawer-panel header, .drawer-panel footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.drawer-panel header h3 { margin: 0; color: var(--accent); }
@media (max-width: 500px) {
  .drawer-panel { width: 100%; border-left: none; }
}

/* ---------- Confirm modal ---------- */
.confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 110;
  background: rgba(10, 15, 38, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.confirm-modal.hidden { display: none; }
.confirm-card {
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px;
  width: 100%;
  max-width: 440px;
}
.confirm-card h3 {
  margin: 0 0 10px;
  font-family: "Impact","Arial Black",sans-serif;
  color: var(--danger);
  letter-spacing: 1px;
}
.confirm-card p { margin: 0 0 18px; line-height: 1.5; }
.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ---------- Status bar ---------- */
.status-bar {
  min-height: 1.5em;
  color: var(--muted);
  padding: 6px 2px;
  font-size: 0.9rem;
}
.status-bar.ok { color: #7bffa1; }
.status-bar.err { color: var(--danger); }
