:root {
  --bg: #111214;
  --surface: #1b1d21;
  --fg: #f4f4f5;
  --muted: #8b8d93;
  --line: #2a2c31;
  --accent: #42b883;
  --ring: clamp(8rem, 38vw, 11rem);   /* spin button, and the gutter it sits in */
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* author rules beat the UA sheet, so [hidden] needs saying out loud here */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  margin: 0;
  padding: max(1rem, env(safe-area-inset-top)) 1.25rem max(1.25rem, env(safe-area-inset-bottom));
  background: var(--bg);
  color: var(--fg);
  font: 500 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

header, main { width: 100%; max-width: 32rem; margin: 0 auto; }

header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

main { flex: 1; display: flex; flex-direction: column; }

h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
}

h2 {
  margin: 0;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}

section { flex: 1; display: flex; flex-direction: column; gap: 1.25rem; }

.hint { margin: -.5rem 0 0; font-size: .8rem; color: var(--muted); }

.meters { display: flex; align-items: baseline; gap: .85rem; }

.clock {
  font-size: 1.5rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
}

.moves {
  font-size: .8rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}

/* buttons ---------------------------------------------------------------- */
button {
  min-height: 3.25rem;
  padding: 0 1.25rem;
  border: 1px solid var(--line);
  border-radius: .75rem;
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  font-weight: 600;
  letter-spacing: .06em;
  cursor: pointer;
  touch-action: manipulation;
}

button:active { filter: brightness(1.25); }
button:disabled { opacity: .4; cursor: not-allowed; }

button.big {
  margin-top: auto;
  min-height: 4.5rem;
  border-color: transparent;
  background: var(--accent);
  color: #08130d;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: .12em;
}

button.big:disabled { background: var(--surface); color: var(--muted); }

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

/* holds ------------------------------------------------------------------ */
.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.swatch, .add {
  display: grid;
  place-items: center;
  width: 3.5rem;
  height: 3.5rem;
  min-height: 0;
  padding: 0;
  border: 2px solid var(--line);
  border-radius: .75rem;
}

.add {
  position: relative;
  border-style: dashed;
  color: var(--muted);
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
}

/* the input stays the real, native colour picker — only its trigger is styled */
.add input {
  position: absolute;
  inset: 0;
  opacity: 0;
  border: none;
  padding: 0;
  cursor: pointer;
}

/* the arena -------------------------------------------------------------- */
.arena {
  position: relative;
  display: grid;
  place-items: center;
  flex: 1;
  min-height: 0;
}

.limbs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--ring);
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

.limb {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  font-size: .95rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-align: center;
  text-transform: uppercase;
  color: var(--muted);
}

.dot {
  flex: none;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px #ffffff26;
}

.spin {
  position: absolute;
  top: 50%;
  left: 50%;
  translate: -50% -50%;
  width: var(--ring);
  height: var(--ring);
  display: grid;
  place-items: center;
  padding: 14%;
  border: none;
  border-radius: 50%;
  box-shadow: inset 0 0 0 3px #ffffff26, 0 .75rem 2rem #0006;
  font-size: clamp(1rem, 4.6vw, 1.45rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.spin:active { transform: scale(.96); }

/* history ---------------------------------------------------------------- */
.history {
  counter-reset: move;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.move {
  flex-direction: row;
  align-items: center;
  gap: .85rem;
  font-size: 1.05rem;
  color: var(--fg);
}

.move::before {
  counter-increment: move;
  content: counter(move);
  min-width: 1.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.move .dot { width: 1.6rem; height: 1.6rem; }
