:root {
  color-scheme: dark;
  --bg: #181818;
  --line: #222224;
  --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;
  touch-action: none;
  user-select: none;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.veil {
  position: absolute;
  inset: var(--gap);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 16px;
  border-radius: 10px;
  background: rgba(24, 24, 24, 0.82);
  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;
}
