*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
}
body {
  background: #0e1116;
  color: #e7ecf5;
  font: 1rem/1.4 system-ui, sans-serif;
  padding: 24px;
  overflow-wrap: anywhere;
}
header,
main {
  max-width: 400px;
  margin: 0 auto;
}
h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}
.rule {
  margin: 8px 0 0;
  font-weight: 600;
}
.hud {
  margin-top: 16px;
}
.counts {
  display: flex;
  gap: 24px;
  margin: 0 0 8px;
  font-variant-numeric: tabular-nums;
}
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
button {
  min-height: 44px;
  min-width: 44px;
  padding: 12px 16px;
  border: 1px solid #9fd7ff;
  border-radius: 8px;
  background: transparent;
  color: #e7ecf5;
  font: inherit;
  cursor: pointer;
}
button.primary {
  background: #9fd7ff;
  color: #141820;
}
button:disabled {
  cursor: progress;
  opacity: 0.7;
}
button:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}
.status {
  min-height: 1.4em;
  margin: 8px 0 16px;
}
.stage {
  position: relative;
  max-width: 360px;
}
canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 360 / 560;
  border-radius: 10px;
  background: #141820;
  touch-action: manipulation;
}
canvas:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}
.sorted {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  padding: 20px 24px;
  border-top: 3px solid #9fd7ff;
  border-radius: 8px;
  background: rgb(20 24 32 / 92%);
  text-align: center;
}
.sorted h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}
.sorted p {
  margin: 4px 0 12px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
[hidden] {
  display: none !important;
}
@media (orientation: landscape) and (max-height: 500px) and (min-width: 700px) {
  body {
    display: flex;
    gap: 24px;
    justify-content: center;
    align-items: flex-start;
  }
  header,
  main {
    margin: 0;
  }
  main {
    display: grid;
    grid-template-columns: minmax(0, 260px) auto;
    gap: 0 24px;
    max-width: none;
  }
  .hud,
  .status {
    grid-column: 1;
  }
  .stage {
    grid-column: 2;
    grid-row: 1 / span 3;
    width: calc((100vh - 48px) * 360 / 560);
  }
}
