:root {
  color-scheme: light;
  --bg: #eef3ef;
  --ink: #202720;
  --muted: #5f6861;
  --panel: #fffdf8;
  --line: rgba(32, 39, 32, 0.12);
  --board: #17202a;
  --accent: #d87b3d;
  --accent-dark: #b7642d;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    linear-gradient(135deg, rgba(51, 92, 129, 0.18), transparent 34%),
    linear-gradient(315deg, rgba(216, 123, 61, 0.16), transparent 36%),
    var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

button {
  height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

.game-shell {
  width: min(100%, 760px);
}

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  margin-bottom: 12px;
  color: #335c81;
  font-weight: 800;
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
}

.game-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(36px, 8vw, 58px);
  line-height: 1;
  letter-spacing: 0;
}

.game-header p,
.hint {
  margin-top: 10px;
  color: var(--muted);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(72px, 1fr));
  gap: 10px;
}

.stats div,
.side-panel section {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  text-align: center;
}

.stats span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stats strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
}

.play-layout {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(150px, 1fr);
  gap: 18px;
  align-items: start;
}

.board-wrap {
  position: relative;
}

canvas {
  display: block;
  width: 100%;
  border-radius: 8px;
  background: var(--board);
}

#board {
  aspect-ratio: 1 / 2;
}

.side-panel {
  display: grid;
  gap: 14px;
}

.side-panel h2 {
  margin-bottom: 10px;
  font-size: 18px;
}

#next {
  width: 120px;
  height: 120px;
  margin: 0 auto;
}

.actions {
  display: grid;
  gap: 10px;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  border-radius: 8px;
  background: rgba(238, 243, 239, 0.78);
}

.overlay.hidden {
  display: none;
}

.panel {
  width: min(100%, 260px);
  padding: 22px;
  border-radius: 8px;
  background: var(--panel);
  text-align: center;
  box-shadow: 0 18px 42px rgba(32, 39, 32, 0.18);
}

.panel p {
  margin: 8px 0 16px;
  color: var(--muted);
}

.panel button {
  width: 100%;
}

.hint {
  text-align: center;
}

@media (max-width: 660px) {
  body {
    align-items: start;
    padding: 16px;
  }

  .game-header,
  .play-layout {
    grid-template-columns: 1fr;
    display: grid;
  }

  .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
