:root {
  --page:light-dark(#f7f8fa,#17191c);
  --surface:light-dark(#ffffff,#222529);
  --tile:light-dark(#eceff3,#2b2f35);
  --ink:light-dark(#25282f,#f2f3f5);
  --muted:light-dark(#6b707b,#afb4bf);
  --line:light-dark(#dfe3e9,#3b4049);
  --action:light-dark(#303b50,#c7d3ed);
  --action-ink:light-dark(#ffffff,#1d2433);
  --raised:inset 0 1px 0 #ffffff55,0 3px 0 light-dark(#c5cad3,#101215),0 5px 8px #10162314;
  --raised-small:0 1px 2px #10162308;
  --pressed:inset 0 2px 4px #10162312;
  -webkit-font-smoothing:antialiased;
}
button { transition:background-color .15s ease,border-color .15s ease,box-shadow .15s ease; }
button:disabled { opacity:.4; box-shadow:none!important; }
button:focus-visible,select:focus-visible { outline:3px solid var(--action); outline-offset:3px; }
[data-game-id="domino"],#domino { --game-color:light-dark(#176f5b,#99d5bc); }
[data-game-id="topside"],#game { --game-color:light-dark(#3d5da9,#b0c3fa); }
[data-game-id="second-shift"],#second-shift { --game-color:light-dark(#a25342,#edb09f); }
[data-game-id="shelf"],#companion[data-game="shelf"] { --game-color:light-dark(#43744e,#aad5ad); }
[data-game-id="equal"],#companion[data-game="equal"] { --game-color:light-dark(#896518,#e5cc89); }
[data-game-id="patchwork"],#companion[data-game="patchwork"] { --game-color:light-dark(#9d4674,#e2acca); }
#game,#companion,#second-shift,#domino { --action:var(--game-color); }

#home {
  display:flex; max-width:520px; padding:calc(env(safe-area-inset-top) + 18px) max(20px,env(safe-area-inset-right)) calc(env(safe-area-inset-bottom) + 10px) max(20px,env(safe-area-inset-left));
  scrollbar-width:thin; scrollbar-color:var(--line) transparent;
}
.home-header { flex:none; padding-bottom:18px; }
.home-date-row { display:flex; justify-content:space-between; align-items:center; height:30px; margin-bottom:7px; }
.home-header .eyebrow { margin:0; font-size:12px; line-height:18px; font-weight:500; }
.home-header h1 { font-family:ui-serif,Georgia,serif; font-size:36px; line-height:42px; font-weight:700; }
.brand-period { color:#d48769; }
.brand-mark { display:grid; grid-template-columns:repeat(2,11px); grid-template-rows:repeat(2,11px); gap:3px; transform:rotate(-8deg); }
.brand-mark i { border-radius:3px; background:#557cc2; }
.brand-mark i:nth-child(2) { background:#eda184; }
.brand-mark i:nth-child(3) { background:#83b499; }
.brand-mark i:nth-child(4) { background:#e5c576; }
.ritual-heading { display:flex; justify-content:space-between; align-items:baseline; margin-top:16px; font-size:12px; color:var(--muted); }
.ritual-count { font-size:14px; font-weight:650; color:var(--ink); font-variant-numeric:tabular-nums; }
.ritual-meter { display:grid; grid-template-columns:repeat(54,minmax(0,1fr)); gap:1px; height:4px; margin-top:10px; }
.ritual-meter span { background:var(--line); border-radius:2px; }
.ritual-meter .complete { background:var(--action); }
.section-heading { display:flex; flex:none; justify-content:space-between; align-items:center; gap:12px; min-height:30px; margin-bottom:8px; }
.section-heading h2 { font-size:13px; font-weight:700; line-height:18px; }
.section-heading>span { color:var(--muted); font-size:11px; }
.game-grid { display:grid; grid-template-columns:minmax(0,1fr); gap:0; flex:none; }
#domino-daily,#shift-daily,#other-games,#collection-games { display:contents; }
.daily-game { position:relative; min-width:0; min-height:102px; padding:16px 4px; border:0; border-bottom:1px solid var(--line); border-radius:0; background:transparent; overflow:hidden; box-shadow:none; }
.game-heading { display:flex; flex-direction:row; align-items:center; height:100%; padding:0 50px 0 0; gap:16px; }
.game-cadence { font-size:10px; line-height:15px; color:var(--muted); font-weight:500; }
.game-name { flex:1; min-width:0; }
.game-heading h2 { font-size:17px; line-height:23px; font-weight:650; overflow-wrap:break-word; }
.game-heading p { font-size:12px; line-height:18px; margin:3px 0 0; }
.game-art { display:block; flex:0 0 72px; width:72px; height:62px; padding:0; border:0; border-radius:0; background:none; filter:drop-shadow(0 3px 2px #15203915); }
.game-art svg { display:block; width:100%; height:100%; }
#shift-daily .game-art { padding:0; }
.game-dots { position:absolute; bottom:29px; right:8px; display:flex; gap:4px; }
.game-dots i { width:5px; height:5px; border:1px solid var(--muted); border-radius:50%; opacity:.5; }
.game-dots .in-progress { border-color:var(--game-color); opacity:1; }
.game-dots .complete { border-color:var(--game-color); background:var(--game-color); opacity:1; }
.daily-count { display:none; }
.game-open { position:absolute; inset:0; width:100%; height:100%; padding:0; background:transparent; border:0; border-radius:0; }
.game-open>svg { position:absolute; top:28px; right:8px; width:20px; height:20px; color:var(--muted); }
.game-open:hover:not(:disabled) { background:color-mix(in srgb,var(--game-color) 4%,transparent); }
.game-open:active:not(:disabled) { background:color-mix(in srgb,var(--game-color) 8%,transparent); }
.game-open:focus-visible { outline-offset:-4px; }
.set-complete .game-heading p { color:var(--game-color); }
.home-footer { flex:none; padding-top:10px; margin:0; }
.home-footer-row { display:flex; justify-content:space-between; align-items:center; gap:12px; }
.practice-entry { display:flex; align-items:center; gap:8px; min-height:44px; padding:0; border:0; background:transparent; font-size:13px; font-weight:600; }
.practice-entry svg { width:16px; height:16px; }
.practice-entry svg:last-child { width:12px; }
.home-footer [data-reset-time] { font-size:11px; text-align:right; color:var(--muted); }
.home-meta { font-size:11px; line-height:18px; color:var(--muted); }
.home-meta p { margin:2px 0; }
.home-meta p:empty { display:none; }
.home-utilities { display:flex; gap:16px; align-items:center; }
.home-utilities .icon-button { width:44px; height:44px; border:0; box-shadow:none; background:transparent; margin-right:-8px; }
#settings-dialog { top:max(var(--dialog-top,18px),calc(env(safe-area-inset-top) + 16px)); width:min(360px,calc(100% - 32px)); max-height:calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 32px); padding:20px; overflow:auto; background:var(--surface); color:var(--ink); border:1px solid var(--line); border-radius:8px; }
.settings-heading { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:12px; }
.settings-heading h2 { font-size:22px; line-height:28px; }
.settings-heading .icon-button { width:44px; height:44px; border:0; box-shadow:none; }
.setting-row { display:flex; justify-content:space-between; align-items:center; gap:16px; min-height:64px; border-top:1px solid var(--line); font-size:15px; }
.setting-row>span { min-width:0; }
.setting-row input[role="switch"] { appearance:none; -webkit-appearance:none; position:relative; flex:none; margin:0; width:50px; height:30px; border:1px solid var(--line); border-radius:20px; background:var(--line); cursor:pointer; }
.setting-row input[role="switch"]::before { content:''; position:absolute; top:3px; left:3px; width:22px; height:22px; border-radius:50%; background:var(--surface); box-shadow:0 1px 3px #0002; transition:transform .15s; }
.setting-row input[role="switch"]:checked { background:var(--action); border-color:var(--action); }
.setting-row input[role="switch"]:checked::before { transform:translateX(20px); }
.setting-row input:disabled { opacity:.4; }
.setting-row input:focus-visible { outline:3px solid var(--action); outline-offset:4px; }
.setting-row input[type="time"] { flex:none; width:120px; min-height:44px; font:inherit; padding:8px; color:var(--ink); background:var(--tile); border:1px solid var(--line); border-radius:6px; }
.settings-status { font-size:12px; line-height:18px; min-height:18px; color:var(--muted); margin:4px 0 20px; }
.settings-storage { border-top:1px solid var(--line); padding-top:20px; }
.settings-storage h3 { font-size:13px; line-height:20px; }
.settings-storage p { font-size:13px; line-height:20px; margin-top:5px; color:var(--muted); }
.settings-storage button { display:flex; gap:8px; align-items:center; margin-top:12px; min-height:44px; }
.settings-day { border-bottom:1px solid var(--line); padding:16px 0; }
.settings-day-heading { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:12px; }
.settings-day-heading h3 { font-size:14px; }
.settings-day-heading span { font-size:12px; color:var(--muted); }
.settings-day>button { width:100%; min-height:44px; display:flex; align-items:center; justify-content:center; gap:8px; }
.settings-day button svg { width:19px; height:19px; }
.settings-day [data-new-day-confirm]>p { font-size:13px; line-height:20px; color:var(--muted); margin-bottom:14px; }
.settings-day .dialog-actions { gap:8px; }
.settings-day .dialog-actions button { min-width:0; min-height:44px; }
.settings-day .settings-status { margin:8px 0 0; min-height:0; }
.settings-day .settings-status:empty { display:none; }
.settings-build { margin-top:24px; font-size:11px; line-height:16px; color:var(--muted); overflow-wrap:anywhere; }
.native-warning { position:fixed; top:env(safe-area-inset-top); left:0; right:0; z-index:100; margin:0; padding:3px 12px; font-size:10px; text-align:center; color:var(--ink); background:var(--tile); pointer-events:none; }
.native-save-warning #home,.native-save-warning #game,.native-save-warning #companion,.native-save-warning #second-shift,.native-save-warning #domino { padding-top:calc(env(safe-area-inset-top) + 36px); }
.home-offline { display:flex; align-items:center; gap:6px; min-height:22px; }
.home-offline svg { width:14px; height:14px; }

#puzzle-sheet { top:auto; bottom:0; margin:0 auto; width:100%; max-width:520px; max-height:calc(var(--visible-height,100dvh) - env(safe-area-inset-top) - 24px); padding:22px 22px max(24px,env(safe-area-inset-bottom)); border:0; border-radius:8px 8px 0 0; overflow-y:auto; }
.sheet-heading { display:flex; justify-content:space-between; align-items:center; gap:12px; padding-bottom:20px; }
.sheet-heading p { font-size:12px; line-height:18px; color:var(--muted); margin:0 0 5px; }
.sheet-heading h2 { font-family:ui-serif,Georgia,serif; font-size:28px; line-height:34px; }
.sheet-heading .icon-button { border:0; background:var(--tile); box-shadow:none; }
.sheet-options { display:grid; gap:0; }
.sheet-choice { display:flex; align-items:center; gap:16px; width:100%; min-height:76px; padding:14px 2px; background:transparent; border:0; border-top:1px solid var(--line); text-align:left; }
.sheet-choice>svg,.choice-mark { width:20px; height:20px; flex:none; color:var(--game-color); }
.choice-mark svg { display:block; width:20px; height:20px; }
.sheet-choice:hover:not(:disabled) { background:var(--tile); }
.choice-copy { flex:1; min-width:0; }
.choice-copy strong { display:block; font-size:17px; line-height:22px; font-weight:600; }
.choice-copy small { display:block; font-size:12px; line-height:18px; color:var(--muted); margin-top:3px; }
.sheet-choice.complete .choice-copy small { color:var(--game-color); }
.difficulty-symbol { display:flex; align-items:flex-end; gap:3px; width:28px; height:24px; flex:none; }
.difficulty-symbol i { width:6px; height:9px; background:var(--line); border-radius:2px; }
.difficulty-symbol i:nth-child(2) { height:16px; }
.difficulty-symbol i:nth-child(3) { height:23px; }
.difficulty-symbol i.filled { background:var(--game-color); }
.practice-choice>span:first-of-type { flex:1; font-size:16px; font-weight:600; }
.practice-choice .practice-total { color:var(--muted); font-size:12px; }

#game,#companion,#second-shift,#domino {
  width:100%; max-width:520px; margin-inline:auto;
  padding:calc(env(safe-area-inset-top) + 12px) max(16px,env(safe-area-inset-right)) calc(env(safe-area-inset-bottom) + 12px) max(16px,env(safe-area-inset-left));
}
.header,#companion .header,#second-shift .header,#domino .header { padding:0 0 12px; min-height:58px; gap:6px; }
.header .brand { min-width:0; }
.header .game-brand { gap:7px; }
.header h1,#companion h1,#second-shift h1,#domino h1 { font-size:20px; line-height:25px; font-weight:700; }
.header .eyebrow,#second-shift .eyebrow,#domino .eyebrow { display:block; margin-top:3px; font-size:10px; line-height:14px; font-weight:400; }
.header .tools,#companion .tools,#second-shift .tools,#domino .tools { gap:0; }
.header .icon-button { width:44px; height:44px; border:0; background:transparent; box-shadow:none; }
.header .game-brand>.icon-button { margin-left:-6px; }
.header .icon-button svg { width:20px; height:20px; stroke-width:1.65; }
.header .icon-button:hover:not(:disabled),.header .icon-button:active:not(:disabled) { background:var(--tile); color:var(--action); transform:none; }
.clean-game .pack-picker,#companion.clean-game .pack-picker,#second-shift.clean-game .pack-picker,#domino.clean-game .pack-picker { display:none; }
.clean-game .comp-meta,.clean-game .dm-meta,.clean-game .daily-date,.clean-game .level-bar.daily,.clean-game.ss-daily .ss-job-row,.clean-game [data-progress],.clean-game [data-comp-progress] { display:none; }
.puzzle-context { display:flex; flex:none; align-items:center; justify-content:space-between; gap:10px; min-height:44px; margin-bottom:8px; border-top:1px solid var(--line); border-bottom:1px solid var(--line); }
.puzzle-switch { display:flex; align-items:center; gap:9px; min-width:0; min-height:44px; padding:0; background:transparent; border:0; font-size:12px; }
.puzzle-switch>span:first-child { color:var(--muted); }
.puzzle-switch strong { font-size:12px; font-weight:600; color:var(--game-color); }
.puzzle-switch svg { width:14px; height:14px; color:var(--muted); flex:none; }
.context-separator { color:var(--line); }
.context-progress { flex:none; font-size:11px; font-variant-numeric:tabular-nums; color:var(--muted); }
.puzzle-complete .context-progress { color:var(--game-color); }
.puzzle-complete .controls .status,.puzzle-complete .dm-status,.puzzle-complete .comp-status { color:var(--game-color); font-size:16px; font-weight:600; }
select { background:var(--surface); border-color:var(--line); border-radius:8px; box-shadow:none; }
.level-bar { min-height:30px; border-top:0; padding-inline:2px; }
.level-picker select,.ss-job-row select { border:0; background:transparent; box-shadow:none; }
.daily-date { margin:4px 2px 0; font-size:12px; }
.comp-meta,.dm-meta,.ss-job-row>span { font-size:12px; color:var(--muted); }
.comp-meta,.dm-meta { min-height:27px; padding-inline:2px; }
.counter { font-size:12px; color:var(--muted); font-variant-numeric:tabular-nums; }
.primary-button { border:1px solid color-mix(in srgb,var(--action) 95%,var(--ink)); box-shadow:none; border-radius:8px; font-size:14px; font-weight:650; }
.primary-button:active:not(:disabled) { box-shadow:var(--pressed); }
.icon-button,.direction,.ss-pad .icon-button,.ss-command>.icon-button,.patch-tools .icon-button,.dm-tool-row .icon-button { border:1px solid var(--line); border-radius:8px; background:var(--surface); box-shadow:var(--raised-small); }
.icon-button:active:not(:disabled),.bank-item:active:not(:disabled),.dm-rack:active:not(:disabled) { box-shadow:var(--pressed); transform:none; }

.controls { padding:8px 0 0; min-height:124px; border-top:1px solid var(--line); }
.controls .status { color:var(--muted); font-size:12px; margin-bottom:4px; }
.controls .direction { width:52px; height:44px; }
.selection-row { margin-bottom:4px; }
.selection-row select { font-size:13px; border:0; background:transparent; min-height:44px; }
.selection-row .remaining { display:none; }
.board .cell { fill:var(--tile); stroke:color-mix(in srgb,var(--line) 80%,var(--ink)); stroke-width:.8; }
.board .chip-depth { filter:drop-shadow(0 4px 2px #18203225); }
.board .chip-face { filter:none; }
.board .chip-edge { stroke:#ffffffb3; stroke-width:1.8; }
.finished { padding-top:8px; }
.finished .best { margin-bottom:10px; }

.comp-goal { font-size:13px; line-height:18px; margin:7px 0; color:var(--ink); }
.comp-bank { padding-top:12px; border-top:1px solid var(--line); }
.comp-footer { padding-top:6px; }
.comp-status { font-size:13px; color:var(--muted); }
.bank-item,.target-slot,.dm-rack { border:1px solid var(--line); box-shadow:var(--raised); border-radius:8px; }
.target-slot:not(.occupied),.bank-item.used,.dm-rack.used { border-style:dashed; background:var(--tile); box-shadow:var(--pressed); }
.bank-item.selected,.target-slot.selected,.dm-rack.selected { border:1px solid var(--action); outline:2px solid var(--action); outline-offset:-2px; background:color-mix(in srgb,var(--action) 5%,var(--surface)); box-shadow:none; }
.bank-item.used,.dm-rack.used { opacity:.5; }
.bank-item:disabled,.target-slot:disabled { opacity:1; }
.shelf-board { padding-top:16px; padding-bottom:14px; }
.shelf-position { border-bottom-color:color-mix(in srgb,var(--game-color) 35%,var(--line)); }
.shelf-clues { margin-top:4px; }
.shelf-clues li { padding:12px 0; font-size:14px; line-height:21px; gap:10px; }
.clue-state { width:20px; height:20px; align-items:center; justify-content:center; }
.satisfied .clue-state { border-radius:50%; background:color-mix(in srgb,var(--action) 10%,var(--surface)); }
.clue-state svg { width:16px; height:16px; }
.comp-finish { flex-wrap:wrap; }
.comp-finish>span { white-space:normal; }
.comp-finish .primary-button { min-width:150px; }
.comp-actions.no-selection .icon-button,.dm-tool-row.no-selection { visibility:hidden; }
.equation-target { font-weight:700; }
#companion[data-game="equal"] .bank-item:not(.used) { background:color-mix(in srgb,var(--game-color) 9%,var(--surface)); }
.patch-target figcaption { font-size:12px; font-weight:600; }

.ss-job-row { border-bottom:1px solid var(--line); }
.ss-take { padding:7px 2px; }
.ss-phase { font-size:12px; }
.ss-phase small { font-size:10px; }
.ss-beat { width:30px; height:30px; background:var(--tile); }
.ss-beat.filled { box-shadow:var(--raised-small); border-color:var(--line); }
.ss-console { padding-top:8px; border-top:1px solid var(--line); }
.ss-log>span { font-size:12px; line-height:16px; }
.ss-log b { font-size:9px; }
.ss-hint { padding:12px; background:var(--surface); box-shadow:0 4px 16px #122b1e16; border:1px solid var(--line); }
.ss-rating { gap:8px; }

.dm-bone { fill:light-dark(#fff,#3b4049); stroke:light-dark(#818a98,#b6bfce); }
.dm-piece:not(.dm-ghost) .dm-bone { filter:drop-shadow(0 3px 1px #15203930); }
.dm-pips { fill:var(--ink); }
.dm-rule { height:38px; }
.dm-rule-main small { font-size:10px; }
.dm-rule-letter,.dm-rule-progress { font-size:12px; }
.dm-rule-letter { color:var(--ink); }
.dm-cell-letter { fill:var(--muted); font-size:10px; }
.dm-region-fill { fill:color-mix(in srgb,var(--region) 10%,var(--surface)); }
.dm-console { padding-top:6px; }
.dm-status { font-size:13px; }
.dm-tool-row .icon-button { color:var(--action); }
.dm-selection { padding-left:4px; }

dialog { background:var(--surface); padding:24px; border:1px solid var(--line); box-shadow:0 18px 60px #0003; }
dialog h2 { font-size:22px; line-height:28px; }
dialog::backdrop { background:#171c2a88; }
.restart-copy { color:var(--muted); font-size:14px; line-height:21px; margin:12px 0 24px; }
.dialog-actions { display:flex; gap:10px; }
.dialog-actions button { flex:1; min-width:0; min-height:48px; border-radius:8px; }
.secondary-button { background:var(--tile); color:var(--ink); border:1px solid var(--line); font-weight:600; }

@media(max-height:650px) {
  #home { padding-top:calc(env(safe-area-inset-top) + 8px); }
  .home-header { padding-bottom:10px; }
  .home-header h1 { font-size:32px; line-height:36px; }
  .home-date-row { height:26px; margin-bottom:4px; }
  .ritual-heading { margin-top:10px; }
  .game-grid { gap:0; }
  .daily-game { padding:14px 4px; }
  .game-heading { gap:16px; }
  .game-heading h2 { font-size:17px; line-height:22px; }
  .game-art { height:62px; width:72px; }
  .home-footer { padding-top:4px; }
  #game,#companion,#second-shift,#domino { padding-top:calc(env(safe-area-inset-top) + 6px); padding-bottom:calc(env(safe-area-inset-bottom) + 6px); }
  .header,#companion .header,#second-shift .header,#domino .header { padding-bottom:6px; min-height:50px; }
  .header h1,#companion h1,#second-shift h1,#domino h1 { font-size:20px; }
  .comp-goal { margin:4px 0; font-size:12px; }
  .shelf-clues li { padding:8px 0; font-size:13px; line-height:19px; }
  .controls { min-height:120px; padding-top:4px; }
  .ss-console { padding-top:5px; }
  .ss-take { padding-block:4px; }
  .dm-rule { height:32px; }
}
@media(prefers-reduced-motion:reduce) { button { transition:none; } }
@media(prefers-contrast:more) {
  :root { --line:light-dark(#687d71,#a9c0b3); --muted:light-dark(#3a5044,#d2e3d9); }
  .daily-options button,.icon-button,.bank-item,.target-slot,.dm-rack { border-color:var(--line); }
}
