:root {
  --ground: #E3EDE4;
  --ground-2: #D2E0D5;
  --paper: #FFFCF4;
  --ink: #25304D;
  --ink-2: #56627F;
  --ink-3: #8C96AC;
  --marigold: #F2A93B;
  --marigold-d: #CF8520;
  --coral: #E8705E;
  --teal: #2F8F82;
  --plum: #5B4A8B;
  --stitch: rgba(37, 48, 77, .26);
  --shadow: 0 2px 0 rgba(37, 48, 77, .1), 0 10px 22px -14px rgba(37, 48, 77, .45);
  --f-display: "Bagel Fat One", "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
  --f-body: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: #C8D8CC;
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 15px;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; padding: 0; }
button:focus-visible { outline: 3px solid var(--marigold); outline-offset: 2px; }
svg { display: block; }
[hidden] { display: none !important; }

#app {
  position: relative;
  max-width: 480px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background-color: var(--ground);
  background-image: radial-gradient(rgba(37, 48, 77, .07) 1.1px, transparent 1.5px);
  background-size: 12px 12px;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.eyebrow {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-2);
}
.eyebrow svg { width: 14px; height: 14px; }
.display {
  font-family: var(--f-display); font-weight: 400; line-height: 1.02;
  margin: 4px 0 8px; font-size: 32px; letter-spacing: .005em; text-wrap: balance;
}
.muted { color: var(--ink-2); font-size: 13px; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 10px; padding: calc(10px + var(--safe-t)) 16px 8px; z-index: 5; }
.icon-btn {
  width: 42px; height: 42px; flex: none; border-radius: 50%;
  display: grid; place-items: center; background: var(--paper); box-shadow: var(--shadow);
}
.icon-btn svg { width: 22px; height: 22px; }
.wallet {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
  background: var(--paper); border-radius: 999px; padding: 6px 14px 6px 7px; box-shadow: var(--shadow);
}
.wallet #wallet-ic svg { width: 26px; height: 26px; }
.wallet b { font-family: var(--f-display); font-weight: 400; font-size: 20px; font-variant-numeric: tabular-nums; }
.wallet small { margin-left: auto; color: var(--teal); font-weight: 800; font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.starcount {
  display: flex; align-items: center; gap: 5px; flex: none;
  background: var(--ink); color: #fff; border-radius: 999px; padding: 9px 13px 9px 10px; box-shadow: var(--shadow);
}
.starcount svg { width: 17px; height: 17px; color: var(--marigold); }
.starcount b { font-variant-numeric: tabular-nums; font-size: 14px; }

/* ---------- screens & tab bar ---------- */
main { position: relative; flex: 1; min-height: 0; }
.screen { position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; display: none; overscroll-behavior: contain; }
.screen.active { display: block; }
.tabbar {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  background: var(--paper); padding: 6px 12px calc(6px + var(--safe-b));
  box-shadow: 0 -1px 0 rgba(37, 48, 77, .08); z-index: 5;
}
.tabbar button {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0 5px; border-radius: 14px; color: var(--ink-3); font-size: 12px; font-weight: 800;
}
.tabbar svg { width: 24px; height: 24px; }
.tabbar button[aria-current="page"] { color: var(--ink); background: var(--ground); }

/* ---------- map ---------- */
#scr-map { background: linear-gradient(180deg, var(--sky, #D4EAD9), var(--land, #B4D8BD)); }
.region-card {
  position: sticky; top: 0; z-index: 3; margin: 4px 16px 0;
  display: flex; align-items: center; gap: 10px;
  background: var(--paper); border-radius: 22px; padding: 12px; box-shadow: var(--shadow);
  outline: 2px dashed var(--stitch); outline-offset: -6px;
}
.rc-mid { flex: 1; min-width: 0; }
.region-card h2 { font-family: var(--f-display); font-weight: 400; font-size: 25px; margin: 1px 0 0; line-height: 1.05; }
.progress { height: 8px; background: var(--ground-2); border-radius: 99px; overflow: hidden; margin: 7px 0 4px; }
.progress i { display: block; height: 100%; width: 0; background: var(--marigold); border-radius: inherit; transition: width .4s; }
.rc-count { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.rc-arrow { width: 40px; height: 52px; flex: none; border-radius: 14px; background: var(--ground); font-size: 30px; line-height: 1; font-weight: 700; }
.rc-arrow:disabled { opacity: .28; cursor: default; }

.map-canvas { position: relative; width: 100%; }
.trail { position: absolute; left: 0; top: 0; pointer-events: none; }
.trail-bed { fill: none; stroke: rgba(255, 252, 244, .72); stroke-width: 28; stroke-linecap: round; }
.trail-stitch { fill: none; stroke: var(--ink); stroke-opacity: .32; stroke-width: 3; stroke-dasharray: 10 9; stroke-linecap: round; }
.deco { position: absolute; font-size: 30px; opacity: .45; pointer-events: none; }
.region-flag {
  position: absolute; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; border-radius: 99px; padding: 6px 14px; font-size: 12px; font-weight: 800; white-space: nowrap;
}

.node {
  position: absolute; width: 58px; height: 58px; margin: -29px 0 0 -29px; border-radius: 50%;
  display: grid; place-items: center; z-index: 1;
  background: var(--paper); color: var(--ink);
  box-shadow: 0 4px 0 #C7B894, 0 10px 16px -8px rgba(37, 48, 77, .5);
}
.node .n { font-family: var(--f-display); font-size: 19px; line-height: 1; font-variant-numeric: tabular-nums; }
.node .mode {
  position: absolute; right: -5px; top: -5px; width: 23px; height: 23px; border-radius: 50%;
  background: var(--ink); color: #fff; display: grid; place-items: center; box-shadow: 0 0 0 2px var(--paper);
}
.node .mode svg { width: 14px; height: 14px; }
.node.t2 { box-shadow: 0 0 0 4px var(--coral), 0 4px 0 4px #B9544A, 0 12px 16px -8px rgba(37, 48, 77, .5); }
.node.t3 { background: var(--plum); color: #fff; box-shadow: 0 0 0 4px var(--marigold), 0 4px 0 4px var(--marigold-d), 0 12px 16px -8px rgba(37, 48, 77, .5); }
.node.locked { background: #E6ECE6; color: var(--ink-3); box-shadow: 0 3px 0 #BFCABF; }
.node.locked.t3 { background: #D9D4E6; }
.node.locked .mode { background: var(--ink-3); }
.node.current { background: var(--marigold); color: var(--ink); box-shadow: 0 4px 0 var(--marigold-d), 0 0 0 7px rgba(242, 169, 59, .35); }
.node .st { position: absolute; bottom: -11px; display: flex; gap: 0; }
.node .st i {
  width: 15px; height: 15px; background: #CFC7B2;
  clip-path: polygon(50% 0, 62% 35%, 98% 36%, 69% 58%, 80% 94%, 50% 72%, 20% 94%, 31% 58%, 2% 36%, 38% 35%);
}
.node .st i.on { background: var(--marigold); }
.node .tag {
  position: absolute; bottom: -9px; font-size: 9px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  background: var(--marigold); color: var(--ink); padding: 2px 6px; border-radius: 99px;
}
.node.chest::after {
  content: ""; position: absolute; left: -9px; bottom: -4px; width: 20px; height: 15px; border-radius: 5px 5px 3px 3px;
  background: linear-gradient(#D09457 0 42%, #6E4524 42% 56%, #D09457 56%);
  box-shadow: 0 0 0 2px var(--ink);
}
.node.chest.done::after { opacity: .35; }
.node .pip { position: absolute; width: 46px; height: 46px; left: -40px; top: -34px; animation: bob 2.6s ease-in-out infinite; pointer-events: none; }
@keyframes bob { 50% { transform: translateY(-5px) rotate(-4deg); } }

.play-cta {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 4;
  display: flex; align-items: baseline; gap: 8px; white-space: nowrap;
  background: var(--ink); color: #fff; border-radius: 999px; padding: 14px 26px;
  box-shadow: 0 5px 0 #151C30, 0 16px 24px -12px rgba(20, 25, 40, .6);
  font-weight: 700;
}
.play-cta b { font-family: var(--f-display); font-weight: 400; font-size: 21px; color: var(--marigold); }
.play-cta:active { transform: translateX(-50%) translateY(3px); box-shadow: 0 2px 0 #151C30; }
main:not([data-tab="map"]) .play-cta { display: none; }

/* ---------- level ---------- */
.level {
  position: fixed; inset: 0; margin: 0 auto; max-width: 480px; z-index: 20;
  display: flex; flex-direction: column;
  background-color: var(--ground);
  background-image: radial-gradient(rgba(37, 48, 77, .07) 1.1px, transparent 1.5px);
  background-size: 12px 12px;
  padding-top: calc(10px + var(--safe-t)); padding-bottom: calc(10px + var(--safe-b));
  user-select: none; -webkit-user-select: none;
}
.lv-top { display: flex; align-items: center; gap: 12px; padding: 0 16px; }
.lv-title { flex: 1; min-width: 0; }
.lv-title .eyebrow { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.lv-title .eyebrow svg { display: inline-block; vertical-align: -2px; margin-right: 4px; }
.lv-title h2 { font-family: var(--f-display); font-weight: 400; font-size: 27px; margin: 0; line-height: 1; }
.chip { flex: none; font-size: 12px; font-weight: 800; padding: 6px 11px; border-radius: 99px; background: var(--ground-2); color: var(--ink); white-space: nowrap; }
.chip.t0 { background: #CBE8DF; color: #1D6B5F; }
.chip.t1 { background: #DFE4EE; color: var(--ink); }
.chip.t2 { background: #F8D3CA; color: #9E3C2C; }
.chip.t3 { background: var(--plum); color: #fff; }
.lv-meta {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 10px 16px 6px; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums;
}
.lv-meta b { color: var(--ink); }
.lv-coins { display: flex; align-items: center; gap: 4px; }
.lv-coins svg { width: 16px; height: 16px; }
#lv-head { padding: 2px 16px 0; }
.goalline { text-align: center; font-size: 13px; color: var(--ink-2); font-weight: 600; }
.board {
  flex: 1; min-height: 0; position: relative;
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 14px;
  padding: 8px 16px; touch-action: none;
}
.boosters { display: flex; justify-content: center; gap: 8px; padding: 4px 16px 0; }
.boost {
  flex: 1; max-width: 100px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: var(--paper); border-radius: 16px; padding: 8px 4px 7px; box-shadow: var(--shadow);
  font-size: 12px; font-weight: 800;
}
.boost > svg { width: 24px; height: 24px; }
.boost small { display: flex; align-items: center; gap: 3px; font-size: 11px; color: var(--ink-2); font-variant-numeric: tabular-nums; font-weight: 700; }
.boost small svg { width: 12px; height: 12px; }
.boost.poor small { color: var(--coral); }
.boost:active { transform: translateY(2px); }

.hint { animation: hintpulse 1s ease-in-out infinite; }
@keyframes hintpulse { 50% { filter: brightness(1.12); transform: scale(1.06); } }
.pop { animation: pop .3s ease-in forwards; }
@keyframes pop { 40% { transform: scale(1.3); } 100% { transform: scale(0); opacity: 0; } }
.enter { animation: enter .28s cubic-bezier(.2, .9, .3, 1.3); }
@keyframes enter { from { transform: scale(.4); opacity: 0; } }
.fly-ghost { position: fixed; z-index: 60; pointer-events: none; margin: 0; }
.drag-ghost { position: fixed; z-index: 60; pointer-events: none; margin: 0; transition: none; }
.burst { position: fixed; z-index: 61; width: 9px; height: 9px; border-radius: 50%; pointer-events: none; }

/* rak */
.shelves { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 18px 10px; width: 100%; }
.shelf {
  position: relative; padding: 20px 5px 0; border-radius: 14px 14px 6px 6px;
  background: linear-gradient(#FDF6E8, #F0E0C3);
  box-shadow: inset 0 -12px 0 #C98F55, 0 4px 0 #9A6838;
}
.shelf.over { box-shadow: inset 0 -12px 0 #C98F55, 0 4px 0 #9A6838, 0 0 0 3px var(--marigold); }
.slots { display: grid; grid-template-columns: repeat(3, 1fr); height: 54px; padding-bottom: 12px; }
.slot { display: grid; place-items: end center; height: 100%; }
.item {
  font-size: var(--is, 30px); line-height: 1; width: 1.3em; height: 1.25em;
  display: grid; place-items: center; transition: transform .15s ease;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, .15));
}
.item.sel { transform: translateY(-10px) scale(1.15); }
.peek {
  position: absolute; left: 6px; right: 6px; top: 3px;
  display: grid; grid-template-columns: repeat(3, 1fr); text-align: center;
  font-size: 14px; line-height: 1; opacity: .38; filter: grayscale(.75);
}
.depth {
  position: absolute; right: -6px; top: -9px; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 99px; background: var(--ink); color: #fff; font-size: 11px; font-weight: 800;
  display: grid; place-items: center;
}
.grill .shelf { background: linear-gradient(#4B413C, #2E2724); box-shadow: inset 0 -12px 0 #1C1715, 0 4px 0 #0F0C0B; }
.grill .slots { background: repeating-linear-gradient(90deg, transparent 0 10px, rgba(255, 255, 255, .1) 10px 12px); border-radius: 6px; }
.grill .shelf::after {
  content: ""; position: absolute; left: 12%; right: 12%; bottom: 8px; height: 12px; pointer-events: none;
  background: radial-gradient(closest-side, rgba(255, 128, 64, .75), transparent); filter: blur(3px);
}
.grill .shelf.over { box-shadow: inset 0 -12px 0 #1C1715, 0 4px 0 #0F0C0B, 0 0 0 3px var(--marigold); }
.grill .peek { filter: grayscale(.3) brightness(1.5); opacity: .45; }

/* kubus */
.board.kubus { --cs: min(36px, calc((min(100vw, 480px) - 72px) / 9)); justify-content: space-evenly; }
#lv-head { --cs: min(30px, calc((min(100vw, 480px) - 48px) / 9 - 8px)); }
.cube {
  --c: #999; position: relative; flex: none;
  width: var(--cs, 34px); height: var(--cs, 34px); border-radius: 24%;
  display: grid; place-items: center;
  background-color: var(--c);
  background-image: linear-gradient(160deg, rgba(255, 255, 255, .5) 0 20%, rgba(255, 255, 255, 0) 21% 70%, rgba(0, 0, 0, .18) 71%);
  box-shadow: 0 2px 0 rgba(0, 0, 0, .22), inset 0 0 0 1.5px rgba(0, 0, 0, .08);
}
.cube b, .ball b { font-size: calc(var(--cs, 34px) * .42); color: rgba(255, 255, 255, .92); text-shadow: 0 1px 0 rgba(0, 0, 0, .3); font-weight: 400; line-height: 1; }
.ball b { font-size: calc(var(--bs, 34px) * .42); }
.cube.mystery, .ball.mystery { --c: #7C8397; color: #fff; font-weight: 800; font-size: 15px; }
.crates { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.crate {
  min-width: 0; border-radius: 12px; padding: 12px 4px 9px;
  background: #fff;
  background: linear-gradient(color-mix(in srgb, var(--c) 22%, #fff), color-mix(in srgb, var(--c) 38%, #fff));
  box-shadow: inset 0 0 0 3px var(--c), 0 3px 0 rgba(0, 0, 0, .2);
}
.crate-slots { display: flex; justify-content: center; gap: 4px; }
.hole { width: var(--cs); height: var(--cs); border-radius: 24%; background: rgba(255, 255, 255, .6); box-shadow: inset 0 2px 3px rgba(0, 0, 0, .14); display: grid; place-items: center; }
.queue { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; margin-top: 8px; font-size: 11px; color: var(--ink-2); font-weight: 700; }
.queue i { width: 14px; height: 14px; border-radius: 4px; background: var(--c); box-shadow: 0 1px 0 rgba(0, 0, 0, .25); }
.queue em { font-style: normal; }
.belt-wrap { width: 100%; }
.belt-label { display: flex; justify-content: space-between; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); margin: 0 4px 5px; font-variant-numeric: tabular-nums; }
.belt {
  width: 100%; display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 4px; padding: 7px; border-radius: 14px;
  background-color: #38425C;
  background-image: repeating-linear-gradient(90deg, rgba(255, 255, 255, .06) 0 12px, transparent 12px 24px);
  background-size: 24px 100%;
  animation: belt 2.8s linear infinite;
  box-shadow: inset 0 0 0 3px #283049, 0 3px 0 rgba(0, 0, 0, .15);
}
.belt.full { box-shadow: inset 0 0 0 3px var(--coral), 0 3px 0 rgba(0, 0, 0, .15); }
@keyframes belt { to { background-position: 24px 0; } }
.bslot { aspect-ratio: 1; display: grid; place-items: center; border-radius: 8px; background: rgba(255, 255, 255, .08); min-width: 0; }
.bslot .cube { width: 86%; height: 86%; }
.piles { display: flex; justify-content: center; gap: 7px; width: 100%; }
.pile {
  display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; max-width: 58px;
  padding: 7px 3px; border-radius: 14px; background: rgba(255, 252, 244, .6); min-height: 56px;
}
.pile .cube:not(.top) { transform: scale(.86); opacity: .92; }
.pile .cube.top { box-shadow: 0 3px 0 rgba(0, 0, 0, .25), 0 0 0 3px #fff; }
.pile em { font-style: normal; font-size: 11px; font-weight: 800; color: var(--ink-2); }
.pile:disabled { opacity: .35; }

/* rajut */
.loom {
  display: grid; grid-template-columns: repeat(12, 1fr); gap: 2px; padding: 10px;
  border-radius: 16px; background: var(--paper); box-shadow: var(--shadow);
  outline: 2px dashed var(--stitch); outline-offset: -5px;
}
.stitch {
  aspect-ratio: 1 / 1.05; border-radius: 3px;
  background: #F2F0EA;
  background: color-mix(in srgb, var(--c) 18%, #fff);
  box-shadow: inset 0 0 0 1px rgba(37, 48, 77, .06);
}
.stitch.on {
  background:
    linear-gradient(62deg, transparent 44%, rgba(0, 0, 0, .17) 45% 55%, transparent 56%) 0 0 / 50% 100% no-repeat,
    linear-gradient(-62deg, transparent 44%, rgba(0, 0, 0, .17) 45% 55%, transparent 56%) 100% 0 / 50% 100% no-repeat,
    var(--c);
  box-shadow: none;
}
.stitch.fresh { animation: knit .45s ease-out both; animation-delay: var(--d, 0ms); }
@keyframes knit { 0% { transform: scale(.2); opacity: .2; } 70% { transform: scale(1.18); } 100% { transform: none; opacity: 1; } }
.tubes {
  display: grid; grid-template-columns: repeat(var(--tc), 1fr); gap: 22px 6px; width: 100%;
  --bs: min(40px, calc((min(100vw, 480px) - 40px) / var(--tc) - 16px));
}
.tube {
  justify-self: center; width: calc(var(--bs) + 12px);
  height: calc(var(--cap) * (var(--bs) + 3px) + 16px);
  display: flex; flex-direction: column-reverse; align-items: center; gap: 3px;
  padding: 6px 0 9px; border-radius: 9px 9px 24px 24px;
  background: linear-gradient(90deg, rgba(255, 255, 255, .35), rgba(255, 255, 255, .75) 40%, rgba(255, 255, 255, .35));
  box-shadow: inset 0 0 0 2.5px rgba(37, 48, 77, .2), 0 3px 0 rgba(37, 48, 77, .1);
}
.tube.sel { box-shadow: inset 0 0 0 3px var(--marigold), 0 0 0 4px rgba(242, 169, 59, .3); }
.tube.spool { animation: spool .38s ease-in; }
@keyframes spool { 50% { transform: scale(1.08) rotate(-3deg); } }
.ball {
  --c: #999; flex: none; width: var(--bs); height: var(--bs); border-radius: 50%;
  display: grid; place-items: center;
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, .55) 0 11%, transparent 12%),
    repeating-linear-gradient(38deg, transparent 0 4px, rgba(0, 0, 0, .13) 4px 6px),
    repeating-linear-gradient(-52deg, transparent 0 7px, rgba(255, 255, 255, .13) 7px 8px),
    var(--c);
  box-shadow: inset -3px -4px 0 rgba(0, 0, 0, .14), 0 1px 0 rgba(0, 0, 0, .18);
  transition: transform .16s ease;
}
.ball.lift { transform: translateY(-20px); }

/* ---------- modal & sheets ---------- */
.modal {
  position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(28, 36, 58, .45);
  padding: 16px; padding-bottom: calc(16px + var(--safe-b));
}
@media (min-height: 640px) { .modal { align-items: center; } }
.sheet {
  position: relative; width: 100%; max-width: 440px; max-height: 88vh; max-height: 88dvh; overflow: auto;
  background: var(--paper); border-radius: 26px; padding: 24px 22px 22px;
  box-shadow: 0 24px 50px -20px rgba(20, 25, 40, .55);
  outline: 2px dashed var(--stitch); outline-offset: -8px;
  animation: rise .3s cubic-bezier(.2, .9, .3, 1.15);
  display: flex; flex-direction: column; gap: 12px;
}
.sheet p { margin: 0; line-height: 1.5; }
@keyframes rise { from { transform: translateY(30px) scale(.97); opacity: 0; } }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 20px; border-radius: 16px; font-weight: 800; font-size: 16px;
}
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--marigold); color: var(--ink); box-shadow: 0 4px 0 var(--marigold-d); }
.btn.primary:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--marigold-d); }
.btn.ink { background: var(--ink); color: #fff; box-shadow: 0 4px 0 #141B2E; }
.btn.ghost { background: var(--ground); color: var(--ink); }
.btn.danger { background: #FBE1DB; color: #9E3C2C; }
.btn.wide { width: 100%; }
.row { display: flex; gap: 10px; }
.row .btn { flex: 1; }
.note { background: var(--ground); border-radius: 12px; padding: 10px 12px; font-size: 13px; }

.pv-top { display: flex; align-items: center; gap: 12px; }
.pv-top > div { flex: 1; min-width: 0; }
.pv-top .display { margin: 2px 0 0; }
.pv-ic { width: 52px; height: 52px; flex: none; border-radius: 16px; background: var(--ink); color: #fff; display: grid; place-items: center; }
.pv-ic svg { width: 28px; height: 28px; }
.pv-stars { display: flex; align-items: center; gap: 4px; }
.pv-stars small { margin-left: 8px; color: var(--ink-2); font-size: 13px; }
.sstar svg { width: 26px; height: 26px; color: #D8D1BF; }
.sstar.on svg { color: var(--marigold); }

.win { text-align: center; align-items: center; }
.bigstars { display: flex; justify-content: center; align-items: flex-end; gap: 6px; margin: 4px 0; }
.bstar svg { width: 58px; height: 58px; color: #DDD6C4; }
.bstar:nth-child(2) svg { width: 74px; height: 74px; }
.bstar.on svg { color: var(--marigold); filter: drop-shadow(0 3px 0 var(--marigold-d)); animation: starin .45s cubic-bezier(.2, .9, .3, 1.5) both; animation-delay: var(--d); }
@keyframes starin { from { transform: scale(0) rotate(-40deg); } }
.reward { display: inline-flex; align-items: center; gap: 8px; font-family: var(--f-display); font-size: 30px; font-variant-numeric: tabular-nums; }
.reward svg { width: 32px; height: 32px; }
.chestline { font-size: 14px; font-weight: 700; color: var(--teal); }

.postcard { background-color: #FFFBF1; background-image: repeating-linear-gradient(0deg, transparent 0 27px, rgba(37, 48, 77, .06) 27px 28px); }
.pc-stamp {
  position: absolute; right: 22px; top: 20px; width: 70px; height: 80px; transform: rotate(6deg);
  background: #fff; border: 3px dotted var(--coral); border-radius: 6px;
  display: grid; place-items: center; font-size: 38px;
}
.postcard .eyebrow, .postcard .display { padding-right: 84px; }
.pc-story { font-size: 15px; line-height: 1.6 !important; max-width: 60ch; }
.pc-souv { display: flex; align-items: center; gap: 12px; background: var(--ground); border-radius: 16px; padding: 10px 12px; }
.pc-souv > span { font-size: 34px; }
.pc-souv b { display: block; }
.pc-souv small { color: var(--ink-2); font-size: 12px; }

.settings .tog { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--stitch); font-weight: 700; }
.settings .tog small { display: block; font-weight: 500; font-size: 12px; color: var(--ink-2); }
.settings input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; width: 50px; height: 30px; flex: none; border-radius: 99px;
  background: var(--ground-2); position: relative; cursor: pointer; transition: background .2s; margin: 0;
}
.settings input[type="checkbox"]::after {
  content: ""; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .2s;
}
.settings input[type="checkbox"]:checked { background: var(--teal); }
.settings input[type="checkbox"]:checked::after { transform: translateX(20px); }
.settings input:focus-visible { outline: 3px solid var(--marigold); outline-offset: 2px; }
.howto-mode { display: flex; gap: 12px; align-items: flex-start; }
.howto-mode .pv-ic { width: 40px; height: 40px; border-radius: 12px; }
.howto-mode .pv-ic svg { width: 22px; height: 22px; }
.howto-mode p { font-size: 14px; color: var(--ink-2); }

/* ---------- village ---------- */
.v-wrap, .a-wrap { padding: 4px 16px 28px; display: flex; flex-direction: column; gap: 12px; }
.v-hero {
  display: flex; gap: 14px; align-items: center; background: var(--paper); border-radius: 22px; padding: 14px;
  box-shadow: var(--shadow); outline: 2px dashed var(--stitch); outline-offset: -6px;
}
.v-hero .display { margin: 2px 0 2px; font-size: 28px; }
.v-hero p { margin: 0; font-size: 13px; color: var(--ink-2); line-height: 1.45; }
.pip-btn {
  width: 96px; height: 96px; flex: none; border-radius: 50%; padding: 12px;
  background: radial-gradient(circle at 50% 72%, #FBE0AE, #F3CB86);
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .06);
}
.pip-btn.squish svg { animation: squish .35s ease; }
@keyframes squish { 40% { transform: scale(1.12, .86); } 70% { transform: scale(.95, 1.06); } }
.v-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.v-stats div { background: var(--ink); color: #fff; border-radius: 16px; padding: 10px 12px; min-width: 0; }
.v-stats small { display: block; font-size: 11px; opacity: .72; font-weight: 700; }
.v-stats b { font-family: var(--f-display); font-weight: 400; font-size: 20px; font-variant-numeric: tabular-nums; }
.v-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.v-bar h3 { margin: 0; font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
.qty { display: flex; background: var(--ground-2); border-radius: 14px; padding: 4px; }
.qty button { padding: 7px 13px; border-radius: 10px; font-weight: 800; font-size: 13px; color: var(--ink-2); }
.qty button[aria-checked="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 0 rgba(0, 0, 0, .1); }
.blist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.bcard { display: flex; align-items: center; gap: 12px; background: var(--paper); border-radius: 18px; padding: 10px; }
.b-ic { width: 54px; height: 54px; flex: none; border-radius: 15px; background: var(--ground); display: grid; place-items: center; font-size: 30px; }
.b-body { flex: 1; min-width: 0; }
.b-name { display: flex; align-items: baseline; gap: 6px; }
.b-name b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.b-lv { font-size: 12px; font-weight: 800; color: var(--teal); font-variant-numeric: tabular-nums; }
.b-body small { display: block; font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.b-mile { height: 5px; border-radius: 99px; background: var(--ground-2); margin: 6px 0 3px; overflow: hidden; }
.b-mile i { display: block; height: 100%; background: var(--teal); border-radius: inherit; }
.buy {
  flex: none; min-width: 86px; min-height: 50px; border-radius: 14px; padding: 4px 10px;
  background: var(--marigold); box-shadow: 0 3px 0 var(--marigold-d);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; font-variant-numeric: tabular-nums;
}
.buy span { display: flex; align-items: center; gap: 4px; }
.buy svg { width: 16px; height: 16px; }
.buy small { font-size: 11px; line-height: 1; }
.buy:disabled { background: var(--ground-2); box-shadow: none; color: var(--ink-3); cursor: default; }
.buy:not(:disabled):active { transform: translateY(2px); box-shadow: 0 1px 0 var(--marigold-d); }
.bcard.locked { background: transparent; outline: 2px dashed var(--stitch); outline-offset: -2px; }
.bcard.locked .b-ic { background: transparent; color: var(--ink-3); font-family: var(--f-display); font-size: 24px; }
.floaty { position: fixed; z-index: 70; pointer-events: none; font-family: var(--f-display); font-size: 22px; color: var(--ink); animation: floaty .9s ease-out forwards; }
@keyframes floaty { to { transform: translateY(-60px); opacity: 0; } }

/* ---------- album ---------- */
.a-head { background: var(--paper); border-radius: 22px; padding: 16px; box-shadow: var(--shadow); outline: 2px dashed var(--stitch); outline-offset: -6px; }
.a-head .display { margin: 2px 0 12px; }
.a-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.a-stats b { display: block; font-family: var(--f-display); font-weight: 400; font-size: 22px; font-variant-numeric: tabular-nums; }
.a-stats small { font-size: 11px; color: var(--ink-2); line-height: 1.3; display: block; }
.souvs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.souv {
  display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center;
  background: var(--paper); border-radius: 18px; padding: 12px 6px; min-width: 0;
}
.souv .sv-ic { font-size: 36px; line-height: 1.2; }
.souv b { font-size: 12px; line-height: 1.25; }
.souv small { font-size: 11px; color: var(--ink-2); }
.souv.empty { background: transparent; outline: 2px dashed var(--stitch); outline-offset: -2px; }
.souv.empty .sv-ic { font-family: var(--f-display); color: var(--ink-3); font-size: 28px; }
.souv.empty b { color: var(--ink-2); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; top: calc(70px + var(--safe-t)); transform: translateX(-50%); z-index: 80;
  width: max-content; max-width: min(92vw, 420px);
  background: var(--ink); color: #fff; border-radius: 14px; padding: 10px 16px; font-size: 14px; font-weight: 600; text-align: center;
  box-shadow: 0 12px 30px -12px rgba(20, 25, 40, .6);
  animation: toastin .25s ease;
}
@keyframes toastin { from { transform: translate(-50%, -10px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media (max-height: 640px) {
  .lv-title h2 { font-size: 22px; }
  .shelves { gap: 12px 8px; }
  .loom { padding: 7px; }
}
