:root {
  --bg: #10141d;
  --paper: #f6edd8;
  --paper-dk: #e9dcbe;
  --ink: #211b12;
  --ink-soft: #7a6c52;
  --red: #c1281b;
  --sun: #f4d35e;
  --mint: #c4d6b0;
  --pink: #f5cac3;
  --sky: #b8d8d8;
  --lav: #bdb2ff;
  --gold: #e6a817;
  --shadow: rgba(8, 11, 18, 0.5);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "Baloo 2", sans-serif;
}

#cam {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  pointer-events: none;
}

#stage {
  position: fixed;
  inset: 0;
  display: block;
}

/* paper grain + warm vignette over the whole stage */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.09;
  z-index: 5;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  background: radial-gradient(
    120% 110% at 50% 38%,
    transparent 48%,
    rgba(10, 14, 22, 0.6) 100%
  );
}

/* fps readout */
.fps {
  position: fixed;
  top: 6px;
  right: 8px;
  z-index: 50;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(16, 12, 8, 0.6);
  color: #8fd694;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}
.fps.warn {
  color: #ffc24b;
}
.fps.bad {
  color: #ff6b4a;
}

/* ============ HUD as sticker badges ============ */
.hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 26px;
  pointer-events: none;
}

.tag {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: var(--sky);
  border: 2.5px solid var(--ink);
  border-radius: 22px;
  padding: 10px 20px 12px;
  box-shadow: 4px 5px 0 var(--shadow);
  line-height: 1;
}
.tag-left {
  transform: rotate(-2deg);
}
.tag-right {
  transform: rotate(2deg);
  background: var(--lav);
}
.tag-k {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  opacity: 0.65;
}
.tag-v {
  font-family: "Caprasimo", serif;
  font-size: 42px;
  font-variant-numeric: tabular-nums;
}
.tag-v.strikes {
  color: var(--red);
  font-size: 34px;
  letter-spacing: 0.08em;
}
.tag-best {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink);
  opacity: 0.65;
}
.tag-best b {
  opacity: 1;
}

.masthead {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  padding: 8px 26px 10px;
  box-shadow: 4px 5px 0 var(--shadow);
  transform: rotate(-0.6deg);
}
.masthead-dept {
  font-family: "Caprasimo", serif;
  font-size: 19px;
  line-height: 1;
}
.masthead-form {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.hand-hint {
  position: fixed;
  bottom: 34px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  background: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  box-shadow: 3px 4px 0 var(--shadow);
  color: var(--ink);
  padding: 9px 20px;
  font-size: 13px;
  font-weight: 700;
  animation: bob 1.6s ease-in-out infinite;
}
@keyframes bob {
  50% {
    transform: translateX(-50%) translateY(-6px);
  }
}

/* ============ overlays ============ */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(
    130% 130% at 50% 30%,
    rgba(10, 14, 24, 0.45),
    rgba(6, 9, 16, 0.88)
  );
}

/* the big sticker card */
.notice {
  position: relative;
  width: min(500px, 93vw);
  background: var(--paper);
  color: var(--ink);
  padding: 44px 42px 38px;
  border: 3px solid var(--ink);
  border-radius: 30px;
  box-shadow:
    10px 12px 0 var(--shadow),
    0 30px 60px -20px rgba(0, 0, 0, 0.8);
  transform: rotate(-1deg);
  text-align: center;
  animation: plop 0.5s cubic-bezier(0.3, 1.4, 0.4, 1) both;
}
.notice::after {
  /* doodle inner ring */
  content: "";
  position: absolute;
  inset: 9px;
  border: 2px dashed rgba(122, 108, 82, 0.45);
  border-radius: 22px;
  pointer-events: none;
}
.notice-closed {
  transform: rotate(0.8deg);
}
/* end-of-run cards get more room to breathe */
#gameover .notice,
#lbscreen .notice {
  width: min(660px, 94vw);
  padding: 40px 56px 36px;
}
.notice-wide {
  width: min(1100px, 96vw) !important;
  padding: 32px 40px 26px !important;
}

/* secondary/ghost button */
.btn-ghost {
  background: var(--paper);
  font-size: 16px;
  padding: 9px 24px 11px;
  margin-top: 12px;
  box-shadow: 4px 5px 0 var(--ink);
}
.btn-ghost:hover {
  background: var(--sky);
}

/* Pick Your Chaos screen */
.item-controls {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
}
.chip-btn {
  font-family: inherit;
  font-weight: 700;
  font-size: 12px;
  color: var(--ink);
  background: var(--paper-dk);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 5px 14px;
  cursor: pointer;
}
.chip-btn:hover {
  background: var(--sun);
}
.item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
  max-height: 56vh;
  overflow-y: auto;
  padding: 6px 4px 10px;
  margin-bottom: 22px;
  border-top: 2px dashed rgba(122, 108, 82, 0.4);
  border-bottom: 2px dashed rgba(122, 108, 82, 0.4);
}
.item-cell {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--paper-dk);
  border: 2px solid var(--ink);
  border-radius: 14px;
  padding: 5px 8px;
  transition: opacity 0.12s ease;
}
.item-cell .item-check {
  width: 16px;
  height: 16px;
  flex: none;
  accent-color: var(--red);
  cursor: pointer;
}
.item-cell .item-ico {
  width: 28px;
  height: 28px;
  flex: none;
}
.item-cell .item-label-input {
  flex: 1;
  min-width: 0;
  background: var(--paper);
  border: 1.5px solid rgba(122, 108, 82, 0.55);
  border-radius: 8px;
  font-family: inherit;
  font-weight: 700;
  font-size: 12px;
  color: var(--ink);
  padding: 4px 8px;
  outline: none;
  cursor: text;
}
.item-cell .item-label-input:hover {
  border-color: var(--ink);
}
.item-cell .item-label-input:focus {
  border-color: var(--red);
  background: #fff;
}
.item-cell.off {
  opacity: 0.42;
  background: transparent;
}

/* dev tuner action button */
.tuner-row-button {
  grid-template-columns: 1fr;
}
.tuner-action {
  font-family: inherit;
  font-weight: 700;
  font-size: 12px;
  color: var(--ink);
  background: var(--sky);
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 7px 10px;
  cursor: pointer;
}
.tuner-action:hover {
  background: var(--sun);
}
@keyframes plop {
  from {
    opacity: 0;
    transform: rotate(-1deg) scale(0.85);
  }
}

.dept {
  display: inline-block;
  background: var(--mint);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 4px 16px 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  margin-bottom: 18px;
  transform: rotate(-1.5deg);
}

.title {
  font-family: "Caprasimo", serif;
  font-size: clamp(46px, 9.6vw, 72px);
  line-height: 0.95;
  margin-bottom: 12px;
}
.title em,
.closed-title {
  color: var(--red);
  font-style: normal;
}
.closed-title {
  font-size: clamp(34px, 6.5vw, 52px);
}

/* save-score box — make the save action obvious */
.save-box {
  background: var(--paper-dk);
  border: 2.5px solid var(--ink);
  border-radius: 18px;
  padding: 16px 18px 14px;
  margin: 0 auto 18px;
  width: min(420px, 100%);
  box-shadow: 3px 4px 0 var(--shadow);
}
.save-box .name-row {
  margin-bottom: 12px;
}
.save-btn {
  background: var(--red);
  color: var(--paper);
  font-size: 15px;
  padding: 9px 22px 11px;
  animation: savepulse 1.8s ease-in-out infinite;
}
.save-btn:hover {
  background: var(--red-dk, #8f1c12);
}
@keyframes savepulse {
  50% {
    box-shadow:
      5px 6px 0 var(--ink),
      0 0 0 5px rgba(193, 40, 27, 0.18);
  }
}
.save-hint {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-top: 9px;
}
.save-box.saved .save-btn {
  background: #3f7a3a;
  animation: none;
}

.end-options {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 16px;
}
.end-options .pause-toggle {
  margin-bottom: 0;
  font-size: 12px;
}
.subtitle {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 20px;
}

.lede {
  font-size: 14.5px;
  font-weight: 500;
  line-height: 1.6;
  margin-bottom: 22px;
}
.lede b {
  font-weight: 800;
}
.missed-inline {
  display: inline-block;
  background: var(--red);
  color: var(--paper);
  font-weight: 800;
  font-size: 12px;
  padding: 1px 10px 2px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  transform: rotate(-2deg);
}

.form-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 11px;
  margin: 0 auto 24px;
  width: fit-content;
  text-align: left;
}
.form-list li {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 17.5px;
  font-weight: 700;
}
.form-list .box {
  flex: none;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 2.5px solid var(--ink);
  border-radius: 50%;
  background: var(--sun);
  font-size: 19px;
  box-shadow: 2px 3px 0 var(--shadow);
}
.form-list li:nth-child(2) .box {
  background: var(--mint);
}
.form-list li:nth-child(3) .box {
  background: var(--pink);
}

/* name input */
.name-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 18px;
}
.name-row span {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.name-row input {
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  background: var(--paper-dk);
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  padding: 7px 16px;
  width: 180px;
  text-align: center;
  outline: none;
}
.name-row input:focus {
  background: #fff;
}
/* run-stats chips on the end screen */
.stats-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  max-width: 540px;
  margin: 0 auto;
}
.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 4px 14px 5px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  box-shadow: 2px 2px 0 var(--shadow);
}
.stat-chip .stat-num {
  font-family: "Caprasimo", serif;
  font-size: 15px;
}
.stat-chip.stat-top {
  font-size: 17px;
  padding: 6px 18px 7px;
  box-shadow: 3px 3px 0 var(--ink);
}
.stat-chip.stat-top .stat-num {
  font-size: 19px;
}
.stat-chip.stat-more {
  background: transparent !important;
  border-style: dashed;
  border-color: var(--ink-soft);
  color: var(--ink-soft);
  box-shadow: none;
  font-weight: 600;
}

/* leaderboard */
.lb {
  margin: 2px 0 14px;
  padding-top: 12px;
  border-top: 2px dashed rgba(122, 108, 82, 0.45);
}
.lb-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 8px;
}
.lb-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: min(300px, 100%);
  margin: 0 auto;
}
.lb-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14.5px;
  font-weight: 700;
  padding: 3px 14px;
  border-radius: 999px;
}
.lb-list li .lb-rank {
  width: 22px;
  text-align: right;
  color: var(--ink-soft);
}
.lb-list li .lb-name {
  flex: 1;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-list li .lb-score {
  font-family: "Caprasimo", serif;
  font-size: 16px;
}
.lb-list li.me {
  background: var(--sun);
  border: 2px solid var(--ink);
  box-shadow: 2px 3px 0 var(--shadow);
}
.lb-screen-list {
  margin-bottom: 26px;
}
.lb-screen-list li {
  font-size: 16.5px;
  padding: 5px 16px;
}
.lb-screen-list li .lb-score {
  font-size: 19px;
}
.lb-empty {
  justify-content: center;
  color: var(--ink-soft);
}

.btn-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}

/* pause toggle */
.pause-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
}
.pause-toggle input {
  width: 19px;
  height: 19px;
  accent-color: var(--red);
  cursor: pointer;
}

.btn {
  font-family: "Caprasimo", serif;
  font-size: 22px;
  letter-spacing: 0.02em;
  color: var(--ink);
  background: var(--sun);
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 12px 36px 14px;
  cursor: pointer;
  box-shadow: 5px 6px 0 var(--ink);
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease,
    background 0.12s ease;
}
.btn:hover {
  background: var(--gold);
  transform: translate(2px, 2px) rotate(-1deg);
  box-shadow: 3px 4px 0 var(--ink);
}
.btn:active {
  transform: translate(5px, 6px);
  box-shadow: 0 0 0 var(--ink);
}
.btn:disabled {
  opacity: 0.55;
  cursor: wait;
}
/* finger is dwelling on the button */
.btn.aim {
  background: var(--gold);
  transform: translate(2px, 2px) scale(1.06);
  box-shadow:
    0 0 0 5px rgba(230, 168, 23, 0.4),
    3px 4px 0 var(--ink);
}

.loading {
  margin-top: 16px;
  font-size: 13px;
  font-weight: 700;
  color: var(--red);
}
.fineprint {
  margin-top: 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
}

/* burnout sticker burst */
.stamp {
  position: absolute;
  font-family: "Caprasimo", serif;
  pointer-events: none;
  display: grid;
  place-items: center;
  text-align: center;
}
.stamp-burnout {
  top: -34px;
  right: -26px;
  width: 130px;
  height: 130px;
  background: var(--red);
  color: var(--paper);
  font-size: 24px;
  clip-path: polygon(
    50% 0%,
    59% 12%,
    72% 5%,
    75% 19%,
    90% 18%,
    86% 32%,
    100% 38%,
    90% 50%,
    100% 62%,
    86% 68%,
    90% 82%,
    75% 81%,
    72% 95%,
    59% 88%,
    50% 100%,
    41% 88%,
    28% 95%,
    25% 81%,
    10% 82%,
    14% 68%,
    0% 62%,
    10% 50%,
    0% 38%,
    14% 32%,
    10% 18%,
    25% 19%,
    28% 5%,
    41% 12%
  );
  transform: rotate(12deg) scale(2);
  opacity: 0;
  animation: stickerslam 0.5s 0.15s cubic-bezier(0.3, 1.4, 0.4, 1) forwards;
}
@keyframes stickerslam {
  to {
    transform: rotate(12deg) scale(1);
    opacity: 1;
  }
}

.bignum {
  font-family: "Caprasimo", serif;
  font-size: 86px;
  line-height: 0.9;
  color: var(--ink);
  margin-top: 2px;
}
.bignum-k {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 14px;
}
.assessment {
  border-top: 2px dashed rgba(122, 108, 82, 0.45);
  padding-top: 16px;
  font-weight: 600;
}

.hidden {
  display: none !important;
}

/* ============ finger pointer (dwell-to-click) ============ */
.cursor {
  position: fixed;
  width: 50px;
  height: 50px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 60;
}
.cursor svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.cursor circle {
  fill: none;
  stroke-width: 4;
}
.cur-track {
  stroke: rgba(193, 40, 27, 0.25);
}
.cur-prog {
  stroke: var(--red);
  stroke-linecap: round;
}
.cur-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--red);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 10px rgba(193, 40, 27, 0.8);
}

/* ============ tuner ============ */
.tuner {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 40;
  width: 322px;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  border: 2.5px solid var(--ink);
  border-radius: 20px;
  box-shadow: 6px 8px 0 var(--shadow);
  font-size: 12px;
  overflow: hidden;
}
.tuner-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 2.5px solid var(--ink);
  background: var(--sun);
}
.tuner-title {
  font-family: "Caprasimo", serif;
  font-size: 14px;
}
.tuner-status {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-soft);
}
.tuner-status.ok {
  color: #3f7a3a;
}
.tuner-status.err {
  color: var(--red);
}
.tuner-close {
  background: none;
  border: none;
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.6;
}
.tuner-close:hover {
  opacity: 1;
}
.tuner-body {
  overflow-y: auto;
  padding: 4px 14px 12px;
}
.tuner-sec {
  padding: 13px 0;
  border-bottom: 2px dashed rgba(122, 108, 82, 0.4);
}
.tuner-sec:last-child {
  border-bottom: none;
}
.tuner-sec-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 9px;
}
.tuner-sec-head h3 {
  font-family: "Caprasimo", serif;
  font-size: 15px;
}
.tuner-sec-head p {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-top: 1px;
}
.tuner-reset {
  background: var(--paper-dk);
  border: 2px solid var(--ink);
  border-radius: 999px;
  color: var(--ink);
  padding: 3px 10px;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.tuner-reset:hover {
  color: var(--paper);
  background: var(--red);
}
.tuner-row {
  display: grid;
  grid-template-columns: 92px 1fr 54px;
  align-items: center;
  gap: 8px;
  margin: 7px 0;
}
.tuner-row-select {
  grid-template-columns: 92px 1fr;
}
.tuner-row-toggle {
  grid-template-columns: 1fr auto;
  cursor: pointer;
}
.tuner-check {
  width: 18px;
  height: 18px;
  accent-color: var(--red);
  cursor: pointer;
}
.tuner-select {
  font-family: inherit;
  font-weight: 600;
  font-size: 11px;
  color: var(--ink);
  background: var(--paper-dk);
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 4px 6px;
  cursor: pointer;
}
.tuner-label {
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 11px;
}
.tuner-row output {
  text-align: right;
  color: var(--red);
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 11px;
}
.tuner-row input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--ink-soft);
  border-radius: 2px;
  outline: none;
}
.tuner-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--sun);
  border: 2px solid var(--ink);
  cursor: pointer;
}
.tuner-row input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--sun);
  cursor: pointer;
}
.tuner-foot {
  padding: 10px 14px;
  border-top: 2.5px solid var(--ink);
  background: var(--paper-dk);
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-soft);
}
.tuner-chip {
  position: fixed;
  bottom: 14px;
  right: 14px;
  z-index: 35;
  background: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  box-shadow: 3px 3px 0 var(--shadow);
  color: var(--ink);
  padding: 7px 16px;
  font-family: inherit;
  font-weight: 700;
  font-size: 11px;
  cursor: pointer;
}
.tuner-chip:hover {
  background: var(--sun);
}
