/* 全局：颜色与字体变量、页面底色、画布、按钮的共同规则 */
/* 标题字体：站酷快乐体的精简版，只含游戏里用到的字（npm run font 生成），随站点一起发布 */
@font-face{
  font-family:"ZCOOL KuaiLe";
  src:url("/assets/zcool-kuaile-subset-C6txaf7U.woff2") format("woff2");
  font-weight:400;font-style:normal;font-display:swap;
}
:root{
  /* 布局：全屏画布 + 浮在上方的轻量 HUD 与毛玻璃面板；单一视觉世界（海岸的一天） */
  --ink:#2f3a5f;
  --ink-soft:#5d6a8f;
  --paper:rgba(255,250,244,.78);
  --paper-line:rgba(255,255,255,.9);
  --coral:#f08a7b;
  --sun:#ffd08a;
  --sea:#8ecfdc;
  --font-display:"ZCOOL KuaiLe","PingFang SC","Hiragino Sans GB","Microsoft YaHei",sans-serif;
  --font-body:-apple-system,"PingFang SC","Hiragino Sans GB","Microsoft YaHei","Noto Sans SC",sans-serif;
  color-scheme:light;
  /* 刘海、圆角、底部横条占掉的边距。画面铺满全屏，只有按钮和面板避让 */
  --safe-top:env(safe-area-inset-top,0px);
  --safe-right:env(safe-area-inset-right,0px);
  --safe-bottom:env(safe-area-inset-bottom,0px);
  --safe-left:env(safe-area-inset-left,0px);
}
*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%;text-size-adjust:100%}
html,body{height:100%;margin:0;overflow:hidden;background:#8e9ed6;color:var(--ink);font-family:var(--font-body);
  -webkit-user-select:none;user-select:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent;touch-action:manipulation;overscroll-behavior:none}
#game{position:fixed;inset:0;top:0;left:0;width:100%;height:100%;display:block;touch-action:none}
/* iPhone 主屏幕模式：系统少算了状态栏的高度，画面和面板补足到屏幕底边 */
.ios-standalone body{min-height:calc(100% + env(safe-area-inset-top))}
.ios-standalone #game,.ios-standalone .panel{bottom:auto;height:calc(100% + env(safe-area-inset-top))}
/* 量屏幕尺寸用的隐形元素，不随画面旋转 */
#vp{position:fixed;left:0;top:0;width:100%;height:100%;visibility:hidden;pointer-events:none;z-index:-1}
.ios-standalone #vp{height:calc(100% + env(safe-area-inset-top))}
/* 画面旋转（横竖屏按钮）：舞台的宽高和旋转由脚本设定；刘海、圆角的避让跟着换到对应的边 */
html.turned #stage{position:fixed;left:0;top:0;transform-origin:0 0;overflow:hidden}
html.turned #game,html.turned .panel{bottom:0;height:100%}
html.turn-90{--safe-top:env(safe-area-inset-right,0px);--safe-right:env(safe-area-inset-bottom,0px);--safe-bottom:env(safe-area-inset-left,0px);--safe-left:env(safe-area-inset-top,0px)}
html.turn-180{--safe-top:env(safe-area-inset-bottom,0px);--safe-right:env(safe-area-inset-left,0px);--safe-bottom:env(safe-area-inset-top,0px);--safe-left:env(safe-area-inset-right,0px)}
html.turn-270{--safe-top:env(safe-area-inset-left,0px);--safe-right:env(safe-area-inset-top,0px);--safe-bottom:env(safe-area-inset-right,0px);--safe-left:env(safe-area-inset-bottom,0px)}
button{font:inherit;color:var(--ink);cursor:pointer;pointer-events:auto;
  transition:transform .12s ease,filter .12s ease,background-color .2s ease,box-shadow .12s ease;transform-origin:center}
/* 按下时轻轻缩小、变亮；点击后一圈柔和的光 */
button:not(:disabled):active,button:not(:disabled).press-feedback{transform:scale(.94);filter:brightness(1.14)}
.tap-feedback{position:fixed;z-index:40;pointer-events:none;border:2px solid rgba(240,138,123,.75);box-shadow:0 0 0 2px rgba(255,255,255,.3);animation:tap-feedback .38s ease-out forwards}
@keyframes tap-feedback{from{opacity:.85;transform:scale(.98)}to{opacity:0;transform:scale(1.16)}}
@keyframes tap-feedback-still{from{opacity:.8}to{opacity:0}}
@media (prefers-reduced-motion:reduce){
  button{transition:filter .1s,background-color .1s}
  button:not(:disabled):active,button:not(:disabled).press-feedback{transform:none}
  .tap-feedback{animation-name:tap-feedback-still}
}
button:focus-visible{outline:3px solid var(--coral);outline-offset:2px}
/* HUD：左上角计数与体力、右上角按钮、浮字与提示条 */
.hud{position:fixed;z-index:10;left:0;right:0;top:0;display:flex;justify-content:space-between;align-items:flex-start;gap:12px;
  padding:calc(var(--safe-top) + 14px) calc(var(--safe-right) + 16px) 0 calc(var(--safe-left) + 16px);pointer-events:none}
.left{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.pill{background:var(--paper);border:1px solid var(--paper-line);border-radius:999px;padding:8px 16px;
  backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);box-shadow:0 4px 18px rgba(47,58,95,.12)}
.stats{display:flex;gap:16px;align-items:baseline;font-variant-numeric:tabular-nums}
.stats b{font-family:var(--font-display);font-weight:400;font-size:22px;color:var(--ink)}
.stats span{font-size:12px;color:var(--ink-soft);margin-left:3px}
.right{display:flex;gap:8px;align-items:center;flex:none}
.hearts{display:flex;gap:4px;align-items:center;padding:9px 14px}
.hearts svg{width:18px;height:18px;fill:var(--coral);transition:opacity .3s,transform .3s}
.hearts svg.off{opacity:.22;transform:scale(.8)}
.hud button{width:42px;height:42px;padding:0;display:grid;place-items:center;border-radius:50%}
.hud button[hidden]{display:none}
#btnAlpha{font-family:Georgia,'Times New Roman',serif;font-style:italic;font-size:21px;line-height:1;color:var(--ink-soft)}
#btnAlpha.on{color:#fff;background:var(--coral);border-color:rgba(255,255,255,.6)}
:where(html.w-400) .hud button{width:38px;height:38px}:where(html.w-400) .right{gap:6px}
.hud button svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
@media (hover:hover){.hud button:not(.on):hover{background:rgba(255,255,255,.95)}}
.pop{position:fixed;z-index:30;pointer-events:none;font-family:var(--font-display);font-size:19px;line-height:1;padding:5px 11px;border-radius:999px;
  background:rgba(255,255,255,.95);box-shadow:0 3px 12px rgba(47,58,95,.18);white-space:nowrap;animation:pop 1.4s ease-out forwards}
.pop.heal{color:#35a874}
.pop.bonus{color:#e0932a}
@keyframes pop{0%{opacity:0;transform:translateY(6px) scale(.6)}14%{opacity:1;transform:translateY(0) scale(1.18)}28%{transform:translateY(0) scale(1)}72%{opacity:1;transform:translateY(-3px) scale(1)}100%{opacity:0;transform:translateY(-12px) scale(1)}}
.toast{position:fixed;z-index:12;left:50%;bottom:calc(var(--safe-bottom) + 20px);transform:translateX(-50%);font-size:13px;line-height:1.5;pointer-events:none;opacity:0;transition:opacity .3s;
  width:max-content;max-width:calc(100% - 32px - var(--safe-left) - var(--safe-right));text-align:center;border-radius:18px}
.toast.on{opacity:1}
.timer b{font-family:var(--font-display);font-weight:400;font-size:20px;font-variant-numeric:tabular-nums}
.timer span{font-size:12px;color:var(--ink-soft);margin-right:6px}
.timer{padding:9px 14px}.timer[hidden],.hearts[hidden]{display:none}
.hud{transition:opacity .6s}

/* 睡前模式：面板更淡，宽度固定，数字变化时不伸缩；“+5”调暗调柔 */
body.sleep-mode .stats,body.sleep-mode .timer{background:rgba(255,250,244,.30);border-color:rgba(255,255,255,.45);box-shadow:0 3px 14px rgba(47,58,95,.07)}
body.sleep-mode .stats{width:224px;max-width:100%;display:grid;grid-template-columns:1fr 1.2fr;gap:8px}
body.sleep-mode .stats>div{display:flex;align-items:baseline;justify-content:flex-end;white-space:nowrap}
body.sleep-mode .timer{width:144px;flex:none;white-space:nowrap}
body.sleep-mode .timer b{display:inline-block;width:6ch;text-align:right;font-family:ui-monospace,monospace;font-size:18px}
body.sleep-mode .pop.bonus{color:#ad854c;background:rgba(220,215,205,.55);box-shadow:0 2px 8px rgba(47,58,95,.06);animation-name:sleep-bonus-pop}
@keyframes sleep-bonus-pop{0%{opacity:0;transform:translateY(6px) scale(.6)}14%{opacity:.65;transform:translateY(0) scale(1.18)}28%{transform:translateY(0) scale(1)}72%{opacity:.65;transform:translateY(-3px) scale(1)}100%{opacity:0;transform:translateY(-12px) scale(1)}}
/* 面板：首页、暂停、结算、睡前设置、晚安 */
/* 面板盖住整个屏幕并接住点击：点空白处不会碰到下面的游戏 */
.panel{position:fixed;z-index:5;inset:0;top:0;right:0;bottom:0;left:0;display:flex;align-items:center;justify-content:center;pointer-events:auto;overflow:hidden;
  padding:calc(var(--safe-top) + 16px) calc(var(--safe-right) + 16px) calc(var(--safe-bottom) + 16px) calc(var(--safe-left) + 16px);
  transition:opacity .35s}
.panel[hidden]{display:none}
.card{background:rgba(255,250,244,.58);pointer-events:auto;max-height:100%;overflow-y:auto;overscroll-behavior:contain;touch-action:pan-y;border:1px solid var(--paper-line);border-radius:28px;padding:28px 32px;max-width:420px;width:100%;
  text-align:center;backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);box-shadow:0 12px 40px rgba(47,58,95,.18)}
.card h1{font-family:var(--font-display);font-weight:400;font-size:44px;margin:0 0 6px;letter-spacing:2px;text-wrap:balance}
.card h2{font-family:var(--font-display);font-weight:400;font-size:30px;margin:0 0 6px}
.card p{margin:0 0 14px;color:var(--ink-soft);font-size:15px;line-height:1.7}
.keys{display:grid;gap:6px;margin:0 0 20px;padding:0;list-style:none;font-size:13.5px;color:var(--ink);text-align:left}
.keys li{display:flex;gap:10px;align-items:center}
.keys kbd{font-family:var(--font-body);font-size:12px;background:#fff;border-radius:8px;padding:3px 9px;min-width:86px;text-align:center;
  box-shadow:0 2px 0 rgba(47,58,95,.14)}
.go{font-family:var(--font-display);font-size:22px;letter-spacing:4px;color:#fff;background:var(--coral);border:0;border-radius:999px;
  padding:12px 44px;box-shadow:0 5px 0 #d46f63,0 10px 22px rgba(240,138,123,.4);transition:transform .12s,box-shadow .12s}
@media (hover:hover){.go:hover{transform:translateY(-2px)}}
.go:not(:disabled):active,.go:not(:disabled).press-feedback{transform:translateY(2px) scale(.96);box-shadow:0 2px 0 #d46f63,0 5px 12px rgba(240,138,123,.28)}
@media (prefers-reduced-motion:reduce){.go:not(:disabled):active,.go:not(:disabled).press-feedback{transform:none}}
.ghost{font-size:14.5px;background:rgba(255,255,255,.7);border:1px solid var(--paper-line);border-radius:999px;padding:9px 20px;color:var(--ink)}
@media (hover:hover){.ghost:hover{background:#fff}}
.card .ghost{margin-top:12px}
.card.live{pointer-events:auto;text-align:left}
.card.live h2{text-align:center}.card.live>p{text-align:center}
.field{display:grid;gap:8px;margin:0 0 16px}
.field .lab{font-size:13px;color:var(--ink-soft)}
.field small{font-size:12px;color:var(--ink-soft);line-height:1.5}
.chips{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
.chip{font-size:14px;background:#fff;border:1.5px solid transparent;border-radius:999px;padding:7px 14px;font-variant-numeric:tabular-nums;box-shadow:0 2px 0 rgba(47,58,95,.1)}
.chip[aria-pressed="true"]{background:var(--coral);color:#fff;box-shadow:0 2px 0 #d46f63}
.custom{display:inline-flex;align-items:center;gap:6px;font-size:13px;color:var(--ink-soft)}
.custom input{width:92px;font:inherit;font-size:16px;color:var(--ink);background:#fff;border:1.5px solid transparent;border-radius:999px;padding:7px 12px;text-align:center;
  -webkit-user-select:text;user-select:text;touch-action:manipulation}
.custom input:focus-visible{outline:3px solid var(--coral);outline-offset:2px}
.custom input.sel{border-color:var(--coral)}
.sw{display:flex;align-items:center;justify-content:space-between;gap:12px}
.switch{flex:none;width:50px;height:28px;border-radius:999px;border:0;background:#c9cee0;position:relative;transition:background .2s;padding:0}
.switch::after{content:"";position:absolute;left:3px;top:3px;width:22px;height:22px;border-radius:50%;background:#fff;box-shadow:0 1px 4px rgba(47,58,95,.3);transition:transform .2s}
.switch[aria-checked="true"]{background:var(--coral)}
.switch[aria-checked="true"]::after{transform:translateX(22px)}
.acts{display:flex;justify-content:center;align-items:center;gap:12px;margin-top:4px}
.acts .ghost{margin-top:0}
.sfxBox{display:grid;gap:8px;text-align:left}
.volRow{display:flex;align-items:center;gap:12px;margin:0 0 16px;font-size:14px;color:var(--ink);text-align:left}
.volLabel{flex:none;color:var(--ink-soft);font-size:13px}
/* 自绘的滑块：整条 44px 高都能按，点轨道任意位置直接跳过去；--v 是 0 到 1 的当前值 */
.vol{--v:1;position:relative;flex:1;min-width:0;height:44px;margin:-8px 0;touch-action:none;cursor:pointer;
  -webkit-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent;outline:none;border-radius:12px}
.vol:focus-visible{box-shadow:0 0 0 3px var(--coral)}
.vol-track{position:absolute;left:12px;right:12px;top:50%;height:6px;margin-top:-3px;border-radius:3px;background:rgba(93,106,143,.22);overflow:hidden}
.vol-fill{position:absolute;left:0;top:0;bottom:0;width:calc(var(--v) * 100%);background:var(--coral);border-radius:3px}
.vol-thumb{position:absolute;top:50%;left:calc(12px + (100% - 24px) * var(--v));width:24px;height:24px;margin:-12px 0 0 -12px;border-radius:50%;
  background:#fff;box-shadow:0 1px 4px rgba(47,58,95,.3),0 0 0 1px rgba(47,58,95,.06);transition:transform .12s ease}
.vol.dragging .vol-thumb{transform:scale(1.15)}
@media (prefers-reduced-motion:reduce){.vol-thumb{transition:none}.vol.dragging .vol-thumb{transform:none}}
.subs{display:flex;gap:8px;transition:opacity .2s}
.subs.off{opacity:.4}
.sub{flex:1;display:flex;align-items:center;justify-content:space-between;gap:6px;background:rgba(255,255,255,.6);border-radius:14px;padding:6px 8px 6px 12px;font-size:13.5px}
.switch.sm{width:42px;height:24px}
.switch.sm::after{width:18px;height:18px}
.switch.sm[aria-checked="true"]::after{transform:translateX(18px)}
.switch:disabled{cursor:default}
#pauseSfx{margin:0 0 16px}
#pauseSfx[hidden]{display:none}
.night{text-align:center;color:rgba(235,238,255,.42);font-family:var(--font-display);font-size:34px;letter-spacing:6px;display:grid;gap:10px}
.night{pointer-events:auto}
.night .ghost{justify-self:center;margin-top:16px;color:#dfe6ff;background:rgba(255,255,255,.1);border-color:rgba(255,255,255,.2)}
.night small{font-family:var(--font-body);font-size:13px;letter-spacing:1px;color:rgba(235,238,255,.28)}
.result{display:flex;justify-content:center;gap:22px;margin:10px 0 18px;font-variant-numeric:tabular-nums}
.result div{display:grid;gap:2px}
.result b{font-family:var(--font-display);font-weight:400;font-size:28px}
.result small{font-size:12px;color:var(--ink-soft)}
/* 小屏适配。必须最后加载，才能覆盖前面的规则。
   不用 @media：画面可能被旋转过，浏览器报告的屏幕方向和宽高不一定是画面的。
   改为看 <html> 上的标记（core/stage.js 按画面实际宽高打的）：
   lay-portrait / lay-landscape 横竖，w-480 / w-400 / w-370 宽度不超过，h-480 / h-720 高度不超过。
   :where() 不增加优先级，和原来写在 @media 里时一样 */
:where(html.w-480) .card{padding:22px 20px;border-radius:24px}
:where(html.w-480) .card h1{font-size:36px}
:where(html.w-480) .stats{gap:12px;padding:7px 14px}
:where(html.w-480) .stats b{font-size:19px}
:where(html.w-480) .hearts{padding:8px 12px}
:where(html.w-480) .hearts svg{width:16px;height:16px}
:where(html.w-480) .result{gap:16px}
:where(html.w-480) .result b{font-size:24px}
/* 横屏手机：高度很小，面板改成紧凑的两栏 */
:where(html.h-480) .card{max-width:560px;padding:16px 24px;border-radius:22px}
:where(html.h-480) .card h1{font-size:30px;margin-bottom:2px}
:where(html.h-480) .card h2{font-size:24px;margin-bottom:2px}
:where(html.h-480) .card p{font-size:13.5px;margin-bottom:8px}
:where(html.h-480) .keys{grid-template-columns:1fr 1fr;gap:5px 14px;margin-bottom:12px;font-size:12.5px}
:where(html.h-480) .keys kbd{min-width:72px}
:where(html.h-480) .field{margin-bottom:10px;gap:5px}
:where(html.h-480) .volRow{margin-bottom:8px}
:where(html.h-480) .card .ghost{margin-top:8px}
:where(html.h-480) .acts .ghost{margin-top:0}
:where(html.h-480) .card.live{max-height:100%;overflow:auto;touch-action:pan-y;max-width:640px;padding:12px 22px}
:where(html.h-480) .card.live>p,:where(html.h-480) .card.live .field>small{display:none}
:where(html.h-480) .card.live h2{font-size:21px;margin-bottom:6px}
:where(html.h-480) .chip{padding:6px 12px;font-size:13.5px}
:where(html.h-480) .custom input{padding:6px 10px;width:84px}
:where(html.h-480) .sub{padding:4px 8px 4px 12px}
:where(html.h-480) .result{margin:6px 0 12px}
:where(html.h-480) .result b{font-size:22px}
:where(html.h-480) .go{font-size:19px;padding:9px 38px}
:where(html.h-480) .stats b{font-size:18px}
:where(html.h-480) .hud button{width:38px;height:38px}

/* —— HUD 布局 —— 放在最后，覆盖上面按宽高写的通用规则 */
:where(html.w-370) .hud{gap:6px;padding-left:calc(var(--safe-left) + 8px);padding-right:calc(var(--safe-right) + 8px)}
:where(html.w-370) .stats{gap:7px;padding:7px 9px}
:where(html.w-370) .stats b{font-size:17px}
:where(html.w-370) .stats span{font-size:10px}
:where(html.w-370) .right{gap:4px}
:where(html.w-370) .hud button{width:36px;height:36px}
/* 竖屏：左上角固定两行（计数一行，体力或剩余时间一行），右上角按钮排成两列。
   按钮自动排进格子，隐藏的按钮不占位置 */
:where(html.lay-portrait) .hud{gap:10px}
:where(html.lay-portrait) .left{flex:1;min-width:0;flex-direction:column;align-items:flex-start;flex-wrap:nowrap;gap:8px}
:where(html.lay-portrait) .stats{flex:none;gap:10px;max-width:100%;padding:8px 12px}
:where(html.lay-portrait) .stats>div{white-space:nowrap}
:where(html.lay-portrait) .stats b{font-size:19px}
:where(html.lay-portrait) .stats span{font-size:11px}
:where(html.lay-portrait) .right{display:grid;grid-template-columns:repeat(2,40px);gap:8px}
:where(html.lay-portrait) .hud button{width:40px;height:40px}
:where(html.lay-portrait) .hearts,:where(html.lay-portrait) .timer{flex:none}
:where(html.lay-portrait) body.sleep-mode .stats{width:100%}
/* 首页、暂停、结算面板贴在右上角按钮下面，把下方留给地面和鹈鹕 */
:where(html.lay-portrait) #panelStart,:where(html.lay-portrait) #panelPause,:where(html.lay-portrait) #panelOver{align-items:flex-start;padding-top:calc(var(--hud-bottom, 110px) + 10px)}
/* 矮的竖屏：首页面板去掉副标题、收紧间距，给鹈鹕留出位置 */
:where(html.lay-portrait.h-720) #panelStart .card>p{display:none}
:where(html.lay-portrait.h-720) #panelStart .card h1{margin-bottom:12px}
:where(html.lay-portrait.h-720) #panelStart .keys{margin-bottom:16px}
:where(html.lay-portrait.w-370) .hud{gap:8px}
:where(html.lay-portrait.w-370) .right{grid-template-columns:repeat(2,36px);gap:6px}
:where(html.lay-portrait.w-370) .hud button{width:36px;height:36px}
:where(html.lay-portrait.w-370) .stats{gap:6px;padding:8px}
:where(html.lay-portrait.w-370) .stats b{font-size:16px}
:where(html.lay-portrait.w-370) .stats span{font-size:10px;margin-left:2px}
/* 横屏：体力固定在顶部正中，不随计数面板的宽度移动 */
:where(html.lay-landscape) .hud .hearts{position:absolute;left:50%;top:calc(var(--safe-top) + 14px);transform:translateX(-50%);flex:none}
