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

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  background: #f4e3c1;
  color: #3d2b1f;
  display: flex;
  height: 100%;
  overflow-y: auto;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  margin: auto; /* 有富余空间时居中;内容溢出时自动置顶,允许滚动 */
  padding: calc(8px + env(safe-area-inset-top)) 12px calc(8px + env(safe-area-inset-bottom));
  gap: 10px;
}

.status {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 1px;
  padding: 6px 14px;
  border-radius: 999px;
  background: #fff8ec;
  box-shadow: 0 1px 3px rgba(90, 60, 30, .18);
}

#controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

.segmented {
  display: inline-flex;
  background: #e5cfa6;
  border-radius: 999px;
  padding: 3px;
  box-shadow: inset 0 1px 2px rgba(90, 60, 30, .25);
}

.seg-btn {
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  color: #6b4a2c;
  padding: 6px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
}

.seg-btn.active {
  background: #7b4a2b;
  color: #fff8ec;
  box-shadow: 0 1px 3px rgba(90, 60, 30, .4);
}

.btn {
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 7px 18px;
  border-radius: 999px;
  background: #fff8ec;
  color: #7b4a2b;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(90, 60, 30, .25);
}

.btn.primary {
  background: #7b4a2b;
  color: #fff8ec;
}

.btn:active, .seg-btn:active {
  transform: scale(.96);
}

#boardWrap {
  position: relative;
}

canvas {
  display: block;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(90, 60, 30, .35);
}

#hint {
  font-size: 12px;
  color: #9a7b58;
}

#overlay {
  position: fixed;
  inset: 0;
  background: rgba(45, 28, 12, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  backdrop-filter: blur(2px);
}

#overlay.hidden {
  display: none;
}

.card {
  background: #fff8ec;
  border-radius: 18px;
  padding: 28px 36px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(45, 28, 12, .4);
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  animation: pop .18s ease-out;
}

@keyframes pop {
  from { transform: scale(.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.card-title {
  font-size: 26px;
  font-weight: 700;
}

.card-sub {
  font-size: 14px;
  color: #9a7b58;
}
