:root {
  color-scheme: dark;
  --bg: #222625;
  --ink: #f1eee6;
  --muted: #b8b9b1;
  --line: #555b56;
  --accent: #ed7960;
  font-family: "Avenir Next", Avenir, system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
main {
  max-width: 1160px;
  margin: 0 auto;
  padding: 28px 40px 32px;
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}
h1 {
  font-size: 36px;
  letter-spacing: 1px;
  font-weight: 450;
  margin: 0;
}
.results {
  display: flex;
  gap: 24px;
  align-items: center;
}
#score {
  font-size: 30px;
  font-variant-numeric: tabular-nums;
}
#combo {
  color: #e6bd61;
  font-size: 18px;
}
button,
select,
input {
  font: inherit;
  border: 1px solid #646963;
  border-radius: 7px;
  background: #303532;
  color: var(--ink);
  padding: 9px 12px;
}
button {
  cursor: pointer;
}
button:hover {
  background: #424840;
}
button:focus-visible,
select:focus-visible,
input:focus-visible,
summary:focus-visible,
#board:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
button:disabled,
select:disabled,
input:disabled {
  opacity: 0.5;
  cursor: default;
}
#restart {
  font-size: 34px;
  width: 54px;
  height: 54px;
  line-height: 1;
  padding: 4px;
}
.play {
  text-align: center;
}
.clock {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 14px 0 18px;
}
.clock strong {
  font-size: 48px;
  line-height: 1.1;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.clock span {
  font-size: 16px;
  color: var(--muted);
  letter-spacing: 1px;
}
#board {
  position: relative;
  width: min(58vh, 520px, 100%);
  aspect-ratio: 1;
  margin: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
  border: 2px solid #c7c4b6;
  border-radius: 9px;
  background: #d5d0bf;
  box-shadow: 0 3px 8px #0005;
  overflow: hidden;
}
#board:active {
  cursor: grabbing;
}
#tiles,
#orbs,
#trace {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
#tiles {
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  grid-template-rows: repeat(var(--n), 1fr);
}
#tiles > span {
  background: #d5d0c2;
  border: 1px solid #aaa694;
  border-radius: 6px;
  box-shadow:
    inset 1px 2px 3px #fff9,
    inset -1px -2px 2px #80765e44;
}
.orb {
  position: absolute;
  display: grid;
  place-items: center;
  will-change: transform;
}
#trace {
  pointer-events: none;
  overflow: visible;
}
#trace polyline {
  stroke: #725447;
  stroke-width: 0.9;
  stroke-dasharray: 2 1;
  fill: none;
}
#trace rect {
  stroke: #ff866c;
  stroke-width: 1;
  fill: none;
  filter: drop-shadow(0 0 1px #cb392a);
}
#trace text {
  fill: #fff7e4;
  font-size: 7px;
  text-anchor: middle;
}
.play {
  position: relative;
}
.board-stage {
  position: relative;
  width: min(58vh, 520px, calc(100% - 52px));
  aspect-ratio: 1;
  margin: 30px auto;
}
.board-stage #board {
  width: 100%;
}
#slots {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.edge-slot {
  position: absolute;
  background: #090c0a;
  border: 3px solid #a5a392;
  border-radius: 8px;
  box-shadow: inset 0 3px 5px #000;
}
.edge-slot.top,
.edge-slot.bottom {
  width: 40px;
  height: 16px;
  left: var(--lane);
  transform: translateX(-50%);
}
.edge-slot.top {
  bottom: calc(100% + 7px);
}
.edge-slot.bottom {
  top: calc(100% + 7px);
}
.edge-slot.left,
.edge-slot.right {
  width: 16px;
  height: 40px;
  top: var(--lane);
  transform: translateY(-50%);
}
.edge-slot.left {
  right: calc(100% + 7px);
}
.edge-slot.right {
  left: calc(100% + 7px);
}
#level {
  color: var(--muted);
  font-size: 14px;
  margin: 14px 0 0;
}
#reserve-count {
  color: var(--muted);
  font-size: 13px;
  margin: 8px 0;
}
.collector {
  margin: 18px auto 0;
  width: 180px;
}
#slot {
  height: 22px;
  border-radius: 50%;
  background: #0a0d0b;
  border: 3px solid #8b8c7d;
  box-shadow:
    inset 0 5px 7px #000,
    0 2px 0 #c4c3ac55;
}
#collected {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}
#drops {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}
.dropping-orb {
  position: absolute;
  object-fit: contain;
  will-change: transform, opacity;
}
#status {
  font-size: 18px;
  letter-spacing: 0;
  margin: 24px 0 5px;
  min-height: 26px;
}
#queue {
  color: var(--muted);
  font-size: 13px;
  min-height: 18px;
  margin: 0;
}
.guidance {
  border-top: 1px solid var(--line);
  max-width: 520px;
  padding-top: 17px;
  margin: 20px auto 24px;
  color: var(--muted);
  font-size: 15px;
}
.config {
  display: flex;
  gap: 16px;
  align-items: end;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}
.config label {
  font-size: 13px;
  display: flex;
  flex: 1;
  min-width: 100px;
  flex-direction: column;
  gap: 6px;
}
.config input,
.config select {
  width: 100%;
  font-size: 14px;
}
.config button {
  white-space: nowrap;
}
.config input {
  max-width: 130px;
}
details {
  margin-top: 20px;
  color: var(--muted);
  font-size: 14px;
}
summary {
  cursor: pointer;
  width: fit-content;
}
details p {
  max-width: 850px;
  line-height: 1.6;
}
#board[style*="--n: 7"] .stone {
  font-size: 24px;
}
.stone-art {
  display: block;
  width: 94%;
  height: 94%;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 3px 3px #0005);
}
@media (max-width: 600px) {
  main {
    padding: 20px 18px;
  }
  h1 {
    font-size: 25px;
  }
  .results {
    gap: 12px;
  }
  #score {
    font-size: 23px;
  }
  #combo {
    font-size: 13px;
  }
  #restart {
    width: 40px;
    height: 40px;
    font-size: 28px;
  }
  .clock {
    margin: 24px 0 20px;
  }
  .clock strong {
    font-size: 42px;
  }
  #board {
    width: min(100%, 52vh);
  }
  #status {
    font-size: 14px;
    letter-spacing: 1px;
    margin-top: 22px;
  }
  .guidance {
    font-size: 13px;
    line-height: 1.6;
  }
  .config {
    gap: 12px;
  }
  .config label {
    min-width: calc(50% - 12px);
  }
  .config button {
    width: 100%;
  }
  .stone {
    font-size: 32px;
  }
}
