:root {
  color-scheme: dark;
  --bg: #181818;
  --line: #222224;
  --slot: #101011;
  --gap: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  height: 100dvh;
  max-height: 100dvh;
  background: var(--bg);
  color: #fff;
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", system-ui, sans-serif;
  font-weight: 500;
  overscroll-behavior: none;
}

button,
p {
  margin: 0;
}

.sr {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.stage {
  --board: min(100cqw, 100cqh);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 16px;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
  container-type: size;
  padding:
    max(16px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
}

.stage.show-side {
  --board: min(100cqh, calc(100cqw - 136px));
  justify-content: flex-start;
}

.side {
  display: none;
  flex: none;
  flex-direction: column;
  gap: 18px;
  width: 104px;
  min-height: 0;
}

.stage.show-side .side {
  display: flex;
}

.stats {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stat {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.stat-name {
  color: #3a3a3c;
  font-size: 12px;
}

.stat-num {
  color: #454548;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  line-height: 1;
}

.board {
  position: relative;
  flex: none;
  width: var(--board);
  height: var(--board);
  padding: var(--gap);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 18px;
  container-type: inline-size;
  user-select: none;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: clamp(4px, 1.4cqw, 10px);
  height: 100%;
}

.box {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: clamp(1px, 0.5cqw, 4px);
}

.cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: clamp(2px, 0.9cqw, 8px);
  background: var(--slot);
  color: #4c4c4e;
  font: 500 clamp(10px, 5.6cqw, 52px) / 1 "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.cell:hover {
  background: #161617;
}

.cell.given {
  color: #58585a;
  font-weight: 600;
  cursor: default;
}

.cell.entry {
  color: #7c7c7f;
  font-weight: 400;
}

.cell.peer {
  background: #141415;
}

.cell.same {
  background: #1f1f21;
}

.cell.selected {
  background: #2a2a2c;
}

.cell.bad {
  color: #8a4b4b;
}

.cell:focus-visible {
  outline: 2px solid #444;
  outline-offset: -2px;
}

.picker {
  position: absolute;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  width: min(156px, calc(100% - 2 * var(--gap)));
  padding: 6px;
  border-radius: 10px;
  background: #1c1c1e;
  box-shadow:
    inset 0 0 0 1px #2a2a2c,
    0 10px 24px rgba(0, 0, 0, 0.35);
}

.picker[hidden] {
  display: none;
}

.picker button {
  min-height: 38px;
  padding: 0;
  border-radius: 6px;
  background: #141415;
  color: #6c6c6e;
  font-size: 17px;
}

.picker button:hover {
  background: #232325;
}

.picker button:disabled {
  opacity: 0.35;
}

.picker .wide {
  grid-column: 1 / -1;
  min-height: 30px;
  color: #4a4a4c;
  font-size: 12px;
}

.veil {
  position: absolute;
  inset: var(--gap);
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 16px;
  border-radius: 10px;
  background: rgba(24, 24, 24, 0.86);
  text-align: center;
}

.veil[hidden] {
  display: none;
}

.veil p {
  color: #5a5a5c;
  font-size: clamp(18px, 5cqw, 28px);
  font-weight: 500;
  line-height: 1.3;
}

.actions {
  display: flex;
  flex: none;
  flex-direction: column;
  gap: 8px;
}

.actions button {
  width: 100%;
}

button {
  min-height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: #1e1e20;
  color: #3f3f42;
  font: 500 12px/1 "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", system-ui, sans-serif;
  white-space: nowrap;
  cursor: pointer;
}

button:hover {
  background: #242426;
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:focus-visible {
  outline: 2px solid #444;
  outline-offset: 3px;
}

button:disabled {
  opacity: 0.7;
  cursor: default;
}

button.ghost {
  background: transparent;
  color: #3a3a3c;
  box-shadow: inset 0 0 0 1px #2a2a2c;
}

button.ghost:hover {
  background: #1c1c1e;
}

.veil button.ghost {
  min-height: 34px;
  padding: 0 18px;
  color: #5a5a5c;
  box-shadow: inset 0 0 0 1px #3a3a3c;
  font-size: 13px;
}

.back {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  border-radius: 6px;
  color: #3a3a3c;
  box-shadow: inset 0 0 0 1px #2a2a2c;
  font-size: 12px;
  text-decoration: none;
}

.back:hover {
  background: #1c1c1e;
}

.back:focus-visible {
  outline: 2px solid #444;
  outline-offset: 3px;
}
