:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --paper: #ffffff;
  --ink: #171716;
  --muted: #7b7b76;
  --hairline: #e6e4df;
  --thumb: #20201f;
  --track: #d9d7d1;
  --shadow: 0 22px 52px rgba(22, 22, 20, 0.11), 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,.92), rgba(244,244,242,.97) 46%, #efefed 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(18px, 5vw, 62px);
}

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

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

#plate {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: auto;
  filter: contrast(1.08) grayscale(1);
}

.grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .14;
  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;
}

.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 25px 0 14px;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.65rem, 3.1vw, 2.22rem);
  font-weight: 500;
  line-height: .95;
  letter-spacing: -0.045em;
}

.icon-row {
  display: flex;
  align-items: center;
  gap: 15px;
}

.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;
  cursor: pointer;
  transition: color .16s ease, transform .16s ease;
}

.icon:hover,
.icon.active { color: #111; }
.icon:hover { transform: translateY(-1px); }
.icon:focus-visible,
input:focus-visible { outline: 2px solid #111; outline-offset: 3px; }

.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-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 11px;
  line-height: 1.1;
  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);
}

body.grid-on .canvas-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(0,0,0,.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,.055) 1px, transparent 1px);
  background-size: 34px 34px;
}

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