:root {
  --bg: #050406;
  --ink: #f2efe6;
  --dim: #9a958c;
  --red: #ff3b3b;
  --red-deep: #8a0f12;
  --green: #5dff8a;
  --panel: rgba(12, 10, 14, 0.92);
  --line: #2a2530;
  --font: 'VT323', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 22px;
  line-height: 1.25;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}

.vignette,
.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
}

.vignette {
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.75) 100%);
}

.scanlines {
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.18) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}

/* ---- screens --------------------------------------------------------- */

.screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow-y: auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}

.screen.center {
  display: grid;
  place-items: center;
}

.screen.dim {
  background: rgba(0, 0, 0, 0.7);
  z-index: 30;
}

[hidden] {
  display: none !important;
}

.card {
  width: min(560px, 100%);
  background: var(--panel);
  border: 2px solid var(--line);
  padding: 22px 22px 18px;
  box-shadow: 0 0 0 1px #000, 0 30px 80px rgba(0, 0, 0, 0.8);
}

.card.narrow {
  width: min(360px, 100%);
  text-align: center;
}

h2 {
  margin: 0 0 12px;
  font-size: 40px;
  font-weight: normal;
  letter-spacing: 1px;
  color: var(--ink);
}

p {
  margin: 0 0 12px;
}

small {
  color: var(--dim);
  font-size: 0.85em;
}

b {
  font-weight: normal;
  color: #fff;
}

/* ---- title ----------------------------------------------------------- */

#title {
  background: radial-gradient(ellipse at 50% 40%, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.8));
}

.title-wrap {
  text-align: center;
  width: min(620px, 100%);
}

.logo {
  position: relative;
  margin: 0 0 6px;
  font-size: clamp(64px, 17vw, 132px);
  line-height: 0.9;
  font-weight: normal;
  letter-spacing: 2px;
  color: var(--ink);
  text-shadow: 3px 0 rgba(255, 30, 30, 0.75), -3px 0 rgba(0, 220, 255, 0.45);
  animation: jitter 3.2s infinite steps(1);
}

@keyframes jitter {
  0%, 91%, 100% { transform: none; }
  92% { transform: translate(-3px, 1px) skewX(-6deg); }
  94% { transform: translate(4px, -1px); text-shadow: -5px 0 rgba(255, 30, 30, 0.8), 5px 0 rgba(0, 220, 255, 0.5); }
  96% { transform: translate(-1px, 0) scaleY(1.04); }
}

.tagline {
  font-size: 26px;
  color: var(--ink);
  opacity: 0.9;
}

.dare {
  color: var(--red);
  font-size: 24px;
}

.menu {
  display: grid;
  gap: 10px;
  margin: 22px auto 14px;
  width: min(420px, 100%);
}

.menu small {
  display: block;
  margin-top: -2px;
}

.best {
  color: var(--red);
  margin: -4px 0 12px;
}

.row-links {
  display: flex;
  gap: 10px;
  justify-content: center;
  color: var(--dim);
}

.fine {
  color: var(--dim);
  font-size: 18px;
  margin-top: 14px;
}

/* ---- controls -------------------------------------------------------- */

.btn {
  display: inline-block;
  min-height: 52px;
  padding: 10px 18px;
  border: 2px solid #3a3440;
  background: #141118;
  color: var(--ink);
  font-size: 26px;
  letter-spacing: 1px;
  cursor: pointer;
  text-transform: uppercase;
  transition: transform 0.06s, background 0.15s, border-color 0.15s;
}

.btn:hover {
  border-color: #6a6070;
  background: #1c1820;
}

.btn:active {
  transform: translateY(2px);
}

.btn:focus-visible,
.link:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

.btn.primary {
  background: var(--red-deep);
  border-color: var(--red);
  color: #fff;
  box-shadow: 0 0 24px rgba(255, 40, 40, 0.25);
}

.btn.primary:hover {
  background: #a51418;
}

.btn.ghost {
  background: transparent;
}

.btn.small {
  min-height: 40px;
  font-size: 20px;
  padding: 4px 12px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.link {
  background: none;
  border: 0;
  padding: 4px;
  color: var(--dim);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link:hover {
  color: var(--ink);
}

.actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}

.actions.col {
  flex-direction: column;
}

.actions.wrap {
  flex-wrap: wrap;
  justify-content: center;
}

.toggle {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin: 10px 0;
  cursor: pointer;
}

.toggle input {
  width: 22px;
  height: 22px;
  margin-top: 2px;
  accent-color: var(--red);
  flex: none;
}

.field {
  margin: 14px 0;
}

.field label {
  display: block;
  color: var(--dim);
  margin-bottom: 4px;
}

.field input[type='text'],
.field select {
  width: 100%;
  min-height: 46px;
  background: #0b090d;
  border: 2px solid #3a3440;
  padding: 6px 10px;
}

.field input[type='range'] {
  width: 100%;
  accent-color: var(--red);
}

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

.inline input {
  flex: 1;
}

.status {
  color: var(--dim);
  white-space: nowrap;
}

.status.ok {
  color: var(--green);
}

.code {
  flex: 1;
  background: #0b090d;
  border: 1px dashed #3a3440;
  padding: 6px 8px;
  font-size: 18px;
  word-break: break-word;
}

.warn-list,
.how-list {
  padding-left: 22px;
  margin: 0 0 12px;
}

.warn-list li,
.how-list li {
  margin-bottom: 8px;
}

.error {
  color: var(--red);
  border: 1px solid var(--red-deep);
  padding: 10px;
  margin-top: 10px;
}

.tip {
  color: var(--dim);
  font-size: 19px;
}

/* ---- camera setup ---------------------------------------------------- */

.preview {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #000;
  border: 2px solid var(--line);
  overflow: hidden;
  margin-bottom: 10px;
}

.preview video,
.preview canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.preview video {
  filter: grayscale(0.6) contrast(1.1);
}

.face-status {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.7);
  font-size: 22px;
}

.face-status.ok {
  color: var(--green);
}

.face-status.bad {
  color: var(--red);
}

.mic-row {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--dim);
}

.meter {
  flex: 1;
  height: 10px;
  background: #1a161d;
  border: 1px solid #2c2630;
  overflow: hidden;
}

.meter i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--green);
  transition: width 0.08s linear;
}

/* ---- HUD ------------------------------------------------------------- */

#hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.hud-top {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: 16px;
  right: 16px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  text-shadow: 0 2px 0 #000;
}

.hud-night {
  color: var(--dim);
  font-size: 22px;
}

.hud-clock {
  font-size: 46px;
  color: var(--red);
  text-shadow: 0 0 12px rgba(255, 40, 40, 0.6), 0 2px 0 #000;
  letter-spacing: 2px;
}

.hud-lives {
  justify-self: end;
  display: flex;
  gap: 6px;
  margin-right: 46px;
}

.hud-lives i {
  width: 26px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle, #111 0 3px, var(--ink) 4px 100%);
  border: 2px solid var(--ink);
}

.hud-lives i.gone {
  background: none;
  border-color: var(--red);
  border-radius: 0;
  height: 4px;
  margin-top: 6px;
}

/* This hour's chore, under the clock. */
.hud-task {
  position: absolute;
  top: calc(max(10px, env(safe-area-inset-top)) + 54px);
  left: 16px;
  right: 16px;
  text-align: center;
  font-size: 26px;
  color: var(--ink);
  text-shadow: 0 2px 0 #000;
}

.hud-task:empty {
  display: none;
}

.hud-task.done {
  color: var(--dim);
  text-decoration: line-through;
}

.hud-task.new {
  animation: task-in 1.4s steps(6);
}

@keyframes task-in {
  0%,
  40% {
    color: var(--red);
    transform: scale(1.15);
  }
  100% {
    color: var(--ink);
    transform: none;
  }
}

.pause-btn {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  right: 12px;
  width: 40px;
  height: 40px;
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.5);
  border: 2px solid #3a3440;
  cursor: pointer;
  font-size: 22px;
}

.cam-inset {
  position: absolute;
  right: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  width: clamp(110px, 18vw, 180px);
  border: 2px solid #3a3440;
  background: #000;
}

.cam-inset video {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  transform: scaleX(-1);
  filter: grayscale(1) contrast(1.2);
}

.calm {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 3px 6px;
  font-size: 16px;
  color: var(--dim);
}

.calm .meter i {
  background: var(--green);
}

.chat-feed {
  position: absolute;
  left: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  width: min(320px, 60vw);
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 20px;
  text-shadow: 0 2px 0 #000;
}

.chat-feed div {
  background: rgba(0, 0, 0, 0.55);
  padding: 2px 8px;
  animation: in 0.2s ease-out;
}

.chat-feed b {
  color: #c9a0ff;
}

.banner {
  position: absolute;
  left: 0;
  right: 0;
  top: 22%;
  text-align: center;
  font-size: clamp(40px, 9vw, 80px);
  text-shadow: 0 0 20px rgba(0, 0, 0, 0.9), 0 3px 0 #000;
  animation: in 0.4s ease-out;
}

.banner small {
  display: block;
  font-size: 0.4em;
  color: var(--ink);
}

.verdict {
  position: absolute;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%) rotate(-3deg);
  padding: 10px 22px;
  border: 4px solid currentColor;
  background: rgba(0, 0, 0, 0.7);
  text-align: center;
  font-size: clamp(44px, 10vw, 90px);
  line-height: 0.95;
  animation: stamp 0.18s ease-out;
  white-space: nowrap;
}

.verdict small {
  display: block;
  font-size: 0.38em;
  color: inherit;
  margin-top: 6px;
}

.verdict.bad {
  color: var(--red);
}

.verdict.good {
  color: var(--green);
  font-size: clamp(30px, 6vw, 52px);
}

@keyframes stamp {
  from { transform: translate(-50%, -50%) rotate(-3deg) scale(1.8); opacity: 0; }
}

@keyframes in {
  from { opacity: 0; transform: translateY(6px); }
}

.lost {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  background: rgba(0, 0, 0, 0.6);
  gap: 6px;
}

.lost b {
  font-size: 54px;
  color: var(--red);
}

/* ---- results --------------------------------------------------------- */

#result {
  background: rgba(0, 0, 0, 0.88);
  z-index: 25;
}

.result-wrap {
  width: min(980px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr minmax(220px, 300px);
  grid-template-areas:
    'head clip'
    'actions clip';
  gap: 16px 28px;
  align-items: start;
  padding-top: 20px;
}

.result-head {
  grid-area: head;
}

.result-head h2 {
  font-size: clamp(48px, 9vw, 86px);
  line-height: 0.95;
  margin-bottom: 8px;
}

.result-head h2.bad {
  color: var(--red);
}

.result-head h2.good {
  color: var(--green);
}

.faces {
  font-size: 34px;
  letter-spacing: 2px;
  margin: 10px 0 14px;
  word-break: break-all;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stats div {
  border: 1px solid var(--line);
  padding: 8px 10px;
  background: rgba(20, 16, 22, 0.8);
}

.stats b {
  display: block;
  font-size: 34px;
}

.stats span {
  color: var(--dim);
  font-size: 18px;
}

.clip-box {
  grid-area: clip;
}

.clip-box video {
  display: block;
  width: 100%;
  aspect-ratio: 9 / 16;
  background: #000;
  border: 2px solid var(--line);
}

.clip-pick {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.clip-pick button {
  flex: 1;
  min-width: 60px;
  min-height: 40px;
  background: #141118;
  border: 2px solid #3a3440;
  cursor: pointer;
  font-size: 18px;
}

.clip-pick button.on {
  border-color: var(--red);
}

.result-wrap > .actions {
  grid-area: actions;
  justify-content: flex-start;
  margin-top: 0;
}

.tip-link {
  grid-column: 1;
  color: var(--dim);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #000;
  border: 2px solid var(--ink);
  padding: 8px 16px;
  z-index: 60;
}

@media (max-width: 720px) {
  html,
  body {
    font-size: 20px;
  }
  .result-wrap {
    grid-template-columns: 1fr;
    grid-template-areas:
      'head'
      'clip'
      'actions';
  }
  .clip-box video {
    max-height: 56vh;
    width: auto;
    margin: 0 auto;
  }
  .result-wrap > .actions {
    justify-content: center;
  }
  .btn {
    font-size: 22px;
  }
  .actions {
    flex-wrap: wrap;
  }
  .actions .btn {
    flex: 1;
  }
  .hud-clock {
    font-size: 36px;
  }
  .hud-night {
    font-size: 18px;
  }
  .hud-task {
    top: calc(max(10px, env(safe-area-inset-top)) + 44px);
    font-size: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .logo {
    animation: none;
  }
}

.noscript {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
}
