/* Mobile first. The same cards and controls are shared by every viewport. */
:root {
    color-scheme: light;
    --page: #e5eced; --panel: #f4f5e9; --panel-raised: #e9eddf;
    --text: #243548; --muted: #5b6c77; --line: #96a9ad; --line-soft: #bac8c5;
    --inset: #d8e1d9; --gold: #edbd62; --gold-text: #4a3216;
    --mint: #29876a; --mint-soft: #e0eee0; --coral: #b04740; --shadow: #b6c7c5;
}
* { box-sizing: border-box; }
html { scroll-padding-bottom: 110px; }
body { margin: 0; background: var(--page); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 14px; line-height: 1.5; -webkit-tap-highlight-color: transparent; }
button, select, input { font: inherit; }
button, summary, a, input, select { touch-action: manipulation; }
button { color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; }
a { color: inherit; text-underline-offset: 4px; }
button:focus-visible, summary:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid var(--mint); outline-offset: 4px; }
h1, h2, h3, h4, p { margin: 0; }
.hidden, .hiddenTask { display: none !important; }
.tab { display: none; }
#jobs { display: block; }
.category-group:has(> .headerRow.hidden) { display: none; }
.pixel-icon { width: 24px; height: 24px; flex: 0 0 auto; vertical-align: middle; shape-rendering: crispEdges; }
[data-icon], .category-icon, .entity-icon { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.game-shell { max-width: 1120px; margin: 0 auto; padding: 0 14px 110px; }
.app-header { min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 2px solid var(--line-soft); margin-bottom: 18px; }
.brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; }
.brand-emblem .pixel-icon { width: 42px; height: 46px; }
.brand h1 { font-size: 26px; line-height: 1.12; font-weight: 900; letter-spacing: 2px; white-space: nowrap; }
.brand-subtitle { display: block; margin-top: 6px; font-size: 8px; font-weight: 750; letter-spacing: 2.25px; color: var(--gold); }
.header-actions { display: flex; gap: 8px; align-items: center; }
.header-actions { flex-shrink: 0; }
html[lang="en"] .brand h1 { font-size: 20px; letter-spacing: 0; }
html[lang="en"] .age-line { flex-wrap: wrap; white-space: normal; }
html[lang="en"] .day-line { white-space: nowrap; }
.button { min-height: 44px; padding: 8px 16px; background: var(--panel-raised); border: 1px solid var(--line); border-radius: 5px; box-shadow: inset 0 2px 0 #ffffff12, 0 2px 0 var(--shadow); font-weight: 700; transition: background .15s, border-color .15s; }
.button:hover { border-color: var(--gold); }
.button:active { transform: translateY(1px); box-shadow: none; }
.pause-button { background: var(--gold); color: var(--gold-text); border-color: #ffdf90; padding: 8px 13px; white-space: nowrap; }
.pause-button::before { content: 'Ⅱ'; font-weight: 900; margin-right: 7px; }
.pause-button.is-paused::before { content: '▶'; font-size: 12px; }
.icon-button { padding: 8px; width: 44px; }
.icon-button .pixel-icon { width: 24px; height: 24px; }
.pixel-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; box-shadow: inset 0 0 0 2px #ffffff06, 0 3px 0 var(--shadow); }
.profile-card { overflow: hidden; }
.profile-top { display: flex; align-items: center; position: relative; min-height: 110px; padding: 14px 12px 0; isolation: isolate; }
.knight-portrait { width: 84px; height: 94px; align-self: end; object-fit: contain; object-position: bottom; image-rendering: pixelated; flex-shrink: 0; z-index: 1; }
.life-info { padding: 0 0 12px 9px; z-index: 2; min-width: 0; text-shadow: 0 0 6px var(--panel), 0 1px 2px var(--panel); }
.age-line { display: flex; align-items: baseline; gap: 4px; font-size: 19px; font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
.day-line { font-size: 12px; margin-left: 2px; color: var(--text); }
.lifespan { margin-top: 8px; display: flex; align-items: center; gap: 3px; color: var(--muted); font-size: 12px; }
.lifespan .pixel-icon { width: 16px; height: 16px; margin-right: 2px; }
.village-scene { position: absolute; z-index: -1; right: 0; top: 0; height: 100%; width: 48%; object-fit: cover; object-position: 65% center; opacity: .65; image-rendering: pixelated; mask-image: linear-gradient(to right, transparent, #000 65%); }
.balance-details { margin: 0 12px; }
.balance-details summary { list-style: none; display: grid; grid-template-columns: 1fr auto 16px; align-items: center; gap: 8px; border-top: 1px solid var(--line); padding: 14px 0; cursor: pointer; min-height: 65px; }
summary::-webkit-details-marker { display: none; }
.wallet { display: flex; align-items: center; gap: 8px; min-width: 0; }
.wallet .pixel-icon { width: 29px; height: 29px; }
.wallet strong { font-size: 20px; line-height: 1.3; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.currency { font-variant-numeric: tabular-nums; }
.currency > span { white-space: nowrap; }
.wallet .currency > span { color: var(--text) !important; }
.net-balance { display: flex; flex-direction: column; align-items: end; gap: 1px; font-size: 10px; color: var(--muted); }
.net-balance strong { font-size: 13px; color: var(--mint); }
.net-balance .currency span { color: inherit !important; }
.net-balance.is-negative strong { color: var(--coral); }
.net-balance #signDisplay { color: inherit !important; }
.disclosure .pixel-icon { width: 15px; height: 15px; transition: transform .15s; }
.balance-details[open] .disclosure .pixel-icon { transform: rotate(180deg); }
.income-details { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 11px 0 13px; border-top: 1px solid var(--line-soft); }
.income-details > div { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; font-size: 11px; color: var(--muted); flex-wrap: wrap; }
.income-details > div + div { border-left: 1px solid var(--line-soft); padding-left: 14px; }
.income-details strong { font-size: 12px; }
.positive, .positive .currency span { color: var(--mint) !important; }
.negative, .negative .currency span { color: var(--coral) !important; }
.activity-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0 0; }
.activity-card { display: block; text-align: left; padding: 12px 11px 13px; min-width: 0; }
.activity-card:hover { border-color: var(--mint); }
.activity-heading { display: block; color: var(--muted); font-size: 11px; margin-bottom: 9px; }
.activity-body { display: flex; align-items: center; gap: 8px; min-height: 42px; }
.activity-icon .pixel-icon { width: 32px; height: 32px; }
.activity-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.activity-name strong { font-size: 14px; overflow-wrap: anywhere; }
.activity-value { color: var(--muted); font-size: 10px; overflow-wrap: anywhere; }
.activity-progress { display: flex; align-items: center; gap: 7px; margin-top: 11px; }
.progress-track, .progress-bar { height: 11px; display: block; flex: 1; overflow: hidden; background: var(--inset); border: 1px solid var(--line); border-radius: 4px; min-width: 0; }
.progressFill { display: block; height: 100%; background: var(--mint); box-shadow: inset 0 2px 0 #ffffff2b; border-right: 1px solid #c1ffe080; }
.percent { font-size: 11px; min-width: 29px; text-align: right; font-variant-numeric: tabular-nums; }
.main-content { margin-top: 26px; min-width: 0; }
.section-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.section-heading { display: flex; align-items: center; gap: 9px; margin-right: auto; }
.section-heading .pixel-icon { width: 28px; height: 28px; }
.section-heading h2 { font-size: 24px; line-height: 1.3; font-weight: 850; }
.section-description { color: var(--muted); font-size: 12px; margin: 10px 0 24px; }
.automation { font-size: 11px; }
.switch-label { display: flex; align-items: center; gap: 7px; position: relative; cursor: pointer; min-height: 44px; }
.switch-label input { position: absolute; right: 0; width: 36px; height: 28px; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.switch-track { width: 32px; height: 19px; border: 1px solid var(--line); border-radius: 12px; background: var(--inset); position: relative; }
.switch-track::after { content: ''; position: absolute; width: 13px; height: 13px; background: var(--muted); top: 2px; left: 2px; border-radius: 50%; transition: transform .15s; }
.switch-label input:checked + .switch-track { background: var(--mint); border-color: var(--mint); }
.switch-label input:checked + .switch-track::after { background: #f5fff4; transform: translateX(13px); }
.switch-label input:focus-visible + .switch-track { outline: 3px solid var(--gold); outline-offset: 3px; }
.learn-control { display: none; }
body[data-tab="skills"] .learn-control { display: flex; }
body[data-tab="skills"] .promote-control { display: none; }
body:not([data-tab="jobs"]):not([data-tab="skills"]) .automation { display: none; }
.happiness { display: inline-flex; gap: 4px; align-items: center; color: var(--muted); font-size: 10px; padding: 5px 7px; border: 1px solid var(--line); border-radius: 4px; }
.happiness .pixel-icon { width: 15px; height: 15px; }
.happiness strong { color: var(--mint); font-size: 12px; }
.entity-list { display: flex; flex-direction: column; gap: 25px; }
.category-group { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.category-heading { display: flex; gap: 9px; align-items: center; order: -2; margin-bottom: 2px; color: var(--gold); }
.category-heading .pixel-icon { width: 24px; height: 24px; }
.category-heading h3 { font-size: 17px; font-weight: 750; }
.category-rule { flex: 1; height: 1px; background: var(--line-soft); margin-left: 5px; }
.task-card, .item-card { padding: 15px 15px 0; min-width: 0; }
.task-card.is-current { order: -1; border-color: var(--mint); background: var(--mint-soft); box-shadow: inset 0 0 0 1px var(--mint), 0 3px 0 var(--shadow); }
.task-top { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.entity-icon .pixel-icon { width: 34px; height: 34px; }
.task-top h4 { font-size: 17px; line-height: 1.35; min-width: 0; flex: 1; overflow-wrap: anywhere; font-weight: 750; }
.level-label { font-size: 13px; margin-left: 7px; white-space: nowrap; color: var(--muted); }
.task-action { font-size: 12px; min-width: 70px; padding: 8px 11px; min-height: 44px; color: var(--gold); border-color: var(--gold); background: transparent; }
.is-current .task-action { color: var(--gold-text); background: var(--gold); border-color: #ffdd8a; }
.task-card > .value { font-size: 13px; padding: 7px 0 12px 44px; color: var(--muted); }
.task-card .income span, .item-card .expense span { color: var(--gold) !important; }
.per-day { margin-left: 4px; font-size: 11px; }
.task-progress { display: flex; align-items: center; gap: 12px; margin-bottom: 13px; }
.task-progress .progress-bar { padding: 0; height: 12px; }
.task-progress .percent { font-size: 12px; min-width: 34px; }
.task-details { border-top: 1px solid var(--line-soft); font-size: 12px; }
.task-details summary { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 11px; min-height: 44px; padding: 6px 0; cursor: pointer; list-style: none; }
.task-details summary::after { content: '+'; font-size: 15px; }
.task-details[open] summary::after { content: '−'; }
.task-details p { margin: 5px 0 13px; color: var(--muted); line-height: 1.8; }
.task-stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 10px 0 14px; }
.task-stat-grid > span { background: var(--inset); padding: 8px; display: flex; flex-direction: column; gap: 4px; font-size: 10px; color: var(--muted); }
.task-stat-grid strong { color: var(--text); font-size: 13px; }
.max-level-stat:has(.hidden) { display: none; }
.skipSkill { padding: 0 0 14px; }
.skipSkill input { vertical-align: middle; accent-color: var(--mint); width: 18px; height: 18px; margin-right: 8px; }
.required-card { order: 1; background: var(--panel-raised); padding: 14px 15px; border: 1px dashed var(--line); border-radius: 6px; }
.required-heading { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.required-heading .pixel-icon { width: 22px; height: 22px; }
.required-heading strong { font-size: 16px; font-weight: 600; }
.locked-label { margin-left: auto; font-size: 10px; }
.requirement-body { border-top: 1px solid var(--line-soft); margin-top: 12px; padding-top: 12px; font-size: 11px; color: var(--muted); }
.requirement-body > span:first-child { display: block; margin-bottom: 8px; }
.levels { display: flex; flex-wrap: wrap; gap: 6px; }
.requirement-chip { border: 1px solid var(--line); padding: 5px 8px; font-size: 11px; border-radius: 3px; background: var(--inset); }
.requirement-chip.is-met { color: var(--mint); border-color: var(--mint); }
.item-card.is-active { border-color: var(--mint); }
.item-button { min-height: 44px; padding: 8px 12px; font-size: 12px; color: var(--gold); }
.item-button:disabled { opacity: .45; }
.active { width: 7px; height: 7px; display: block; border-radius: 1px; background: var(--line) !important; }
.is-active .active { background: var(--mint) !important; box-shadow: 0 0 5px var(--mint); }
.item-effect { color: var(--mint); font-size: 13px; padding: 10px 0 4px; }
.item-cost { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 12px; padding-bottom: 14px; }
.notice { padding: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 5px; color: var(--muted); line-height: 1.8; font-size: 12px; }
.notice p { margin-top: 8px; }
.danger { color: var(--coral); border-color: var(--coral); margin-top: 16px; }
.extra-stats { display: grid; gap: 10px; margin-top: 16px; }
.extra-stats:has(> .hidden + .hidden) { display: none; }
.extra-stats .notice { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.extra-stats .notice small { flex-basis: 100%; }
#shop > .notice { margin-bottom: 20px; }
#rebirth ul, .settings-list { padding: 0; list-style: none; display: grid; gap: 16px; }
#rebirth li, .settings-list > li { margin: 0 !important; padding: 20px; background: var(--panel); border: 1px solid var(--line); border-radius: 5px; }
#rebirth { line-height: 1.9; font-size: 14px; }
#rebirth i { color: var(--muted) !important; font-size: 12px; }
#rebirth .button { margin-top: 15px !important; color: var(--gold); }
.settings-list h2 { font-size: 16px; margin-bottom: 15px; }
select, #importExportBox { max-width: 100%; width: 100%; min-height: 44px; padding: 10px; color: var(--text); background: var(--inset); border: 1px solid var(--line); border-radius: 4px; }
.save-field { margin-top: 15px; }
.settings-list .button { margin-right: 8px; }
.w3-red { color: var(--coral); border-color: var(--coral); }
.community-link { color: var(--gold); }
.game-footer { text-align: center; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px; color: var(--muted); font-size: 10px; margin: 32px 0 0; }
.game-footer small { width: 100%; font-size: 8px; letter-spacing: 2px; margin-top: 5px; opacity: .65; }
.footer-spark .pixel-icon { width: 12px; height: 12px; }
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: stretch; gap: 6px; padding: 9px max(12px, env(safe-area-inset-right)) calc(9px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); background: var(--page); border-top: 2px solid var(--line); box-shadow: 0 -8px 25px #00000020; z-index: 10; }
.nav-button { position: relative; min-height: 62px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 5px; color: var(--muted); font-size: 12px; font-weight: 700; box-shadow: inset 0 2px 0 #ffffff08; }
.nav-button .pixel-icon { width: 25px; height: 25px; }
.nav-button[aria-current="page"] { background: var(--gold); color: var(--gold-text); border-color: #ffdf90; box-shadow: inset 0 3px 0 #fff0bf88; }
.nav-button[aria-current="page"] .pixel-icon { filter: brightness(.5) sepia(1); }
.nav-button:disabled { opacity: .45; }
.nav-lock { display: none; position: absolute; top: 5px; right: 7px; }
.nav-lock .pixel-icon { width: 10px; height: 10px; }
.nav-button:disabled .nav-lock { display: inline-flex; }
.icon-button[aria-current="page"] { color: var(--gold); border-color: var(--gold); }
@media (min-width: 540px) {
    .game-shell { padding-left: 24px; padding-right: 24px; }
    .age-line { font-size: 22px; }
    .day-line { font-size: 14px; }
    .profile-top { min-height: 124px; }
    .knight-portrait { width: 100px; height: 108px; }
    .life-info { padding-left: 15px; }
    .activity-card { padding: 15px; }
    .activity-name strong { font-size: 16px; }
    .activity-value { font-size: 12px; }
    .bottom-nav { left: 50%; transform: translateX(-50%); width: 520px; border: 1px solid var(--line); border-radius: 9px 9px 0 0; }
}
@media (min-width: 820px) {
    .game-shell { display: grid; grid-template-columns: 320px minmax(0, 1fr); column-gap: 30px; }
    .app-header, .game-footer { grid-column: 1 / -1; }
    .app-header { min-height: 100px; margin-bottom: 30px; }
    .brand h1 { font-size: 30px; }
    .brand-subtitle { font-size: 9px; }
    .dashboard { align-self: start; position: sticky; top: 20px; }
    .main-content { margin-top: 0; }
    .profile-top { padding-left: 8px; }
    .knight-portrait { width: 78px; height: 96px; }
    .age-line { font-size: 19px; }
    .day-line { font-size: 11px; }
    .life-info { padding-left: 6px; }
    .wallet strong { font-size: 18px; }
    .net-balance strong { font-size: 12px; }
    .activity-grid { gap: 10px; }
    .activity-card { padding: 12px 9px; }
    .activity-name strong { font-size: 13px; }
    .activity-value { font-size: 9px; }
    .activity-icon .pixel-icon { width: 28px; height: 28px; }
}
@media (max-width: 359px) {
    .game-shell { padding-left: 10px; padding-right: 10px; }
    .brand h1 { font-size: 22px; }
    html[lang="en"] .brand h1 { font-size: 16px; }
    .brand-emblem .pixel-icon { width: 32px; }
    .brand-subtitle { letter-spacing: 1.6px; font-size: 7px; }
    .pause-button { padding: 8px; font-size: 12px; }
    .header-actions { gap: 5px; }
    .icon-button { width: 38px; }
    .happiness { margin-left: auto; }
    .activity-icon .pixel-icon { width: 24px; }
    .activity-card { padding-left: 8px; padding-right: 8px; }
    .activity-name strong { font-size: 12px; }
    .wallet strong { font-size: 17px; }
    .age-line { font-size: 17px; }
    .day-line { font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; } }
