/* 发情节拍器 · 样式（定版：樱粉软糖，2026-10-16 董事长和嫂子选的）
   浅色奶粉底 + 玫红，圆滚滚按钮、粗环，可爱但一眼 18+。风格色由 html[data-style] 切换。 */

:root {
  --bg: #fff1f6;
  --bg2: #ffd9e6;
  --card: #ffffff;
  --card2: #ffe4ee;
  --line: rgba(255, 77, 148, 0.18);
  --ink: #3b1427;
  --ink2: #8c4f6b;
  --ink3: #b98aa0;
  --gold: #f2a33a;
  --accent: #ff4d94;
  --accent2: #ff8fb8;
  --glow: rgba(255, 77, 148, 0.35);
  --shadow: rgba(255, 77, 148, 0.4);
  --font-display: 'ZCOOL KuaiLe', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-body: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --track: rgba(255, 77, 148, 0.12);
  --veil: rgba(255, 228, 238, 0.65);
  --veil-strong: rgba(255, 241, 246, 0.96);
  --chip: rgba(255, 255, 255, 0.92);
  --sheet: #fff7fa;
}
html[data-style="G"] { --accent: #ff4d94; --accent2: #ff8fb8; --glow: rgba(255, 77, 148, 0.35); --bg2: #ffd9e6; }
html[data-style="P"] { --accent: #ff6b6b; --accent2: #ffa3a3; --glow: rgba(255, 107, 107, 0.35); --bg2: #ffe0dc; }
html[data-style="S"] { --accent: #e0245e; --accent2: #ff5c8a; --glow: rgba(224, 36, 94, 0.35); --bg2: #ffc9db; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 var(--font-body);
  overflow-x: hidden;
  min-height: 100svh;
  position: relative;
}
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -2;
  background:
    radial-gradient(90% 50% at 10% 0%, var(--bg2) 0%, transparent 60%),
    radial-gradient(70% 40% at 100% 100%, #ffe3c2 0%, transparent 60%),
    var(--bg);
  transition: background 0.6s ease;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hidden { display: none !important; }

.screen { max-width: 480px; margin: 0 auto; padding: 20px 16px calc(28px + var(--safe-b)); min-height: 100svh; display: flex; flex-direction: column; }

/* ---------- 品牌 ---------- */
.brand { position: relative; padding: 18px 0 8px; }
.brand-row { display: flex; align-items: baseline; gap: 12px; padding-right: 48px; }
.brand-title {
  margin: 0;
  font: 400 50px/1 var(--font-display);
  color: var(--accent);
  letter-spacing: 0.02em;
}
.seal {
  display: inline-block; transform: rotate(-8deg); align-self: center;
  border: 2px solid var(--accent); color: var(--accent); background: #fff; border-radius: 999px;
  padding: 1px 8px; font: 700 13px/1.4 var(--font-body); letter-spacing: 0.08em;
}
.brand-sub { margin: 10px 0 0; color: var(--ink2); font-size: 14px; letter-spacing: 0.04em; }
.icon-btn {
  position: absolute; right: -6px; top: 14px; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; color: var(--ink2);
}
.icon-btn:active { background: var(--card2); }

/* ---------- 区块 ---------- */
.block { margin-top: 26px; }
.block.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.label {
  margin: 0 0 10px; font-size: 13px; font-weight: 500; color: var(--ink3); letter-spacing: 0.3em;
  display: flex; align-items: center; gap: 10px;
}
.label::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.styles { display: grid; gap: 10px; }
.style-card {
  position: relative; text-align: left; padding: 14px 16px 12px; border-radius: 22px;
  background: var(--card); border: 1px solid transparent; box-shadow: 0 6px 20px -12px var(--shadow);
  display: grid; gap: 3px; transition: border-color 0.25s, box-shadow 0.25s, transform 0.15s;
  overflow: hidden;
}
.style-card::before {
  content: ""; position: absolute; inset: 0; opacity: 0; transition: opacity 0.3s;
  background: radial-gradient(90% 120% at 100% 0%, var(--glow), transparent 60%);
}
.style-card b { font-size: 19px; font-weight: 700; letter-spacing: 0.06em; position: relative; }
.style-card span { font-size: 13px; color: var(--ink2); position: relative; }
.style-card i { font-style: normal; font-size: 12px; color: var(--ink3); position: relative; margin-top: 4px; }
.style-card[data-style="G"] { --accent: #ff4d94; --glow: rgba(255, 77, 148, 0.35); }
.style-card[data-style="P"] { --accent: #ff6b6b; --glow: rgba(255, 107, 107, 0.35); }
.style-card[data-style="S"] { --accent: #e0245e; --glow: rgba(224, 36, 94, 0.35); }
.style-card.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset, 0 10px 26px -12px var(--glow); }
.style-card.on::before { opacity: 0.2; }
.style-card.on b { color: var(--accent); }
.style-card:active { transform: scale(0.985); }

.seg {
  display: flex; background: #fff; border: 1px solid transparent; border-radius: 999px; padding: 4px; gap: 4px;
  box-shadow: 0 4px 14px -10px var(--shadow);
}
.seg button {
  flex: 1; padding: 10px 0; border-radius: 999px; font-size: 17px; font-weight: 700; color: var(--ink2);
  display: flex; flex-direction: column; align-items: center; line-height: 1.15; transition: background 0.2s, color 0.2s;
}
.seg button small { font-size: 11px; font-weight: 500; color: var(--ink3); letter-spacing: 0.05em; }
.seg button.on { background: var(--accent); color: #fff; box-shadow: 0 4px 16px -4px var(--glow); }
.seg button.on small { color: rgba(255, 255, 255, 0.8); }
.seg.small button { padding: 7px 0; font-size: 14px; }
.hint { margin: 10px 2px 0; font-size: 13px; color: var(--ink3); min-height: 1.6em; }

.start {
  margin-top: 26px; width: 100%; padding: 18px; border-radius: 999px;
  font-size: 22px; font-weight: 900; letter-spacing: 0.5em; text-indent: 0.5em; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 14px 30px -12px rgba(255, 77, 148, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.2) inset;
  transition: transform 0.15s, filter 0.2s;
}
.start:active { transform: scale(0.98); filter: brightness(1.05); }
.foot { margin: 14px 0 0; text-align: center; font-size: 12px; color: var(--ink3); }

/* ---------- 18+ ---------- */
.gate { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: var(--veil-strong); backdrop-filter: blur(10px); padding: 24px; }
.gate-card { max-width: 360px; width: 100%; text-align: center; }
.gate-title { font: 400 48px/1.1 var(--font-display); color: var(--accent); }
.gate-card p { color: var(--ink2); margin: 14px 0 6px; }
.gate-card .start { letter-spacing: 0.1em; text-indent: 0; font-size: 18px; }

/* ---------- 游戏页 ---------- */
#screenPlay { padding-top: 14px; }
.loadbar { height: 2px; background: var(--track); border-radius: 2px; overflow: hidden; margin-bottom: 10px; opacity: 1; transition: opacity 0.6s; }
.loadbar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.3s; }
.loadbar.done { opacity: 0; }

.phases { display: flex; justify-content: space-between; align-items: center; padding: 4px 2px 0; }
.phases span {
  font-size: 12px; color: var(--ink3); letter-spacing: 0.05em; position: relative; padding-top: 10px; transition: color 0.3s;
}
.phases span::before {
  content: ""; position: absolute; left: 50%; top: 0; width: 5px; height: 5px; border-radius: 50%; transform: translateX(-50%);
  background: var(--ink3); opacity: 0.5; transition: all 0.3s;
}
.phases span.done { color: var(--ink2); }
.phases span.done::before { background: var(--ink2); opacity: 0.6; }
.phases span.on { color: var(--accent); font-weight: 700; }
.phases span.on::before { background: var(--accent); box-shadow: 0 0 10px var(--glow); opacity: 1; width: 7px; height: 7px; top: -1px; }

.stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; padding: 10px 0; }
.glow {
  position: absolute; width: min(90vw, 420px); aspect-ratio: 1; border-radius: 50%; z-index: -1;
  background: radial-gradient(circle, var(--glow) 0%, transparent 62%); opacity: 0.28; filter: blur(10px);
  animation: breathe 5s ease-in-out infinite;
}
@keyframes breathe { 0%, 100% { transform: scale(0.92); opacity: 0.2; } 50% { transform: scale(1.05); opacity: 0.32; } }

.ring-wrap { position: relative; width: min(68vw, 290px); aspect-ratio: 1; transition: transform 0.08s ease-out; }
.ring-wrap.beat { transform: scale(1.035); transition-duration: 0.05s; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.ring-bg { fill: none; stroke: var(--track); stroke-width: 14; }
.ring-fg {
  fill: none; stroke: var(--accent); stroke-width: 14; stroke-linecap: round;
  stroke-dasharray: 741.4; stroke-dashoffset: 0; transition: stroke-dashoffset 0.12s linear, stroke 0.4s;
}
.ring-wrap.hold .ring-fg { stroke: var(--gold); }
.center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.center-num {
  font: 900 min(26vw, 108px)/1 var(--font-body); color: var(--accent); letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.center-num.pop { animation: pop 0.35s ease-out; }
@keyframes pop { 0% { transform: scale(1.18); } 100% { transform: scale(1); } }
.center-label { margin-top: 4px; font-size: 14px; color: var(--ink2); letter-spacing: 0.3em; text-indent: 0.3em; }
.ring-wrap.hold .center-label { color: var(--gold); }
.ring-wrap.hold .center-num { color: var(--gold); }

.instruction {
  margin: 26px 0 0; padding: 0 6px; min-height: 4.6em; text-align: center;
  font-size: 22px; font-weight: 700; line-height: 1.55; letter-spacing: 0.02em; color: var(--ink);
}
.instruction.rise { animation: rise 0.45s ease-out; }
@keyframes rise { from { opacity: 0.35; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.cue { margin: 4px 0 0; min-height: 1.7em; text-align: center; font-size: 17px; color: #e0245e; opacity: 0; letter-spacing: 0.08em; }
.cue.show { animation: cueFlash 2.2s ease-out forwards; }
@keyframes cueFlash { 0% { opacity: 0; transform: translateY(4px) scale(0.98); } 12% { opacity: 1; transform: none; } 70% { opacity: 1; } 100% { opacity: 0; } }

.tempo { margin-top: 10px; display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--ink3); letter-spacing: 0.15em; min-height: 18px; }
.dots { display: inline-flex; gap: 5px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink3); opacity: 0.35; }
.dots[data-n="1"] i:nth-child(-n+1), .dots[data-n="2"] i:nth-child(-n+2), .dots[data-n="3"] i:nth-child(-n+3), .dots[data-n="4"] i:nth-child(-n+4) { background: var(--accent); opacity: 1; box-shadow: 0 0 8px var(--glow); }

.paused-veil {
  position: fixed; inset: 0; z-index: 20; display: none; place-items: center; pointer-events: none;
  background: var(--veil); backdrop-filter: blur(3px);
}
.paused-veil span { font-size: 18px; letter-spacing: 0.3em; color: var(--ink); border: 1px solid var(--line); padding: 10px 22px; border-radius: 999px; background: var(--chip); }
.paused-veil.show { display: grid; }

.controls { display: grid; grid-template-columns: 1.4fr 1fr 0.8fr; gap: 10px; align-items: center; margin-top: 18px; position: relative; z-index: 21; }
.btn-primary {
  padding: 15px; border-radius: 999px; font-size: 18px; font-weight: 700; letter-spacing: 0.3em; text-indent: 0.3em; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); box-shadow: 0 14px 30px -12px rgba(255, 77, 148, 0.6);
}
.btn-ghost {
  padding: 14px; border-radius: 999px; font-size: 16px; letter-spacing: 0.2em; text-indent: 0.2em; color: var(--ink2);
  border: 1px solid transparent; background: #fff; box-shadow: 0 4px 14px -10px var(--shadow);
}
.btn-ghost.small { padding: 7px 14px; font-size: 13px; }
.btn-ghost.wide, .btn-primary.wide { width: 100%; margin-top: 12px; }
.btn-quiet { padding: 14px 6px; font-size: 14px; letter-spacing: 0.15em; color: var(--ink3); }
.btn-primary:active, .btn-ghost:active, .btn-quiet:active { transform: scale(0.97); }

/* ---------- 结束页 ---------- */
.end-wrap { flex: 1; display: flex; flex-direction: column; justify-content: center; text-align: center; }
.end-title { font: 400 64px/1.1 var(--font-display); color: var(--accent); }
.end-line { margin: 16px 0 0; font-size: 19px; font-weight: 700; line-height: 1.6; }
.summary { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 22px 0 6px; }
.summary span { font-size: 13px; color: var(--ink2); border: 1px solid transparent; background: #fff; border-radius: 999px; padding: 6px 12px; box-shadow: 0 4px 14px -10px var(--shadow); }
.summary span b { color: var(--accent); font-weight: 700; margin-left: 4px; }

/* ---------- 设置抽屉 ---------- */
.sheet { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; }
.sheet-back { position: absolute; inset: 0; background: var(--veil); backdrop-filter: blur(4px); }
.sheet-panel {
  position: relative; width: 100%; max-width: 480px; margin: 0 auto; background: var(--sheet); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 26px 26px 0 0; padding: 18px 18px calc(20px + var(--safe-b)); animation: up 0.3s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-panel h3 { margin: 0 0 10px; font-size: 15px; letter-spacing: 0.3em; color: var(--ink3); font-weight: 500; }
.sheet-panel .row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); }
.sheet-panel .row > span { font-size: 15px; color: var(--ink); white-space: nowrap; }
.sheet-panel .seg { flex: 1; max-width: 240px; }
input[type="range"] { flex: 1; max-width: 240px; accent-color: var(--accent); }
.switch { position: relative; width: 48px; height: 28px; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: var(--card2); border: 1px solid transparent; transition: background 0.2s; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15); transition: transform 0.2s; }
.switch input:checked + i { background: var(--accent); border-color: var(--accent); }
.switch input:checked + i::after { transform: translateX(20px); }

@media (min-width: 560px) {
  .brand-title { font-size: 58px; }
  .instruction { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  .glow { animation: none; }
  .ring-wrap.beat { transform: none; }
}
