/* Cozy Café Sort — sticker-style UI: warm paper, chunky ink outlines, wood. */

:root {
  --bg: #fff3e4;
  --paper: #fffaf3;
  --cream: #fff6ea;
  --ink: #4a2e22;
  --ink-soft: #8a6a58;
  --ink-faint: rgba(74, 46, 34, .14);
  --wood: #c98b5b;
  --wood-dark: #9c6440;
  --wood-light: #e2ad7e;
  --coral: #ff8a5b;
  --coral-dark: #e0663a;
  --mint: #5fbf98;
  --gold: #ffc94a;
  --font: 'Fredoka', ui-rounded, 'Nunito', 'Segoe UI', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: #f0d6ba;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

#app {
  position: fixed;
  inset: 0;
  max-width: 520px;
  margin: 0 auto;
  overflow: hidden;
  background:
    radial-gradient(circle at 15% -5%, #fffaf2 0, transparent 50%),
    radial-gradient(circle at 110% 105%, #ffd9b6 0, transparent 45%),
    var(--bg);
  box-shadow: 0 0 0 1px rgba(74, 46, 34, .08), 0 20px 60px rgba(74, 46, 34, .2);
}
#app::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(201, 139, 91, .14) 1.6px, transparent 1.7px);
  background-size: 22px 22px;
  pointer-events: none;
}

#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 300; }
#fx-back { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 90; }

/* ---------------------------------------------------------------- screens */

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(.985);
  transition: opacity .32s ease, transform .45s cubic-bezier(.2, .9, .3, 1), visibility 0s .32s;
}
.screen.active {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity .32s ease, transform .45s cubic-bezier(.2, .9, .3, 1), visibility 0s;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 14px) 16px 6px;
}
.currency { display: flex; gap: 8px; }
.screen-title { margin: 0; font-size: 24px; font-weight: 700; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 72px;
  padding: 3px 14px 3px 5px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  font-weight: 700;
  font-size: 18px;
  box-shadow: 0 4px 0 var(--ink-faint);
}
.pill-icon svg { width: 26px; height: 26px; display: block; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
  transition: transform .08s, box-shadow .08s;
}
.icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.icon-btn svg { width: 26px; height: 26px; }

/* ---------------------------------------------------------------- buttons */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border: 3px solid var(--ink);
  border-radius: 18px;
  background: var(--paper);
  font-weight: 600;
  font-size: 18px;
  line-height: 1.1;
  box-shadow: 0 5px 0 var(--ink);
  cursor: pointer;
  transition: transform .08s, box-shadow .08s, filter .2s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { filter: grayscale(.7) opacity(.55); cursor: default; transform: none; box-shadow: 0 5px 0 var(--ink); }
.btn svg { width: 22px; height: 22px; flex: none; }
.btn-primary { background: var(--coral); color: #fff; text-shadow: 0 2px 0 rgba(74, 46, 34, .35); }
.btn-mint { background: var(--mint); color: #fff; text-shadow: 0 2px 0 rgba(74, 46, 34, .3); }
.btn-gold { background: var(--gold); }
.btn-secondary { background: var(--paper); }
.btn-danger { background: #f8cfc4; }
.btn-big { font-size: 24px; padding: 14px 24px; border-radius: 22px; }
.btn-small { font-size: 15px; padding: 8px 12px; border-radius: 14px; box-shadow: 0 3px 0 var(--ink); }
.btn-small:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.btn.glow { animation: glow 1.6s ease-in-out infinite; }
.inline-icon { display: inline-flex; }
.inline-icon svg { width: 20px; height: 20px; }

@keyframes glow {
  0%, 100% { box-shadow: 0 5px 0 var(--ink), 0 0 0 0 rgba(255, 201, 74, 0); }
  50% { box-shadow: 0 5px 0 var(--ink), 0 0 0 7px rgba(255, 201, 74, .55); }
}

.link {
  margin-top: 14px;
  padding: 4px;
  border: 0;
  background: none;
  color: var(--ink-soft);
  font-size: 15px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* ---------------------------------------------------------------- home */

.logo { margin: 4px 0 0; text-align: center; line-height: .95; }
.logo-top {
  display: block;
  font-size: clamp(36px, 10vw, 48px);
  font-weight: 700;
  color: var(--coral);
  letter-spacing: .01em;
  text-shadow:
    2.5px 0 var(--ink), -2.5px 0 var(--ink), 0 2.5px var(--ink), 0 -2.5px var(--ink),
    2px 2px var(--ink), -2px 2px var(--ink), 2px -2px var(--ink), -2px -2px var(--ink),
    0 7px 0 var(--ink);
  animation: logoBob 4s ease-in-out infinite;
}
.logo-sort {
  display: inline-block;
  margin-top: 10px;
  padding: 2px 14px 2px 18px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: var(--mint);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .32em;
  box-shadow: 0 4px 0 var(--ink);
  transform: rotate(-3deg);
}
@keyframes logoBob { 0%, 100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-4px) rotate(1deg); } }

.home-hero, .cafe-hero {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px 10px;
  container-type: size;
}
.cafe-frame {
  display: block;
  width: min(100cqw, 80cqh);
  aspect-ratio: 4 / 5;
  padding: 0;
  overflow: hidden;
  border: 3px solid var(--ink);
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 8px 0 var(--ink-faint), 0 20px 40px rgba(74, 46, 34, .18);
}
button.cafe-frame { cursor: pointer; transition: transform .2s; }
button.cafe-frame:active { transform: scale(.98); }
.cafe-svg { display: block; width: 100%; height: 100%; }

.home-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 26px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
}
.bar {
  flex: 1;
  height: 14px;
  overflow: hidden;
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  background: var(--cream);
}
.bar i {
  display: block;
  height: 100%;
  width: calc(var(--p, 0) * 100%);
  border-radius: 999px;
  background: linear-gradient(90deg, var(--mint), #9be0c2);
  transition: width .7s cubic-bezier(.2, .9, .3, 1);
}

.home-actions {
  display: grid;
  gap: 14px;
  padding: 16px 22px calc(env(safe-area-inset-bottom) + 22px);
}
.btn-play { padding: 12px 24px; gap: 14px; }
.play-icon svg { width: 34px; height: 34px; }
.play-text { display: flex; flex-direction: column; align-items: flex-start; font-size: 28px; line-height: 1; }
.play-text small { font-size: 15px; font-weight: 500; opacity: .92; margin-top: 3px; }
.home-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.home-row .btn { font-size: 17px; padding: 11px 10px; }
.dot-badge {
  position: absolute;
  top: -10px;
  right: -8px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 2.5px solid var(--ink);
  border-radius: 50%;
  background: var(--gold);
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  text-shadow: none;
  animation: badgePop 1.4s ease-in-out infinite;
}
@keyframes badgePop { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.18); } }

/* ---------------------------------------------------------------- game HUD */

.game-top {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 12px) 14px 4px;
}
.level-title { text-align: center; min-width: 0; }
.lvl { font-size: 26px; font-weight: 700; line-height: 1.05; }
.sub { font-size: 13px; font-weight: 500; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.moves-pill {
  min-width: 80px;
  padding: 3px 10px 4px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: var(--paper);
  text-align: center;
  box-shadow: 0 4px 0 var(--ink-faint);
}
.star-meter { display: flex; justify-content: center; gap: 1px; }
.m-star svg { width: 17px; height: 17px; display: block; transition: transform .3s; }
.m-star svg path { transition: fill .3s; }
.m-star.off svg { transform: scale(.85); }
.m-star.off svg path { fill: #eadccc; }
.moves-row { font-size: 13px; color: var(--ink-soft); font-weight: 600; line-height: 1.1; }
.moves-row b { color: var(--ink); font-size: 20px; margin-right: 2px; }

.board-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 44px 10px 12px;
}

.coach {
  position: absolute;
  top: 6px;
  left: 50%;
  z-index: 10;
  max-width: 90%;
  padding: 8px 16px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: var(--paper);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 4px 0 var(--ink-faint);
  transform: translateX(-50%);
  animation: coachIn .4s cubic-bezier(.2, 1.4, .4, 1);
}
@keyframes coachIn { from { transform: translate(-50%, -10px) scale(.9); opacity: 0; } }

/* ---------------------------------------------------------------- board */

.board {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: center;
  column-gap: var(--gap-x, 12px);
  row-gap: var(--gap-y, 32px);
  touch-action: none;
}

.shelf {
  position: relative;
  z-index: 1;
  width: var(--shelf-w);
  height: var(--shelf-h);
  cursor: pointer;
}
.shelf.selected, .shelf.flying { z-index: 6; }

.shelf-back {
  position: absolute;
  inset: 0 0 calc(var(--shelf-w) * .08) 0;
  border: 3px solid var(--ink);
  border-radius: calc(var(--shelf-w) * .26) calc(var(--shelf-w) * .26) 12px 12px;
  background:
    linear-gradient(90deg, rgba(201, 139, 91, .18), transparent 24%, transparent 76%, rgba(201, 139, 91, .18)),
    linear-gradient(#fffaf3, #fbe7cf);
  box-shadow: inset 0 6px 0 rgba(255, 255, 255, .75), 0 6px 14px rgba(74, 46, 34, .08);
  transition: background .25s, box-shadow .25s, transform .25s;
}
.shelf-lip {
  position: absolute;
  left: -6px;
  right: -6px;
  bottom: 0;
  height: calc(var(--shelf-w) * .2);
  border: 3px solid var(--ink);
  border-radius: 10px;
  background:
    repeating-linear-gradient(90deg, transparent 0 14px, rgba(74, 46, 34, .08) 14px 16px),
    linear-gradient(var(--wood-light), var(--wood) 55%, var(--wood-dark));
  box-shadow: 0 5px 0 rgba(74, 46, 34, .22);
}
.shelf-items { position: absolute; inset: 0; }

.shelf.selected .shelf-back {
  background: linear-gradient(#fff7e2, #ffe9bf);
  box-shadow: inset 0 6px 0 rgba(255, 255, 255, .75), 0 0 0 4px var(--gold);
}
.shelf.packed .shelf-back {
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, .5) 0 8px, transparent 8px 16px),
    linear-gradient(#fff6d6, #ffe3a3);
}
.shelf-ribbon {
  position: absolute;
  top: calc(var(--shelf-w) * -.3);
  left: 50%;
  z-index: 4;
  width: calc(var(--shelf-w) * .9);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -16px) scale(.3) rotate(-20deg);
  transition: transform .5s cubic-bezier(.2, 1.6, .4, 1), opacity .2s;
}
.shelf-ribbon svg { display: block; width: 100%; }
.shelf.packed .shelf-ribbon { opacity: 1; transform: translate(-50%, 0) scale(1) rotate(0); }

.shelf.hint-from .shelf-back, .shelf.hint-to .shelf-back {
  border-color: var(--mint);
  background: linear-gradient(#f2fbf6, #dff3e8);
  animation: hintPulse 1s ease-in-out infinite;
}
@keyframes hintPulse {
  0%, 100% { box-shadow: inset 0 6px 0 rgba(255, 255, 255, .75), 0 0 0 0 rgba(95, 191, 152, 0); }
  50% { box-shadow: inset 0 6px 0 rgba(255, 255, 255, .75), 0 0 0 7px rgba(95, 191, 152, .8); }
}

.item {
  position: absolute;
  left: 50%;
  bottom: calc(var(--pad-b) + var(--i) * var(--step));
  width: var(--item);
  height: var(--item);
  margin-left: calc(var(--item) / -2);
  pointer-events: none;
  transition: transform .26s cubic-bezier(.3, 1.6, .5, 1);
}
.item.lifted { transform: translateY(calc(var(--item) * -.62)); }
.item.lifted .bob { animation: float 1.2s ease-in-out infinite; }
.bob, .art { width: 100%; height: 100%; }
.art { transform: scale(var(--scale, 1)); transform-origin: 50% 92%; }
.art svg { display: block; width: 100%; height: 100%; overflow: visible; }
@keyframes float {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-5px) rotate(3deg); }
}

/* Recipe Sort: ingredients merge away and the finished treat is served. */
.shelf.served .item {
  opacity: 0;
  transform: translateY(calc(var(--step) * -.4)) scale(.35);
  transition: transform .38s cubic-bezier(.5, 0, .7, .4), opacity .3s ease-in .08s;
}
.dish {
  position: absolute;
  left: 50%;
  bottom: calc(var(--pad-b) + var(--step) * .3);
  z-index: 3;
  width: calc(var(--item) * 1.18);
  transform: translateX(-50%);
  pointer-events: none;
  text-align: center;
}
.dish svg { display: block; width: 100%; height: auto; overflow: visible; }
.dish-name {
  display: inline-block;
  margin-top: 4px;
  padding: 1px 8px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.recipe-book {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 6px;
  padding: 4px 14px 0;
}
.recipe-card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 3px 4px;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  background: var(--paper);
  transition: background .3s;
}
.recipe-card .r-ing { width: 22px; height: 22px; flex: none; }
.recipe-card .r-ing svg { width: 100%; height: 100%; display: block; }
.recipe-card .r-dish { width: 26px; height: 26px; flex: none; }
.recipe-card .r-dish svg { width: 100%; height: 100%; display: block; }
.recipe-card .r-sep { font-size: 11px; font-weight: 700; color: var(--ink-soft); }
.recipe-card.done { background: #dff4e9; }
.recipe-card.done::after {
  content: '✓';
  position: absolute;
  top: -8px;
  right: -6px;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--mint);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}
.rule-art.recipe { align-items: center; }
.rule-art .rule-eq { font-size: 24px; font-weight: 700; color: var(--ink-soft); margin: 0 2px; }
.rule-art.recipe span { width: 52px; height: 52px; }
.rule-card .rule-art.recipe span { width: 22px; height: 22px; }
.rule-card .rule-art.recipe .rule-eq { font-size: 14px; margin: 0 1px 4px; }

.hand {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 20;
  width: 54px;
  margin: -5px 0 0 -22px;
  opacity: 0;
  pointer-events: none;
  transition: transform .5s cubic-bezier(.3, .9, .3, 1), opacity .25s;
}
.hand.show { opacity: 1; }
.hand svg {
  display: block;
  width: 100%;
  transform-origin: 40% 10%;
  filter: drop-shadow(0 4px 0 rgba(74, 46, 34, .25));
  animation: tap 1.1s ease-in-out infinite;
}
@keyframes tap {
  0%, 100% { transform: translateY(10px) scale(1); }
  45% { transform: translateY(0) scale(.9); }
}

/* ---------------------------------------------------------------- boosters */

.boosters {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 6px 16px calc(env(safe-area-inset-bottom) + 16px);
}
.booster {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 9px 4px 7px;
  border: 3px solid var(--ink);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
  transition: transform .08s, box-shadow .08s, opacity .2s;
}
.booster:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.booster.inactive { opacity: .5; }
.booster.plain { background: #f7ece0; }
.b-icon svg { width: 28px; height: 28px; display: block; }
.b-label { font-size: 13px; font-weight: 600; }
.booster .count {
  position: absolute;
  top: -10px;
  right: -7px;
  display: grid;
  place-items: center;
  min-width: 25px;
  height: 25px;
  padding: 0 6px;
  border: 2.5px solid var(--ink);
  border-radius: 13px;
  background: var(--coral);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}
.booster.empty .count { background: var(--mint); }
.booster .count:empty { display: none; }

/* ---------------------------------------------------------------- toast */

.toast {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom) + 104px);
  left: 50%;
  z-index: 250;
  max-width: 92%;
  padding: 9px 18px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity .25s, transform .3s cubic-bezier(.2, 1.4, .4, 1);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
/* The café's bottom panel holds the task card; show messages over the scene instead. */
#app[data-screen="cafe"] .toast { bottom: auto; top: calc(env(safe-area-inset-top) + 84px); }

/* ---------------------------------------------------------------- modals */

.modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  background: rgba(74, 46, 34, .45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity .22s ease;
}
.modal-backdrop.open { opacity: 1; }
.modal {
  position: relative;
  width: min(100%, 400px);
  max-height: 100%;
  overflow: auto;
  padding: 26px 22px 22px;
  border: 3px solid var(--ink);
  border-radius: 28px;
  background: var(--paper);
  text-align: center;
  box-shadow: 0 10px 0 rgba(74, 46, 34, .3);
  transform: scale(.85) translateY(24px);
  transition: transform .4s cubic-bezier(.2, 1.4, .4, 1);
}
.modal.win { overflow: visible; padding-top: 34px; }
.modal-backdrop.open .modal { transform: none; }
.modal h2 { margin: 2px 0 6px; font-size: 28px; line-height: 1.1; }
.modal p { margin: 6px 0; color: var(--ink-soft); font-size: 16px; line-height: 1.4; }
.modal .stack { display: grid; gap: 12px; margin-top: 18px; }
.modal .fine { margin-top: 14px; font-size: 13px; }
.modal-x {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  background: var(--cream);
  cursor: pointer;
}
.modal-x svg { width: 18px; height: 18px; }
.modal-icon { display: inline-grid; place-items: center; width: 64px; height: 64px; margin-bottom: 4px; border: 3px solid var(--ink); border-radius: 20px; background: var(--gold); }
.modal-icon svg { width: 34px; height: 34px; }
.eyebrow { font-size: 13px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--coral-dark); }
.tips { margin: 12px 0 0; padding: 0; list-style: none; text-align: left; display: grid; gap: 6px; }
.tips li { position: relative; padding-left: 26px; font-weight: 500; }
.tips li::before { content: ''; position: absolute; left: 4px; top: 5px; width: 12px; height: 12px; border: 2.5px solid var(--ink); border-radius: 50%; background: var(--mint); }

.rule-art { display: flex; justify-content: center; align-items: flex-end; gap: 4px; height: 76px; margin: 10px 0 4px; }
.rule-art span { display: block; width: calc(64px * var(--s, 1)); height: calc(64px * var(--s, 1)); }
.rule-art svg { width: 100%; height: 100%; display: block; overflow: visible; }

/* win */
.banner {
  display: inline-block;
  margin: -62px auto 6px;
  padding: 6px 24px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: var(--coral);
  color: #fff;
  font-size: 28px;
  font-weight: 700;
  text-shadow: 0 2px 0 rgba(74, 46, 34, .35);
  box-shadow: 0 5px 0 var(--ink);
  transform: rotate(-2deg);
}
.win-stars { display: flex; justify-content: center; align-items: flex-end; gap: 2px; margin: 8px 0 2px; }
.win-star { width: 64px; height: 64px; transform: scale(0) rotate(-30deg); }
.win-star.mid { width: 84px; height: 84px; margin-bottom: 12px; }
.win-star svg { display: block; width: 100%; height: 100%; }
.win-star.on { animation: starPop .55s cubic-bezier(.2, 1.7, .4, 1) forwards; }
.win-star.dim { animation: starDim .4s ease forwards; }
.win-star.dim svg path { fill: #eadccc; }
@keyframes starPop { to { transform: scale(1) rotate(0); } }
@keyframes starDim { to { transform: scale(.82); } }
.win-line { font-weight: 600; color: var(--ink) !important; }
.win-line span { color: var(--ink-soft); font-weight: 500; }
.rewards { display: flex; justify-content: center; gap: 10px; margin: 10px 0 2px; }
.reward {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 16px 4px 6px;
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  background: var(--cream);
  font-size: 19px;
}
.reward svg { width: 28px; height: 28px; }

/* rule lab */
.rule-cards { display: grid; gap: 12px; margin-top: 16px; }
.rule-card {
  display: grid;
  grid-template-columns: 112px 1fr;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 3px solid var(--ink);
  border-radius: 20px;
  background: var(--paper);
  text-align: left;
  box-shadow: 0 4px 0 var(--ink-faint);
  cursor: pointer;
}
.rule-card.active { background: #fff1d4; box-shadow: 0 0 0 4px var(--gold); }
@media (max-width: 380px) {
  .rule-card { grid-template-columns: 1fr; gap: 4px; padding: 10px 12px; }
  .rule-card .rule-art { justify-content: flex-start; height: 40px; }
  .rule-desc { font-size: 13px; }
  .modal { padding: 22px 16px 18px; }
  .modal h2 { font-size: 24px; }
}
.rule-card .rule-art { height: 56px; margin: 0; gap: 0; }
.rule-card .rule-art span { width: calc(36px * var(--s, 1)); height: calc(36px * var(--s, 1)); }
.rule-name { font-size: 19px; font-weight: 700; }
.rule-desc { font-size: 14px; color: var(--ink-soft); line-height: 1.3; margin: 2px 0 4px; }
.rule-meta { font-size: 13px; font-weight: 600; color: var(--coral-dark); }

/* variant picker */
.swatches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.swatch {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 12px 6px;
  border: 3px solid var(--ink);
  border-radius: 18px;
  background: var(--paper);
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
}
.swatch:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.swatch-chip { width: 54px; height: 54px; border: 3px solid var(--ink); border-radius: 50%; }

/* settings */
.settings { margin-top: 10px; text-align: left; }
.setting-row { display: flex; align-items: center; justify-content: space-between; padding: 11px 2px; border-bottom: 2px dashed var(--ink-faint); }
.setting-label { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; font-size: 17px; }
.setting-label svg { width: 22px; height: 22px; }
.switch {
  position: relative;
  width: 54px;
  height: 32px;
  padding: 0;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: #eadccc;
  cursor: pointer;
  transition: background .2s;
}
.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--ink);
  border-radius: 50%;
  background: #fff;
  transition: transform .25s cubic-bezier(.3, 1.5, .5, 1);
}
.switch[aria-checked="true"] { background: var(--mint); }
.switch[aria-checked="true"]::after { transform: translateX(22px); }

.playtest { margin-top: 16px; text-align: left; border: 3px solid var(--ink); border-radius: 18px; background: var(--cream); overflow: hidden; }
.playtest summary { display: flex; align-items: center; gap: 8px; padding: 10px 14px; font-weight: 600; cursor: pointer; list-style: none; }
.playtest summary::-webkit-details-marker { display: none; }
.playtest summary svg { width: 20px; height: 20px; }
.pt-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 0 12px 10px; }
.pt-stats div { display: grid; padding: 8px 4px; border-radius: 12px; background: var(--paper); text-align: center; }
.pt-stats b { font-size: 17px; }
.pt-stats span { font-size: 11px; color: var(--ink-soft); }
.pt-row { display: flex; align-items: center; gap: 8px; padding: 0 12px 12px; flex-wrap: wrap; font-weight: 600; font-size: 15px; }
.pt-row input {
  width: 72px;
  padding: 6px 8px;
  border: 2.5px solid var(--ink);
  border-radius: 10px;
  background: #fff;
  font: inherit;
  color: inherit;
}

/* ---------------------------------------------------------------- café */

.cafe-panel { display: grid; gap: 12px; padding: 6px 20px calc(env(safe-area-inset-bottom) + 18px); }
.cafe-panel .home-progress { padding: 0 4px; }
.task-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  padding: 10px 10px 10px 16px;
  border: 3px solid var(--ink);
  border-radius: 20px;
  background: var(--paper);
  box-shadow: 0 4px 0 var(--ink-faint);
}
.task-label { font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); }
.task-name { font-size: 20px; font-weight: 700; }
.task-card .btn { flex: none; gap: 4px; }

.cafe-obj { transition: opacity .5s, filter .5s; }
.cafe-obj.todo { opacity: .16; filter: grayscale(1); }
.cafe-obj.restore-pop { animation: restorePop .85s cubic-bezier(.2, 1.5, .4, 1) both; transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes restorePop {
  0% { transform: scale(.4); opacity: 0; filter: brightness(1.8); }
  60% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); filter: none; }
}
.tag { cursor: pointer; }
.tag circle { fill: var(--cream); stroke: var(--ink); stroke-width: 2.5; }
.tag text { font: 700 13px var(--font); fill: var(--ink); }
.tag.can circle { fill: var(--gold); }
.tag.can.next { animation: tagPulse 1.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.tag.locked { opacity: .5; }
@keyframes tagPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.14); } }
.cat-z { animation: zz 2.6s ease-in-out infinite; transform-box: fill-box; }
@keyframes zz { 0%, 100% { transform: translateY(0); opacity: 1; } 50% { transform: translateY(-5px); opacity: .5; } }

/* ---------------------------------------------------------------- simulated ad */

.fake-ad {
  position: absolute;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 16px) 22px calc(env(safe-area-inset-bottom) + 24px);
  background: radial-gradient(circle at 50% 35%, #4a3a31, #1d1612 70%);
  color: #fff;
  opacity: 0;
  transition: opacity .25s;
}
.fake-ad.open { opacity: 1; }
.fake-ad-top { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; opacity: .8; }
.fake-ad-count { display: grid; place-items: center; width: 34px; height: 34px; border: 2px solid #fff; border-radius: 50%; font-size: 16px; letter-spacing: 0; }
.fake-ad-body { text-align: center; }
.fake-ad-art { width: 140px; height: 140px; margin: 0 auto 10px; animation: logoBob 2.4s ease-in-out infinite; }
.fake-ad-art svg { width: 100%; height: 100%; }
.fake-ad h3 { margin: 0 0 6px; font-size: 24px; }
.fake-ad p { margin: 0 auto; max-width: 300px; opacity: .75; line-height: 1.4; }

.boot-error {
  position: absolute;
  inset: 0;
  z-index: 400;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  background: var(--bg);
  font-size: 18px;
  font-weight: 600;
}

/* ---------------------------------------------------------------- small / short screens */

@media (max-height: 700px) {
  .logo-top { font-size: 34px; }
  .logo-sort { margin-top: 6px; font-size: 14px; }
  .home-actions { gap: 10px; padding-top: 10px; }
  .btn-play { padding: 8px 20px; }
  .play-text { font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------------------------------------------------------------- layered drinks */

/* Shelves become tall glasses; layers sit flush inside. */
.board[data-rule="drinks"] .shelf-back {
  inset: 0 6% calc(var(--shelf-w) * .08) 6%;
  border-radius: 10px 10px calc(var(--shelf-w) * .3) calc(var(--shelf-w) * .3);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, .9) 0 9%, transparent 9% 84%, rgba(255, 255, 255, .55) 84% 90%, transparent 90%),
    linear-gradient(#f4fbff, #e3f2fb);
  box-shadow: inset 0 -8px 0 rgba(140, 200, 236, .25), 0 6px 14px rgba(74, 46, 34, .08);
}
.board[data-rule="drinks"] .shelf-lip {
  left: 2px;
  right: 2px;
  height: calc(var(--shelf-w) * .14);
  border-radius: 999px;
  background: linear-gradient(#e7f3fa, #c6dfee);
}
.board[data-rule="drinks"] .shelf.selected .shelf-back { background: linear-gradient(#fffbea, #ffefc4); }
.board[data-rule="drinks"] .shelf.packed .shelf-back { background: linear-gradient(#fff9e0, #ffe8a8); }
.board[data-rule="drinks"] .item.lifted { transform: translateY(calc(var(--item) * -.5)) rotate(-8deg); }
.board[data-rule="drinks"] .item.lifted .bob { animation-duration: 1.6s; }
.rule-art span.liquid { height: 34px; align-self: center; }
.rule-card .rule-art span.liquid { height: 14px; }
.recipe-card.drinks .r-ing { height: 15px; }

/* ---------------------------------------------------------------- unlocks & café */

.tag .unlock-dot, .tag.can .unlock-dot { fill: var(--mint); stroke: var(--ink); stroke-width: 2; }
.task-unlock { margin-top: 2px; font-size: 13px; font-weight: 600; color: var(--mint-dark, #3f9d7a); }
.travel-btn { justify-self: center; }
.unlock-hint { margin: -4px 0 0 !important; font-size: 13px !important; font-weight: 600; color: var(--mint-dark, #3f9d7a) !important; }
.tip-line { font-size: 14px !important; font-weight: 600; color: var(--coral-dark) !important; }
.unlock-list { display: grid; gap: 10px; margin-top: 14px; text-align: left; }
.unlock-row {
  display: grid;
  grid-template-columns: 56px 1fr;
  align-items: center;
  gap: 12px;
  padding: 8px 12px 8px 8px;
  border: 3px solid var(--ink);
  border-radius: 18px;
  background: var(--cream);
}
.unlock-art { display: grid; place-items: center; width: 56px; height: 56px; }
.unlock-art svg { width: 100%; height: 100%; overflow: visible; }
.unlock-text { display: grid; line-height: 1.2; }
.unlock-text small { font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--coral-dark); }
.unlock-text b { font-size: 18px; }
.unlock-text em { font-style: normal; font-size: 13px; color: var(--ink-soft); }
.booster.free .count { background: var(--mint); color: #fff; font-size: 10px; }

/* ---------------------------------------------------------------- rule lab */

.lab-label {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 18px 2px 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  text-align: left;
}
.lab-label span { font-size: 11px; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--ink-soft); }
.lab .rule-cards { margin-top: 0; gap: 8px; }
.lab .rule-card { padding: 8px 10px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.segmented button {
  display: grid;
  gap: 2px;
  padding: 10px 8px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: var(--paper);
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.segmented button b { font-size: 17px; }
.segmented button small { font-size: 12px; color: var(--ink-soft); }
.segmented button.active { background: #fff1d4; box-shadow: 0 0 0 4px var(--gold); }
.segmented.muted { opacity: .5; }

/* ---------------------------------------------------------------- playtest */

.pt-modes { width: calc(100% - 24px); margin: 0 12px 12px; border-collapse: collapse; font-size: 12px; }
.pt-modes th, .pt-modes td { padding: 4px; border-bottom: 1.5px solid var(--ink-faint); text-align: left; }
.pt-modes th { font-size: 11px; color: var(--ink-soft); }
.pt-row input.wide { flex: 1; min-width: 120px; }
.report-text {
  width: 100%;
  min-height: 220px;
  margin-top: 10px;
  padding: 10px;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  font: 12px/1.4 ui-monospace, monospace;
}
.lab .rule-cards { grid-template-columns: 1fr 1fr; }
.lab .rule-card { grid-template-columns: 1fr; justify-items: center; gap: 2px; padding: 8px 6px; text-align: center; }
.lab .rule-card .rule-art { justify-content: center; height: 44px; }
.lab .rule-name { font-size: 16px; line-height: 1.15; }
.lab-desc { margin: 10px 2px 0 !important; font-size: 14px !important; text-align: left; }

/* ---------------------------------------------------------------- v0.3: journey, tiers, customers, rewards */

.home-hero { position: relative; }
.income-bubble {
  position: absolute;
  top: 18px;
  right: 22px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px 5px 7px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: var(--gold);
  box-shadow: 0 4px 0 var(--ink);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  animation: bubbleBob 2.2s ease-in-out infinite;
}
.income-bubble svg { width: 24px; height: 24px; display: block; }
@keyframes bubbleBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

.home-extras { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px 22px 0; }
.chip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 10px;
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  background: var(--paper);
  box-shadow: 0 3px 0 var(--ink);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.chip svg { width: 20px; height: 20px; display: block; flex: none; }
.chip:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.chip.muted { color: var(--ink-soft); background: var(--cream); }
.chip.glow { background: #fff1c9; animation: chipGlow 1.6s ease-in-out infinite; }
@keyframes chipGlow {
  0%, 100% { box-shadow: 0 3px 0 var(--ink), 0 0 0 0 rgba(255, 201, 74, 0); }
  50% { box-shadow: 0 3px 0 var(--ink), 0 0 0 5px rgba(255, 201, 74, .55); }
}
.home-actions { padding-top: 12px; }

.tier-tag {
  display: inline-block;
  padding: 1px 8px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  vertical-align: middle;
  white-space: nowrap;
}
.tier-tag.tier-easy { background: #dff4e9; }
.tier-tag.tier-hard { background: var(--coral); color: #fff; }
.tier-tag.tier-super { background: #8e5bd8; color: #fff; }
.lvl .tier-tag { font-size: 11px; transform: translateY(-3px); }

.goal-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 14px 0;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-soft);
  white-space: nowrap;
}
.goal-pill b { color: var(--ink); font-weight: 600; }
.goal-pill .inline-icon svg { width: 13px; height: 13px; vertical-align: -2px; }
.goal-pill .bar { height: 9px; border-width: 2px; min-width: 50px; }
#goal-text { overflow: hidden; text-overflow: ellipsis; }

.recipe-book { padding-top: 12px; row-gap: 12px; }
.recipe-card { padding-left: 18px; }
.r-face {
  position: absolute;
  top: -11px;
  left: -9px;
  width: 26px;
  height: 26px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  overflow: hidden;
  background: #ffe9d2;
}
.r-face svg { width: 100%; height: 100%; display: block; }
.recipe-card.done .r-face { background: #dff4e9; }
.recipe-book.tickets { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px 8px; }
.recipe-card.ticket { padding: 3px 6px 3px 18px; }
.recipe-card.ticket .r-dish { width: 24px; height: 24px; }
.tip-float {
  position: absolute;
  top: -14px;
  right: -4px;
  display: flex;
  align-items: center;
  gap: 1px;
  font-size: 14px;
  font-weight: 700;
  color: var(--coral-dark);
  pointer-events: none;
  animation: tipFloat 1.3s ease-out forwards;
}
.tip-float svg { width: 16px; height: 16px; }
@keyframes tipFloat { 0% { opacity: 0; transform: translateY(6px); } 20% { opacity: 1; } 100% { opacity: 0; transform: translateY(-24px); } }

.ad-double { width: 100%; margin: 8px 0 4px; }
.ad-double svg { width: 20px; height: 20px; }
.tip-line.doubled { color: var(--mint-dark, #3f9d7a) !important; }
.chest-row { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 8px 0 12px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.chest-row .bar { max-width: 140px; height: 11px; }
.chest-icon svg, .chest-won svg { width: 22px; height: 22px; vertical-align: -5px; }
.chest-won { margin: 8px 0 12px !important; }
.modal-icon.gift svg { color: var(--coral-dark); }

.pre-tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 4px 0 2px; }
.pre-tags .tier-tag { font-size: 13px; padding: 2px 10px; }
.pre-perk { padding: 2px 10px; border-radius: 999px; background: #fff1c9; font-size: 13px; font-weight: 600; }
.pre-perk svg { width: 14px; height: 14px; vertical-align: -2px; }
.pre-best { display: flex; justify-content: center; gap: 4px; margin: 2px 0 8px; }
.pre-best span { width: 26px; height: 26px; }
.pre-best svg { width: 100%; height: 100%; }
.pre-best .off { filter: grayscale(1) opacity(.35); }

.streak { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 6px 0 10px; }
.streak-day {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 6px 2px;
  border: 2px solid var(--ink-faint);
  border-radius: 12px;
  background: var(--paper);
  font-size: 12px;
  line-height: 1.15;
}
.streak-day small { font-size: 10px; color: var(--ink-soft); font-weight: 600; }
.streak-day.past { opacity: .5; }
.streak-day.past::after { content: '✓'; color: var(--mint); font-weight: 700; }
.streak-day.today { border-color: var(--ink); background: var(--gold); }

/* Journey map */
#screen-map .topbar { position: relative; z-index: 2; }
.map-scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 10px 0 calc(env(safe-area-inset-bottom) + 30px); }
.map-path {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  background: linear-gradient(var(--wood-light), var(--wood-light)) center / 8px 100% no-repeat;
}
.map-row { display: flex; flex-direction: column; align-items: center; gap: 4px; transform: translateX(calc(var(--x) * 72px)); }
.map-new {
  padding: 3px 12px;
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  background: var(--mint);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 3px 0 var(--ink);
}
.map-node {
  position: relative;
  display: grid;
  place-items: center;
  width: 70px;
  height: 70px;
  padding: 0;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 5px 0 var(--ink);
  cursor: pointer;
}
.map-node:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--ink); }
.map-node .map-art { position: absolute; inset: 9px; opacity: .9; }
.map-node .map-art svg { width: 100%; height: 100%; display: block; }
.map-node b {
  position: absolute;
  bottom: -9px;
  left: 50%;
  min-width: 30px;
  padding: 0 6px;
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  font-size: 14px;
  line-height: 1.3;
  transform: translateX(-50%);
}
.map-node.done { background: #dff4e9; }
.map-node.current { background: #fff1c9; animation: chipGlow 1.4s ease-in-out infinite; }
.map-node.current b { background: var(--coral); color: #fff; }
.map-node.locked { background: var(--cream); box-shadow: 0 5px 0 var(--ink-faint); border-color: rgba(74, 46, 34, .45); }
.map-node.locked .map-art { filter: grayscale(1) opacity(.35); }
.map-node.tier-hard { border-color: var(--coral-dark); }
.map-node.tier-super { border-color: #8e5bd8; border-width: 4px; }
.map-tier {
  position: absolute;
  top: -8px;
  right: -10px;
  padding: 0 6px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--coral);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.map-node.tier-super .map-tier { background: #8e5bd8; }
.map-stars { position: absolute; top: -10px; left: 50%; display: flex; transform: translateX(-50%); }
.map-stars i { width: 17px; height: 17px; display: block; }
.map-stars svg { width: 100%; height: 100%; display: block; }
.map-stars i.off { filter: grayscale(1) opacity(.4); }
.map-node.tier-hard .map-stars, .map-node.tier-super .map-stars { left: 40%; }
.tip-line svg { width: 16px; height: 16px; vertical-align: -3px; }
.modal.win .stack { gap: 10px; }
.modal.win .win-stars { margin-bottom: 0; }
.modal p svg, .pre-perk svg { width: 1.05em; height: 1.05em; vertical-align: -.18em; }
