/* Foundation and shared interactive controls. No JavaScript dependency. */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: 2rem; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 var(--text-base)/var(--leading) var(--font-ui); overflow-wrap: anywhere; }
[hidden] { display: none !important; }
h1, h2, h3, h4, p, ul, ol, figure, blockquote, dl { margin: 0; }
h1, h2, h3, h4 { line-height: 1.5; font-weight: 700; }
ul, ol { padding-inline-start: 1.5em; }
a { color: var(--indigo); text-underline-offset: .25em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
button, input, select, textarea { font: inherit; }
button, input, select, textarea { color: inherit; }
button { cursor: pointer; }
button { touch-action: manipulation; }
button, select, input, textarea { max-width: 100%; }
button:disabled, [aria-disabled="true"] { cursor: not-allowed; }
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea { min-height: var(--tap); padding: .65rem .85rem; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface-raised); }
textarea { width: 100%; min-height: 7rem; resize: vertical; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--indigo); }
input[aria-invalid="true"] { border: 2px solid var(--error); }
::placeholder { color: var(--muted); opacity: 1; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
::selection { background: var(--selected); color: var(--ink); }
img, svg, canvas { display: block; max-width: 100%; }
img { height: auto; }
table { border-collapse: collapse; width: 100%; }
th { text-align: start; }
hr { border: 0; border-top: 1px solid var(--line); margin-block: var(--space-6); }
small { font-size: var(--text-xs); }
.icon { width: 1.5rem; height: 1.5rem; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.container { width: min(100%, var(--content-max)); padding-inline: var(--gutter); margin-inline: auto; }
.page { padding-block: var(--space-7) var(--space-8); }
.page--game { padding-block-start: var(--space-5); }
.section + .section { margin-block-start: var(--space-8); }
.section__title { font: 700 var(--text-xl)/1.6 var(--font-editorial); margin-block-end: var(--space-5); display: flex; align-items: center; gap: .7rem; }
.section__title::before { content: ""; width: .3rem; height: 1.15em; background: var(--stamp); flex-shrink: 0; }
.page-head { margin-block: var(--space-5) var(--space-7); }
.page-head__title { font: 700 var(--text-2xl)/1.5 var(--font-editorial); letter-spacing: .06em; }
.page-head__lead { color: var(--muted); max-width: 44rem; margin-top: .75rem; }
.crumbs { display: flex; flex-wrap: wrap; gap: .25rem .75rem; font-size: var(--text-sm); color: var(--muted); }
.crumbs a { display: inline-flex; align-items: center; min-height: 44px; }
.crumbs > * + *::before { content: "/"; margin-right: .75rem; color: var(--muted); }
.site-header { background: var(--surface); border-top: 4px solid var(--ink); border-bottom: 1px solid var(--line); }
.site-header__inner { max-width: 88rem; margin: auto; padding: .8rem var(--gutter); display: flex; align-items: center; gap: var(--space-5); flex-wrap: wrap; }
.brand { color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: .65rem; flex-shrink: 0; min-height: var(--tap); }
.brand__mark { width: 2.8rem; height: 2.8rem; }
.brand__name { font: 700 1.65rem/1 var(--font-editorial); letter-spacing: .12em; }
.global-nav { display: flex; align-items: center; gap: .25rem; flex-wrap: wrap; margin-inline: auto; }
.global-nav a, .drawer__nav a { min-height: var(--tap); display: flex; align-items: center; padding: .5rem .65rem; color: var(--ink); text-decoration: none; font-size: var(--text-sm); border-bottom: 2px solid transparent; }
.global-nav a[aria-current="page"], .drawer__nav a[aria-current="page"] { color: var(--stamp); border-color: var(--stamp); font-weight: 700; }
.global-nav a:hover, .drawer__nav a:hover { background: var(--surface-sunken); }
.header-status { display: flex; align-items: center; gap: .6rem; margin-left: auto; }
.points-chip, .streak-chip { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; font-size: var(--text-sm); }
.points-chip { color: var(--gold); font-variant-numeric: tabular-nums; }
.streak-chip { color: var(--stamp); }
.menu-btn, .icon-btn { min-width: var(--tap); min-height: var(--tap); display: inline-grid; place-items: center; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--ink); padding: .6rem; }
.menu-btn { display: none; }
.menu-btn:hover, .icon-btn:hover { background: var(--surface-sunken); }
.drawer { position: fixed; inset: 0 0 0 auto; margin: 0; width: min(23rem, 92vw); height: 100dvh; max-height: 100dvh; padding: var(--space-5); border: 0; border-left: 1px solid var(--line); background: var(--surface); color: var(--ink); overflow-y: auto; box-shadow: var(--shadow-dialog); }
.drawer__nav { display: grid; gap: .4rem; margin-top: var(--space-5); }
.drawer__nav a { gap: .7rem; border-radius: var(--radius-sm); }
dialog::backdrop { background: #141c246b; }
.site-footer { border-top: 1px solid var(--line); padding: var(--space-6) var(--gutter); background: var(--surface); text-align: center; }
.site-footer__links { display: flex; justify-content: center; flex-wrap: wrap; gap: .25rem 1.5rem; margin-bottom: var(--space-4); }
.site-footer__links a { display: inline-flex; align-items: center; min-height: 44px; font-size: var(--text-sm); color: var(--ink); }
.site-footer__note { color: var(--muted); font-size: var(--text-xs); }
.btn { min-height: var(--tap); display: inline-flex; align-items: center; justify-content: center; gap: .55rem; padding: .65rem 1.2rem; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--ink); font-weight: 700; line-height: 1.6; text-decoration: none; text-align: center; transition: background var(--duration), box-shadow var(--duration); }
.btn:hover { background: var(--surface-sunken); }
.btn--primary { background: var(--vermillion); color: var(--on-accent); border-color: var(--vermillion); box-shadow: 0 2px 0 #00000018; }
.btn--primary:hover { background: var(--vermillion); box-shadow: inset 0 0 0 2px var(--on-accent); }
.btn--secondary { border-color: var(--indigo); color: var(--indigo); background: var(--indigo-soft); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--indigo); }
.btn--small { font-size: var(--text-sm); padding: .4rem .75rem; min-height: 44px; }
.btn--block { width: 100%; }
.btn:disabled, .icon-btn:disabled, .tool:disabled { color: var(--muted); border-color: var(--line); background: var(--surface-sunken); box-shadow: none; border-style: dashed; }
.tools { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; }
.tool { position: relative; min-height: 4.5rem; min-width: 44px; padding: .6rem .2rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .25rem; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--ink); }
.tool__icon { width: 1.5rem; height: 1.5rem; }
.tool__label { font-size: var(--text-xs); }
.tool__badge { position: absolute; top: -.35rem; right: -.15rem; min-width: 1.3rem; height: 1.3rem; border-radius: 50%; font: 700 .75rem/1.3rem var(--font-ui); background: var(--ink); color: var(--surface); }
.tool.is-on, .tool[aria-pressed="true"] { background: var(--indigo-soft); color: var(--indigo); border: 2px solid var(--indigo); }
.tool:hover:not(:disabled) { box-shadow: inset 0 0 0 1px currentColor; }
.tabs, .level-tabs { display: flex; flex-wrap: wrap; gap: .25rem; border-bottom: 1px solid var(--line); }
.tab, .level-tab { display: inline-flex; min-height: var(--tap); align-items: center; justify-content: center; border: 0; border-bottom: 3px solid transparent; padding: .5rem 1rem; background: transparent; color: var(--muted); text-decoration: none; }
.tab[aria-selected="true"], .level-tab[aria-current="page"] { color: var(--indigo); border-bottom-color: currentColor; font-weight: 700; }
.tab:hover, .level-tab:hover { background: var(--surface-sunken); }
.badge { display: inline-flex; align-items: center; gap: .25rem; width: fit-content; border: 1px solid var(--line); padding: .15rem .55rem; border-radius: var(--radius-sm); color: var(--muted); background: var(--surface); font-size: var(--text-xs); font-weight: 700; }
.badge--gold { color: var(--gold); background: var(--gold-soft); border-color: currentColor; }
.badge--success { color: var(--leaf); background: var(--leaf-soft); border-color: currentColor; }
.badge--daily { color: var(--stamp); background: var(--madder-soft); border-color: currentColor; }
.badge--indigo { color: var(--indigo); background: var(--indigo-soft); border-color: currentColor; }
.switch { position: relative; display: inline-flex; align-items: center; justify-content: center; min-width: 3.25rem; min-height: var(--tap); cursor: pointer; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch__track { pointer-events: none; position: relative; width: 3.25rem; height: 1.875rem; border: 2px solid var(--line-strong); border-radius: 2rem; background: var(--surface-sunken); }
.switch__track::after { content: ""; position: absolute; width: 1.25rem; height: 1.25rem; top: .1875rem; left: .1875rem; border-radius: 50%; background: var(--muted); transition: transform var(--duration); }
.switch input:checked + .switch__track { background: var(--indigo); border-color: var(--indigo); }
.switch input:checked + .switch__track::after { transform: translateX(1.35rem); background: var(--surface); }
.switch input:focus-visible + .switch__track { outline: 3px solid var(--focus); outline-offset: 3px; }
.switch input:disabled + .switch__track { border-style: dashed; opacity: .65; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: var(--space-5); padding-block: 1.1rem; border-bottom: 1px solid var(--line); }
.setting__label { display: block; font-weight: 700; }
.setting__text { min-width: 0; }
.setting__desc { display: block; font-size: var(--text-sm); color: var(--muted); margin-top: .25rem; line-height: 1.7; }
.progress { height: .65rem; border-radius: 1rem; background: var(--surface-sunken); overflow: hidden; border: 1px solid var(--line); }
.progress__bar { display: block; height: 100%; width: clamp(0%, calc(var(--p, 0) * 100%), 100%); background: var(--leaf); border-radius: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip-link { position: absolute; z-index: 20; top: .5rem; left: 1rem; transform: translateY(-200%); }
.skip-link:focus { transform: none; }
.stack { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.cluster { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-3); }
.muted { color: var(--muted); }
.text-center { text-align: center; }
.field { display: grid; gap: .4rem; }
.field__label { font-weight: 700; }
.field__help { color: var(--muted); font-size: var(--text-sm); }
.field__error { color: var(--error); font-size: var(--text-sm); }
.field--check { display: flex; align-items: center; gap: .65rem; min-height: var(--tap); }
@media (max-width: 74rem) { .global-nav { display: none; } .menu-btn { display: inline-grid; } }
@media (max-width: 35rem) {
  .site-header__inner { gap: .5rem; padding-block: .6rem; }
  .brand { gap: .35rem; } .brand__mark { width: 2rem; height: 2rem; } .brand__name { font-size: 1.25rem; letter-spacing: .06em; }
  .header-status { gap: .4rem; } .streak-chip { display: none; } .points-chip { font-size: var(--text-xs); gap: .2rem; }
  .page { padding-top: var(--space-5); } .section + .section { margin-top: var(--space-7); }
  .tab, .level-tab { padding-inline: .7rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) { .btn, .tool, .badge, .switch__track { border: 1px solid ButtonText; } .progress__bar { background: Highlight; } }
