/* Layout and shared components. Fonts: Noto Sans TC / Noto Serif TC from Google Fonts with system fallbacks (spec 8.2.1).
 * Mobile first (spec 8.5): base styles are for phones; breakpoints add layout upward.
 * Breakpoints: tablet >= 600px, desktop >= 1024px, wide >= 1440px. */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[tabindex="-1"]:focus { outline: none; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-sans); font-size: 16px; line-height: 1.6; overflow-wrap: anywhere; }
a { color: var(--primary); }
a:focus-visible, button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

.site-head { border-bottom: 1px solid var(--line); background: var(--bg-panel); }
.site-head .wrap { display: flex; align-items: center; gap: 12px; padding-block: 10px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 10px; min-height: 44px; text-decoration: none; color: var(--text); }
.logo-text { font-family: var(--font-display); font-weight: 900; font-size: 1.15rem; letter-spacing: .04em; }
.logo-text em { font-style: normal; color: var(--breaking); }
[data-theme="dark"] .logo-text em { color: var(--gold); }
.live { background: var(--breaking); color: var(--on-breaking); font-weight: 900; font-size: .72rem; letter-spacing: .12em; padding: 2px 8px; border-radius: 3px; }
.head-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.head-nav { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; font-size: .9rem; font-weight: 700; color: var(--text); text-decoration: none; }
.head-link { display: none; align-items: center; min-height: 44px; font-size: .85rem; color: var(--text-muted); text-decoration: none; }
.theme-toggle { font: inherit; font-size: .8rem; cursor: pointer; color: var(--text); background: transparent; border: 1px solid var(--line); border-radius: 999px; min-height: 44px; padding: 4px 14px; }

.studio { position: relative; overflow: hidden; padding-block: 28px; }
.studio::before { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(60% 50% at 25% -10%, var(--glow-1), transparent 70%), radial-gradient(40% 40% at 85% -10%, var(--glow-2), transparent 70%),
    repeating-linear-gradient(90deg, var(--wall) 0 120px, transparent 120px 124px); }
.studio-grid { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; align-items: start; }
.eyebrow { margin: 0; color: var(--text-muted); font-size: .85rem; letter-spacing: .08em; }
.intro h1 { font-family: var(--font-display); font-weight: 900; font-size: clamp(2.2rem, 6vw, 3.6rem); line-height: 1.15; margin: 8px 0 16px; text-wrap: balance; }
.lead { font-size: clamp(1rem, 2.4vw, 1.2rem); max-width: 34em; margin: 0 0 20px; }
.start { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.start-btn { display: inline-flex; align-items: center; min-height: 52px; padding: 10px 28px; background: var(--selected-bg, var(--gold)); color: var(--on-gold); font-weight: 900; font-size: 1.1rem; text-decoration: none; border-radius: var(--radius); }

.ladder { list-style: none; margin: 0; padding: 8px; background: var(--bg-panel); border: 1px solid var(--line); border-radius: 10px; font-family: var(--font-num); font-variant-numeric: tabular-nums;
  /* phone and tablet: a horizontal strip, lowest prize first, scrolling inside itself */
  display: flex; gap: 4px; overflow-x: auto; font-size: .75rem; }
.ladder li { flex: none; display: flex; flex-direction: column; align-items: center; gap: 0; padding: 4px 8px; border-radius: 3px; color: var(--text-muted); overflow-wrap: normal; }
.ladder li.safe { background: var(--breaking); color: var(--on-breaking); }
.ladder li.top { color: var(--text); font-weight: 700; }
.ladder li.safe span:first-child::after { content: " 保底"; font-family: var(--font-sans); font-size: .7rem; font-weight: 700; }

/* stats (/stats): stat tiles + single-series horizontal bars; widths come from .w0–.w100 (CSP forbids inline styles) */
.stats-page { display: grid; gap: 20px; padding-block: 28px 16px; max-width: 860px; }
.stats-page h1 { margin: 4px 0 8px; font-family: var(--font-display); font-weight: var(--display-weight); font-size: clamp(1.8rem, 5vw, 2.4rem); }
.stats-intro, .stats-note, .stats-foot { margin: 0; color: var(--text-muted); }
.stats-empty { margin: 0; padding: 16px; background: var(--bg-panel); border: 1px dashed var(--line); border-radius: 12px; }
.stat-tiles { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.stat-tile { display: grid; gap: 2px; padding: 16px; background: var(--bg-panel); border: 1px solid var(--line); border-radius: 12px; }
.stat-num { font-family: var(--font-num); font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--text-muted); font-size: .9rem; }
.stats-block { display: grid; gap: 10px; padding: 16px 18px; background: var(--bg-panel); border: 1px solid var(--line); border-radius: 12px; }
.stats-block h2 { margin: 0; font-size: 1.15rem; }
.hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.hbar { display: grid; grid-template-columns: 8.5em minmax(0, 1fr) 5.5em; gap: 10px; align-items: center; }
.hbar-label { font-size: .92rem; }
.hbar-track { height: 12px; background: var(--line); border-radius: 4px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; background: var(--primary); border-radius: 0 4px 4px 0; }
.hbar-value { font-family: var(--font-num); font-variant-numeric: tabular-nums; text-align: right; }
.hbar-value small { display: block; font-size: .72rem; color: var(--text-muted); }
.w0 { width: 0%; } .w5 { width: 5%; } .w10 { width: 10%; } .w15 { width: 15%; } .w20 { width: 20%; } .w25 { width: 25%; } .w30 { width: 30%; } .w35 { width: 35%; } .w40 { width: 40%; } .w45 { width: 45%; } .w50 { width: 50%; } .w55 { width: 55%; } .w60 { width: 60%; } .w65 { width: 65%; } .w70 { width: 70%; } .w75 { width: 75%; } .w80 { width: 80%; } .w85 { width: 85%; } .w90 { width: 90%; } .w95 { width: 95%; } .w100 { width: 100%; }
@media (min-width: 600px) { .stat-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* about */
.about { display: grid; gap: 16px; padding-block: 28px 16px; max-width: 860px; }
.about-card { background: var(--bg-panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; }
.about-card h1, .about-card h2 { margin: 0 0 10px; font-family: var(--font-display); font-weight: var(--display-weight); }
.about-card h1 { font-size: clamp(1.6rem, 5vw, 2.2rem); }
.about-card h2 { font-size: 1.3rem; }
.about-card h3 { margin: 16px 0 6px; font-size: 1.02rem; }
.about-card p, .about-card ul { margin: 0 0 8px; }
.about-card ul { padding-left: 1.2em; display: grid; gap: 6px; }
.about-card li { color: var(--text); }
.credits li { font-size: .92rem; }
.about-btn { display: inline-flex; align-items: center; min-height: 48px; padding: 8px 20px; border-radius: var(--radius); background: var(--selected-bg, var(--gold)); color: var(--on-selected, var(--on-gold)); font-weight: 700; text-decoration: none; }

/* home: how to play */
.howto { padding-block: 8px 40px; }
.howto h2 { margin: 0 0 16px; font-family: var(--font-display); font-weight: var(--display-weight); font-size: clamp(1.4rem, 4vw, 1.8rem); }
.howto-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; counter-reset: step; }
.howto-steps li { counter-increment: step; position: relative; padding: 16px 16px 16px 60px; background: var(--bg-panel); border: 1px solid var(--line); border-radius: 12px; }
.howto-steps li::before { content: counter(step); position: absolute; left: 16px; top: 16px; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--selected-bg, var(--gold)); color: var(--on-selected, var(--on-gold)); font-family: var(--font-num); font-weight: 700; }
.howto-steps h3 { margin: 0 0 4px; font-size: 1.05rem; }
.howto-steps p { margin: 0; color: var(--text-muted); }
@media (min-width: 600px) { .howto-steps li:nth-child(5) { grid-column: span 2; } }
.howto-note { margin: 16px 0 0; font-size: .9rem; color: var(--text-muted); }
.error-page { padding-block: 48px; }
.error-page h1 { font-family: var(--font-display); }

.site-foot { border-top: 1px solid var(--line); margin-top: 48px; font-size: .85rem; color: var(--text-muted); }
.site-foot .wrap { display: grid; gap: 4px; padding-block: 20px; }
.site-foot .ver { font-family: var(--font-num); font-size: .75rem; }

@media (min-width: 600px) {
  .howto-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .studio { padding-block: 40px; }
  .head-link { display: inline-flex; }
}
@media (min-width: 1024px) {
  .studio { padding-block: 56px; }
  /* first sentence on one line: the font shrinks with the column (about 45 characters wide) */
  .lead { max-width: none; font-size: min(1.2rem, calc((min(100vw, var(--wrap)) - 340px) / 45)); }
  .lead-1 { white-space: nowrap; }
  .studio-grid { grid-template-columns: minmax(0, 1fr) 260px; gap: 40px; }
  .howto-steps { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  /* desktop: the headline ranking column, top prize first */
  .ladder { flex-direction: column-reverse; gap: 2px; overflow: visible; padding: 10px; font-size: .85rem; }
  .ladder li { flex-direction: row; justify-content: space-between; padding: 3px 8px; }
}
@media (min-width: 1440px) {
  :root { --wrap: 1280px; }
  body { font-size: 18px; }
  .studio-grid { grid-template-columns: minmax(0, 1fr) 300px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
