:root {
  --sun: #f5f70b;
  --grape: #ab1dfd;
  --ice: #45fbfc;
  --ember: #f73e0b;
  --ink: #160018;
  --good: #d6ff4a;
  --bad: #ff3d6e;
  --paper: rgba(18, 0, 28, 0.88);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: Arial, Helvetica, sans-serif;
  color: #fff;
  background: var(--ink);
}

::selection {
  background: var(--sun);
  color: var(--ink);
}

.sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 15% 20%, rgba(245, 247, 11, 0.55), transparent 32%),
    radial-gradient(circle at 85% 15%, rgba(171, 29, 253, 0.7), transparent 36%),
    radial-gradient(circle at 50% 100%, rgba(69, 251, 252, 0.45), transparent 34%),
    var(--ink);
  background-size: 140% 140%;
  animation: drift 22s ease-in-out infinite alternate;
}

.sky::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.16) 0 1px,
    transparent 1px 4px
  );
  opacity: 0.35;
}

.blob {
  position: absolute;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  filter: blur(2px);
  opacity: 0.85;
}

.blob-a {
  top: 8%;
  left: -40px;
  background: radial-gradient(circle, var(--sun), transparent 68%);
  animation: float-a 16s ease-in-out infinite alternate;
}

.blob-b {
  top: 20%;
  right: -60px;
  background: radial-gradient(circle, var(--grape), transparent 68%);
  animation: float-b 18s ease-in-out infinite alternate;
}

.blob-c {
  bottom: -40px;
  left: 30%;
  background: radial-gradient(circle, var(--ice), transparent 68%);
  animation: float-c 20s ease-in-out infinite alternate;
}

.stage {
  position: relative;
  z-index: 1;
  width: min(760px, calc(100% - 24px));
  margin: 28px auto;
  padding: 18px 18px 12px;
  background: var(--paper);
  border: 4px solid var(--sun);
  box-shadow: 10px 10px 0 var(--grape);
}

.banner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 3px solid var(--ice);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--sun);
  font-family: "Courier New", Courier, monospace;
  font-size: 0.82rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1, h2, .diff-kicker, .verb, .sum-score {
  font-family: Impact, Haettenschweiler, "Arial Black", sans-serif;
  font-weight: 400;
  letter-spacing: 0.03em;
}

h1 {
  margin: 0;
  color: var(--ice);
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  line-height: 0.9;
  text-shadow: 4px 4px 0 var(--grape), -1px -1px 0 var(--sun);
}

.lede {
  margin: 8px 0 0;
  color: #fff;
  font-size: 1rem;
}

.rec {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0 0;
  color: var(--bad);
  font-family: "Courier New", Courier, monospace;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.rec span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bad);
  box-shadow: 0 0 8px var(--bad);
  animation: blink 1.1s steps(2, end) infinite;
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

[hidden] { display: none !important; }

.diffs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.diff, .opt, .go, .tab, .dir, .board-dir, .back {
  font: inherit;
  color: #fff;
  cursor: pointer;
}

.diff {
  position: relative;
  min-height: 92px;
  padding: 16px 12px 14px;
  text-align: left;
  background: linear-gradient(#2a0638, #120014 55%, #3a0a4e);
  border: 3px solid var(--ice);
  box-shadow:
    inset 3px 3px 0 rgba(245, 247, 11, 0.85),
    inset -3px -3px 0 #5a1478;
}

.diff::before,
.diff::after {
  content: "";
  position: absolute;
  top: 8px;
  width: 8px;
  height: 8px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--sun);
}

.diff::before { left: 8px; }
.diff::after { right: 8px; }

.diff:hover { border-color: var(--sun); }

.diff:active, .opt:active, .go:active, .tab:active, .dir:active, .board-dir:active, .back:active {
  transform: translate(2px, 2px);
  box-shadow: inset 2px 2px 0 #5a1478;
}

.diff:disabled, .opt:disabled, .dir:disabled, .len:disabled {
  cursor: wait;
  opacity: 0.7;
}

.go:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.diff-kicker {
  display: block;
  margin-top: 8px;
  color: var(--sun);
  font-size: 1.5rem;
}

.diff-copy {
  display: block;
  margin-top: 4px;
  color: var(--ice);
  font-size: 0.92rem;
  line-height: 1.3;
}

.rules, .fine, .status, .sum-meta {
  margin: 0;
  line-height: 1.45;
}

.rules { color: #fff; }

.fine, .status { color: var(--ice); font-size: 0.92rem; }

.prep {
  position: relative;
  padding: 14px 14px 12px;
  background: #070014;
  border: 4px solid var(--ice);
  box-shadow: inset 0 0 0 4px #160018, 6px 6px 0 var(--grape);
  overflow: hidden;
}

.prep::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(69, 251, 252, 0.09) 0 1px,
    transparent 1px 5px
  );
  animation: prep-scan 2.4s linear infinite;
}

.prep-kicker {
  position: relative;
  margin: 0;
  color: var(--sun);
  font-family: "Courier New", Courier, monospace;
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.prep-verb {
  position: relative;
  margin: 10px 0 12px;
  color: var(--ice);
  font-family: Impact, Haettenschweiler, "Arial Black", sans-serif;
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  line-height: 1;
  text-align: center;
  text-shadow: 0 0 12px rgba(69, 251, 252, 0.85);
}

.prep-verb.enter { animation: slide 0.35s ease; }

.prep-bars {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.prep-bars span {
  display: block;
  height: 16px;
  border: 3px solid #2a0038;
  background: linear-gradient(100deg, #c9a400 0%, #fff36a 35%, #fff 50%, #f5f70b 65%, #ff8a2a 100%);
  background-size: 220% 100%;
  animation: prep-shine 1.15s linear infinite;
}

.prep-bars span:nth-child(2) { width: 86%; animation-delay: 0.12s; }
.prep-bars span:nth-child(3) { width: 68%; animation-delay: 0.24s; }

.prep-line {
  position: relative;
  margin: 12px 0 0;
  color: var(--ice);
  font-family: "Courier New", Courier, monospace;
  text-align: center;
  letter-spacing: 0.04em;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.pending {
  padding: 12px;
  border: 3px dashed var(--sun);
}

.save-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}

.save-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.92rem;
}

input {
  min-width: min(100%, 220px);
  padding: 8px 10px;
  color: var(--sun);
  font-family: "Courier New", Courier, monospace;
  font-size: 1.05rem;
  background: #070014;
  border: 3px solid var(--ice);
}

h2 {
  margin: 0;
  color: var(--sun);
  font-size: 1.6rem;
  text-shadow: 2px 2px 0 var(--grape);
}

.dirs, .tabs { display: flex; gap: 8px; flex-wrap: wrap; }

.choice {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.choice-label {
  margin: 0;
  color: var(--sun);
  font-family: "Courier New", Courier, monospace;
  font-size: 0.82rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.tab, .dir, .board-dir, .len {
  padding: 6px 12px;
  background: transparent;
  border: 3px solid var(--grape);
}

.len {
  min-width: 7.2rem;
  padding: 10px 16px;
  font-family: Impact, Haettenschweiler, "Arial Black", sans-serif;
  font-size: 1.25rem;
  letter-spacing: 0.03em;
}

.tab[aria-selected="true"],
.board-dir[aria-selected="true"],
.dir[aria-pressed="true"],
.len[aria-pressed="true"],
.len[aria-selected="true"] {
  color: var(--ink);
  background: var(--sun);
  border-color: var(--sun);
}

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-family: "Courier New", Courier, monospace;
  font-size: 0.95rem;
}

th, td {
  padding: 7px 8px;
  text-align: left;
  border-bottom: 1px solid rgba(69, 251, 252, 0.35);
}

th {
  color: var(--ink);
  background: var(--ice);
}

td:nth-child(3), th:nth-child(3) { color: inherit; font-weight: 700; }

tbody tr:nth-child(1) td:nth-child(2) { color: var(--sun); }
tbody tr:nth-child(2) td:nth-child(2) { color: var(--ice); }
tbody tr:nth-child(3) td:nth-child(2) { color: #ffb36b; }

.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-family: "Courier New", Courier, monospace;
}

.pill {
  padding: 2px 8px;
  color: var(--ink);
  background: var(--sun);
}

.scorebox { position: relative; }

.scorebox strong, .hud strong { color: var(--sun); font-size: 1.2rem; }

.pop {
  position: absolute;
  left: 100%;
  top: -6px;
  margin-left: 8px;
  color: var(--good);
  font-weight: 700;
  opacity: 0;
}

.pop.show { animation: floatup 0.8s ease; }

.pips { display: flex; flex-wrap: wrap; gap: 5px; }

.pip {
  width: 16px;
  height: 12px;
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.45);
}

.pip.now { border-color: var(--sun); background: var(--sun); }
.pip.ok { border-color: var(--good); background: var(--good); }
.pip.no { border-color: var(--bad); background: var(--bad); }

.verb {
  margin: 0;
  min-height: 96px;
  padding: 22px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--ice);
  font-size: clamp(1.45rem, 4vw, 2.15rem);
  line-height: 1.15;
  background: #070014;
  border: 4px solid var(--ice);
  box-shadow: inset 0 0 0 4px #160018, 6px 6px 0 var(--grape);
  text-shadow: 0 0 12px rgba(69, 251, 252, 0.85);
}

.verb.enter { animation: slide 0.35s ease; }

.opts {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.opt {
  padding: 11px 12px 11px 16px;
  text-align: left;
  color: var(--ink);
  background: linear-gradient(#fff36a, var(--sun) 46%, #ff8a2a);
  border: 3px solid #2a0038;
  border-left: 8px solid var(--grape);
  box-shadow:
    inset 2px 2px 0 #fffceb,
    inset -2px -2px 0 #b85a00;
  text-shadow: none;
}

.opt:hover:not(:disabled) { filter: brightness(1.08); }

.opt.is-good {
  color: var(--ink);
  background: var(--good);
  border-color: #204000;
  text-shadow: none;
  animation: popin 0.35s ease;
}

.opt.is-bad {
  border-color: var(--bad);
  animation: shake 0.4s ease;
}

.result {
  min-height: 1.5rem;
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.result.good { color: var(--good); }
.result.bad { color: var(--bad); }

.explain { margin: 0; color: #fff; line-height: 1.4; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.actions-start { justify-content: flex-start; }

.go {
  padding: 8px 14px;
  background: linear-gradient(#ffe56a, var(--sun) 40%, #e2b100);
  color: var(--ink);
  border: 3px solid #2a0038;
  box-shadow:
    inset 2px 2px 0 #fff6a8,
    inset -2px -2px 0 #8a6a00;
  text-shadow: none;
  font-weight: 700;
}

.go-ghost {
  color: var(--ice);
  background: transparent;
  border-color: var(--ice);
  box-shadow: none;
}

.sum-score {
  margin: 0;
  color: var(--sun);
  font-size: clamp(3rem, 10vw, 4.5rem);
  line-height: 0.85;
  text-shadow: 4px 4px 0 var(--grape);
}

.mistakes {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 240px;
  overflow: auto;
}

.mistakes li {
  padding: 8px 0;
  border-bottom: 1px solid rgba(171, 29, 253, 0.45);
}

.mistakes .de { display: block; color: var(--ice); }
.mistakes .cs { display: block; color: var(--good); font-weight: 700; }
.mistakes .whyline { display: block; color: #fff; font-size: 0.92rem; }

.foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
  padding-top: 10px;
  border-top: 3px solid var(--grape);
  color: var(--ice);
  font-family: "Courier New", Courier, monospace;
}

.back {
  padding: 4px 10px;
  color: var(--ink);
  text-decoration: none;
  background: var(--ice);
  border: 3px solid #08383a;
  box-shadow: 3px 3px 0 var(--sun);
}

.diff:focus-visible,
.opt:focus-visible,
.go:focus-visible,
.tab:focus-visible,
.dir:focus-visible,
.board-dir:focus-visible,
.back:focus-visible,
input:focus-visible {
  outline: 3px solid var(--ice);
  outline-offset: 2px;
}

@keyframes drift {
  from { background-position: 0% 0%; }
  to { background-position: 100% 40%; }
}

@keyframes float-a {
  from { transform: translate(0, 0); }
  to { transform: translate(40px, 30px); }
}

@keyframes float-b {
  from { transform: translate(0, 0); }
  to { transform: translate(-50px, 40px); }
}

@keyframes float-c {
  from { transform: translate(0, 0); }
  to { transform: translate(30px, -24px); }
}

@keyframes blink {
  50% { opacity: 0.15; }
}

@keyframes slide {
  from { opacity: 0; transform: translateX(28px); }
  to { opacity: 1; transform: none; }
}

@keyframes popin {
  0% { transform: scale(0.98); }
  45% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

@keyframes floatup {
  0% { opacity: 0; transform: translateY(6px); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-16px); }
}

@keyframes prep-shine {
  from { background-position: 120% 0; }
  to { background-position: -120% 0; }
}

@keyframes prep-scan {
  from { transform: translateY(-8%); }
  to { transform: translateY(8%); }
}

@media (max-width: 700px) {
  .diffs { grid-template-columns: 1fr; }
  .when { display: none; }
  .stage { margin: 12px auto; padding: 14px 12px 10px; }
  .opt { padding: 10px 10px 10px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
