:root {
  --wood-900: #1b120b;
  --wood-800: #24180f;
  --wood-700: #33221a;
  --wood-600: #4a3020;
  --wood-400: #7a5434;
  --parch: #f1e5c9;
  --parch-2: #e2d0a8;
  --ink: #2b1f16;
  --ink-soft: #5c4a3a;
  --gold: #d6a446;
  --gold-hi: #f2cf7a;
  --ember: #e0773b;
  --slate: #34373c;
  --slate-hi: #4b4f56;
  --cream: #fff6dc;
  --radius: 14px;
  --display: 'Cinzel', 'Trajan Pro', Georgia, serif;
  --body: 'Alegreya', Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.45;
  color: var(--cream);
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(240, 170, 80, .22), transparent 60%),
    radial-gradient(900px 600px at 110% 110%, rgba(0, 0, 0, .55), transparent 60%),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .18) 0 2px, transparent 2px 140px),
    repeating-linear-gradient(0deg, rgba(255, 220, 160, .025) 0 1px, transparent 1px 7px),
    linear-gradient(180deg, var(--wood-700), var(--wood-900));
}
html { background: var(--wood-900); }
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .16;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 1;
}
body.in-quarry { overflow: hidden; }

h1, h2, h3 { font-family: var(--display); margin: 0; letter-spacing: .04em; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; }
button { font: inherit; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: rgba(255, 246, 220, .62); font-size: .92em; }
.center { text-align: center; }
.kicker {
  font-family: var(--display);
  font-size: .72rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--gold);
}

#app { position: relative; z-index: 2; max-width: 1360px; margin: 0 auto; padding: 18px clamp(12px, 2.4vw, 28px) 28px; }

/* ---------- header ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 22px;
  animation: rise .6s ease-out both;
}
.brand { display: flex; align-items: center; gap: 16px; }
.portrait {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, #5b3a22, #22150c);
  border: 3px solid var(--gold);
  box-shadow: 0 0 0 4px rgba(0, 0, 0, .35), 0 10px 30px rgba(240, 160, 60, .25);
  overflow: hidden;
  flex: none;
}
.portrait svg { width: 100%; height: 100%; display: block; transform: translateY(6px) scale(1.08); }
h1 {
  font-size: clamp(1.7rem, 3.6vw, 2.8rem);
  font-weight: 900;
  color: var(--parch);
  text-shadow: 0 2px 0 #000, 0 0 24px rgba(240, 170, 80, .35);
  line-height: 1.05;
}
.stats { display: flex; gap: 12px; flex-wrap: wrap; }
.stat {
  background: linear-gradient(180deg, rgba(0, 0, 0, .35), rgba(0, 0, 0, .55));
  border: 1px solid rgba(214, 164, 70, .4);
  border-radius: var(--radius);
  padding: 10px 16px;
  min-height: 64px;
}
.stat .label { display: block; font-size: .7rem; letter-spacing: .18em; text-transform: uppercase; color: rgba(255, 246, 220, .6); }
.stat strong { font-family: var(--display); font-size: 1.45rem; color: var(--gold-hi); }
.gold-stat { display: flex; align-items: center; gap: 12px; }
.rank-stat { min-width: 250px; }
.rank-stat strong { font-size: 1.15rem; }
.repbar { height: 8px; border-radius: 6px; background: rgba(255, 255, 255, .1); margin: 6px 0 4px; overflow: hidden; }
#repFill { height: 100%; background: linear-gradient(90deg, var(--ember), var(--gold-hi)); transform-origin: left; transition: transform .6s cubic-bezier(.2, .8, .2, 1); }
.replabel { font-size: .8rem; color: rgba(255, 246, 220, .7); }

.coin {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff1b8, var(--gold) 55%, #8a5f17);
  box-shadow: inset 0 0 0 1.5px rgba(90, 60, 10, .5);
  vertical-align: -2px;
  margin-right: 5px;
}
.coin.big { width: 30px; height: 30px; margin: 0; }

/* ---------- layout ---------- */
.layout {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(290px, .82fr);
  grid-template-areas:
    "board workshop side"
    "showroom showroom side"
    "cemetery cemetery cemetery";
  grid-template-rows: auto 1fr auto;
  align-items: start;
}
.side { grid-area: side; display: grid; gap: 20px; grid-template-areas: "yard" "tools"; min-width: 0; }
.yard { grid-area: yard; }
.board { grid-area: board; }
.workshop { grid-area: workshop; }
.tools { grid-area: tools; }
.showroom { grid-area: showroom; }
.cemetery { grid-area: cemetery; }

.panel {
  position: relative;
  border-radius: 18px;
  padding: 18px;
  animation: rise .6s ease-out both;
}
.board { animation-delay: .08s; }
.workshop { animation-delay: .16s; }
.yard { animation-delay: .24s; }
.tools { animation-delay: .32s; }
.showroom { animation-delay: .4s; }
.panel h2 {
  font-size: 1.05rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .16em;
  color: var(--gold-hi);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.panel h2::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, rgba(214, 164, 70, .6), transparent); }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.panel-head h2 { flex: 1; }

/* cork board */
.board {
  background:
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, .05) 0 2px, transparent 3px) 0 0 / 22px 22px,
    radial-gradient(circle at 70% 60%, rgba(0, 0, 0, .12) 0 2px, transparent 3px) 0 0 / 18px 18px,
    linear-gradient(160deg, #8a6440, #6c4b2d);
  border: 10px solid #3b2617;
  box-shadow: inset 0 0 30px rgba(0, 0, 0, .45), 0 18px 40px rgba(0, 0, 0, .45);
}
.board h2 { color: var(--cream); text-shadow: 0 2px 0 rgba(0, 0, 0, .5); }
.order-list { display: grid; gap: 18px; }
.order {
  position: relative;
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 14px;
  padding: 16px 16px 14px;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .35), transparent 30%),
    linear-gradient(135deg, var(--parch), var(--parch-2));
  border-radius: 4px 4px 10px 4px;
  box-shadow: 0 10px 18px rgba(0, 0, 0, .35), inset 0 0 22px rgba(140, 100, 50, .25);
  transform: rotate(var(--tilt, 0deg));
  transition: transform .25s ease, box-shadow .25s ease;
}
.order:hover { transform: rotate(0deg) translateY(-3px); box-shadow: 0 16px 26px rgba(0, 0, 0, .4), inset 0 0 22px rgba(140, 100, 50, .25); }
.pin {
  position: absolute;
  top: -7px;
  left: 50%;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff9b7a, #a8321c 70%);
  box-shadow: 0 3px 4px rgba(0, 0, 0, .45);
}
.order-art { align-self: center; }
.order-art .monument { width: 112px; height: 112px; filter: drop-shadow(0 4px 4px rgba(0, 0, 0, .25)); }
.order h3 { font-size: 1.02rem; color: var(--ink); }
.stone-line { display: flex; align-items: center; gap: 7px; font-style: italic; color: var(--ink-soft); margin: 2px 0 6px; }
.swatch { width: 13px; height: 13px; border-radius: 3px; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .35); flex: none; }
.facts { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: .9rem; }
.facts span { font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft); margin-right: 6px; }
.facts em { color: var(--ink-soft); }
.reward { font-family: var(--display); font-weight: 700; margin: 8px 0 10px; font-size: 1.05rem; }
.reward .rep { font-family: var(--body); font-weight: 600; font-size: .85rem; color: #6b4a1a; background: rgba(214, 164, 70, .25); padding: 1px 8px; border-radius: 99px; margin-left: 6px; }
.order-actions { display: flex; align-items: center; gap: 14px; }
.why { margin-top: 8px; font-size: .88rem; color: #8a3a22; }

/* buttons */
.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  padding: 9px 16px;
  border-radius: 10px;
  font-family: var(--display);
  font-weight: 700;
  font-size: .86rem;
  letter-spacing: .06em;
  color: var(--cream);
  background: linear-gradient(180deg, #5d6168, #3a3d42);
  box-shadow: 0 3px 0 #1e2023, inset 0 1px 0 rgba(255, 255, 255, .2);
  transition: transform .08s ease, filter .15s ease, box-shadow .08s ease;
}
.btn:hover:not(:disabled) { filter: brightness(1.12); }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 #1e2023, inset 0 1px 0 rgba(255, 255, 255, .2); }
.btn:disabled { cursor: not-allowed; opacity: .45; filter: grayscale(.4); }
.btn:focus-visible, .btn-link:focus-visible, .bench-work:focus-visible { outline: 3px solid var(--gold-hi); outline-offset: 3px; }
.btn.gold, .btn.big {
  color: #2b1a08;
  background: linear-gradient(180deg, #f6d68a, #c98f2e);
  box-shadow: 0 4px 0 #7a4f12, inset 0 1px 0 rgba(255, 255, 255, .5);
}
.btn.big { width: 100%; padding: 14px 20px; font-size: 1.02rem; border-radius: 12px; }
.btn.small { padding: 7px 12px; font-size: .82rem; white-space: nowrap; }
.btn-link { background: none; border: 0; cursor: pointer; color: inherit; text-decoration: underline; text-underline-offset: 3px; opacity: .75; padding: 4px; }
.btn-link:hover { opacity: 1; }

/* workshop */
.workshop {
  background:
    radial-gradient(500px 260px at 50% 0%, rgba(255, 190, 100, .22), transparent 70%),
    linear-gradient(180deg, #3f3a36, #26221f);
  border: 1px solid rgba(255, 255, 255, .08);
  box-shadow: inset 0 0 0 6px rgba(0, 0, 0, .25), 0 18px 40px rgba(0, 0, 0, .45);
}
.benches { display: grid; gap: 16px; }
.bench {
  display: grid;
  grid-template-columns: 150px 1fr;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(0, 0, 0, .22);
  border: 1px solid rgba(255, 255, 255, .06);
}
.bench.empty { grid-template-columns: 1fr; text-align: center; padding: 22px 16px; border: 1px dashed rgba(255, 246, 220, .2); }
.bench.empty .bench-top { width: 70%; margin: 0 auto 12px; }
.bench.ready { border-color: rgba(242, 207, 122, .6); box-shadow: 0 0 24px rgba(242, 207, 122, .2); }
.bench h3 { font-size: .98rem; color: var(--cream); }
.bench .stone-line { color: rgba(255, 246, 220, .7); }
.bench-top {
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(180deg, #a77447, #6a4527);
  box-shadow: 0 6px 0 #3b2617, 0 10px 12px rgba(0, 0, 0, .4);
}
.bench-work {
  position: relative;
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  color: inherit;
}
.bench.ready .bench-work { cursor: default; }
.bench-work.tap .carving { animation: knock .18s ease-out; }
.carving { position: relative; width: 150px; height: 130px; }
.carving svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.carving .rough { opacity: calc(1 - var(--p)); transition: opacity .2s linear; }
.carving .emerging { clip-path: inset(0 0 calc((1 - var(--p)) * 100%) 0); transition: clip-path .2s linear; }
.bench.ready .carving .emerging { animation: gleam 1.8s ease-in-out infinite; }
.progress { height: 10px; border-radius: 6px; background: rgba(255, 255, 255, .1); overflow: hidden; margin: 6px 0; }
.progress-fill { height: 100%; transform-origin: left; transform: scaleX(var(--p)); background: linear-gradient(90deg, var(--ember), var(--gold-hi)); transition: transform .2s linear; }
.chip-fx {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 1px;
  pointer-events: none;
  animation: chip .6s ease-out forwards;
}

/* stone yard */
.yard {
  background: linear-gradient(180deg, rgba(0, 0, 0, .3), rgba(0, 0, 0, .5));
  border: 1px solid rgba(214, 164, 70, .25);
}
.stockpile { list-style: none; display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 16px; }
.stock {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
  padding: 8px 4px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .05);
}
.stock .chip-svg { width: 38px; height: 34px; }
.stock-name { font-size: .78rem; color: rgba(255, 246, 220, .75); }
.stock b { font-family: var(--display); font-size: 1.15rem; color: var(--gold-hi); }
.stock small { font-size: .62rem; line-height: 1.1; color: rgba(255, 246, 220, .5); }
.stock.locked .chip-svg { filter: grayscale(.8) brightness(.6); }
.stock.locked b { line-height: 1; }
.lock-icon { width: 14px; height: 16px; color: rgba(255, 246, 220, .55); }
.quarry-btn { margin-bottom: 8px; }

/* tools */
.tools { background: linear-gradient(180deg, rgba(0, 0, 0, .3), rgba(0, 0, 0, .5)); border: 1px solid rgba(214, 164, 70, .25); }
.tool-list { list-style: none; display: grid; gap: 10px; }
.tool {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .05);
  transition: background .2s ease;
}
.tool:hover { background: rgba(255, 255, 255, .08); }
.tool-icon { width: 44px; height: 44px; background: rgba(241, 229, 201, .9); border-radius: 10px; padding: 3px; }
.tool h3 { font-size: .9rem; color: var(--cream); }
.tool p { font-size: .85rem; color: rgba(255, 246, 220, .66); line-height: 1.3; }
.tool.owned { opacity: .7; }
.tool.locked .tool-icon { filter: grayscale(1) brightness(.75); }
.badge { display: inline-block; font-size: .72rem; padding: 4px 9px; border-radius: 99px; background: rgba(242, 207, 122, .2); color: var(--gold-hi); white-space: nowrap; }
.badge.lock { background: rgba(255, 255, 255, .08); color: rgba(255, 246, 220, .6); }

/* showroom */
.showroom {
  background:
    linear-gradient(180deg, transparent calc(100% - 26px), #5a3b22 calc(100% - 26px), #3b2617),
    radial-gradient(700px 200px at 50% 0%, rgba(255, 220, 160, .14), transparent 70%),
    linear-gradient(180deg, #2c2420, #1f1915);
  border: 1px solid rgba(255, 255, 255, .06);
  padding-bottom: 34px;
}
.shelf { display: flex; gap: 14px; overflow-x: auto; padding: 6px 2px 4px; scrollbar-width: thin; }
.piece { margin: 0; flex: none; width: 116px; text-align: center; animation: rise .5s ease-out both; }
.piece .monument { width: 116px; height: 116px; filter: drop-shadow(0 6px 6px rgba(0, 0, 0, .4)); }
.piece figcaption { font-size: .78rem; color: rgba(255, 246, 220, .7); line-height: 1.2; }
.empty-shelf { padding: 26px 8px; text-align: center; width: 100%; }

.foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 26px; font-size: .9rem; color: rgba(255, 246, 220, .6); }
.foot a { color: var(--gold-hi); }

/* ---------- quarry ---------- */
.quarry {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: radial-gradient(circle at 50% 40%, #2f2218, #0e0905);
}
.quarry-frame { position: absolute; inset: 10px; display: grid; place-items: center; }
#qcanvas, #ccanvas, #dcanvas { display: block; border-radius: 14px; box-shadow: 0 0 0 3px #3b2617, 0 0 0 5px rgba(214, 164, 70, .5), 0 30px 60px rgba(0, 0, 0, .6); touch-action: none; user-select: none; -webkit-user-select: none; }
.q-action {
  position: absolute;
  right: max(22px, env(safe-area-inset-right));
  bottom: max(22px, env(safe-area-inset-bottom));
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: 3px solid #7a4f12;
  background: radial-gradient(circle at 40% 35%, #f6d68a, #c98f2e);
  box-shadow: 0 6px 0 #5a3a0c, 0 10px 20px rgba(0, 0, 0, .5);
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  display: grid;
  place-items: center;
}
.q-action .tool-icon { width: 52px; height: 52px; background: none; }
.q-action:active { transform: translateY(3px); box-shadow: 0 3px 0 #5a3a0c; }
.q-home {
  position: absolute;
  left: max(22px, env(safe-area-inset-left));
  bottom: max(22px, env(safe-area-inset-bottom));
  padding: 8px 14px;
  border-radius: 99px;
  border: 1px solid rgba(214, 164, 70, .6);
  background: rgba(36, 23, 14, .85);
  color: var(--cream);
  cursor: pointer;
}
.rotate-hint { display: none; }
@media (orientation: portrait) and (max-width: 760px) {
  .rotate-hint {
    display: block;
    position: absolute;
    top: 90px;
    left: 20px;
    right: 20px;
    text-align: center;
    color: rgba(255, 246, 220, .8);
    font-style: italic;
  }
}
@media (hover: hover) and (pointer: fine) {
  .q-action { width: 70px; height: 70px; opacity: .85; }
}
.q-summary, .modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(10, 6, 3, .7);
  backdrop-filter: blur(3px);
  z-index: 30;
}
.summary-card, .modal-card {
  width: min(460px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 26px;
  border-radius: 16px;
  color: var(--ink);
  text-align: center;
  background: linear-gradient(180deg, rgba(255, 255, 255, .35), transparent 25%), linear-gradient(135deg, var(--parch), var(--parch-2));
  box-shadow: 0 30px 60px rgba(0, 0, 0, .6), inset 0 0 0 2px rgba(122, 79, 18, .35);
  animation: pop .35s cubic-bezier(.2, 1.4, .4, 1) both;
}
.summary-card h2, .modal-card h2 { font-size: 1.5rem; margin: 4px 0 12px; color: var(--ink); }
.summary-card .kicker, .modal-card .kicker { color: #8a5f17; }
.summary-card p, .modal-card p { margin-bottom: 14px; }
.haul { list-style: none; display: grid; gap: 6px; margin: 0 auto 16px; max-width: 280px; text-align: left; }
.haul li { display: flex; align-items: center; gap: 10px; padding: 6px 10px; background: rgba(0, 0, 0, .06); border-radius: 8px; }
.haul b { margin-left: auto; font-family: var(--display); }
.note { font-size: .9rem; color: #8a3a22; }
.modal-portrait { width: 110px; height: 110px; margin: -6px auto 10px; border-radius: 50%; overflow: hidden; background: radial-gradient(circle at 50% 35%, #5b3a22, #22150c); border: 3px solid var(--gold); }
.modal-portrait svg { width: 100%; height: 100%; transform: translateY(7px) scale(1.08); }
.steps, .ticks { text-align: left; margin: 0 0 18px 20px; display: grid; gap: 8px; }

.toasts { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 40; pointer-events: none; }
.toast {
  padding: 10px 18px;
  border-radius: 99px;
  background: rgba(30, 20, 12, .94);
  border: 1px solid rgba(214, 164, 70, .5);
  color: var(--cream);
  box-shadow: 0 10px 24px rgba(0, 0, 0, .5);
  animation: rise .3s ease-out both;
  transition: opacity .4s ease, transform .4s ease;
  text-align: center;
}
.toast.gold { color: var(--gold-hi); }
.toast.out { opacity: 0; transform: translateY(8px); }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: none; } }
@keyframes knock { 0% { transform: translateX(0); } 30% { transform: translateX(-3px) rotate(-1deg); } 60% { transform: translateX(3px) rotate(1deg); } 100% { transform: none; } }
@keyframes chip { to { transform: translate(var(--dx), var(--dy)) rotate(200deg); opacity: 0; } }
@keyframes gleam { 0%, 100% { filter: drop-shadow(0 0 0 rgba(242, 207, 122, 0)); } 50% { filter: drop-shadow(0 0 10px rgba(242, 207, 122, .7)); } }

/* ---------- carving bench ---------- */
.edition {
  margin: 4px 0 0;
  font-family: var(--display);
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--gold-hi);
}
.panel-sub { margin: -6px 0 14px; }
.family { margin: 0; font-size: .92rem; color: var(--ink-soft); }
.family b { font-family: var(--display); letter-spacing: .06em; }
.bench .family { color: rgba(255, 246, 220, .75); }
.order .small { font-size: .8rem; margin: 0 0 6px; color: var(--ink-soft); }
.bench-info .btn { margin-top: 4px; }
.piece .stars, .result-stars { color: var(--gold-hi); letter-spacing: .1em; }
.result-stars { font-size: 2.4rem; line-height: 1; margin: 2px 0 10px; color: #c98f2e; text-shadow: 0 2px 0 rgba(90, 58, 12, .35); }
.result-stars span { color: rgba(43, 31, 22, .18); text-shadow: none; }
.c-tools {
  position: absolute;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
}
.c-tool {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 250px;
  padding: 6px 14px 6px 8px;
  border-radius: 14px;
  border: 2px solid rgba(214, 164, 70, .45);
  background: rgba(36, 23, 14, .9);
  color: var(--cream);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
div.c-tool { cursor: default; }
.c-tool .tool-icon { width: 40px; height: 40px; flex: none; }
.c-tool b { display: block; font-family: var(--display); font-size: .85rem; letter-spacing: .04em; }
.c-tool small { display: block; font-size: .78rem; line-height: 1.2; color: rgba(255, 246, 220, .7); }
.c-tool.on { border-color: var(--gold-hi); background: linear-gradient(180deg, #5a3a1a, #33200f); box-shadow: 0 0 18px rgba(242, 207, 122, .3); }
.c-tool:focus-visible { outline: 3px solid var(--gold-hi); outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) {
  #ccanvas { cursor: none; }
}
@media (max-height: 520px), (max-width: 760px) {
  .c-tool small { display: none; }
  .c-tool { padding: 4px 10px 4px 6px; }
  .c-tool .tool-icon { width: 32px; height: 32px; }
}

/* ---------- start over ---------- */
.stats { align-items: stretch; }
.reset-btn { display: inline-flex; align-items: center; gap: 8px; align-self: center; }
.reset-btn svg { width: 18px; height: 18px; }
.modal-actions { display: flex; gap: 10px; align-items: stretch; }
.modal-actions .btn { flex: 1; }
.modal-actions .btn.big { width: auto; }
.btn.danger { color: var(--cream); background: linear-gradient(180deg, #c0563a, #8f2f1d); box-shadow: 0 4px 0 #561a0f, inset 0 1px 0 rgba(255, 255, 255, .3); }

/* ---------- truck & cemetery ---------- */
.truck-btn { flex: none; }
.showroom .panel-sub { margin: -6px 0 10px; }
.cemetery { background: linear-gradient(180deg, rgba(0, 0, 0, .25), rgba(0, 0, 0, .45)); border: 1px solid rgba(214, 164, 70, .25); animation-delay: .44s; }
.cem-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: -4px 0 12px; }
.cem-tabs:empty { display: none; }
.cem-tab { font-family: var(--display); font-size: .78rem; letter-spacing: .08em; padding: 5px 12px; border-radius: 99px; border: 1px solid rgba(214, 164, 70, .45); background: rgba(255, 255, 255, .05); color: var(--cream); cursor: pointer; }
.cem-tab.on { background: rgba(242, 207, 122, .22); color: var(--gold-hi); border-color: var(--gold-hi); }
.cem-note { margin-top: 12px; }

.cemetery-field {
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  padding: clamp(80px, 12vw, 128px) 2% 34px;
  background:
    radial-gradient(120% 60% at 50% 100%, rgba(255, 240, 190, .12), transparent 70%),
    linear-gradient(180deg, #f3d9a4 0, #d7cb9c 70px, #627f3e 140px, #4f6e31 70%, #45622a);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .25), inset 0 -30px 50px rgba(0, 0, 0, .2);
}
.cem-backdrop { position: absolute; left: 0; right: 0; top: 0; height: clamp(90px, 13vw, 140px); pointer-events: none; }
.cem-backdrop svg { width: 100%; height: 100%; display: block; }
.cem-rows { position: relative; z-index: 1; }
.cem-row { display: grid; grid-template-columns: repeat(8, 1fr); gap: 1%; width: calc(70% + var(--row) * 15%); margin: -2.5% auto 0; }
.cem-row:first-child { margin-top: 0; }
.cem-path { position: absolute; left: 0; right: 0; bottom: 0; height: 26px; background: linear-gradient(180deg, #a68559, #8a6b45); box-shadow: inset 0 3px 0 rgba(0, 0, 0, .15); }
.plot { position: relative; aspect-ratio: 1; display: grid; align-items: end; justify-items: center; margin: 0; padding: 0; border: 0; background: none; color: inherit; }
.plot .monument { position: relative; z-index: 1; width: 100%; height: auto; filter: drop-shadow(0 4px 3px rgba(0, 0, 0, .35)); }
.mound { position: absolute; left: 14%; right: 14%; bottom: 4%; height: 16%; border-radius: 50%; background: radial-gradient(closest-side, rgba(66, 90, 34, .9), rgba(52, 74, 26, .4)); box-shadow: 0 1px 0 rgba(255, 255, 255, .06); }
.plot.filled .mound { display: none; }
.plot.fresh .monument { animation: settle .8s cubic-bezier(.2, 1.3, .4, 1) both; }
.plot.open { cursor: pointer; border-radius: 10px; }
.plot.open .mound { border: 2px dashed rgba(242, 207, 122, .75); background: rgba(242, 207, 122, .12); animation: beckon 1.6s ease-in-out infinite; }
.plot.open:hover .mound, .plot.open:focus-visible .mound { background: rgba(242, 207, 122, .35); border-style: solid; }
.plot.open:focus-visible { outline: 3px solid var(--gold-hi); outline-offset: 2px; }

/* the locals */
.critter { position: absolute; left: var(--x); top: var(--y); z-index: 2; width: 32px; pointer-events: none; animation: mill var(--d) ease-in-out var(--delay) infinite; }
.critter-body { display: block; animation: turn var(--d) step-end var(--delay) infinite; }
.critter svg { display: block; width: 100%; height: auto; }
.c-rabbit svg { animation: hop .55s ease-in-out infinite; }
.c-squirrel svg { animation: hop .3s ease-in-out infinite; }
.c-duck svg { animation: waddle .5s ease-in-out infinite; transform-origin: 50% 90%; }
.c-crow svg { animation: peck 2.2s ease-in-out infinite; transform-origin: 70% 80%; }
.c-butterfly { width: 18px; z-index: 3; }
.c-butterfly svg { animation: flutter 2.4s ease-in-out infinite; }
.c-butterfly .wings { animation: flap .18s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: center; }

@keyframes mill { 0%, 6% { transform: translateX(0); } 44%, 56% { transform: translateX(var(--run)); } 94%, 100% { transform: translateX(0); } }
@keyframes turn { 0% { transform: scaleX(var(--f)); } 50% { transform: scaleX(calc(var(--f) * -1)); } }
@keyframes hop { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-22%); } }
@keyframes waddle { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
@keyframes peck { 0%, 60%, 100% { transform: rotate(0); } 70%, 80% { transform: rotate(28deg); } 75% { transform: rotate(18deg); } }
@keyframes flutter { 0%, 100% { transform: translate(0, 0); } 25% { transform: translate(10px, -14px); } 50% { transform: translate(-6px, -24px); } 75% { transform: translate(-12px, -8px); } }
@keyframes flap { from { transform: scaleX(1); } to { transform: scaleX(.25); } }
@keyframes settle { from { opacity: 0; transform: translateY(-40%) scale(1.08); } to { opacity: 1; transform: none; } }
@keyframes beckon { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }

/* setting stones */
.burial {
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow: auto;
  padding: 16px clamp(10px, 3vw, 32px) 24px;
  background: radial-gradient(circle at 50% 30%, #2f2218, #0e0905);
}
.burial-card { max-width: 1180px; margin: 0 auto; animation: rise .4s ease-out both; }
.burial-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.burial-head h2 { font-size: clamp(1.3rem, 2.6vw, 1.8rem); color: var(--parch); }
.burial-head p:not(.kicker) { color: rgba(255, 246, 220, .8); }
.burial-tray { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.tray-piece { margin: 0; width: 88px; text-align: center; opacity: .6; }
.tray-piece .monument { width: 88px; height: 88px; }
.tray-piece figcaption { font-size: .8rem; color: rgba(255, 246, 220, .75); }
.tray-piece.next { opacity: 1; animation: gleam 1.6s ease-in-out infinite; }
.tray-piece.next figcaption { color: var(--gold-hi); font-weight: 700; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .side { display: contents; }
  .layout {
    grid-template-rows: none;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      "yard yard"
      "board workshop"
      "showroom showroom"
      "cemetery cemetery"
      "tools tools";
  }
  .tool-list { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
}
@media (max-width: 720px) {
  body { font-size: 16px; }
  .layout { grid-template-columns: 1fr; grid-template-areas: "yard" "board" "workshop" "showroom" "cemetery" "tools"; }
  .reset-btn { margin-left: auto; }
  .cem-row { gap: 0; }
  .critter { width: 24px; }
  .c-butterfly { width: 13px; }
  .portrait { width: 68px; height: 68px; }
  .stats, .stat { width: 100%; }
  .rank-stat { min-width: 0; }
  .order { grid-template-columns: 84px 1fr; }
  .order-art .monument { width: 84px; height: 84px; }
  .bench { grid-template-columns: 112px 1fr; }
  .carving { width: 112px; height: 100px; }
  .tool-list { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
