:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --paper: #ffffff;
  --ink: #171716;
  --muted: #77766f;
  --track: #d9d7d1;
  --thumb: #20201f;
  --shadow: 0 24px 58px rgba(22, 22, 20, 0.13), 0 3px 16px rgba(22, 22, 20, 0.07);
  font-family: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 50% 42%, rgba(255,255,255,.94), rgba(244,244,242,.98) 47%, #ededeb 100%);
  color: var(--ink);
  overflow-x: hidden;
}

.playground-chrome {
  opacity: 0;
  pointer-events: none;
  height: 1px;
  min-height: 0;
  padding: 0;
  border: 0;
}

.stage {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(16px, 4.5vw, 58px);
}

#webcam {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 148px;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  transform: scaleX(-1);
  opacity: 0;
  pointer-events: none;
  border-radius: 2px;
  filter: grayscale(1) contrast(1.14);
  box-shadow: 0 8px 28px rgba(0,0,0,.13);
  transition: opacity .18s ease;
  z-index: 2;
}
body.camera-live #webcam { opacity: .38; }

.plate-card {
  width: min(790px, calc(100vw - 32px));
  background: var(--paper);
  border-radius: 2px;
  box-shadow: var(--shadow);
  padding: clamp(16px, 2.55vw, 30px);
}

.canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 2px;
  background: #fefefe;
  cursor: crosshair;
}

#plate,
#hand {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

#plate {
  image-rendering: auto;
  filter: contrast(1.1) grayscale(1);
}

#hand {
  pointer-events: none;
  mix-blend-mode: multiply;
  opacity: .34;
}

.grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .13;
  mix-blend-mode: multiply;
  background-image:
    repeating-radial-gradient(circle at 17% 23%, rgba(0,0,0,.16) 0 1px, transparent 1px 3px),
    repeating-radial-gradient(circle at 73% 61%, rgba(0,0,0,.11) 0 1px, transparent 1px 4px);
  background-size: 9px 9px, 13px 13px;
}

.cursor {
  position: absolute;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border: 1px solid rgba(0,0,0,.42);
  border-radius: 999px;
  pointer-events: none;
  transform: translate3d(50%, 50%, 0) scale(.8);
  opacity: .65;
  mix-blend-mode: multiply;
}
.cursor::after {
  content: "";
  position: absolute;
  inset: 11px;
  border-radius: inherit;
  background: #111;
}

.title-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin: 24px 0 11px;
}

.kicker {
  margin: 0 0 5px;
  font: 700 10px/1.1 ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--muted);
}
h1 {
  margin: 0;
  font-size: clamp(1.7rem, 3.4vw, 2.35rem);
  font-weight: 500;
  line-height: .95;
  letter-spacing: -0.045em;
}

.icon-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px 13px;
}

button {
  cursor: pointer;
  transition: color .16s ease, transform .16s ease, opacity .16s ease;
}
.icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 0;
  padding: 0;
  background: transparent;
  color: #7c7c78;
  font: 16px/1 ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.icon:hover,
.icon.active { color: #111; }
.pill {
  border: 1px solid #d5d3cb;
  border-radius: 999px;
  padding: .52rem .72rem;
  background: #fbfaf6;
  color: #34332f;
  font: 700 11px/1 ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.pill.primary,
.pill[aria-pressed="true"] {
  background: #171716;
  border-color: #171716;
  color: #fff;
}
button:hover { transform: translateY(-1px); }
button:focus-visible,
input:focus-visible { outline: 2px solid #111; outline-offset: 3px; }

.status {
  min-height: 1.2em;
  margin: 0 0 13px;
  color: var(--muted);
  font: 12px/1.45 ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 27px;
  row-gap: 7px;
  padding-bottom: 2px;
}
.control {
  min-width: 0;
  display: grid;
  gap: 4px;
  font: 11px/1.1 ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #494945;
}
.control:nth-child(2) { grid-column: 2; grid-row: 1; }
.control:nth-child(3) { grid-column: 1; grid-row: 2; }
.control:nth-child(4) { grid-column: 2; grid-row: 2; }
.meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
output { color: #6d6d68; font-variant-numeric: tabular-nums; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 15px;
  margin: 0;
  background: transparent;
  cursor: ew-resize;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  background: linear-gradient(90deg, #222 var(--pct, 50%), var(--track) var(--pct, 50%));
  border-radius: 999px;
}
input[type="range"]::-moz-range-track { height: 2px; background: var(--track); border-radius: 999px; }
input[type="range"]::-moz-range-progress { height: 2px; background: #222; border-radius: 999px; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  margin-top: -5.5px;
  background: var(--thumb);
  border: 0;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,.22);
}
input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  background: var(--thumb);
  border: 0;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,.22);
}

@media (max-width: 560px) {
  .stage { padding: 12px; }
  .plate-card { width: min(430px, calc(100vw - 24px)); padding: 13px; }
  .title-row { align-items: flex-start; flex-direction: column; margin-top: 18px; }
  .icon-row { justify-content: flex-start; }
  h1 { font-size: 1.42rem; }
  .controls { column-gap: 18px; }
  .control { font-size: 9.5px; }
  #webcam { display: none; }
  input[type="range"]::-webkit-slider-thumb { width: 11px; height: 11px; margin-top: -4.5px; }
}
