:root {
  --bg: #ffffff;
  --panel: #f7fafc;
  --line: #dbe3ec;
  --text: #1a202c;
  --muted: #4a5568;
  --accent: #2f855a;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Malgun Gothic", sans-serif;
}

.game {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hud {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--muted);
}

.hud__item {
  white-space: nowrap;
}

.hud__item strong {
  color: var(--text);
  font-size: 17px;
}

.btn {
  margin-left: auto;
  padding: 8px 16px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.btn:active {
  transform: translateY(1px);
}

.diff {
  display: flex;
  gap: 6px;
}

.diff__btn {
  flex: 1;
  padding: 7px 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}

.diff__btn.is-active {
  border-color: var(--accent);
  background: #e6f3ec;
  color: #22543d;
  font-weight: 600;
}

.stage {
  position: relative;
  width: min(100%, 420px, 68vh);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
}

#board {
  display: block;
  width: 100%;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #eef2f7;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.82);
  text-align: center;
  font-size: 15px;
  line-height: 1.5;
  color: var(--muted);
  pointer-events: none;
}

.overlay[hidden] {
  display: none;
}

.overlay p {
  margin: 0;
}

.pad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.pad__row {
  display: flex;
  gap: 6px;
}

.pad__btn {
  width: 58px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.pad__btn:active {
  background: #e2e8f0;
}

@media (max-height: 560px) {
  .pad {
    flex-direction: row;
    justify-content: center;
  }
}
