/* RANDOM.ORG.ANDREAS.RO — a friendly parody. Not affiliated with RANDOM.ORG. */
:root {
  --blue: #1f4e8c;
  --blue-dark: #163a69;
  --nav: #2c5a98;
  --ink: #222;
  --muted: #5f6873;
  --line: #cdd6e1;
  --panel: #f4f7fb;
  --red: #c62828;
  --green: #1e7e34;
  --sticker: #ffd23f;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: #e6ebf1;
  color: var(--ink);
  font: 14px/1.55 Verdana, Geneva, "DejaVu Sans", sans-serif;
}
.page {
  max-width: 980px;
  margin: 0 auto;
  background: #fff;
  min-height: 100vh;
  box-shadow: 0 0 0 1px #d3dbe5;
  display: flex;
  flex-direction: column;
}
a { color: var(--blue); }

/* ---------- header ---------- */
header.top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 20px;
  padding: 26px 24px 14px;
}
.logo {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  white-space: nowrap;
}
.logo .word {
  font: 700 42px/1 Georgia, "Times New Roman", serif;
  letter-spacing: .01em;
  color: var(--blue);
  text-shadow: 1px 1px 0 #a9c0df, 2px 2px 0 #cfdcee, 3px 3px 0 #e6edf6;
}
.sticker {
  display: inline-block;
  margin-left: 6px;
  padding: 7px 10px 6px;
  background: var(--sticker);
  color: #3b2d00;
  font: 800 15px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  letter-spacing: .05em;
  border: 1px dashed rgba(0, 0, 0, .3);
  border-radius: 3px;
  transform: rotate(-7deg) translateY(-16px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, .12), 0 5px 12px rgba(0, 0, 0, .18);
}
.tagline {
  font: italic 16px/1.3 Georgia, "Times New Roman", serif;
  color: var(--muted);
  padding-bottom: 4px;
}
.tagline a { text-decoration: none; }

nav.menu {
  display: flex;
  flex-wrap: wrap;
  background: var(--nav);
  border-top: 1px solid var(--blue-dark);
  border-bottom: 3px solid var(--blue-dark);
}
nav.menu a {
  color: #fff;
  text-decoration: none;
  padding: 9px 15px;
  font-size: 13px;
  font-weight: bold;
  border-right: 1px solid rgba(255, 255, 255, .14);
}
nav.menu a:hover,
nav.menu a:focus-visible,
nav.menu a[aria-current] { background: var(--blue-dark); }

main { flex: 1; padding: 22px 24px 36px; }
h1 {
  margin: 2px 0 14px;
  font: 700 23px/1.25 Verdana, Geneva, sans-serif;
  color: var(--blue);
}
h2 { margin: 24px 0 8px; font-size: 15px; color: #333; }
p { margin: 0 0 12px; }

/* ---------- forms ---------- */
fieldset {
  margin: 0 0 16px;
  padding: 10px 16px 6px;
  border: 1px solid var(--line);
  background: var(--panel);
}
legend {
  padding: 0 6px;
  font-weight: bold;
  color: var(--blue);
}
fieldset p { margin: 6px 0 10px; }
input[type=number], input[type=text] {
  width: 7.5em;
  padding: 3px 5px;
  font: inherit;
  border: 1px solid #9aa7b8;
  border-radius: 2px;
  background: #fff;
}
input.short { width: 4.5em; }
label.radio { display: inline-block; margin: 2px 18px 6px 0; white-space: nowrap; }
button, .btn {
  padding: 5px 14px;
  font: inherit;
  color: #1b2430;
  background: linear-gradient(#fefefe, #dfe4ea);
  border: 1px solid #8f9cad;
  border-radius: 3px;
  cursor: pointer;
}
button:hover { background: linear-gradient(#fff, #d3dae3); }
button:active { background: #d3dae3; }
button.primary { font-weight: bold; }
.note { color: var(--muted); font-size: 13px; }
.error {
  padding: 8px 12px;
  color: var(--red);
  background: #fdecec;
  border: 1px solid #f2b8b8;
}

/* ---------- results ---------- */
.result-panel {
  position: relative;
  margin: 6px 0 14px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  background: #fff;
  overflow: hidden;
}
#status { font-weight: bold; min-height: 1.55em; }
#status.qa { color: #b45309; }
#status.done { color: var(--green); }

.numbers {
  display: grid;
  grid-template-columns: repeat(var(--cols, 5), max-content);
  gap: 6px 26px;
  margin: 10px 0 8px;
  font-family: "Courier New", Courier, "DejaVu Sans Mono", monospace;
  font-size: 22px;
  font-weight: bold;
}
.numbers.few { font-size: 40px; gap: 10px 36px; }
.numbers.single {
  display: block;
  margin: 18px 0 18px;
  font-size: clamp(72px, 17vw, 150px);
  line-height: 1;
}
.numbers.many { font-size: 16px; gap: 2px 18px; }
.num {
  position: relative;
  display: inline-block;
  min-width: 1ch;
  transition: color .3s;
}
.num.rolling { color: #8a96a6; filter: blur(.6px); }
.num.final { color: var(--green); }

/* glitch: chromatic split + slice jitter */
.num.glitch {
  color: #333;
  animation: jitter .18s steps(2, end) infinite;
}
.num.glitch::before,
.num.glitch::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.num.glitch::before {
  color: #ff1f5a;
  transform: translateX(-4px);
  animation: slice-a .3s steps(3, end) infinite;
}
.num.glitch::after {
  color: #00b8d9;
  transform: translateX(4px);
  animation: slice-b .26s steps(3, end) infinite;
}
.numbers.glitch-all { animation: jitter .18s steps(2, end) infinite, flicker .5s steps(2, end) infinite; }

@keyframes jitter {
  0%   { transform: translate(0, 0) skewX(0); }
  25%  { transform: translate(-3px, 1px) skewX(-7deg); }
  50%  { transform: translate(3px, -1px) skewX(4deg); }
  75%  { transform: translate(-1px, 2px) skewX(9deg); }
  100% { transform: translate(1px, 0) skewX(0); }
}
@keyframes slice-a {
  0%   { clip-path: inset(0 0 78% 0); }
  33%  { clip-path: inset(38% 0 34% 0); }
  66%  { clip-path: inset(72% 0 2% 0); }
  100% { clip-path: inset(12% 0 60% 0); }
}
@keyframes slice-b {
  0%   { clip-path: inset(64% 0 8% 0); }
  33%  { clip-path: inset(6% 0 70% 0); }
  66%  { clip-path: inset(45% 0 30% 0); }
  100% { clip-path: inset(20% 0 52% 0); }
}
@keyframes flicker {
  0% { opacity: 1; } 50% { opacity: .55; } 100% { opacity: 1; }
}

/* scanlines over the panel while "quality assurance" runs */
.result-panel.qa::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, .06) 0 1px, transparent 1px 3px);
  animation: flicker .35s steps(2, end) infinite;
}

/* rubber stamp */
.stamp {
  position: absolute;
  right: 6%;
  top: 34%;
  padding: 6px 14px 5px;
  color: var(--green);
  border: 4px double var(--green);
  border-radius: 6px;
  font: 900 20px/1.1 Impact, "Arial Black", system-ui, sans-serif;
  letter-spacing: .08em;
  text-transform: uppercase;
  text-align: center;
  background: rgba(255, 255, 255, .55);
  transform: rotate(-11deg);
  opacity: .92;
  pointer-events: none;
  animation: stamp-in .42s cubic-bezier(.2, 1.4, .4, 1) both;
}
.stamp small { display: block; font: 700 10px/1.3 Verdana, sans-serif; letter-spacing: .12em; }
#numbers:not(.single) ~ .stamp { top: 12px; right: 16px; }
@keyframes stamp-in {
  0%   { transform: rotate(-24deg) scale(3); opacity: 0; }
  70%  { opacity: .95; }
  100% { transform: rotate(-11deg) scale(1); opacity: .92; }
}

#verdict { min-height: 1.55em; }
#verdict .big { font-weight: bold; color: var(--green); }
.timestamp { color: var(--muted); font-size: 13px; }
.timestamp .corr { color: #b45309; }

/* distribution chart */
.dist {
  margin: 18px 0 16px;
  padding: 12px 16px 10px;
  border: 1px solid var(--line);
  background: var(--panel);
}
.dist h2 { margin: 0 0 10px; font-size: 13px; }
.bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 120px;
  border-bottom: 1px solid #8f9cad;
}
.bar {
  flex: 1 1 0;
  min-width: 3px;
  height: 2px;
  background: #b9c5d4;
  transition: height 1s cubic-bezier(.2, .9, .3, 1.05);
}
.bar.hit { background: var(--green); }
.axis {
  position: relative;
  height: 1.6em;
  font-size: 11px;
  color: var(--muted);
}
.axis span { position: absolute; top: 2px; transform: translateX(-50%); white-space: nowrap; }
.dist .cap { margin: 4px 0 0; font-size: 12px; color: var(--muted); }

/* flying 18s */
.confetti {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  font: 900 18px/1 Verdana, sans-serif;
  animation: fly 1.3s cubic-bezier(.15, .7, .3, 1) forwards;
}
@keyframes fly {
  0%   { transform: translate(-50%, -50%) scale(.4) rotate(0); opacity: 1; }
  80%  { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1) rotate(var(--rot)); opacity: 0; }
}

/* ---------- home page ---------- */
.home { display: grid; grid-template-columns: 270px 1fr; gap: 28px; align-items: start; }
.widget {
  border: 1px solid #9fb2cc;
  background: linear-gradient(#f7faff, #e7eef8);
  border-radius: 4px;
  padding: 12px 14px 10px;
  text-align: center;
}
.widget h2 { margin: 0 0 10px; font-size: 14px; color: var(--blue); }
.widget .row { display: flex; justify-content: center; gap: 10px; margin-bottom: 10px; }
.widget label { font-size: 13px; }
.widget input { width: 5.5em; }
.widget .out {
  position: relative;
  margin: 10px 0 6px;
  padding: 8px 4px;
  min-height: 72px;
  background: #fff;
  border: 1px solid var(--line);
  overflow: hidden;
}
.widget .out .lbl { display: block; font-size: 12px; color: var(--muted); }
.widget .out .num { font: bold 40px/1.2 "Courier New", Courier, monospace; }
.widget .out .stamp { top: 26px; right: 6px; font-size: 12px; padding: 3px 7px 2px; border-width: 3px; }
.widget .fine { font-size: 11px; color: var(--muted); margin: 0; min-height: 1.4em; }
.widget .powered { font-size: 10px; color: var(--muted); margin: 8px 0 0; }
.quick { margin: 0; padding-left: 18px; }
.quick li { margin: 3px 0; }

/* ---------- footer ---------- */
footer {
  padding: 14px 24px 20px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  background: #fafbfd;
}
footer p { margin: 0 0 6px; }

/* ---------- toast ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 60;
  max-width: min(560px, calc(100vw - 24px));
  padding: 12px 18px;
  color: #fff;
  background: #1d2a3a;
  border-radius: 6px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .3);
  font-size: 14px;
  transform: translate(-50%, 140%);
  opacity: 0;
  transition: transform .35s cubic-bezier(.2, 1.2, .4, 1), opacity .25s;
}
#toast.show { transform: translate(-50%, 0); opacity: 1; }
#toast b { color: var(--sticker); }

@media (max-width: 720px) {
  header.top { padding: 22px 14px 10px; }
  .logo .word { font-size: 30px; }
  .sticker { font-size: 12px; transform: rotate(-7deg) translateY(-12px); }
  main { padding: 18px 14px 28px; }
  footer { padding: 14px; }
  .home { grid-template-columns: 1fr; }
  .numbers.few { font-size: 30px; }
  .stamp { right: 4%; font-size: 16px; }
  nav.menu a { padding: 8px 10px; font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .num.glitch, .numbers.glitch-all, .result-panel.qa::after { animation: none; }
  .num.glitch::before, .num.glitch::after { display: none; }
  .stamp { animation: none; }
  .bar { transition: none; }
}
