@font-face {
  font-family: 'Anton';
  src: url('/fonts/anton-latin.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}

:root {
  --bg: #0a0d12;
  --panel: #10151c;
  --panel-2: #151b24;
  --line: #1f2834;
  --text: #c8d3df;
  --muted: #6f7f92;
  --dim: #4a5768;
  --ok: #3ddc97;
  --warn: #ffb547;
  --err: #ff4d5e;
  --cyan: #57c7ff;
  --lfc: #c8102e;
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --display: 'Anton', Impact, 'Arial Narrow Bold', sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, .035) 1px, transparent 0) 0 0 / 22px 22px,
    var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ---------- shell ---------- */
.app {
  min-height: 100vh;
  max-width: 1680px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: opacity .25s ease-out;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  font: 12px var(--mono);
  letter-spacing: .06em;
  color: var(--muted);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 700; }
.ver { color: var(--muted); font-weight: 400; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); animation: pulse 1.2s ease-in-out infinite; }
.dot.err { background: var(--err); box-shadow: 0 0 10px var(--err); animation-duration: .4s; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 3px 8px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); white-space: nowrap; }
.chip b { color: var(--text); }
.ok { color: var(--ok) !important; }
.warn { color: var(--warn) !important; }
.err { color: var(--err) !important; }
.blink { animation: blink .7s steps(2, jump-none) infinite; }

/* ---------- hero + progress ---------- */
.kicker { margin: 0; font: 11px var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
h1 {
  margin: 2px 0 12px;
  font: 400 clamp(36px, 5.4vw, 72px)/1.02 var(--display);
  letter-spacing: .01em;
  text-transform: uppercase;
  color: #fff;
}
.progress-meta { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 6px; font: 12px var(--mono); color: var(--muted); }
#phase { color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta-right { flex-shrink: 0; }
#pct { color: #fff; font-size: 14px; }
.progress { position: relative; height: 14px; overflow: hidden; border: 1px solid var(--line); border-radius: 3px; background: var(--panel); }
.bar {
  width: 0;
  height: 100%;
  background: repeating-linear-gradient(-45deg, var(--cyan) 0 10px, #3a9fd6 10px 20px);
  background-size: 28.28px 28.28px;
  animation: stripes .6s linear infinite;
  transition: width .7s cubic-bezier(.2, .8, .2, 1);
}
.bar.hurt { background-image: repeating-linear-gradient(-45deg, var(--err) 0 10px, #b52a39 10px 20px); }
.bar.final { background-image: repeating-linear-gradient(-45deg, var(--lfc) 0 10px, #e0233f 10px 20px); }

/* ---------- grid ---------- */
.grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.panel { display: flex; flex-direction: column; min-height: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  font: 11px var(--mono);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}
.live { color: var(--err); animation: blink 1s steps(2, jump-none) infinite; }
.log-panel { height: 52vh; }

@media (min-width: 720px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .log-panel { grid-column: 1 / -1; height: 44vh; }
  .stats-panel { grid-column: 1 / -1; }
}
@media (min-width: 1100px) {
  .app { height: 100vh; height: 100dvh; }
  .grid {
    flex: 1;
    min-height: 0;
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1.1fr) minmax(0, 1fr);
  }
  .log-panel { grid-column: 1; grid-row: 1 / 3; height: auto; }
  .stats-panel { grid-column: 2 / 4; grid-row: 1; }
  .chart-panel { grid-column: 2; grid-row: 2; }
  .words-panel { grid-column: 3; grid-row: 2; }
}

/* ---------- log ---------- */
.log { flex: 1; margin: 0; padding: 10px 12px; overflow-y: auto; list-style: none; font: 12.5px/1.6 var(--mono); scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.l { display: grid; grid-template-columns: auto auto minmax(0, 1fr); gap: 0 10px; animation: rise .18s ease-out; }
.ts { color: var(--dim); }
.tag { color: var(--cyan); }
.msg { overflow-wrap: anywhere; }
.l-warn .msg { color: var(--warn); }
.l-err .msg { color: var(--err); }
.l-ok .msg { color: var(--ok); }
.l-quote .msg { color: #b8c4ff; font-style: italic; }
.l-chart .msg { white-space: pre; overflow-wrap: normal; }
.l-chart-red .msg { white-space: pre; overflow-wrap: normal; color: var(--err); }
.spin { margin-left: .5ch; color: var(--cyan); }
.res { margin-left: .5ch; font-weight: 700; }
.res-ok { color: var(--ok); }
.res-warn { color: var(--warn); }
.res-err { color: var(--err); }
@media (max-width: 520px) { .ts { display: none; } .l { grid-template-columns: auto minmax(0, 1fr); } }

/* ---------- stats ---------- */
.stats { flex: 1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--line); }
@media (min-width: 900px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 2px; padding: 10px 12px; background: var(--panel); }
.stat .label { font: 10.5px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.stat b { font: 400 clamp(24px, 2.5vw, 38px)/1.1 var(--display); letter-spacing: .02em; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat small { font: 10.5px var(--mono); color: var(--dim); }
.stat.bad b { color: var(--err); }
.stat.good b { color: var(--ok); }
.flash { animation: flash 1s ease-out; }

/* ---------- chart ---------- */
.chart-wrap { position: relative; flex: 1; min-height: 170px; }
.chart-wrap canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }

/* ---------- words ---------- */
.words { flex: 1; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 6px; min-height: 140px; margin: 0; padding: 10px 12px; overflow: auto; list-style: none; }
.w { display: inline-flex; gap: 6px; padding: 3px 8px; border: 1px solid rgba(255, 77, 94, .5); border-radius: 3px; background: rgba(255, 77, 94, .08); font: 12px var(--mono); color: var(--err); animation: pop .28s cubic-bezier(.2, 1.4, .4, 1); }
.w s { color: #ffb3bb; text-decoration-thickness: 2px; }

/* ---------- footer ---------- */
.foot { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px 16px; padding-top: 10px; border-top: 1px solid var(--line); font: 11px/1.5 var(--mono); color: var(--dim); }
.foot p { margin: 0; }
.foot strong { color: var(--muted); }
.credits { flex: 1 1 420px; text-align: right; }
@media (max-width: 720px) { .credits { text-align: left; } }
.skip { padding: 6px 10px; border: 1px solid var(--line); border-radius: 4px; background: transparent; font: 12px var(--mono); color: var(--muted); cursor: pointer; }
.skip:hover, .skip:focus-visible { border-color: var(--muted); color: var(--text); }

/* ---------- modal + toast ---------- */
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgba(5, 7, 10, .72); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.modal[hidden] { display: none; }
.modal-card { width: 100%; max-width: 470px; padding: 20px 22px; border: 1px solid var(--line); border-top: 3px solid var(--warn); border-radius: 8px; background: var(--panel-2); box-shadow: 0 24px 70px rgba(0, 0, 0, .55); animation: modal-in .25s cubic-bezier(.2, 1.3, .4, 1); }
.modal-card.danger { border-top-color: var(--err); }
.modal-card.calm { border-top-color: var(--cyan); }
.modal-card h2 { margin: 0 0 8px; font: 700 18px/1.3 var(--sans); color: #fff; }
.modal-card p { margin: 0 0 10px; }
.modal-card .note { font-size: 12.5px; color: var(--muted); }
.modal-card .note:empty { display: none; }
.modal-card button { margin-top: 6px; padding: 8px 14px; border: 0; border-radius: 5px; background: #fff; font: 600 13px var(--sans); color: #0a0d12; cursor: pointer; transition: transform .12s, background .2s; }
.modal-card button.pressed { transform: scale(.94); background: var(--ok); }

.toast { position: fixed; bottom: 18px; left: 50%; z-index: 30; max-width: calc(100vw - 32px); padding: 10px 14px; transform: translateX(-50%); border: 1px solid var(--err); border-radius: 6px; background: var(--panel-2); box-shadow: 0 12px 40px rgba(0, 0, 0, .5); font: 12.5px/1.5 var(--mono); color: var(--text); animation: rise .2s ease-out; }
.toast[hidden] { display: none; }

/* ---------- the verdict ---------- */
body.is-verdict { overflow: hidden; background: var(--lfc); }
body.is-verdict .app { opacity: 0; }
.verdict { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; overflow: hidden auto; padding: 16px; background: var(--lfc); animation: flood .3s ease-out both, shake .45s .55s; }
.verdict[hidden] { display: none; }
.yes {
  flex: 1 0 auto;
  display: flex;
  align-items: center;
  font: 400 min(68vw, 56vh)/.88 var(--display);
  letter-spacing: .01em;
  color: #fff;
  text-shadow: 0 .03em 0 rgba(0, 0, 0, .18);
  animation: slam .6s cubic-bezier(.2, 1.4, .4, 1) .12s both;
}
.after { width: 100%; max-width: 560px; padding-bottom: max(8px, env(safe-area-inset-bottom)); text-align: center; font: 13px/1.5 var(--mono); color: rgba(255, 255, 255, .9); opacity: 0; visibility: hidden; transition: opacity .9s; }
.after.show { opacity: 1; visibility: visible; }
.after p { margin: 0; }
.fine-line { margin-bottom: 14px !important; }
.try { margin: 0 0 14px; text-align: left; }
.try label { display: block; margin-bottom: 6px; font: 400 20px/1 var(--display); letter-spacing: .04em; text-transform: uppercase; color: #fff; }
.try-row { display: flex; gap: 8px; }
.try input { flex: 1; min-width: 0; padding: 11px 12px; border: 2px solid #fff; border-radius: 6px; background: rgba(0, 0, 0, .18); font: 15px var(--mono); color: #fff; outline: none; }
.try input::placeholder { color: rgba(255, 255, 255, .6); }
.try input:focus { background: rgba(0, 0, 0, .28); }
.try input:disabled { opacity: .7; }
.try button { padding: 0 16px; border: 0; border-radius: 6px; background: #fff; font: 700 13px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--lfc); cursor: pointer; }
.try-out { min-height: 1.5em; margin-top: 8px !important; color: #fff; font-weight: 700; }
.again { padding: 7px 14px; border: 1px solid rgba(255, 255, 255, .6); border-radius: 4px; background: transparent; font: 12.5px var(--mono); color: #fff; cursor: pointer; }
.again:hover, .again:focus-visible { background: rgba(255, 255, 255, .12); }
.made { margin-top: 12px !important; font-size: 11px; color: rgba(255, 255, 255, .6); }

/* ---------- blue screen of caution ---------- */
.bsod { position: fixed; inset: 0; z-index: 80; overflow: auto; padding: 8vh 9vw; background: #0078d7; font-family: 'Segoe UI', system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif; font-weight: 300; color: #fff; cursor: none; }
.bsod[hidden] { display: none; }
.bsod.off { background: #000; }
.bsod.off .bsod-inner { visibility: hidden; }
.bsod-inner { max-width: 980px; }
.bsod p { margin: 0; }
.sad { font-size: clamp(90px, 14vw, 170px); line-height: 1; margin-bottom: 4vh !important; }
.bsod-lead { max-width: 30em; font-size: clamp(18px, 2.3vw, 28px); line-height: 1.35; margin-bottom: 4vh !important; }
.bsod-pct { font-size: clamp(18px, 2.3vw, 28px); margin-bottom: 5vh !important; }
.bsod-foot { display: flex; align-items: flex-start; gap: 20px; }
.bsod-foot canvas { flex-shrink: 0; width: 96px; height: 96px; background: #fff; }
.bsod-small { font-size: clamp(12px, 1.25vw, 15px); line-height: 1.55; }
.bsod-small p + p { margin-top: 1.2em; }
@media (max-width: 560px) { .bsod-foot { flex-direction: column; } }

.noscript { position: fixed; inset: 0; z-index: 99; display: grid; place-items: center; padding: 24px; background: var(--lfc); font: 400 clamp(22px, 4vw, 40px)/1.2 var(--display); text-align: center; color: #fff; }

/* ---------- motion ---------- */
@keyframes pulse { 50% { opacity: .35; } }
@keyframes blink { 50% { opacity: .25; } }
@keyframes stripes { to { background-position: 28.28px 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } }
@keyframes pop { from { opacity: 0; transform: scale(.6); } }
@keyframes flash { 0% { background: rgba(255, 77, 94, .38); } 100% { background: var(--panel); } }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.96); } }
@keyframes flood { from { opacity: 0; } }
@keyframes slam { 0% { opacity: 0; transform: scale(2.8); } 60% { opacity: 1; transform: scale(.94); } 100% { transform: scale(1); } }
@keyframes shake {
  10%, 90% { transform: translate(-2px, 1px); }
  20%, 80% { transform: translate(4px, -2px); }
  30%, 50%, 70% { transform: translate(-7px, 3px); }
  40%, 60% { transform: translate(7px, -3px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
