:root {
  color-scheme: light;
  --paper: #f5f3ea;
  --sheet: #fffdf5;
  --ink: #172e30;
  --muted: #556660;
  --rule: #b8c3b8;
  --mint: #b7e8ce;
  --mint-wash: #e2eee5;
  --focus: #21694e;
  --measure: #244343;
  font-family: "Helvetica Neue", system-ui, sans-serif;
  line-height: 1.5;
}

*, *::before, *::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

button {
  font: inherit;
}

button:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
}

.sheet {
  width: min(100% - 2rem, 58rem);
  margin-inline: auto;
}

.masthead {
  border-bottom: 1px solid var(--rule);
}

.masthead-inner {
  min-height: 3.5rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.brand {
  font-size: 0.95rem;
  font-weight: 750;
  letter-spacing: -0.035em;
}

.brand-mark {
  width: 1.65rem;
  height: 1.05rem;
  background-color: var(--mint);
  background-image:
    linear-gradient(90deg, var(--ink) 1px, transparent 1px),
    linear-gradient(90deg, var(--ink) 1px, transparent 1px);
  background-position: 2px bottom, 6px bottom;
  background-size: 8px 9px, 8px 5px;
  background-repeat: repeat-x;
  border: 1px solid var(--ink);
  border-radius: 2px;
}

.round, .result {
  margin-top: clamp(2.25rem, 7vw, 4.5rem);
}

h1, h2, h3, p {
  margin: 0;
}

h1, .result > h2 {
  max-width: 14ch;
  font-size: clamp(2.75rem, 7.8vw, 6rem);
  font-weight: 760;
  letter-spacing: -0.076em;
  line-height: 0.99;
  text-wrap: balance;
}

.result > h2 {
  max-width: 24ch;
  font-size: clamp(2rem, 5.5vw, 4rem);
}

.instruction {
  margin-top: 0.85rem;
  color: var(--muted);
  font-size: clamp(1rem, 2.7vw, 1.2rem);
}

.choices {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(0.4rem, 1.7vw, 1rem);
  margin-top: clamp(1.65rem, 4.5vw, 3rem);
  padding-top: 0.8rem;
  border-top: 1px solid var(--ink);
}

.choices::before {
  position: absolute;
  inset: 0 0 auto;
  height: 6px;
  background: repeating-linear-gradient(90deg, var(--rule) 0 1px, transparent 1px 12px);
  content: "";
  pointer-events: none;
}

.choice {
  position: relative;
  min-width: 0;
  padding: 0;
  display: grid;
  grid-template-rows: 1fr auto;
  color: var(--ink);
  text-align: left;
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: 0.65rem;
  cursor: pointer;
}

.choice[aria-pressed="true"] {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
  background: var(--mint);
}

.choice:disabled {
  cursor: default;
}

.choice img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  background: var(--mint-wash);
  border-radius: 0.6rem 0.6rem 0 0;
}

.choice-name {
  display: grid;
  align-content: center;
  min-height: 3.15rem;
  padding: 0.55rem clamp(0.45rem, 1.65vw, 1rem);
  border-top: 1px solid var(--rule);
  font-size: clamp(0.78rem, 2.4vw, 1.05rem);
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.choice[aria-pressed="true"] .choice-name {
  border-color: var(--ink);
}

.choice-order {
  position: absolute;
  inset: 0.45rem 0.45rem auto auto;
  display: grid;
  place-items: center;
  width: 1.65rem;
  height: 1.65rem;
  background: var(--ink);
  color: var(--mint);
  border-radius: 50%;
  font-size: 0.82rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.choice-order:empty {
  visibility: hidden;
}

.round-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.55rem 0.7rem;
  margin-top: clamp(0.75rem, 3vw, 1.35rem);
}

.progress {
  color: var(--muted);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 2.75rem;
  padding: 0.55rem 1rem;
  border: 1px solid transparent;
  border-radius: 0.45rem;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.2;
}

.button-primary {
  background: var(--ink);
  color: var(--mint);
}

.button-primary:disabled {
  background: #e2e6dc;
  border-color: var(--rule);
  color: #57645c;
  cursor: default;
}

.button-quiet {
  background: transparent;
  border-color: var(--rule);
  color: var(--ink);
}

.button-quiet:disabled {
  color: var(--muted);
  cursor: default;
}

#check {
  grid-column: 1 / -1;
}

.stage-frame {
  margin-top: clamp(1.15rem, 3vw, 1.8rem);
  overflow: hidden;
  border: 1px solid var(--ink);
  border-radius: 0.7rem;
  background: var(--ink);
}

#stage {
  display: block;
  width: 100%;
  height: clamp(16rem, 61vw, 29rem);
  touch-action: pan-y;
}

.stage-actions, .camera-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.stage-actions {
  padding: 0.65rem;
  border-top: 1px solid #496463;
}

.button-stage {
  min-width: 2.75rem;
  background: transparent;
  border-color: #78948a;
  color: #e1f3e8;
}

.button-stage:focus-visible {
  outline-color: var(--mint);
  outline-offset: 2px;
}

.button-stage[aria-pressed="true"] {
  background: var(--mint);
  border-color: var(--mint);
  color: var(--ink);
}

#rotate-left, #rotate-right {
  padding-inline: 0.6rem;
  font-size: 1.25rem;
}

.answer-list {
  display: grid;
  gap: 0.95rem;
  margin: 1.5rem 0;
  padding: 0;
  list-style: none;
}

.answer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 0.25rem 0.75rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--rule);
}

.answer-name {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.answer-value {
  font-variant-numeric: tabular-nums;
  font-weight: 750;
  white-space: nowrap;
}

.answer-bar {
  grid-column: 1 / -1;
  display: block;
  min-height: 0.35rem;
  background: var(--measure);
  border-radius: 0 2px 2px 0;
}

.answer-source {
  grid-column: 1 / -1;
  width: fit-content;
  color: var(--focus);
  font-size: 0.875rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
  text-underline-offset: 0.18em;
}

.guide {
  display: grid;
  gap: 1.2rem;
  margin-top: clamp(2.25rem, 8vw, 4rem);
  padding: 1.1rem 0 2.5rem;
  border-top: 1px solid var(--rule);
}

.guide h2, .guide h3 {
  margin-bottom: 0.25rem;
  font-size: 1.05rem;
  font-weight: 750;
}

.guide p {
  max-width: 50ch;
  color: var(--muted);
  font-size: 0.9rem;
}

@media (hover: hover) {
  .choice:hover:not(:disabled) {
    border-color: var(--ink);
  }

  .button-quiet:hover:not(:disabled) {
    background: var(--mint-wash);
  }

  .button-primary:hover:not(:disabled) {
    background: var(--measure);
  }

  .button-stage:hover {
    border-color: var(--mint);
  }
}

@media (min-width: 38rem) {
  .sheet {
    width: min(100% - 4rem, 58rem);
  }

  .round-actions {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  #check {
    grid-column: auto;
    min-width: 8.5rem;
  }

  .guide {
    grid-template-columns: 1fr 1fr;
    gap: 2.25rem;
    padding-bottom: 3rem;
  }
}
