* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  background: #0b0b16;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#stage {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1200px 700px at 50% 0%, #1c1c3a 0%, transparent 60%),
    #0b0b16;
}

#board {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(255,255,255,.07), 0 24px 70px rgba(0,0,0,.6);
  --s: 1;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}

/* ---------- 工具按钮 ---------- */
#tools {
  position: absolute;
  top: calc(var(--s) * 16px);
  right: calc(var(--s) * 16px);
  display: flex;
  gap: calc(var(--s) * 10px);
  z-index: 6;
}

.tool {
  width: max(calc(var(--s) * 42px), 40px);
  height: max(calc(var(--s) * 42px), 40px);
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 50%;
  background: rgba(20, 20, 42, .55);
  color: #e9e9f7;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background .15s, transform .1s;
}

.tool:hover { background: rgba(42, 42, 76, .75); }
.tool:active { transform: scale(.94); }
.tool svg { width: max(calc(var(--s) * 22px), 19px); height: max(calc(var(--s) * 22px), 19px); fill: currentColor; }
.tool .ico-off { display: none; }
.tool.muted { color: rgba(233,233,247,.45); }
.tool.muted .ico-on { display: none; }
.tool.muted .ico-off { display: block; }

/* ---------- 浮层 ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(var(--s) * 12px);
  padding: calc(var(--s) * 32px);
  text-align: center;
  color: #eef;
  background: rgba(8, 8, 20, .74);
  backdrop-filter: blur(7px);
  animation: fade .18s ease-out;
}

.overlay.hidden, .hidden { display: none !important; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.eyebrow {
  font-size: max(calc(var(--s) * 13px), 11px);
  letter-spacing: .22em;
  font-weight: 700;
  color: rgba(180, 200, 255, .6);
}

.overlay h1 {
  font-size: max(calc(var(--s) * 46px), 30px);
  line-height: 1.1;
  letter-spacing: .01em;
  color: #fff;
  text-shadow: 0 0 calc(var(--s) * 26px) rgba(120, 200, 255, .35);
}

.sub {
  max-width: calc(var(--s) * 420px);
  font-size: max(calc(var(--s) * 16px), 13px);
  line-height: 1.55;
  color: rgba(228, 230, 250, .78);
}

.hint {
  margin-top: calc(var(--s) * 6px);
  font-size: max(calc(var(--s) * 13px), 11px);
  color: rgba(200, 205, 235, .45);
}

.records {
  font-size: max(calc(var(--s) * 15px), 13px);
  color: rgba(210, 215, 245, .6);
}
.records b { color: #ffd166; font-size: max(calc(var(--s) * 18px), 15px); }

/* ---------- 按钮 ---------- */
.modes {
  margin-top: calc(var(--s) * 10px);
  display: flex;
  flex-direction: column;
  gap: calc(var(--s) * 10px);
  width: max(calc(var(--s) * 260px), 224px);
}

.btn {
  position: relative;
  padding: max(calc(var(--s) * 15px), 13px) max(calc(var(--s) * 24px), 20px);
  font-size: max(calc(var(--s) * 18px), 15px);
  font-weight: 700;
  font-family: inherit;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: transform .1s, filter .15s;
}
.btn:active { transform: translateY(1px) scale(.99); }

.btn.primary {
  color: #06121f;
  background: linear-gradient(180deg, #a6e86a, #57c84d);
  box-shadow: 0 calc(var(--s) * 8px) calc(var(--s) * 22px) rgba(87, 200, 77, .32);
}
.btn.primary:hover { filter: brightness(1.05); }

.btn.ghost {
  color: rgba(235, 238, 255, .88);
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
}
.btn.ghost:hover { background: rgba(255,255,255,.1); }

.btn:disabled,
.btn[aria-disabled="true"] {
  cursor: default;
  color: rgba(235, 238, 255, .4);
  border-style: dashed;
}
.btn:disabled:hover,
.btn[aria-disabled="true"]:hover { background: rgba(255,255,255,.06); }

.btn .tag {
  margin-left: calc(var(--s) * 8px);
  padding: calc(var(--s) * 2px) calc(var(--s) * 7px);
  font-size: max(calc(var(--s) * 11px), 10px);
  font-weight: 700;
  letter-spacing: .06em;
  border-radius: 999px;
  color: rgba(200, 210, 255, .75);
  background: rgba(120, 140, 255, .16);
  vertical-align: middle;
}

/* ---------- 结算 ---------- */
.final-score {
  font-size: max(calc(var(--s) * 76px), 54px);
  font-weight: 800;
  line-height: 1;
  color: #fff;
  letter-spacing: -.02em;
  text-shadow: 0 0 calc(var(--s) * 34px) rgba(255, 209, 102, .28);
}

.new-best {
  font-size: max(calc(var(--s) * 15px), 12px);
  font-weight: 800;
  letter-spacing: .18em;
  color: #ffd166;
  animation: pulse 1.1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: .55; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.04); }
}

.over-best { font-size: max(calc(var(--s) * 15px), 13px); color: rgba(210, 215, 245, .65); }
.over-best b { color: #ffd166; }

.over-fruit {
  display: inline-flex;
  align-items: center;
  gap: calc(var(--s) * 8px);
  padding: calc(var(--s) * 6px) calc(var(--s) * 14px);
  font-size: max(calc(var(--s) * 14px), 12px);
  color: rgba(225, 230, 250, .8);
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 999px;
}

.dot {
  width: calc(var(--s) * 12px);
  height: calc(var(--s) * 12px);
  border-radius: 50%;
  background: #ff8fa0;
  box-shadow: 0 0 calc(var(--s) * 8px) currentColor;
}

/* ---------- Toast ---------- */
.toast {
  position: absolute;
  left: 50%;
  bottom: calc(var(--s) * 40px);
  transform: translateX(-50%);
  z-index: 20;
  padding: calc(var(--s) * 11px) calc(var(--s) * 18px);
  font-size: max(calc(var(--s) * 14px), 12px);
  color: #fff;
  background: rgba(20, 20, 42, .92);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 999px;
  box-shadow: 0 calc(var(--s) * 10px) calc(var(--s) * 30px) rgba(0,0,0,.5);
  animation: toastIn .18s ease-out;
}

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, calc(var(--s) * 8px)); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- 每日挑战 ---------- */
.daily-line {
  font-size: max(calc(var(--s) * 14px), 12px);
  color: rgba(255, 175, 110, .85);
}

.daily-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(var(--s) * 6px);
  margin-top: calc(var(--s) * 8px);
}

.daily-result-line {
  margin: 0;
  font-size: max(calc(var(--s) * 15px), 13px);
  color: rgba(210, 215, 245, .72);
}

.daily-result-line b { color: #ffd166; font-size: max(calc(var(--s) * 18px), 15px); }

.daily-streak {
  margin: 0;
  font-size: max(calc(var(--s) * 15px), 13px);
  font-weight: 800;
  letter-spacing: .04em;
  color: #ff9f6b;
}

.daily-result .btn {
  margin-top: calc(var(--s) * 4px);
  padding: max(calc(var(--s) * 10px), 10px) max(calc(var(--s) * 18px), 16px);
  font-size: max(calc(var(--s) * 15px), 13px);
}
