/* ---- tokens ---- */
:root {
  --bg: #0c0c0e;
  --paper: #111219;
  --ink: #e7e4da;
  --ink-dim: #8b8b83;
  --ink-faint: #55554f;
  --line: #26262c;
  --line-bright: #3a3a42;
  --accent: #ff004d;
  --accent-ink: #0c0c0e;
}

* { box-sizing: border-box; }
html { overflow-x: hidden; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 "Space Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* faint static scanline texture */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(231, 228, 218, 0.028) 0 1px,
    transparent 1px 3px
  );
}

/* ---- window ---- */
.window {
  width: min(92vw, 600px);
  margin: 6vh auto;
  background: var(--paper);
  border: 1px solid var(--line-bright);
}

.titlebar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-bright);
  font-size: 12px;
  color: var(--ink-faint);
}
.dots { display: inline-flex; gap: 6px; flex: none; }
.dots i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--line-bright);
}
.dots i:first-child { background: var(--accent); }
.path {
  flex: 1;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px;
}

/* ---- header ---- */
header { display: flex; flex-direction: column; gap: 8px; }
.titlerow {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.wordmark {
  margin: 0;
  font-size: clamp(30px, 9vw, 42px);
  font-weight: 700;
  letter-spacing: 0.1em;
}
.wordmark span { color: var(--accent); }
.wordmark .caret {
  display: inline-block;
  width: 0.5em;
  height: 1em;
  margin-left: 0.12em;
  background: var(--ink);
  vertical-align: -0.12em;
  animation: blink 1.1s steps(1, end) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .wordmark .caret { animation: none; }
}
.tag { color: var(--ink-dim); font-size: 13px; }

.prompt { margin: 4px 0 0; }
.prompt .sigil { color: var(--accent); font-weight: 700; }
.prompt sup { color: var(--accent); }
.comment { margin: 0; color: var(--ink-dim); font-size: 13px; }
.foot {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 2px;
}
a {
  color: var(--ink);
  text-decoration-color: var(--ink-dim);
  text-underline-offset: 2px;
}
a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

/* ---- grid ---- */
#grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-auto-rows: 1fr;
  gap: 2px;
  width: 100%;
  aspect-ratio: 1;
  padding: 2px;
  background: #000;
  border: 3px double var(--ink-dim);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.cell {
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  cursor: crosshair;
}
@media (hover: hover) {
  .cell:hover {
    position: relative;
    z-index: 1;
    outline: 2px solid var(--accent);
    outline-offset: -2px;
  }
}

/* ---- the 101st ---- */
.ghost-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  color: var(--ink-dim);
  font-size: 13px;
}
#ghost {
  flex: none;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid var(--line-bright);
  background: var(--bg);
  cursor: not-allowed;
}

/* ---- counter ---- */
.counter { margin: 0; font-size: 14px; }
.counter b { color: var(--accent); font-weight: 700; }
.counter span { color: var(--ink-dim); }

/* ---- palette ---- */
#palette {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  width: 100%;
  max-width: 340px;
}
.swatch {
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.4);
}
.swatch.active {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}
.swatch:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- toolbar ---- */
.toolbar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 440px;
}
.tool {
  font: inherit;
  font-size: 13px;
  line-height: 1;
  padding: 9px 8px;
  text-align: center;
  border: 1px solid var(--ink-dim);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-transform: lowercase;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.tool::before { content: "["; margin-right: 7px; color: var(--ink-faint); }
.tool::after { content: "]"; margin-left: 7px; color: var(--ink-faint); }
.tool:hover { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tool:hover::before,
.tool:hover::after { color: var(--bg); }
.tool:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tool.primary {
  border-color: var(--accent);
  color: var(--accent);
  text-transform: uppercase;
}
.tool.primary::before,
.tool.primary::after { color: var(--accent); }
.tool.primary:hover {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.tool.primary:hover::before,
.tool.primary:hover::after { color: var(--accent-ink); }

/* ---- toast ---- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 10000;
  transform: translateX(-50%) translateY(12px);
  max-width: 90vw;
  padding: 8px 14px;
  background: var(--ink);
  color: var(--bg);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
#toast::before { content: "$ "; color: var(--accent); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- small screens ---- */
@media (max-width: 480px) {
  .window {
    width: 100vw;
    min-height: 100vh;
    margin: 0;
    border-left: 0;
    border-right: 0;
  }
  .screen { padding: 16px; }
  .toolbar { grid-template-columns: repeat(2, 1fr); }
}
