:root {
  color-scheme: dark;
  --bg: #101719;
  --ink: #f5f3ea;
  --muted: #aeb8b0;
  --line: rgba(245, 243, 234, 0.14);
  --panel: rgba(28, 38, 40, 0.92);
  --accent: #f2c14e;
  --mint: #6fd1b8;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overscroll-behavior: none;
}

body {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: max(12px, env(safe-area-inset-top)) 12px max(16px, env(safe-area-inset-bottom));
  background:
    linear-gradient(135deg, rgba(111, 209, 184, 0.09), transparent 32%),
    radial-gradient(circle at 70% 12%, rgba(242, 193, 78, 0.10), transparent 24%),
    var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  touch-action: none;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 48px;
  height: 44px;
  background: #223033;
  color: var(--ink);
  font: 800 16px/1 system-ui, sans-serif;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}

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

.shell {
  width: min(100%, 540px);
  display: grid;
  gap: 10px;
}

.topbar,
.panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--mint);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.28rem, 7vw, 1.95rem);
  line-height: 1.05;
}

.stats {
  display: grid;
  grid-auto-flow: column;
  gap: 8px;
}

.stats span,
.target {
  display: grid;
  place-items: center;
  min-width: 58px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-weight: 800;
}

#levelLabel::before {
  content: "ST ";
}

#moveLabel::before {
  content: "MV ";
}

.difficulty {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

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

.difficulty-btn {
  min-width: 0;
  height: 38px;
  font-size: 0.9rem;
}

.lite-btn,
.hint-btn {
  width: 94px;
  min-width: 94px;
  height: 34px;
  font-size: 0.82rem;
}

.lite-btn.active,
.hint-btn.active {
  background: var(--mint);
  color: #172123;
}

.hint-btn {
  background: #2c3638;
}

#versionLabel {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.difficulty-btn.active {
  background: var(--accent);
  color: #172123;
  border-color: rgba(255, 255, 255, 0.5);
}

.board-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #172123;
  overflow: hidden;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.28);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  max-width: calc(100% - 28px);
  padding: 9px 12px;
  border-radius: 8px;
  background: rgba(16, 23, 25, 0.9);
  color: var(--ink);
  font-weight: 800;
  text-align: center;
}

.target {
  grid-template-columns: auto auto;
  gap: 8px;
  padding: 0 13px;
}

.target span {
  color: var(--muted);
  font-size: 0.8rem;
}

.target strong {
  color: var(--accent);
  font-size: 1.55rem;
}

.actions {
  display: grid;
  grid-auto-flow: column;
  gap: 8px;
}

.actions button {
  font-size: 22px;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.45;
  text-align: center;
}

@media (max-height: 680px) {
  body {
    padding-block: 8px;
  }

  .shell {
    gap: 7px;
  }

  .hint {
    display: none;
  }

  .difficulty-btn {
    height: 34px;
  }
}
