:root, :root[data-theme="bean"] {
  color-scheme: light;
  --bg: #edf5ee; --surface: #fbfdf9; --surface-secondary: #e4efe6;
  --text-primary: #173e36; --text-secondary: #647b70; --primary: #477b68;
  --primary-hover: #396b59; --on-primary: #fff; --border: #ccdbd0;
  --shadow-color: rgba(39, 79, 63, .10); --shadow: 0 12px 32px var(--shadow-color);
  --grid-bg: #fbfdf9; --grid-text: #173f39; --grid-shadow: rgba(38, 73, 63, .13);
  --grid-highlight: rgba(255,255,255,.72); --hero-from: #e4f1e6; --hero-to: #fffaf2;
  --accent-blue: #dbecef; --accent-apricot: #f3ddc8; --accent-gold: #f3e3a0;
  --success-bg: #dcebdd; --wrong-bg: #f7e8e1; --nav-bg: rgba(251,253,249,.94);
  --danger: #a96159; --radius: 24px; --safe-bottom: env(safe-area-inset-bottom, 0px);
}
:root[data-theme="morning"] {
  --bg:#fbfaf6; --surface:#fffefa; --surface-secondary:#f3f5f2; --text-primary:#183c43;
  --text-secondary:#687d82; --primary:#417565; --primary-hover:#315f52; --border:#d8e0dc;
  --shadow-color:rgba(38,73,70,.09); --grid-bg:#fff; --grid-text:#173e45; --grid-shadow:rgba(38,73,70,.12);
  --grid-highlight:rgba(255,255,255,.9); --hero-from:#f1f8f2; --hero-to:#fffdf7;
  --accent-blue:#dceef4; --accent-apricot:#f6dcc6; --accent-gold:#f7e8a7; --success-bg:#e6f2e8;
  --wrong-bg:#fff3ee; --nav-bg:rgba(255,255,252,.94);
}
:root[data-theme="mist"] {
  --bg:#eaf2f5; --surface:#f8fcfd; --surface-secondary:#dfecef; --text-primary:#203b4a;
  --text-secondary:#687d88; --primary:#477681; --primary-hover:#38646e; --border:#c9dbe0;
  --shadow-color:rgba(42,75,91,.10); --grid-bg:#f9fdfe; --grid-text:#1d4051; --grid-shadow:rgba(37,72,88,.13);
  --grid-highlight:rgba(255,255,255,.76); --hero-from:#dfeef2; --hero-to:#fdfbf4;
  --accent-blue:#cfe5eb; --accent-apricot:#f2dfce; --accent-gold:#eee4aa; --success-bg:#dcebed;
  --wrong-bg:#f6e9e4; --nav-bg:rgba(248,252,253,.94);
}
:root[data-theme="apricot"] {
  --bg:#f5eddf; --surface:#fffaf1; --surface-secondary:#ede4d5; --text-primary:#493d35;
  --text-secondary:#7d7065; --primary:#64775a; --primary-hover:#526449; --border:#ded1bf;
  --shadow-color:rgba(79,65,49,.10); --grid-bg:#fffaf0; --grid-text:#493d35; --grid-shadow:rgba(83,66,46,.13);
  --grid-highlight:rgba(255,255,255,.76); --hero-from:#f2e6d4; --hero-to:#fffaf1;
  --accent-blue:#dce9e6; --accent-apricot:#efd3b6; --accent-gold:#eee0a0; --success-bg:#e2ead9;
  --wrong-bg:#f4e2db; --nav-bg:rgba(255,250,241,.94);
}
:root[data-theme="night"] {
  color-scheme: dark;
  --bg:#202c35; --surface:#293944; --surface-secondary:#334651; --text-primary:#f3efe4;
  --text-secondary:#b5c4c6; --primary:#6f9f88; --primary-hover:#7eae96; --on-primary:#132d27; --border:#40545e;
  --shadow-color:rgba(4,13,18,.22); --grid-bg:#30434e; --grid-text:#fff8e8; --grid-shadow:rgba(4,13,18,.28);
  --grid-highlight:rgba(255,255,255,.07); --hero-from:#2e414a; --hero-to:#35463f;
  --accent-blue:#365260; --accent-apricot:#55493f; --accent-gold:#5d583d; --success-bg:#365347;
  --wrong-bg:#55423f; --nav-bg:rgba(36,50,59,.95); --danger:#e19a8f;
}
:root { --cream:var(--bg); --paper:var(--surface); --ink:var(--text-primary); --muted:var(--text-secondary); --sage:#88ae91; --sage-deep:var(--primary); --sage-soft:var(--surface-secondary); --blue:var(--accent-blue); --apricot:var(--accent-apricot); --yellow:var(--accent-gold); }
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text-primary); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; transition: background-color .18s ease, color .18s ease; }
body { min-height: 100dvh; overflow-x: hidden; }
button, input, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(66,119,104,.32); outline-offset: 2px; }
.app-shell { width: min(100%, 760px); min-height: 100dvh; margin: 0 auto; padding: max(20px, env(safe-area-inset-top)) 18px calc(92px + var(--safe-bottom)); }
.screen { animation: fade-in .22s ease; }
@keyframes fade-in { from { opacity: 0; transform: translateY(5px); } }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 46px; margin-bottom: 20px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 43px; height: 43px; border-radius: 14px; object-fit: cover; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 2px; font-size: 1.35rem; font-weight: 850; letter-spacing: .035em; text-shadow: 0 1px 0 var(--grid-highlight), 0 2px 3px var(--shadow-color); }
h2 { font-size: 1.55rem; margin-bottom: 8px; }
h3 { font-size: 1rem; margin-bottom: 5px; }
.eyebrow, .muted { color: var(--muted); }
.eyebrow { font-size: .82rem; margin: 0; }
.date { color: var(--muted); font-size: .86rem; text-align: right; }
.icon-btn { border: 1px solid var(--border); background: var(--surface); box-shadow: 0 4px 14px var(--shadow-color); width: 44px; height: 44px; border-radius: 15px; cursor: pointer; }
.hero-card, .card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.hero-card { position: relative; overflow: hidden; padding: 25px 24px; background: linear-gradient(135deg, var(--hero-from) 0%, var(--hero-to) 68%); }
.hero-card::after { content: ''; position: absolute; width: 130px; height: 130px; border-radius: 50%; background: var(--yellow); opacity: .25; right: -45px; top: -45px; }
.hero-row { display: flex; align-items: center; gap: 14px; }
.owl { width: 94px; height: 94px; flex: 0 0 auto; object-fit: contain; }
.welcome { min-height: calc(100dvh - 60px); display: grid; place-items: center; text-align: center; }
.welcome-panel { width: min(100%, 430px); }
.welcome .owl { width: 190px; height: 190px; margin-bottom: 16px; }
.welcome h1 { font-size: 2rem; margin-bottom: 10px; }
.welcome p { color: var(--muted); margin-bottom: 30px; }
.activation { min-height: calc(100dvh - 40px); display: grid; place-items: center; }
.activation-panel { width: min(100%, 500px); padding: 26px; text-align: center; }
.activation-icon { width: 88px; height: 88px; margin-bottom: 12px; border-radius: 24px; box-shadow: 0 10px 28px var(--shadow-color); }
.activation-panel h1 { margin: 4px 0 12px; font-size: 1.7rem; }
.activation-panel form { margin-top: 20px; }
.activation-panel textarea { width: 100%; min-height: 108px; resize: vertical; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text-primary); padding: 13px; font: inherit; line-height: 1.5; }
.device-code { display: grid; gap: 8px; margin-top: 20px; padding: 17px; border: 1px dashed var(--primary); border-radius: 17px; background: var(--surface-secondary); }
.device-code span { color: var(--muted); font-size: .84rem; }
.device-code strong { overflow-wrap: anywhere; font-size: 1.08rem; letter-spacing: .08em; }
.device-code button { justify-self: center; min-height: 38px; padding: 0 16px; border: 0; border-radius: 12px; background: var(--surface); color: var(--primary); font-weight: 750; cursor: pointer; }
.license-message { min-height: 24px; margin: 14px 0 0; color: var(--danger); font-weight: 700; }
.license-note { margin: 4px 0 0; color: var(--muted); font-size: .8rem; line-height: 1.6; }
.primary, .secondary, .text-btn, .danger-btn { min-height: 48px; border-radius: 16px; border: 0; padding: 0 20px; cursor: pointer; font-weight: 700; }
.primary { background: var(--primary); color: var(--on-primary); box-shadow: 0 5px 0 color-mix(in srgb, var(--primary) 76%, #000), 0 10px 18px var(--shadow-color); transition: transform .12s ease, box-shadow .12s ease, background .12s ease; }
.primary:hover { background: var(--primary-hover); }
.primary:active { transform: translateY(2px); box-shadow: 0 2px 0 color-mix(in srgb, var(--primary) 76%, #000), 0 5px 10px var(--shadow-color); }
.primary.wide { width: 100%; }
.secondary { background: var(--sage-soft); color: var(--sage-deep); }
.text-btn { background: transparent; color: var(--sage-deep); padding: 0 8px; }
.danger-btn { background: #fff0ed; color: var(--danger); }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; margin: 26px 2px 13px; }
.section-head h2 { margin: 0; font-size: 1.22rem; }
.tasks { display: grid; gap: 11px; }
.task-card { display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 12px; width: 100%; padding: 15px; background: var(--surface); border: 1px solid var(--border); border-radius: 19px; box-shadow: 0 5px 15px var(--shadow-color); text-align: left; cursor: pointer; }
.task-card.done { background: var(--surface-secondary); opacity: .78; }
.task-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 14px; background: var(--blue); color: var(--sage-deep); font-weight: 800; }
.task-card:nth-child(2) .task-icon { background: var(--apricot); }
.task-card:nth-child(3) .task-icon { background: var(--yellow); }
.task-card h3, .task-card p { margin: 0; }
.task-card p { font-size: .86rem; color: var(--muted); margin-top: 3px; }
.task-state { color: var(--sage-deep); font-size: 1.2rem; }
.progress-wrap { margin: 18px 2px 24px; }
.progress-label { display: flex; justify-content: space-between; font-size: .88rem; color: var(--muted); margin-bottom: 8px; }
.progress-track { height: 8px; border-radius: 9px; background: var(--surface-secondary); overflow: hidden; }
.progress-fill { height: 100%; border-radius: inherit; background: var(--sage); transition: width .3s; }
.rest-card { padding: 18px; background: var(--sage-soft); border-radius: 20px; color: var(--sage-deep); text-align: center; }
.quick-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 11px; }
.quick-card { border: 1px solid var(--border); border-radius: 20px; min-height: 92px; background: var(--surface); box-shadow: 0 7px 24px var(--shadow-color); padding: 16px; text-align: left; cursor: pointer; }
.quick-card span { font-size: 1.45rem; display: block; margin-bottom: 8px; }
.bottom-nav { position: fixed; z-index: 30; left: 50%; bottom: 0; transform: translateX(-50%); width: min(100%, 760px); display: grid; grid-template-columns: repeat(4, 1fr); padding: 8px 12px calc(8px + var(--safe-bottom)); background: var(--nav-bg); backdrop-filter: blur(16px); border-top: 1px solid var(--border); }
.bottom-nav button { min-height: 52px; border: 0; background: none; color: var(--muted); font-size: .76rem; cursor: pointer; }
.bottom-nav span { display: block; font-size: 1.15rem; margin-bottom: 2px; }
.bottom-nav button.active { color: var(--sage-deep); font-weight: 700; }
.form-card { padding: 23px; }
.field { display: grid; gap: 8px; margin-bottom: 18px; text-align: left; }
.field label { font-weight: 700; font-size: .92rem; }
.field input, .field select { width: 100%; min-height: 50px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); padding: 0 14px; font-size: 1rem; color: var(--text-primary); }
.hint { font-size: .82rem; color: var(--muted); }
.game-shell { min-height: 100dvh; width: min(100%, 780px); margin: auto; padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)); display: grid; grid-template-rows: auto 1fr auto; }
.game-head { display: grid; grid-template-columns: 56px 1fr 75px; align-items: center; text-align: center; gap: 5px; }
.target-label { margin: 0; color: var(--muted); font-size: .82rem; }
.target { font-size: clamp(2rem, 7vw, 3rem); font-weight: 850; line-height: 1.05; text-shadow: 0 1px 0 var(--grid-highlight), 0 2px 3px var(--shadow-color); }
.timer { font-variant-numeric: tabular-nums; font-weight: 750; font-size: .95rem; }
.game-stage { display: grid; place-items: center; min-height: 0; padding: 10px 0; }
.game-grid { --size: 4; --gap: clamp(4px, 1.4vw, 10px); width: min(94vw, calc(100dvh - 185px), 610px); aspect-ratio: 1; display: grid; grid-template-columns: repeat(var(--size), 1fr); gap: var(--gap); }
.cell { min-width: 0; border: 1px solid var(--border); border-radius: clamp(8px, 2vw, 17px); background: var(--grid-bg); color: var(--grid-text); box-shadow: inset 0 1px 0 var(--grid-highlight), 0 3px 0 color-mix(in srgb, var(--grid-shadow) 75%, transparent), 0 6px 13px var(--grid-shadow); font-size: clamp(1rem, calc(6.2vw - var(--size) * .28vw), 2.2rem); font-weight: 800; text-shadow: 0 1px 0 var(--grid-highlight), 0 1.5px 2px var(--grid-shadow); cursor: pointer; touch-action: manipulation; transition: transform .14s ease, box-shadow .14s ease, background .14s ease; }
.cell:active { transform: translateY(1px) scale(.985); box-shadow: inset 0 1px 0 var(--grid-highlight), 0 1px 0 var(--grid-shadow), 0 3px 7px var(--grid-shadow); }
.game-grid[data-size="7"] { --gap: 4px; }
.game-grid[data-size="7"] .cell { border-radius: 8px; font-size: clamp(.88rem, 4.5vw, 1.45rem); }
.cell.correct { animation: correct .16s ease; background: var(--success-bg); color: var(--primary); opacity: .62; }
.cell.wrong { animation: wrong .22s ease; background: var(--wrong-bg); }
@keyframes correct { 50% { transform: scale(.9); } }
@keyframes wrong { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.game-foot { text-align: center; padding: 6px 0; }
.game-message { min-height: 24px; color: var(--muted); margin: 0 0 5px; }
.countdown { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 92%, transparent); font-size: min(30vw, 8rem); font-weight: 850; color: var(--primary); }
.countdown.pop { animation: pop .48s ease; }
@keyframes pop { from { opacity: .3; transform: scale(.75); } }
.result { text-align: center; padding-top: 10px; }
.result-owl { width: 145px; height: 145px; object-fit: contain; }
.result h2 { font-size: 2rem; }
.record-pill { display: inline-block; padding: 8px 16px; border-radius: 99px; background: var(--yellow); font-weight: 800; margin-bottom: 20px; }
.score-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin: 18px 0; }
.score-item { padding: 17px 8px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.score-item strong { display: block; font-size: 1.25rem; }
.score-item span { display: block; color: var(--muted); font-size: .8rem; margin-top: 4px; }
.button-stack { display: grid; gap: 10px; margin-top: 22px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.stat { padding: 16px 8px; text-align: center; }
.stat strong { display: block; font-size: 1.35rem; }
.stat span { font-size: .78rem; color: var(--muted); }
.record-list { display: grid; gap: 9px; }
.record-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 17px; }
.record-row p { margin: 0; font-size: .86rem; color: var(--muted); }
.record-score { text-align: right; font-weight: 750; }
.chart { display: flex; align-items: end; gap: 7px; height: 138px; padding: 14px 12px 22px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; }
.bar { flex: 1; max-width: 46px; min-height: 8px; border-radius: 8px 8px 3px 3px; background: var(--sage); position: relative; }
.bar span { position: absolute; bottom: -19px; left: 50%; transform: translateX(-50%); font-size: .68rem; color: var(--muted); white-space: nowrap; }
.stations { display: grid; gap: 12px; }
.station { display: grid; grid-template-columns: 54px 1fr auto; gap: 13px; align-items: center; padding: 16px; border-radius: 21px; background: var(--surface); border: 1px solid var(--border); }
.station.locked { opacity: .48; filter: grayscale(.45); }
.station-icon { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 18px; background: var(--sage-soft); font-size: 1.55rem; }
.badge-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 11px; }
.badge { min-height: 150px; padding: 18px 12px; text-align: center; }
.badge.locked { opacity: .45; filter: grayscale(1); }
.badge-icon { font-size: 2rem; margin-bottom: 8px; }
.badge p { color: var(--muted); font-size: .78rem; margin: 5px 0 0; }
.settings-list { display: grid; gap: 10px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 62px; padding: 0 17px; background: var(--surface); border: 1px solid var(--border); border-radius: 17px; }
.switch { width: 51px; height: 30px; border: 0; padding: 3px; background: #cfd9d4; border-radius: 99px; cursor: pointer; }
.switch::after { content: ''; display: block; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch.on { background: var(--sage-deep); }
.switch.on::after { transform: translateX(21px); }
.modal-backdrop { position: fixed; inset: 0; z-index: 80; display: grid; place-items: end center; padding: 18px; background: rgba(22,55,60,.32); }
.modal { width: min(100%, 520px); max-height: 86dvh; overflow: auto; padding: 23px; background: var(--surface); border: 1px solid var(--border); border-radius: 26px; box-shadow: 0 25px 70px rgba(22,55,60,.2); }
.toast { position: fixed; z-index: 100; left: 50%; bottom: calc(88px + var(--safe-bottom)); transform: translate(-50%, 15px); background: #173e45; color: #fff; padding: 11px 18px; border-radius: 99px; opacity: 0; pointer-events: none; transition: .2s; white-space: nowrap; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.install-tip { margin-top: 18px; padding: 14px 16px; background: var(--blue); border-radius: 17px; font-size: .88rem; }
.theme-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.theme-card { position: relative; display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 10px; min-height: 76px; padding: 11px; border: 2px solid transparent; border-radius: 17px; background: var(--surface); color: var(--text-primary); cursor: pointer; text-align: left; }
.theme-card.selected { border-color: var(--primary); }
.theme-check { position: absolute; right: 8px; top: 6px; color: var(--primary); font-weight: 900; }
.theme-swatch { width: 34px; height: 45px; padding: 5px; border-radius: 10px; background: var(--sample-bg); border: 1px solid var(--sample-border); }
.theme-swatch::before { content:''; display:block; height:13px; border-radius:5px; background:var(--sample-surface); box-shadow:0 12px 0 var(--sample-primary); }
.theme-card small { display:block; color:var(--text-secondary); margin-top:3px; }
.result-main { padding: 22px; margin-top: 10px; }
.result-time { margin: 8px 0 12px; font-size: clamp(2.5rem, 12vw, 4.5rem); line-height: 1; font-weight: 880; font-variant-numeric: tabular-nums; text-shadow: 0 1px 0 var(--grid-highlight), 0 3px 5px var(--shadow-color); }
.feedback-card { margin: 14px 0; padding: 16px; border-radius: 18px; background: var(--surface-secondary); }
.feedback-card h3 { font-size: 1.15rem; }
.result-sections { display: grid; gap: 11px; margin-top: 14px; text-align: left; }
.result-section { padding: 18px; }
.result-section h3 { color: var(--text-secondary); font-size: .86rem; margin-bottom: 12px; }
.compare-line { display:flex; justify-content:space-between; gap:12px; margin:7px 0; }
.compare-highlight { color: var(--primary); font-weight: 800; margin: 10px 0 0; }
.reference-note { font-size: .76rem; line-height:1.6; color:var(--text-secondary); }
.eye-note { margin-top:18px; padding:14px 16px; border:1px solid var(--border); border-radius:16px; background:var(--surface-secondary); color:var(--text-secondary); font-size:.84rem; line-height:1.6; }
.error-dot { display:inline-block; width:7px; height:7px; border-radius:50%; background:var(--accent-apricot); margin-left:3px; }
@media (min-width: 620px) { .quick-grid { grid-template-columns: repeat(4, 1fr); } .badge-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-height: 610px) and (orientation: landscape) { .game-grid { width: min(72vh, 510px); } .game-head { position: absolute; left: 12px; right: 12px; } .game-foot { position: absolute; right: 22px; bottom: 20px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
