:root {
  --bg: #12151a;
  --panel: #1b1f27;
  --panel-2: #232833;
  --line: #2c323d;
  --text: #e6e9ef;
  --muted: #939bab;
  --accent: #3ddc84;
  --accent-dim: #1f6b45;
  --warn: #ffb020;
  --bad: #ff6b6b;
  --radius: 14px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 0 1rem 3rem;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  max-width: 720px;
  margin-inline: auto;
}

/* ---------- boot ---------- */

.boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  z-index: 10;
}
.boot-inner { text-align: center; color: var(--muted); }
.boot-sub { font-size: .85rem; opacity: .7; margin-top: -.5rem; }
.spinner {
  width: 34px; height: 34px;
  margin: 0 auto 1rem;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* ---------- layout ---------- */

header { padding: 1.75rem 0 .5rem; }
h1 { font-size: 1.5rem; margin: 0; letter-spacing: -.02em; }
.sub { color: var(--muted); margin: .25rem 0 0; font-size: .9rem; }

h2 {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--muted);
  margin: 0 0 .5rem;
  font-weight: 600;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin-top: .85rem;
}

.hint { color: var(--muted); font-size: .85rem; margin: 0 0 .7rem; }
.rotate-note { margin: .6rem 0 0; }
.optional {
  text-transform: none; letter-spacing: 0; font-weight: 400;
  color: var(--muted); opacity: .7;
}

.row { display: flex; gap: .5rem; align-items: center; }
.row.space { justify-content: space-between; margin-bottom: .5rem; }

footer { color: var(--muted); font-size: .78rem; margin-top: 1.5rem; opacity: .65; }
footer p { margin: 0; }

/* ---------- chips ---------- */

.chips { display: flex; flex-wrap: wrap; gap: .4rem; }

.chip {
  flex: 1 1 auto;
  min-width: 60px;
  min-height: 52px;
  padding: .45rem .5rem;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .1rem;
  transition: background .12s, border-color .12s;
}
.chip:hover { border-color: #3d4553; }
.chip .big { font-size: 1.05rem; font-weight: 650; line-height: 1.1; }
.chip .small { font-size: .68rem; color: var(--muted); }
.chip[aria-pressed="true"] {
  background: var(--accent-dim);
  border-color: var(--accent);
}
.chip[aria-pressed="true"] .small { color: #cfe9d9; }

.chip .swatch {
  width: 15px; height: 15px; border-radius: 4px;
  border: 1px solid rgba(255,255,255,.18);
}

/* ---------- switch ---------- */

.switch {
  display: flex; align-items: center; gap: .5rem;
  margin-top: .7rem; font-size: .87rem; color: var(--muted);
  cursor: pointer;
}
.switch input { width: 18px; height: 18px; accent-color: var(--accent); }

/* ---------- scramble ---------- */

.scramble {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: clamp(1.1rem, 5.2vw, 1.5rem);
  font-weight: 600;
  letter-spacing: .04em;
  line-height: 1.45;
  margin: 0;
  padding: .7rem .8rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  word-spacing: .25em;
}

.net { margin: .9rem 0 .8rem; display: flex; justify-content: center; }
.net svg { width: 100%; max-width: 260px; height: auto; }

.length-hint {
  margin: .6rem 0 0; font-size: .9rem; color: var(--accent);
}

/* ---------- buttons and input ---------- */

button {
  font: inherit;
  border-radius: 10px;
  cursor: pointer;
  min-height: 46px;
  padding: 0 1rem;
  border: 1px solid transparent;
  transition: filter .12s, background .12s;
}
button:hover { filter: brightness(1.08); }
button:active { filter: brightness(.94); }

.primary { background: var(--accent); color: #06240f; font-weight: 650; flex: 1; }
.ghost { background: var(--panel-2); color: var(--text); border-color: var(--line); }
.ghost.small { min-height: 34px; padding: 0 .7rem; font-size: .8rem; }

input[type="text"] {
  flex: 1;
  min-width: 0;
  min-height: 46px;
  padding: 0 .75rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1rem;
}
input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
}

/* ---------- verdict and warnings ---------- */

.verdict {
  margin: .75rem 0 0;
  padding: .6rem .75rem;
  border-radius: 10px;
  font-size: .9rem;
  background: var(--panel-2);
  border: 1px solid var(--line);
}
.verdict strong { font-weight: 650; }
.verdict.good { background: #14251b; border-color: var(--accent-dim); }
.verdict.good strong { color: var(--accent); }
.verdict.close { background: #2a2416; border-color: #6b551f; }
.verdict.close strong { color: var(--warn); }
.verdict.bad { background: #2a1a1a; border-color: #6b2f2f; }
.verdict.bad strong { color: var(--bad); }

.warning { color: var(--warn); font-size: .85rem; margin: .6rem 0 0; }

/* ---------- solutions ---------- */

.solutions:empty::after {
  content: "Hidden until you reveal them.";
  color: var(--muted);
  font-size: .87rem;
}

.group { margin-top: .75rem; }
.group:first-child { margin-top: 0; }
.group-title {
  font-size: .8rem;
  color: var(--muted);
  margin: 0 0 .4rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .5rem;
}
.group-title .tag {
  color: var(--accent);
  font-weight: 650;
}

ol.sols { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; }
ol.sols li {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .98rem;
  letter-spacing: .03em;
  word-spacing: .2em;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .45rem .6rem;
  display: flex;
  justify-content: space-between;
  gap: .75rem;
}
ol.sols li.yours {
  border-color: var(--accent);
  background: #14251b;
}
ol.sols li .ergo {
  color: var(--muted);
  font-size: .78rem;
  font-family: system-ui, sans-serif;
  white-space: nowrap;
}
.more { color: var(--muted); font-size: .8rem; margin: .4rem 0 0; }

/* ---------- stats ---------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: .5rem; }
.stat {
  background: var(--panel-2);
  border-radius: 10px;
  padding: .55rem .6rem;
}
.stat .v { font-size: 1.15rem; font-weight: 650; }
.stat .k { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.stats-empty { color: var(--muted); font-size: .87rem; grid-column: 1 / -1; margin: 0; }

table.by-diff {
  grid-column: 1 / -1;
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
  margin-top: .3rem;
}
table.by-diff th, table.by-diff td {
  text-align: right;
  padding: .3rem .4rem;
  border-top: 1px solid var(--line);
}
table.by-diff th:first-child, table.by-diff td:first-child { text-align: left; }
table.by-diff th { color: var(--muted); font-weight: 500; border-top: 0; }
