:root {
  color-scheme: light dark;
  --bg: #0b1020;
  --panel: rgba(255,255,255,0.06);
  --text: rgba(255,255,255,0.92);
  --muted: rgba(255,255,255,0.7);
  --border: rgba(255,255,255,0.14);
  --accent: #7ee787;
  --danger: #ff7b72;
  --focus: #f2cc60;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1100px 700px at 20% 0%, rgba(126,231,135,0.16), transparent 55%),
              radial-gradient(900px 600px at 95% 20%, rgba(88,166,255,0.18), transparent 60%),
              var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.skip {
  position: absolute;
  left: -999px;
  top: 0;
  background: #111;
  color: #fff;
  padding: 10px 12px;
  border: 1px solid var(--border);
}
.skip:focus { left: 12px; top: 12px; z-index: 10; outline: 3px solid var(--focus); }

.wrap {
  width: min(1050px, calc(100% - 32px));
  margin: 0 auto;
}

header.wrap { padding: 28px 0 6px; }

h1 { font-size: clamp(22px, 2.8vw, 34px); margin: 0 0 8px; }
.lede { margin: 0; color: var(--muted); }

main.wrap {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 16px 0 36px;
}

@media (min-width: 900px) {
  main.wrap { grid-template-columns: 1fr 1.2fr; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  backdrop-filter: blur(8px);
}

h2 { font-size: 18px; margin: 0 0 10px; }

.fieldset {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}
legend { padding: 0 8px; color: var(--muted); }

.radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
}

.row { margin-top: 12px; }

.check { display: inline-flex; align-items: center; gap: 10px; }

button {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.08);
  color: var(--text);
  font-weight: 600;
}
button:hover { background: rgba(255,255,255,0.12); }
button:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

input:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.hint { margin: 10px 0 0; color: var(--muted); font-size: 13px; }

.status {
  margin: 14px 0 0;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
}
.status div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px dashed rgba(255,255,255,0.10);
}
.status div:last-child { border-bottom: 0; }
.status dt { color: var(--muted); }
.status dd { margin: 0; font-variant-numeric: tabular-nums; }

.stage {
  position: relative;
  border-radius: 14px;
  border: 1px solid var(--border);
  height: 320px;
  overflow: hidden;
  background:
    linear-gradient(120deg, rgba(126,231,135,0.18), rgba(88,166,255,0.16), rgba(255,255,255,0.04));
}

/* Animated background “motion” */
.stage::before {
  content: "";
  position: absolute;
  inset: -40%;
  background: conic-gradient(from 0deg,
    rgba(126,231,135,0.0), rgba(126,231,135,0.18),
    rgba(88,166,255,0.18), rgba(255,123,114,0.12),
    rgba(126,231,135,0.0));
  animation: spin 4.5s linear infinite;
  filter: blur(28px);
  opacity: 0.75;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.card {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(360px, calc(100% - 32px));
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(0,0,0,0.35);
  padding: 14px 16px;
  box-shadow: 0 16px 50px rgba(0,0,0,0.35);
}

.badge {
  display: inline-block;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(126,231,135,0.18);
  border: 1px solid rgba(126,231,135,0.30);
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.title { font-size: 20px; margin-top: 10px; font-weight: 800; }
.subtitle { color: var(--muted); }

/* “Camera shake” simulation applied to the card */
body.shake-running .card {
  animation: shake 180ms linear infinite;
}

@keyframes shake {
  0% { transform: translate(-50%, -50%) translate(0, 0); }
  25% { transform: translate(-50%, -50%) translate(2px, -1px); }
  50% { transform: translate(-50%, -50%) translate(-2px, 2px); }
  75% { transform: translate(-50%, -50%) translate(1px, 2px); }
  100% { transform: translate(-50%, -50%) translate(0, 0); }
}

/* Reduced-motion: pause decorative animations */
body.reduced-motion .stage::before,
body.reduced-motion .card {
  animation: none !important;
}

/* Also respect system preference even without JS (baseline) */
@media (prefers-reduced-motion: reduce) {
  .stage::before,
  .card { animation: none !important; }
}

.code { margin-top: 12px; }
summary { cursor: pointer; }
pre {
  margin: 10px 0 0;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.30);
  overflow: auto;
}

.footer-note { margin: 12px 0 0; color: var(--muted); font-size: 13px; }
