*{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%;overflow:hidden;background:#0c1832}
body{font-family:-apple-system,BlinkMacSystemFont,"PingFang SC","Hiragino Sans GB","Microsoft YaHei","Noto Sans CJK SC",sans-serif;color:#fff3df;-webkit-text-size-adjust:100%;overscroll-behavior:none}
button{font:inherit;color:inherit;cursor:pointer;-webkit-tap-highlight-color:transparent;touch-action:manipulation}
#app{position:fixed;top:0;left:0;width:100%;height:100vh;height:100dvh;display:flex;flex-direction:column;overflow:hidden;
  touch-action:none;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none;
  --sa-t:env(safe-area-inset-top,0px);--sa-r:env(safe-area-inset-right,0px);--sa-b:env(safe-area-inset-bottom,0px);--sa-l:env(safe-area-inset-left,0px);
  padding:var(--sa-t) var(--sa-r) 0 var(--sa-l)}

/* ===== background: dusk temple ===== */
.bg{position:absolute;top:0;left:0;width:100%;height:100%;overflow:hidden;z-index:0;pointer-events:none}
.bg>*{position:absolute}
.sky{top:0;left:0;width:100%;height:100%;background:linear-gradient(180deg,#081226 0%,#0d1b38 22%,#132a4b 44%,#1a3d5b 62%,#21506a 76%,#285d70 86%,#1d4256 100%)}
/* calm night: faint stars, soft crescent moon, muted temple silhouettes, low mist — no glow/rays */
.nightstars{top:0;left:0;width:100%;height:100%;fill:#e9f1ff}
.nightstars .tw1{animation:twinkle 7s ease-in-out infinite}
.nightstars .tw2{animation:twinkle 11s ease-in-out -4s infinite}
@keyframes twinkle{0%,100%{opacity:1}50%{opacity:.45}}
.moon{right:12%;top:9%;width:46px;height:46px;border-radius:50%;background:transparent;box-shadow:inset -12px 6px 0 0 #e9e5d0;opacity:.8}
.temples{left:0;bottom:0;width:100%;height:62%}
.temples.far{fill:#2c5368;opacity:.55}
.temples.near{fill:#0f2236;opacity:.78;height:52%}
.mist{left:0;bottom:0;width:100%;height:40%;background:linear-gradient(180deg,rgba(170,205,220,0) 0,rgba(170,205,220,.10) 45%,rgba(150,190,205,.16) 70%,rgba(10,24,40,.25) 100%)}
@media (prefers-reduced-motion:reduce){.nightstars g{animation:none}}

/* ===== header ===== */
#top{position:relative;z-index:2;display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:6px 12px;
  margin:8px 10px 0;padding:6px 12px;border-radius:14px;background:rgba(16,30,50,.55);border:1px solid rgba(255,220,170,.16);box-shadow:0 4px 18px rgba(20,8,30,.25)}
.brand{display:flex;align-items:baseline;gap:8px;white-space:nowrap}
.brand h1{font-size:22px;letter-spacing:3px;color:#ffe2a6;text-shadow:0 2px 0 rgba(120,40,20,.5)}
.brand .en{font-size:11px;letter-spacing:1px;opacity:.7}
.discsel{display:flex;align-items:center;gap:4px}
.discsel .lbl{font-size:12px;opacity:.75;margin-right:2px}
.discsel button{width:32px;height:32px;border-radius:9px;border:1px solid rgba(255,225,180,.25);background:rgba(255,240,215,.1);font-weight:700;font-size:15px}
.discsel button.on{background:linear-gradient(180deg,#f8cf5c,#e49a1e);color:#4a1d06;border-color:#ffe29a;box-shadow:0 2px 8px rgba(240,170,40,.45)}
.discsel button.max{position:relative}
.discsel button.max::after{content:"";position:absolute;top:-3px;right:-3px;width:8px;height:8px;border-radius:50%;background:#e0352f;border:1px solid #ffd27a}
.stats{display:flex;align-items:center;gap:12px}
.stat{display:flex;flex-direction:column;align-items:center;line-height:1.05;min-width:34px}
.stat b{font-size:18px;font-variant-numeric:tabular-nums;color:#fff6e6}
.stat small{font-size:10px;opacity:.7;margin-top:2px;white-space:nowrap}
.stars b{font-size:15px;letter-spacing:1px}
.stars i,.bigstars i{font-style:normal;color:rgba(255,240,220,.22)}
.stars i.on,.bigstars i.on{color:#ffcf4a;text-shadow:0 0 6px rgba(255,190,60,.6)}

/* ===== stage ===== */
#stage{position:relative;z-index:1;flex:1 1 auto;min-height:0;touch-action:none}
#cv{position:absolute;top:0;left:0;width:100%;height:100%;display:block;touch-action:none;cursor:pointer}
#toast{position:absolute;left:50%;top:10px;transform:translate(-50%,-8px);max-width:92%;padding:7px 14px;border-radius:999px;background:rgba(10,20,36,.86);border:1px solid rgba(255,214,150,.3);
  font-size:13px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;opacity:0;pointer-events:none;transition:opacity .2s,transform .2s;z-index:5}
#toast.show{opacity:1;transform:translate(-50%,0)}
#toast.bad{border-color:rgba(255,110,90,.6);color:#ffd9cf}

/* ===== bottom bar ===== */
#bar{position:relative;z-index:2;display:flex;justify-content:center;gap:6px;padding:6px 8px;padding-bottom:calc(6px + var(--sa-b));
  background:linear-gradient(180deg,#4a2c22 0,#22140f 100%);box-shadow:inset 0 6px 10px -6px rgba(0,0,0,.5)}
#bar button{flex:0 1 64px;min-width:0;height:48px;border-radius:12px;border:1px solid rgba(255,225,180,.22);background:rgba(16,30,52,.62);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1px}
#bar button .ic{font-size:18px;line-height:1.1;font-weight:700}
#bar button .lb{font-size:11px;opacity:.85;white-space:nowrap}
#bar button:active{transform:translateY(1px)}
#bar button.on{background:linear-gradient(180deg,#f8cf5c,#e49a1e);color:#4a1d06;border-color:#ffe29a}
#bar button:disabled{opacity:.4}
@media (hover:hover){#bar button:hover:not(:disabled),.discsel button:hover{border-color:rgba(255,225,160,.6)}}

/* ===== overlays ===== */
.overlay{position:absolute;top:0;left:0;width:100%;height:100%;z-index:20;display:none;align-items:center;justify-content:center;padding:16px;background:rgba(24,10,32,.45);touch-action:pan-y}
.overlay.show{display:flex}
.card{max-width:440px;width:100%;max-height:100%;overflow:auto;-webkit-overflow-scrolling:touch;touch-action:pan-y;padding:18px 20px;border-radius:18px;background:linear-gradient(180deg,rgba(30,48,78,.97),rgba(18,32,56,.97));border:1px solid rgba(255,214,150,.3);box-shadow:0 14px 40px rgba(10,0,20,.5);text-align:center}
.card h2{font-size:22px;color:#ffe2a6;margin-bottom:8px;letter-spacing:2px}
.card h3{font-size:15px;color:#ffd27a;margin:12px 0 6px}
.card p{font-size:14px;line-height:1.6;margin:4px 0}
.card .muted{opacity:.72;font-size:12.5px}
.card .gold{color:#ffd27a;font-weight:700}
.help{text-align:left}.help h2,.help .row{text-align:center}
.help ul{padding-left:18px}.help li{font-size:13.5px;line-height:1.6;margin:3px 0}
.row{display:flex;gap:10px;justify-content:center;margin-top:12px;flex-wrap:wrap}
.btn{min-height:40px;padding:0 18px;border-radius:999px;border:1px solid rgba(255,225,180,.3);background:rgba(255,240,215,.12);font-weight:700;font-size:15px;display:inline-flex;align-items:center;gap:6px}
.btn.gold{background:linear-gradient(180deg,#f8cf5c,#e49a1e);color:#4a1d06;border-color:#ffe29a}
.bigstars{font-size:40px;letter-spacing:6px;margin:2px 0 6px}
.bigstars i{display:inline-block;transform:scale(.6);transition:transform .35s cubic-bezier(.3,1.6,.5,1)}
.bigstars i.on{transform:scale(1)}
#winOv{background:rgba(24,10,32,.25)}

/* ===== too-small bar ===== */
#tinyBar{position:absolute;left:0;right:0;top:0;z-index:40;display:none;align-items:center;justify-content:center;gap:10px;padding:5px 8px;background:rgba(10,18,36,.9);font-size:13px}
#tinyBar .btn{min-height:30px;font-size:13px;padding:0 12px}
#app.tiny #tinyBar{display:flex}

/* ===== layout variants (classes set by JS) ===== */
#app.compact #top{margin:5px 8px 0;padding:4px 10px}
#app.compact .brand h1{font-size:18px}
#app.compact .brand .en{display:none}
#app.compact .stat b{font-size:16px}
#app.compact #bar button{height:42px}
#app.narrow .brand .en{display:none}
#app.narrow .discsel button{width:30px;height:30px;font-size:14px}
#app.narrow .stats{gap:8px}
#app.narrow #top{justify-content:space-around}
#app.short #bar button .lb{display:none}
#app.short #bar button{height:38px}
#app.short .stat small{font-size:9px}
#app.short .discsel .lbl{display:none}

/* landscape phones: side panels */
#app.side{flex-direction:row;padding-bottom:var(--sa-b)}
#app.side #top{flex-direction:column;flex-wrap:nowrap;justify-content:center;align-items:stretch;width:168px;flex:0 0 168px;margin:6px 0 6px 6px;padding:8px;gap:8px}
#app.side .brand{justify-content:center}
#app.side .brand .en{display:none}
#app.side .discsel{flex-wrap:wrap;justify-content:center}
#app.side .discsel .lbl{width:100%;text-align:center}
#app.side .discsel button{width:31px;height:30px}
#app.side .stats{flex-wrap:wrap;justify-content:center;gap:6px 10px}
#app.side #bar{flex-direction:column;justify-content:center;width:60px;flex:0 0 60px;padding:6px;gap:4px;background:none}
#app.side #bar button{flex:0 1 38px;height:auto;min-height:30px;width:48px}
#app.side #bar button .lb{display:none}
#app.side #bar button .ic{font-size:16px}
#app.side.short .brand h1{font-size:17px}

/* css pseudo-fullscreen (no Fullscreen API at top level) */
#app.cssfs #top .brand{display:none}
#speedIc{white-space:nowrap;letter-spacing:-.03em}#bar button #speedIc.long{font-size:15px}#app.side #bar button #speedIc.long{font-size:14px}
#app .moon{right:3.5%;top:11%}#app.narrow .moon{top:94px;right:5%;width:34px;height:34px;box-shadow:inset -9px 5px 0 0 #e9e5d0}#app.side .moon{right:84px;top:5%;width:34px;height:34px;box-shadow:inset -9px 5px 0 0 #e9e5d0}

/* help: two columns on wide screens so it fits without scrolling; single column + scroll on small phones */
.help .cols{display:block}
@media (min-width:720px){
  .card.help{max-width:880px;padding:18px 26px}
  .help .cols{display:grid;grid-template-columns:1.2fr 1fr;gap:6px 28px;align-items:start}
  .help .col h3:first-child{margin-top:4px}
}
@media (min-width:720px) and (max-height:620px){
  .card.help{padding:12px 22px}.card.help h2{margin-bottom:4px}
  .help li{line-height:1.5;margin:2px 0}.help p{line-height:1.5}
}
