:root {
  color-scheme: light dark;
  --bg: #f6e3c8;
  --ink: #3a2414;
  --soft: #6b4b34;
  --panel: #fff8ee;
  --surface: #fbecd8;
  --well: #f2dfc4;
  --line: #d9bfa2;
  --shadow: #38221559;
  --sun: #f7b73d;
  --sun-edge: #a66b27;
  --accent: #365f54;
  --accent-soft: #dbebe0;
  --danger: #a73428;
  --serif: "Fraunces", Georgia, serif;
  --sans: "DM Sans", system-ui, sans-serif;
}
:root[data-theme="cream"] { color-scheme: only light; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="cream"]) {
    --bg: #29241e;
    --ink: #fff4e3;
    --soft: #dbc1a5;
    --panel: #30241d;
    --surface: #3b2b22;
    --well: #453326;
    --line: #735741;
    --shadow: #110903ab;
    --sun-edge: #d78c37;
    --accent: #c2e9d0;
    --accent-soft: #304c3b;
    --danger: #ffb5a8;
  }
}
* { box-sizing: border-box; }
html, body {
  height: 100%; margin: 0; overflow: hidden; color: var(--ink);
  background: var(--bg); font-family: var(--sans); user-select: none;
  -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { color: inherit; cursor: pointer; font: inherit; min-height: 44px; }
button:disabled { cursor: default; }
button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1, h2, p, figure { margin: 0; }
h1, h2 { font-family: var(--serif); }
.glyph { width: 25px; height: 25px; object-fit: contain; flex: none; vertical-align: middle; }
#view {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block;
  touch-action: none; -webkit-touch-callout: none;
}

.hud {
  position: fixed; inset: 0 0 auto;
  display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: start; gap: 8px;
  padding: max(10px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) 0 max(12px,env(safe-area-inset-left));
  pointer-events: none;
}
.hud button { pointer-events: auto; }
.clock, .goal, .gold-chip, .sizebar, .icon {
  background: var(--panel); color: var(--ink); border: 1px solid var(--line);
  box-shadow: 0 3px 0 var(--shadow);
}
.clock, .gold-chip {
  min-height: 44px; border-radius: 13px; display: flex; align-items: center; justify-content: center;
}
.clock { gap: 4px; padding: 0 8px; }
.clock .glyph { width: 20px; height: 20px; }
.clock b { font: 700 1.7rem/1 var(--serif); font-variant-numeric: tabular-nums; min-width: 2ch; }
.clock b.low { color: var(--danger); }
.goal { padding: 7px 9px 6px; border-radius: 13px; text-align: center; }
.goal small, #lvlname { display: block; font-size: .70rem; line-height: 1.17; }
.goal small { margin-top: 4px; font-weight: 800; font-variant-numeric: tabular-nums; }
#lvlname { margin-top: 2px; color: var(--soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { position: relative; height: 10px; border-radius: 999px; background: var(--well); overflow: hidden; }
.bar i {
  position: absolute; inset: 0 auto 0 0; width: 0; border-radius: inherit;
  background: #dc8a29; transition: width .15s;
}
.bar i.done { background: #4e9d73; }
.bar .par {
  position: absolute; inset: 0 3px 0 auto; left: auto !important;
  width: 2px; background: var(--ink); opacity: .7;
}
.hud-right { display: flex; gap: 7px; align-items: center; }
.gold-chip { width: 37px; }
.gold-chip .glyph { filter: grayscale(1); opacity: .66; }
.gold-chip.got { border-color: #b6772c; background: #ffdc82; }
.gold-chip.got .glyph { filter: none; opacity: 1; }
.icon {
  display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0;
  border-radius: 13px;
}
.sizebar {
  position: fixed; left: 50%; bottom: max(14px,env(safe-area-inset-bottom));
  transform: translateX(-50%); display: flex; align-items: center; gap: 8px;
  border-radius: 16px; padding: 6px 11px; font-weight: 800; font-size: .83rem; white-space: nowrap;
  pointer-events: none;
}
.sizebar .glyph { width: 19px; height: 19px; }
.bar.small { width: clamp(75px,22vw,137px); height: 8px; }
.bar.small i { background: #59a780; }
.frenzy, .toast {
  position: fixed; left: 50%; transform: translate(-50%,-5px);
  border-radius: 14px; pointer-events: none; opacity: 0;
  transition: opacity .18s,transform .18s; box-shadow: 0 3px 0 #3a241454;
}
.frenzy.on, .toast.on { opacity: 1; transform: translate(-50%,0); }
.frenzy {
  top: calc(max(10px,env(safe-area-inset-top)) + 74px); display: flex; align-items: center; gap: 6px;
  padding: 5px 13px 8px 9px; overflow: hidden; white-space: nowrap;
  background: #fbbb57; color: #382211; border: 1px solid #804818; font-size: .85rem;
}
.frenzy i { position: absolute; bottom: 0; left: 0; width: 0; height: 4px; background: #fff0ba; }
.frenzy .glyph { width: 21px; height: 21px; }
.toast {
  top: max(24%,calc(max(10px,env(safe-area-inset-top)) + 115px));
  width: max-content; max-width: min(86vw,420px);
  background: #3a2414; color: #fff4df; padding: 9px 15px; text-align: center;
  font-size: .85rem; font-weight: 800; border: 1px solid #a07754;
}
.toast.gold { background: #ffda80; color: #412600; border-color: #a46d24; }

.stick {
  position: fixed; width: 110px; height: 110px; margin: -55px 0 0 -55px; border-radius: 50%;
  border: 3px solid #3a241433; background: #ffffff22; pointer-events: none; opacity: 0; transition: opacity .15s;
}
.stick.on { opacity: 1; }
.stick i {
  position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px;
  border-radius: 50%; background: #3a241466;
}
.fps {
  position: fixed; right: 8px; bottom: 8px; font: 700 12px/1.3 ui-monospace,monospace;
  background: #000a; color: white; padding: 4px 7px; border-radius: 6px; pointer-events: none; white-space: pre;
}

.veil {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: #33201381; visibility: hidden; opacity: 0; pointer-events: none;
  padding: max(12px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right))
           max(12px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left));
  transition: opacity .18s;
}
.veil.on { visibility: visible; opacity: 1; pointer-events: auto; }
.veil:has(.home-screen) {
  background: linear-gradient(180deg,#422a1b40,#38241865), url("assets/art/menu_bg.webp") center 53% / cover;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="cream"]) .veil:has(.home-screen) {
    background-image: linear-gradient(180deg,#2a1c13a6,#1f130fbd),url("assets/art/menu_bg.webp");
  }
}
.sheet {
  width: min(420px,100%); max-height: 100%; overflow: auto; overscroll-behavior: contain;
  background: var(--panel); border: 1px solid var(--line); border-radius: 24px;
  padding: 22px; box-shadow: 0 17px 45px var(--shadow); text-align: center;
}
.sheet:has(.home-screen) { padding: 15px; }
#sheet-title:focus:not(:focus-visible), #sheet-title:focus-visible { outline: none; }
.sheet-head { display: grid; justify-items: center; gap: 7px; margin-bottom: 17px; }
.sheet-head h2 { font-size: clamp(1.9rem,7vw,2.45rem); line-height: 1.07; letter-spacing: -.034em; }
.sheet-head p { font-size: .89rem; color: var(--soft); font-weight: 700; }
.eyebrow { color: var(--accent); font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.panel-icon {
  width: 50px; height: 50px; display: grid; place-items: center; border-radius: 16px;
  background: var(--accent-soft); border: 1px solid var(--line);
}
.panel-icon .glyph { width: 32px; height: 32px; }
.home-top { position: relative; display: grid; justify-items: center; padding: 0 26px; margin-bottom: 11px; }
.home-top h1 { width: min(100%,291px); }
.home-top h1 img { display: block; width: 100%; height: auto; }
.home-top .icon { position: absolute; right: 0; top: 0; }
.world { overflow: hidden; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); text-align: left; }
.world-title { display: flex; gap: 9px; padding: 9px 12px; align-items: center; }
.world-title h2 { font-size: 1.32rem; line-height: 1.1; letter-spacing: -.026em; }
.world-symbol { width: 38px; height: 38px; }
.world-map {
  min-height: 78px; aspect-ratio: 4;
  background: #a6b77d url("assets/art/world_bakery_map.webp") center / cover;
  border-block: 1px solid var(--line);
}
.world-progress { font-size: .75rem; color: var(--soft); }
.world-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; padding: 8px 9px; }
.world-actions .btn { font-size: .82rem; }
.level-note { margin: 2px 11px 8px; color: var(--soft); font-size: .72rem; }
.level-entry { display: grid; grid-template-columns: minmax(0,1fr) 57px; border-top: 1px solid var(--line); }
.level-entry .level { border-bottom: 0; }
.zen-entry {
  display: grid; place-content: center; justify-items: center; gap: 2px; min-height: 44px;
  border: 0; border-left: 1px solid var(--line); background: transparent; font-size: .64rem;
}
.zen-entry .glyph { width: 20px; height: 20px; }
.zen-entry:disabled { color: var(--soft); }
.zen-entry:enabled:hover { background: var(--well); }
.level-list { display: grid; }
.level {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; text-align: left; border: 0; background: transparent;
  border-bottom: 1px solid var(--line); min-height: 49px; width: 100%;
}
.level:last-child { border-bottom: 0; }
.level:focus-visible { outline-offset: -3px; }
.level:enabled:hover { background: var(--well); }
.level-number {
  border-radius: 8px; background: var(--well); color: var(--soft); width: 25px; height: 25px;
  display: grid; flex: 0 0 25px; place-items: center; font-size: .77rem; font-weight: 800;
}
.level-copy { flex: 1 1 auto; min-width: 0; }
.level-copy strong, .level-copy small { display: block; }
.level-copy strong { font-size: .89rem; line-height: 1.11; }
.level-copy small { font-size: .72rem; line-height: 1.1; color: var(--soft); margin-top: 4px; }
.level .glyph { width: 21px; height: 21px; }
.stars { display: inline-flex; flex: none; gap: 1px; }
.stars span {
  display: inline-block; width: 16px; height: 16px; color: transparent; font-size: 0;
  background: url("assets/ui/star_on.webp") center/contain no-repeat;
}
.stars .off { background-image: url("assets/ui/star_off.webp"); }
.how { margin-top: 12px; font-size: .77rem; color: var(--soft); line-height: 1.35; }
.host-note {
  display: grid; grid-template-columns: 64px 1fr; align-items: center; gap: 10px;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 15px;
  background: var(--surface); text-align: left; margin-bottom: 13px;
}
.host-note img { width: 64px; height: 64px; object-fit: contain; align-self: end; }
.host-note strong { color: var(--accent); font-size: .83rem; }
.host-note p { margin-top: 3px; font-size: .89rem; line-height: 1.34; }
.checks { padding: 0; margin: 0 0 15px; list-style: none; text-align: left; }
.checks li {
  min-height: 36px; display: flex; gap: 7px; align-items: center; padding: 4px 7px;
  border-bottom: 1px solid var(--line); font-size: .84rem; font-weight: 700;
}
.checks .glyph { width: 22px; height: 22px; }
.actions { display: grid; gap: 8px; }
.split { grid-template-columns: 1fr 1fr; }
.btn {
  min-height: 46px; padding: 6px 13px; display: flex; gap: 6px; align-items: center; justify-content: center;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  font-weight: 800; line-height: 1.15;
}
.btn .glyph { width: 21px; height: 21px; }
.btn:hover { background: var(--well); }
.btn.primary { background: var(--sun); color: #3a2414; border-color: var(--sun-edge); box-shadow: 0 2px 0 var(--sun-edge); }
.btn.primary:hover { background: #ffd174; }
.btn.primary:active { transform: translateY(1px); box-shadow: 0 1px 0 var(--sun-edge); }
.setting-list { margin: 0; }
.row {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 5px 8px;
  border-bottom: 1px solid var(--line); padding: 5px 0; font-size: .86rem; font-weight: 800;
}
.row span:first-child { display: flex; align-items: center; gap: 5px; }
.row .glyph { width: 22px; height: 22px; }
.seg { display: flex; gap: 2px; padding: 2px; background: var(--well); border-radius: 11px; }
.seg button {
  min-width: 44px; padding: 0 6px; border: 1px solid transparent; background: transparent;
  border-radius: 8px; font-size: .75rem; font-weight: 800;
}
.seg button[aria-pressed="true"] { background: var(--sun); border-color: var(--sun-edge); color: #3a2414; }
.setting-list + .how { margin: 11px 0 13px; }
.result-head { margin-bottom: 4px; }
.big-stars { display: flex; gap: 4px; margin: 0; }
.big-stars img { display: block; width: 51px; height: 51px; }
.big-stars .on { animation: star .35s ease-out backwards; }
.big-stars :nth-child(2).on { animation-delay: .12s; }
.big-stars :nth-child(3).on { animation-delay: .24s; }
@keyframes star { from { transform: scale(.6) rotate(-16deg); opacity: .65; } to { transform: none; opacity: 1; } }
.results { margin-bottom: 8px; }
.results li::before {
  content: "–"; display: grid; place-items: center; width: 20px; height: 20px;
  border-radius: 7px; background: var(--well); color: var(--soft); flex: none;
}
.results li.ok::before { content: "✓"; background: var(--accent-soft); color: var(--accent); }
.results b { margin-left: auto; font-variant-numeric: tabular-nums; }
.stats {
  display: grid; grid-template-columns: repeat(3,1fr); border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--soft); font-size: .71rem; overflow: hidden; margin-bottom: 9px;
}
.stats span { padding: 7px 3px; }
.stats span + span { border-left: 1px solid var(--line); }
.stats b { color: var(--ink); font-size: .77rem; }
.personal-best { margin: 7px 0; color: var(--accent); font-weight: 800; font-size: .8rem; }
.cellar { position: relative; height: clamp(58px,12vh,106px); border-radius: 11px; overflow: hidden; margin-bottom: 12px; }
.cellar img { width: 100%; height: 100%; object-fit: cover; object-position: center 59%; display: block; }
.cellar figcaption {
  position: absolute; left: 8px; bottom: 7px; background: #3a2414ed; color: #fff4df;
  border-radius: 7px; font-size: .70rem; padding: 4px 7px; font-weight: 800;
}
@media (max-width: 390px) {
  .hud { gap: 5px; }
  .hud-right { gap: 5px; }
  .clock { padding-inline: 6px; }
  .sheet { padding: 17px; }
  .home-top { padding-right: 38px; padding-left: 30px; }
  .level { padding-inline: 8px; }
}
@media (max-height: 650px) {
  .home-top h1 { width: min(100%,233px); }
  .sheet-head { margin-bottom: 12px; }
  .result-head { margin-bottom: 3px; }
  .big-stars img { width: 43px; height: 43px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

.skin-link { width: 100%; margin-top: 10px; }
.skin-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 7px; margin-bottom: 11px; }
.skin-tile { display: grid; justify-items: center; gap: 2px; align-content: start;
  padding: 5px 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: .72rem; }
.skin-tile[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.skin-tile:disabled img { opacity: .61; }
.skin-tile small { color: var(--soft); }
.skin-tabs { display: flex; width: fit-content; margin: 0 auto 12px; }
.face-grid { padding: 0; list-style: none; grid-template-columns: repeat(2,minmax(0,1fr)); }
.face-tile { padding: 8px 6px; gap: 4px; }
.face-tile img { border-radius: 12px; }
.face-tile .btn { min-height: 36px; padding: 4px 12px; font-size: .72rem; }
.face-tile .btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.face-reward { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 6px; padding: 8px; margin: 8px 0; border-radius: 10px; background: var(--accent-soft); }
.face-reward p { margin: 0; }

/* The playtest reuses the campaign HUD and cards. */
.hud.no-clock { grid-template-columns: minmax(0,1fr) auto; }
.order-counts {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 3px 7px;
  margin: 5px 0 0; padding: 0; list-style: none;
  font-size: .7rem; font-variant-numeric: tabular-nums;
}
.order-counts li { display: inline-flex; gap: 3px; white-space: nowrap; }
.order-counts b { color: var(--soft); }
.order-counts .ok b { color: var(--ink); text-decoration: underline; }
.objectives li > b { margin-left: auto; }
a.skin-link { color: var(--ink); text-decoration: none; }

.world-test-menu > .world + .world { margin-top: 10px; }
.goal .world-status { color: var(--accent); font-weight: 800; }

.world-tabs { display:flex; flex-wrap:wrap; gap:.35rem; margin:0 0 .8rem; }
.world-tabs .btn { flex:1; min-width:6.8rem; min-height:2.75rem; padding:.35rem .5rem; font-size:.8rem; }
.world-tabs [aria-pressed="true"] { background:#244f4b; color:#fff8e7; border-color:#244f4b; }
.world-map[data-map="harbour"] { background-image:url("assets/art/world_harbour_map.webp"); }
.world-map[data-map="ridge"] { background-image:url("assets/art/world_ridge_map.webp"); }
.world-map:is([data-map="harbour"],[data-map="ridge"]) { aspect-ratio:2.85; background-color:#aac6bf; }
.world-map[data-map="ridge"] { background-color:#d6a77f; }
.world-stickers { list-style:none; margin:.7rem 0; padding:0; display:grid; grid-template-columns:repeat(2,1fr); gap:.6rem; }
.world-stickers li { display:grid; justify-items:center; align-content:start; text-align:center; padding:.5rem; border-radius:.8rem; background:#f9ecce; min-height:7rem; }
.world-stickers img { width:4rem; height:4rem; object-fit:contain; }
.world-stickers small { padding-top:.25rem; }
