@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Fraunces:opsz,wght@9..144,500;9..144,600&family=Noto+Sans+SC:wght@400;500;600;700&display=swap');

:root {
  --paper: #f4f1e8;
  --paper-deep: #e9e4d8;
  --ink: #1d1d1b;
  --muted: #77736b;
  --line: #d8d2c5;
  --coral: #ee684e;
  --coral-dark: #d65039;
  --night: #14181c;
  --night-soft: #283038;
  --cream: #fffbf0;
  --display: 'Fraunces', 'Songti SC', serif;
  --body: 'Noto Sans SC', 'Microsoft YaHei', sans-serif;
  --mono: 'DM Mono', 'Courier New', monospace;
  --shadow: 0 18px 42px rgba(44, 37, 29, .08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font: 400 14px/1.65 var(--body);
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: .08;
  background-image: repeating-linear-gradient(0deg, rgba(29, 29, 27, .22) 0, rgba(29, 29, 27, .22) 1px, transparent 1px, transparent 4px);
}
button, input { font: inherit; }
.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; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
a { color: inherit; }
.skip-link { position: fixed; left: 12px; top: -80px; z-index: 10; background: var(--ink); color: var(--cream); padding: 10px 16px; border-radius: 4px; }
.skip-link:focus { top: 12px; }
:focus-visible { outline: 3px solid var(--coral); outline-offset: 3px; }

.topbar {
  width: min(1180px, calc(100% - 64px));
  height: 80px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 17px; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid var(--ink); border-radius: 50%; font: 500 14px/1 var(--display); }
.topbar-meta { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 11px; letter-spacing: .04em; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--coral); box-shadow: 0 0 0 4px rgba(238, 104, 78, .11); }
.divider { width: 1px; height: 13px; margin: 0 4px; background: var(--line); }
.profile-button { display: flex; align-items: center; gap: 9px; max-width: 180px; border: 0; padding: 3px; color: var(--ink); background: transparent; font-size: 12px; }
.profile-button #profile-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { display: grid; place-items: center; flex: 0 0 29px; width: 29px; height: 29px; border-radius: 50%; color: var(--cream); background: var(--ink); font-size: 12px; }
.chevron { color: var(--muted); font-size: 15px; line-height: 1; }

.shell { width: min(1180px, calc(100% - 64px)); margin: 0 auto; padding: 0 0 28px; }
.welcome-row { min-height: 204px; display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; padding: 48px 0 33px; }
.eyebrow { display: flex; align-items: center; gap: 9px; margin: 0 0 12px; color: var(--muted); font: 500 10px/1.3 var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.eyebrow-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ink); }
.eyebrow-dot.coral { background: var(--coral); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font: 500 clamp(58px, 8vw, 102px)/.9 var(--display); letter-spacing: -.05em; }
.title-period { color: var(--coral); font-style: italic; }
.welcome-copy { max-width: 255px; margin: 0 0 9px; color: var(--muted); font-size: 13px; line-height: 1.9; text-align: right; }

.dashboard { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(330px, .88fr); min-height: 450px; border: 1px solid var(--line); background: var(--cream); box-shadow: var(--shadow); }
.checkin-panel { position: relative; overflow: hidden; padding: 30px 36px 26px; }
.panel-topline { display: flex; align-items: center; justify-content: space-between; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.section-label { font: 500 10px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; }
.date-chip { color: var(--muted); font: 400 10px/1 var(--mono); }
.status-block { display: flex; align-items: center; gap: 30px; min-height: 170px; padding: 20px 0 8px; }
.status-orbit { position: relative; display: grid; place-items: center; flex: 0 0 116px; height: 116px; }
.orbit-ring { position: absolute; inset: 5px; border: 1px solid var(--line); border-radius: 50%; }
.orbit-ring::after { content: ''; position: absolute; inset: 13px; border: 1px dashed rgba(29, 29, 27, .16); border-radius: 50%; }
.orbit-moon { position: relative; width: 51px; height: 51px; border-radius: 50%; background: var(--coral); box-shadow: inset -13px -7px 0 var(--ink), 0 0 0 11px rgba(238, 104, 78, .14); transform: rotate(-20deg); }
.orbit-star { position: absolute; z-index: 1; color: var(--ink); }
.star-one { top: 7px; right: 13px; font-size: 17px; }
.star-two { bottom: 17px; left: 16px; font-size: 24px; color: var(--coral); }
.status-kicker { margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.status-copy h2 { margin-bottom: 5px; font: 500 27px/1.2 var(--display); letter-spacing: -.02em; }
.status-copy > p:last-child { margin: 0; color: var(--muted); font-size: 12px; }
.timer-row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid rgba(238, 104, 78, .3); background: rgba(238, 104, 78, .06); }
.timer-label { color: var(--muted); font-size: 11px; }
.timer-row strong { font: 500 17px/1 var(--mono); letter-spacing: .02em; }
.timer-pulse { width: 5px; height: 5px; border-radius: 50%; background: var(--coral); animation: breathe 1.8s ease-in-out infinite; }
.action-row { display: flex; align-items: stretch; gap: 10px; margin-top: 20px; }
.primary-button, .wake-button, .auto-button { display: inline-flex; align-items: center; justify-content: center; gap: 11px; min-height: 47px; border: 1px solid var(--ink); border-radius: 2px; transition: transform .18s ease, background .18s ease, color .18s ease; }
.primary-button { flex: 1; padding: 0 18px; color: var(--cream); background: var(--ink); font-weight: 600; }
.primary-button:hover:not(:disabled) { background: var(--coral-dark); border-color: var(--coral-dark); transform: translateY(-2px); }
.primary-button:disabled, .wake-button:disabled { opacity: .4; }
.button-icon { color: var(--coral); font-size: 19px; line-height: 1; }
.button-arrow { margin-left: auto; font-size: 18px; }
.wake-button { min-width: 100px; padding: 0 14px; color: var(--ink); background: transparent; font-size: 12px; }
.wake-button:hover:not(:disabled) { background: var(--paper-deep); transform: translateY(-2px); }
.panel-footnote { margin: 14px 0 0; color: var(--muted); font-size: 10px; }
.panel-scribble { position: absolute; right: 21px; bottom: 22px; color: rgba(29, 29, 27, .22); font: 500 15px/.92 var(--display); text-align: right; transform: rotate(-7deg); }

.night-panel { position: relative; min-height: 450px; overflow: hidden; color: var(--cream); background: var(--night); }
.night-image { position: absolute; inset: 0; background: url('assets/night-bedroom.jpg') center/cover no-repeat; filter: saturate(.48) brightness(.4) contrast(1.12); transform: scale(1.03); }
.night-overlay { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(10, 15, 19, .18), rgba(10, 15, 19, .84)); }
.night-caption { position: absolute; top: 25px; left: 27px; right: 27px; display: flex; align-items: center; gap: 10px; color: rgba(255, 251, 240, .65); font: 400 8px/1 var(--mono); letter-spacing: .12em; }
.caption-line { width: 23px; height: 1px; background: var(--coral); }
.night-message { position: absolute; left: 32px; bottom: 70px; }
.tiny-label { color: rgba(255, 251, 240, .6); font: 400 8px/1 var(--mono); letter-spacing: .12em; }
.night-message p { margin: 13px 0 9px; font: 500 clamp(34px, 4vw, 54px)/.95 var(--display); letter-spacing: -.04em; }
.night-message-foot { color: rgba(255, 251, 240, .55); font-size: 11px; }
.night-time { position: absolute; right: 27px; bottom: 27px; color: rgba(255, 251, 240, .62); font: 400 10px/1 var(--mono); }

.leaderboard-section { margin-top: 62px; }
.leaderboard-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.leaderboard-heading .eyebrow { margin-bottom: 7px; }
.leaderboard-heading h2 { margin: 0; font: 500 34px/1.1 var(--display); letter-spacing: -.03em; }
.period-control { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--line); }
.period-button { min-width: 55px; border: 0; padding: 7px 12px; color: var(--muted); background: transparent; font-size: 11px; }
.period-button.is-selected { color: var(--ink); background: var(--paper-deep); font-weight: 600; }
.leaderboard-layout { display: grid; grid-template-columns: minmax(0, 1fr) 286px; gap: 16px; align-items: start; }
.rank-main { min-width: 0; border: 1px solid var(--line); background: var(--cream); }
.rank-tabs { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--line); }
.rank-tab { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 52px; border: 0; border-right: 1px solid var(--line); color: var(--muted); background: transparent; font-size: 12px; }
.rank-tab:last-child { border-right: 0; }
.rank-tab.is-selected { color: var(--ink); background: var(--paper-deep); font-weight: 600; }
.rank-tab.is-selected::after { content: ''; position: absolute; right: 17%; bottom: -1px; left: 17%; height: 2px; background: var(--coral); }
.tab-symbol { color: var(--coral); font-size: 16px; }
.rank-list { min-height: 285px; padding: 4px 0; }
.rank-row { display: grid; grid-template-columns: 45px minmax(0, 1fr) 100px 95px; align-items: center; gap: 12px; min-height: 61px; padding: 0 20px; border-bottom: 1px solid rgba(216, 210, 197, .58); animation: rise .45s both; }
.rank-row:last-child { border-bottom: 0; }
.rank-row.is-podium { background: rgba(238, 104, 78, .035); }
.rank-number { color: var(--muted); font: 400 12px/1 var(--mono); }
.rank-row.is-podium .rank-number { color: var(--coral-dark); font-weight: 500; }
.rank-person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.rank-avatar { display: grid; place-items: center; flex: 0 0 28px; width: 28px; height: 28px; border-radius: 50%; color: var(--ink); background: var(--paper-deep); font: 500 11px/1 var(--display); }
.rank-person strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 600; }
.rank-detail { color: var(--muted); font: 400 11px/1.3 var(--mono); }
.rank-value { color: var(--ink); font: 500 12px/1.3 var(--mono); text-align: right; }
.loading-state, .empty-state { display: grid; place-items: center; min-height: 270px; padding: 30px; color: var(--muted); font-size: 12px; text-align: center; }
.empty-state strong { display: block; margin-bottom: 4px; color: var(--ink); font: 500 20px/1.2 var(--display); }
.auto-card { position: relative; overflow: hidden; padding: 23px 22px 20px; border: 1px solid var(--ink); background: var(--coral); color: var(--cream); }
.auto-card::after { content: '☾'; position: absolute; right: -11px; bottom: -37px; color: rgba(255, 251, 240, .14); font: 500 150px/1 var(--display); pointer-events: none; }
.auto-card-heading { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.auto-icon { display: grid; place-items: center; width: 28px; height: 28px; border: 1px solid rgba(255, 251, 240, .45); border-radius: 50%; font-size: 14px; }
.auto-status { color: rgba(255, 251, 240, .75); font: 400 9px/1 var(--mono); letter-spacing: .04em; }
.auto-card h3 { position: relative; z-index: 1; margin: 23px 0 7px; font: 500 25px/1.1 var(--display); letter-spacing: -.03em; }
.auto-card > p { position: relative; z-index: 1; margin-bottom: 19px; color: rgba(255, 251, 240, .8); font-size: 11px; line-height: 1.8; }
.auto-controls { position: relative; z-index: 1; margin-bottom: 14px; }
.auto-controls label { display: block; margin-bottom: 6px; color: rgba(255, 251, 240, .7); font-size: 10px; }
.auto-controls input { width: 100%; height: 38px; border: 1px solid rgba(255, 251, 240, .5); border-radius: 0; padding: 0 10px; color: var(--cream); background: rgba(20, 24, 28, .16); font: 500 14px/1 var(--mono); color-scheme: dark; }
.auto-controls input:disabled { opacity: .65; }
.toggle-row { position: relative; z-index: 1; display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-size: 11px; cursor: pointer; }
.toggle-row input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.toggle-track { position: relative; display: inline-block; width: 31px; height: 17px; flex: 0 0 31px; border: 1px solid rgba(255, 251, 240, .6); border-radius: 20px; }
.toggle-track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 9px; height: 9px; border-radius: 50%; background: var(--cream); transition: transform .18s ease; }
.toggle-row input:checked + .toggle-track { background: var(--ink); border-color: var(--ink); }
.toggle-row input:checked + .toggle-track::after { transform: translateX(14px); background: var(--coral); }
.auto-button { position: relative; z-index: 1; width: 100%; min-height: 40px; border-color: var(--cream); color: var(--ink); background: var(--cream); font-size: 12px; font-weight: 600; }
.auto-button strong { margin-left: auto; font: 500 18px/1 var(--display); }
.auto-button:hover:not(:disabled) { background: var(--ink); color: var(--cream); transform: translateY(-2px); }
.auto-button:disabled { opacity: .55; }
.payment-note { margin: 11px 0 0 !important; color: rgba(255, 251, 240, .74) !important; font: 400 9px/1.3 var(--mono) !important; letter-spacing: .02em; }
.board-note { display: flex; gap: 7px; align-items: center; margin: 15px 0 0; color: var(--muted); font-size: 10px; }
.note-mark { display: grid; place-items: center; width: 14px; height: 14px; flex: 0 0 14px; border: 1px solid var(--line); border-radius: 50%; font: 400 9px/1 var(--display); }
.site-footer { display: flex; justify-content: space-between; gap: 20px; margin-top: 70px; padding-top: 17px; border-top: 1px solid var(--line); color: var(--muted); font: 400 10px/1.4 var(--mono); }
.footer-mark { color: var(--coral); }

.name-dialog { width: min(420px, calc(100% - 32px)); border: 1px solid var(--ink); border-radius: 0; padding: 32px; color: var(--ink); background: var(--cream); box-shadow: 12px 12px 0 rgba(29, 29, 27, .15); }
.name-dialog::backdrop { background: rgba(20, 24, 28, .58); backdrop-filter: blur(3px); }
.name-dialog h2 { margin: 0 0 9px; font: 500 32px/1.1 var(--display); letter-spacing: -.03em; }
.dialog-copy { margin-bottom: 23px; color: var(--muted); font-size: 12px; }
.dialog-close-form { position: absolute; top: 12px; right: 12px; margin: 0; }
.dialog-close { width: 28px; height: 28px; border: 1px solid transparent; color: var(--muted); background: transparent; font-size: 22px; line-height: 1; }
.dialog-close:hover { border-color: var(--line); color: var(--ink); }
.name-dialog label { display: block; margin-bottom: 7px; font-size: 11px; font-weight: 600; }
.name-dialog input { width: 100%; height: 48px; border: 1px solid var(--line); border-radius: 0; padding: 0 13px; color: var(--ink); background: var(--paper); }
.name-dialog input::placeholder { color: #a5a097; }
.field-error { min-height: 22px; margin: 5px 0 10px; color: var(--coral-dark); font-size: 11px; }
.dialog-submit { width: 100%; }
.payment-dialog { width: min(390px, calc(100% - 32px)); border: 1px solid var(--ink); border-radius: 0; padding: 30px; color: var(--ink); background: var(--cream); box-shadow: 12px 12px 0 rgba(29, 29, 27, .15); }
.payment-dialog::backdrop { background: rgba(20, 24, 28, .58); backdrop-filter: blur(3px); }
.payment-dialog h2 { margin-bottom: 7px; font: 500 29px/1.1 var(--display); }
.payment-dialog > p { color: var(--muted); font-size: 12px; }
.pay-options { display: grid; gap: 9px; margin: 22px 0 12px; }
.pay-option { display: flex; align-items: center; gap: 11px; min-height: 58px; border: 1px solid var(--line); padding: 0 14px; background: var(--paper); text-align: left; transition: border-color .18s, background .18s; }
.pay-option:hover { border-color: var(--ink); background: var(--paper-deep); }
.pay-option-logo { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 5px; color: #fff; font-size: 15px; font-weight: 700; }
.pay-option-logo.wx { background: #1aad19; }
.pay-option-logo.ali { background: #1677ff; }
.pay-option strong { font-size: 13px; }
.pay-option small { display: block; color: var(--muted); font-size: 10px; }
.pay-option .button-arrow { margin-left: auto; color: var(--muted); }
.payment-fineprint { margin: 0 !important; font-size: 10px !important; line-height: 1.7; }
.toast { position: fixed; left: 50%; bottom: 25px; z-index: 20; max-width: min(350px, calc(100% - 32px)); padding: 10px 16px; border: 1px solid var(--ink); color: var(--cream); background: var(--ink); box-shadow: 6px 6px 0 rgba(238, 104, 78, .28); font-size: 12px; opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: opacity .2s, transform .2s; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes breathe { 0%, 100% { opacity: .4; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.15); } }

@media (max-width: 820px) {
  .topbar, .shell { width: min(100% - 36px, 620px); }
  .topbar { height: 66px; }
  .topbar-meta { display: none; }
  .welcome-row { min-height: auto; align-items: flex-start; flex-direction: column; gap: 20px; padding: 43px 0 27px; }
  h1 { font-size: clamp(64px, 18vw, 92px); }
  .welcome-copy { max-width: none; margin: 0; text-align: left; }
  .dashboard { grid-template-columns: 1fr; }
  .checkin-panel { min-height: 330px; padding: 22px 22px 20px; }
  .status-block { gap: 18px; min-height: 143px; }
  .status-orbit { flex-basis: 94px; height: 94px; }
  .orbit-moon { width: 43px; height: 43px; }
  .status-copy h2 { font-size: 23px; }
  .night-panel { min-height: 280px; }
  .night-message { left: 24px; bottom: 45px; }
  .night-message p { font-size: 42px; }
  .night-caption { top: 20px; left: 22px; right: 22px; }
  .night-time { right: 22px; bottom: 20px; }
  .leaderboard-section { margin-top: 45px; }
  .leaderboard-heading { align-items: flex-start; flex-direction: column; gap: 16px; }
  .leaderboard-layout { grid-template-columns: 1fr; }
  .auto-card { margin-top: 1px; }
  .site-footer { margin-top: 50px; }
}

@media (max-width: 480px) {
  .topbar, .shell { width: calc(100% - 28px); }
  .brand { font-size: 15px; }
  .brand-mark { width: 27px; height: 27px; font-size: 12px; }
  .profile-button { max-width: 120px; font-size: 11px; }
  .welcome-row { padding-top: 35px; }
  .checkin-panel { padding: 18px 16px 17px; }
  .status-block { gap: 12px; }
  .status-orbit { flex-basis: 79px; height: 79px; }
  .orbit-ring { inset: 2px; }
  .orbit-ring::after { inset: 9px; }
  .orbit-moon { width: 37px; height: 37px; }
  .status-kicker { font-size: 10px; }
  .status-copy h2 { font-size: 20px; }
  .status-copy > p:last-child { font-size: 10px; }
  .action-row { gap: 7px; }
  .primary-button { padding: 0 12px; font-size: 12px; }
  .wake-button { min-width: 85px; padding: 0 9px; font-size: 11px; }
  .button-icon { font-size: 16px; }
  .rank-row { grid-template-columns: 29px minmax(0, 1fr) 77px; gap: 8px; padding: 0 12px; min-height: 59px; }
  .rank-detail { display: none; }
  .rank-value { font-size: 10px; }
  .rank-tab { gap: 4px; min-height: 49px; font-size: 10px; }
  .tab-symbol { font-size: 13px; }
  .leaderboard-heading h2 { font-size: 29px; }
  .site-footer { flex-direction: column; gap: 6px; }
  .name-dialog, .payment-dialog { padding: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
