:root {
  --grass: #6aae48;
  --grass-dark: #44803a;
  --ink: #3b2415;
  --ink-soft: #82603f;
  --cream: #f4e3c1;
  --cream-text: #fff6e2;
  --wood: #c88a52;
  --wood-dark: #6b4424;
  --outline: #4a2a17;
  /* Dark pixel outline around light text, like the signs in the original. */
  --text-outline: 2px 0 0 var(--outline), -2px 0 0 var(--outline), 0 2px 0 var(--outline), 0 -2px 0 var(--outline),
    2px 2px 0 var(--outline), -2px 2px 0 var(--outline), 2px -2px 0 var(--outline), -2px -2px 0 var(--outline),
    0 4px 0 rgba(43, 22, 10, .45);
  --good: #6cc04a;
  --bad: #b8402e;
  --c-common: #c9c2b2;
  --c-uncommon: #8fd16a;
  --c-rare: #5ab4f0;
  --c-epic: #d66be0;
  --c-legendary: #f2c94c;
  --font: 'VT323', ui-monospace, Menlo, monospace;
  --font-pixel: 'Pixelify Sans', ui-monospace, Menlo, monospace;
  /* --ui-* nine-slice images are set from JS (sprites.js → uiSlice). */
}

* { box-sizing: border-box; }
html, body { margin: 0; }

body {
  font-family: var(--font);
  font-size: 20px;
  line-height: 1.15;
  color: var(--ink);
  background-color: var(--grass-dark);
  background-image:
    radial-gradient(circle at 25% 35%, #4e8c40 0 2px, transparent 3px),
    radial-gradient(circle at 75% 70%, #3a7230 0 2px, transparent 3px);
  background-size: 22px 22px, 30px 30px;
  min-height: 100vh;
}

button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; padding: 0; }
img.px { image-rendering: pixelated; image-rendering: crisp-edges; display: block; }
img.px.smooth { image-rendering: auto; }
h2, h3, h4 { font-family: var(--font-pixel); font-weight: 500; margin: 0; }

/* --- Nine-slice pixel boxes ------------------------------------------------- */

.card, .panel, .tooltip, .toast, .hud .pill, .nameplate, .sign, .btn, .slot, .tabs button {
  border: 15px solid transparent;
  border-image: var(--ui-panel) 5 fill / 15px / 0 stretch;
  image-rendering: pixelated;
  background: none;
}

.btn {
  border-image-source: var(--ui-wood);
  color: var(--cream-text);
  font-family: var(--font-pixel);
  font-weight: 500;
  font-size: 16px;
  padding: 0 6px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-shadow: var(--text-outline);
  letter-spacing: .5px;
}
.btn:active:not(:disabled) { transform: translateY(2px); }
.btn:disabled { filter: grayscale(.6) brightness(.9); opacity: .65; cursor: not-allowed; }
.btn.orange { border-image-source: var(--ui-orange); }
.btn.blue { border-image-source: var(--ui-blue); }
.btn.gem { border-image-source: var(--ui-gem); }
.btn.cream { border-image-source: var(--ui-cream); color: var(--ink); text-shadow: 0 2px 0 rgba(255,255,255,.6); }
.btn.small { min-height: 32px; font-size: 13px; }

.sign {
  border-image-source: var(--ui-sign);
  color: var(--cream-text);
  font-family: var(--font-pixel);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 1px;
  padding: 0 8px;
  text-shadow: var(--text-outline);
  white-space: nowrap;
}

/* --- App layout ------------------------------------------------------------- */

.app {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  grid-template-areas: "hud hud" "nav main";
  gap: 10px 14px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 12px 16px 40px;
}

.hud {
  grid-area: hud;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.nameplate {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px 0 0;
  min-width: 240px;
  font-family: var(--font-pixel);
  font-weight: 500;
  font-size: 20px;
  border-image-source: var(--ui-sign);
  color: var(--cream-text);
  text-shadow: var(--text-outline);
}
.nameplate .avatar {
  margin: -8px 0 -8px -8px;
  border-radius: 50%;
  background: #f3c890;
  border: 3px solid var(--ink);
  box-shadow: 0 0 0 3px #c88a52;
  overflow: hidden;
}

.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.hud .pill {
  border-image-source: var(--ui-pill);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 6px 0 0;
  min-height: 42px;
  font-size: 22px;
}
.hud .pill span:first-child { margin-left: -4px; }
.hud .pill .lv { font-family: var(--font-pixel); font-weight: 500; font-size: 14px; color: var(--ink-soft); margin-left: 0; }
.hud .pill small { color: var(--ink-soft); font-size: 16px; }

.tabs {
  grid-area: nav;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-self: start;
  position: sticky;
  top: 12px;
}
.tabs button {
  border-image-source: var(--ui-sign);
  color: var(--cream-text);
  font-family: var(--font-pixel);
  font-weight: 500;
  font-size: 16px;
  text-shadow: var(--text-outline);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
  min-height: 46px;
  position: relative;
  text-align: left;
}
.tabs button.active { border-image-source: var(--ui-blue); }
.tabs .badge {
  margin-left: auto;
  background: #f2c94c;
  color: var(--ink);
  border: 2px solid var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1;
  padding: 1px 5px;
  text-shadow: none;
}

main { grid-area: main; min-width: 0; }

/* --- Scenes ----------------------------------------------------------------- */

.scene-scroll {
  overflow-x: auto;
  border: 4px solid var(--ink);
  box-shadow: 0 0 0 4px #c88a52, 0 0 0 8px var(--ink);
  margin: 8px;
}
.scene {
  position: relative;
  width: 100%;
  min-width: 640px;
  aspect-ratio: 400 / 240;
}
.scene-bg { position: absolute; inset: 0; width: 100%; height: 100%; }

.zone {
  position: absolute;
  border: 3px dashed transparent;
  transition: background .1s;
}
.zone:hover { border-color: rgba(255, 246, 192, .9); background: rgba(255, 246, 192, .12); }
.zone-sign {
  position: absolute;
  transform: translate(-50%, -100%);
  min-height: 38px;
}
.zone-sign::after { /* pointer under the sign */
  content: '';
  position: absolute;
  left: 50%;
  bottom: -18px;
  transform: translateX(-50%);
  border: 7px solid transparent;
  border-top-color: var(--ink);
}
.zone-sign:hover { filter: brightness(1.1); }

.plot {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
}
.plot img { width: 100%; height: 100%; }
.plot.empty:hover img, .plot.growing:hover img { filter: brightness(1.15) drop-shadow(0 0 2px #fff6c0); }
.plot.locked { cursor: not-allowed; }
.plot.never { visibility: hidden; pointer-events: none; }
.plot.ready img { animation: bob 1.1s steps(4) infinite; filter: drop-shadow(0 0 3px #fff6c0); }
.plot .bar {
  position: absolute;
  left: 8%; right: 8%;
  bottom: -6px;
  height: 6px;
  background: var(--ink);
  border: 1px solid var(--ink);
}
.plot .bar i { display: block; height: 100%; background: var(--good); }
.plot .gemdot {
  position: absolute;
  top: -2px; right: -2px;
  width: 9px; height: 9px;
  transform: rotate(45deg);
  background: var(--c-epic);
  border: 2px solid var(--ink);
}
.plot .gemdot.legendary { background: var(--c-legendary); }

.farmer { position: absolute; pointer-events: none; }
.farmer img { width: 100%; height: auto; animation: bob 2.4s steps(2) infinite; }
.farmer-sign { position: absolute; transform: translate(-50%, -50%); }

@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }

.farm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 8px 0;
  align-items: center;
}
.hint { color: var(--cream-text); text-shadow: 2px 0 0 var(--outline), -2px 0 0 var(--outline), 0 2px 0 var(--outline), 0 -2px 0 var(--outline); margin: 12px 8px; }

/* --- Cards / sections ------------------------------------------------------- */

.section-title {
  font-size: 26px;
  margin: 4px 0 12px;
  color: var(--cream-text);
  text-shadow: var(--text-outline);
}

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card { display: flex; flex-direction: column; gap: 10px; padding: 4px; }
.card h4 { font-size: 19px; }
.card.wide { grid-column: 1 / -1; }

.row { display: flex; align-items: center; gap: 10px; }
.row.tight { gap: 2px; flex-wrap: wrap; }
.amt { display: inline-flex; align-items: center; gap: 3px; vertical-align: middle; }
.muted { color: var(--ink-soft); font-size: 18px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.card .actions, .actions.left { justify-content: flex-start; margin-top: auto; }

.odds { width: 100%; border-collapse: collapse; font-size: 19px; }
.odds th, .odds td { padding: 4px 6px; text-align: left; border-bottom: 2px solid #dcc69a; }
.odds th { color: var(--ink-soft); font-weight: normal; }
.odds .num { text-align: right; font-variant-numeric: tabular-nums; }

.rar {
  font-family: var(--font-pixel);
  font-weight: 500;
  font-size: 12px;
  padding: 1px 6px;
  border: 2px solid var(--ink);
  display: inline-block;
}
.rar.common { background: var(--c-common); }
.rar.uncommon { background: var(--c-uncommon); }
.rar.rare { background: var(--c-rare); }
.rar.epic { background: var(--c-epic); }
.rar.legendary { background: var(--c-legendary); }

.list { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.slot { border-image-source: var(--ui-slot); }
.item { display: flex; align-items: center; gap: 8px; text-align: left; padding: 0 2px; min-height: 44px; }
button.item:hover { filter: brightness(1.05); }
.item .meta { display: flex; flex-direction: column; min-width: 0; }
.item .meta b { font-size: 20px; font-weight: normal; }
.item .meta span { font-size: 16px; color: var(--ink-soft); }
.item .qty { margin-left: auto; font-size: 22px; }
.empty-note { color: var(--ink-soft); margin: 0; }

.segbar { display: flex; gap: 4px; }
.segbar i {
  flex: 1;
  height: 14px;
  background: #6b4a34;
  border: 2px solid var(--ink);
  box-shadow: inset 0 2px 0 rgba(0,0,0,.25);
}
.segbar i.on { background: var(--good); box-shadow: inset 0 2px 0 #a8e88a, inset 0 -2px 0 #3e8a2e; }
.segbar.long { gap: 0; }

.levels { max-height: 300px; overflow: auto; }
.levels tr.current td { background: #fbe7a8; }
.levels tr.done td { color: var(--ink-soft); }

/* --- Tooltip / modal / toasts ----------------------------------------------- */

.tooltip {
  position: fixed;
  z-index: 30;
  pointer-events: none;
  padding: 0 2px;
  font-size: 18px;
  max-width: 260px;
}
.tooltip b { font-size: 20px; font-weight: normal; }
.tooltip .line { display: flex; gap: 8px; align-items: center; margin-top: 2px; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(20, 14, 8, .6);
  display: flex;
  align-items: safe center;   /* tall panels start at the top and the backdrop scrolls */
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}
.modal[hidden] { display: none; }
.modal .panel {
  width: min(480px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 8px;
  position: relative;
}
.modal .panel.wide { width: min(640px, 100%); }
.modal h3 { margin: 0 0 12px; font-size: 22px; }
.modal .close { position: absolute; top: 0; right: 4px; font-size: 26px; line-height: 1; z-index: 2; }

/* Crop panel: brown board, cream text, round portrait. */
.modal .panel.crop {
  width: min(420px, 100%);
  border-image-source: var(--ui-sign);
  color: var(--cream-text);
  text-shadow: 0 2px 0 rgba(0,0,0,.25);
}
.panel.crop .close { color: var(--cream-text); }
.cp-head { display: flex; gap: 16px; align-items: center; }
.portrait {
  width: 96px; height: 96px;
  flex: none;
  border-radius: 50%;
  background: radial-gradient(circle, #3a7a9a 0 58%, #6b4424 60% 66%, var(--ink) 67% 71%, #c88a52 72%);
  border: 3px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
}
.portrait img { width: 60px; height: 60px; }
.portrait.common { background: radial-gradient(circle, #8a8476 0 58%, #6b4424 60% 66%, var(--ink) 67% 71%, #c88a52 72%); }
.portrait.uncommon { background: radial-gradient(circle, #4e8a36 0 58%, #6b4424 60% 66%, var(--ink) 67% 71%, #c88a52 72%); }
.portrait.epic { background: radial-gradient(circle, #8a3a9a 0 58%, #6b4424 60% 66%, var(--ink) 67% 71%, #c88a52 72%); }
.portrait.legendary { background: radial-gradient(circle, #b88a1c 0 58%, #6b4424 60% 66%, var(--ink) 67% 71%, #c88a52 72%); }
.cp-name { font-family: var(--font-pixel); font-weight: 500; font-size: 24px; text-transform: uppercase; }
.cp-rar { font-family: var(--font-pixel); font-weight: 500; font-size: 16px; }
.cp-rar.common { color: #e8e2d4; }
.cp-rar.uncommon { color: #a8f07a; }
.cp-rar.rare { color: #8ad4ff; }
.cp-rar.epic { color: #f0a0f5; }
.cp-rar.legendary { color: #ffe070; }
.cp-tier { font-size: 18px; opacity: .85; }
.panel.crop hr { border: 0; border-top: 2px solid #8e5a32; border-bottom: 2px solid #d8a070; margin: 12px 0; }
.cp-row { display: flex; justify-content: space-between; align-items: baseline; margin: 4px 0; font-size: 22px; }
.cp-row b { font-weight: normal; }
.cp-row.small { font-size: 18px; opacity: .9; }
.cp-row.gemline b { color: #a8f0ff; }
.cp-stage { color: #ffe070; font-size: 18px; }
.panel.crop .segbar { margin-top: 6px; }
.cp-effect { text-align: center; font-family: var(--font-pixel); font-weight: 500; font-size: 16px; margin-bottom: 12px; }

/* Gacha: a brown board with a blue title tab, a dark inset, and one slot per seed. */
.modal .panel.gacha-panel {
  width: min(560px, 100%);
  max-height: none;
  margin: 36px 0 8px;
  padding: 26px 10px 10px;
  overflow: visible;
  border-image-source: var(--ui-sign);
  color: var(--cream-text);
}
.panel.gacha-panel > .close {
  top: -14px;
  right: -40px;
  width: 36px;
  height: 36px;
  font-family: var(--font-pixel);
  font-size: 22px;
  line-height: 30px;
  color: #fff;
  background: #d8463a;
  border: 3px solid var(--outline);
  box-shadow: inset 0 -4px 0 #9a2a22, inset 0 3px 0 #f58a7a;
  text-shadow: var(--text-outline);
}
@media (max-width: 640px) { .panel.gacha-panel > .close { right: -6px; top: -44px; } }
.gacha { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.gacha-title {
  position: absolute;
  top: -34px;
  left: 50%;
  transform: translateX(-50%);
  border: 15px solid transparent;
  border-image: var(--ui-blue) 5 fill / 15px / 0 stretch;
  image-rendering: pixelated;
  padding: 0 18px;
  font-family: var(--font-pixel);
  font-weight: 500;
  font-size: 24px;
  letter-spacing: 3px;
  color: #fff;
  text-shadow: var(--text-outline);
  white-space: nowrap;
}
.gacha-box {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 14px 10px 18px;
  background: #7a4a34;
  border: 3px solid var(--outline);
  box-shadow: inset 0 0 0 3px #a86c48, inset 0 8px 14px rgba(30, 14, 6, .4);
}
.gacha-tier { color: #f5dcb4; font-size: 18px; }
.slots { display: grid; gap: 14px 16px; justify-content: center; }
.gacha[style*="68px"] .slots { gap: 10px 12px; }
.gacha[style*="68px"] .slot-label { font-size: 12px; min-width: 76px; }
.gacha[style*="68px"] .won-chip { font-size: 16px; }
.gacha[style*="68px"] .won-chip img { width: 24px; height: 24px; }
.slots.n1 { grid-template-columns: auto; }
.slots.n2 { grid-template-columns: repeat(2, auto); }
.slots.n3 { grid-template-columns: repeat(3, auto); }
.slot { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.slot-window {
  width: calc(var(--cell, 112px) + 8px);   /* inner size = one reel cell */
  height: calc(var(--cell, 112px) + 8px);
  overflow: hidden;
  background: #5a3626;
  border: 4px solid #e8b47a;
  box-shadow: 0 0 0 3px var(--outline), inset 0 10px 10px -6px rgba(0,0,0,.55), inset 0 -10px 10px -6px rgba(0,0,0,.55);
}
.reel { display: flex; flex-direction: column; will-change: transform; }
.reel .cell {
  flex: none;
  width: var(--cell, 112px);
  height: var(--cell, 112px);
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle, rgba(201,194,178,.45), transparent 62%);
}
.reel .cell img { width: 62%; height: 62%; }
.reel .cell.uncommon { background: radial-gradient(circle, rgba(143,209,106,.55), transparent 62%); }
.reel .cell.rare { background: radial-gradient(circle, rgba(90,180,240,.6), transparent 62%); }
.reel .cell.epic { background: radial-gradient(circle, rgba(214,107,224,.7), transparent 62%); }
.reel .cell.legendary { background: radial-gradient(circle, rgba(242,201,76,.85), transparent 66%); }
.reel.spinning .cell img { filter: blur(1.5px); }
.reel .cell.win img { animation: winpulse .5s steps(3) 3; }
.slot-label {
  border: 15px solid transparent;
  border-image: var(--ui-sign) 5 fill / 15px / 0 stretch;
  image-rendering: pixelated;
  margin: -6px 0;
  padding: 0 8px;
  min-width: 96px;
  text-align: center;
  font-family: var(--font-pixel);
  font-weight: 500;
  font-size: 14px;
  color: var(--cream-text);
  text-shadow: var(--text-outline);
}
.slot-label.common { color: #f0ebe0; }
.slot-label.uncommon { color: #b4f08a; }
.slot-label.rare { color: #9adcff; }
.slot-label.epic { color: #f5b0f8; }
.slot-label.legendary { color: #ffe680; }
@keyframes winpulse { 50% { transform: scale(1.15); } }
.gacha-actions { gap: 12px; }
.btn.big { min-width: 150px; min-height: 52px; font-size: 18px; }

.won-list { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; max-width: 500px; }
.won-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px 2px 2px;
  font-size: 18px;
  background: rgba(60, 30, 16, .35);
  border: 2px solid var(--outline);
  border-bottom-width: 4px;
}
.won-chip.common { border-bottom-color: var(--c-common); }
.won-chip.uncommon { border-bottom-color: var(--c-uncommon); }
.won-chip.rare { border-bottom-color: var(--c-rare); }
.won-chip.epic { border-bottom-color: var(--c-epic); }
.won-chip.legendary { border-bottom-color: var(--c-legendary); }
.won-name.legendary { color: #ffe680; }
.won-name.epic { color: #f5b0f8; }
.won-name.rare { color: #9adcff; }

/* Market: batch size picker. */
.qty-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.qty-custom { display: inline-flex; align-items: center; gap: 6px; font-size: 18px; color: var(--ink-soft); }
.qty-custom input {
  width: 58px;
  font: inherit;
  font-size: 20px;
  color: var(--ink);
  background: #fffaf0;
  border: 3px solid var(--outline);
  padding: 2px 6px;
}
.qty-custom.on input { outline: 3px solid #7484cc; }

.gacha-result { min-height: 40px; display: flex; flex-direction: column; align-items: center; justify-content: center; margin-top: 12px; }
.won { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; animation: pop .35s steps(4); }
.won-name { font-family: var(--font-pixel); font-weight: 500; font-size: 28px; text-shadow: var(--text-outline); color: var(--cream-text); }

.reveal { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.reveal p { margin: 0; }
.reveal .stage.pop { animation: pop .4s steps(4); }
.reveal h4 { font-size: 24px; }
.stats { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }

@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 70% { transform: scale(1.1); opacity: 1; } 100% { transform: scale(1); } }

.toasts {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  width: min(440px, calc(100% - 32px));
}
.toast { padding: 0 6px; text-align: center; animation: pop .25s steps(3); }
.toast.bad { border-image-source: var(--ui-orange); }

.float {
  position: fixed;
  z-index: 45;
  pointer-events: none;
  font-family: var(--font-pixel);
  font-weight: 500;
  font-size: 16px;
  color: #fff6c0;
  transform: translateX(-50%);
  text-shadow: 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 2px 0 var(--ink), 0 -2px 0 var(--ink);
  animation: rise 1.2s steps(8) forwards;
  white-space: nowrap;
}
@keyframes rise { to { transform: translate(-50%, -46px); opacity: 0; } }

.dev {
  position: fixed;
  right: 10px;
  bottom: 10px;
  z-index: 20;
  background: var(--bad);
  color: #fff;
  font-size: 16px;
  padding: 2px 8px;
  border: 2px solid var(--ink);
}

/* --- Responsive ------------------------------------------------------------- */

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; grid-template-areas: "hud" "nav" "main"; }
  .tabs { flex-direction: row; overflow-x: auto; position: static; }
  .tabs button { flex: none; }
  .nameplate { min-width: 0; }
}

/* --- Profile forms and leaderboard ------------------------------------------ */

.form { display: flex; flex-direction: column; gap: 10px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 18px; color: var(--ink-soft); }
.form input {
  font: inherit;
  font-size: 22px;
  color: var(--ink);
  background: #fffaf0;
  border: 3px solid var(--ink);
  box-shadow: inset 0 3px 0 #e0cca4;
  padding: 4px 8px;
  border-radius: 0;
}
.form input:focus { outline: 3px solid #f2c94c; outline-offset: 0; }
.form .btn { align-self: flex-start; }
.form p { margin: 0; }
hr.rule { border: 0; border-top: 2px solid #dcc69a; margin: 16px 0; }
.leaders tr.you td { background: #fbe7a8; }
.leaders tr.gap td { border-top: 4px dotted #c8ac7a; }

/* Welcome screen farmer. */
.intro-logo { margin: 4px auto 2px; animation: bob 2.4s steps(2) infinite; }

/* $CROP deposit card. */
.copy-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
code.addr {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 13px;
  background: #fffaf0;
  border: 2px solid var(--outline);
  padding: 4px 6px;
  word-break: break-all;
  user-select: all;
}
code.addr.small { font-size: 11px; padding: 1px 4px; border-width: 1px; }

/* Top bar, right: $CROP contract address and Deposit button. */
.hud-crop { order: 3; margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hud-crop[hidden] { display: none; }
.ca-pill {
  display: inline-flex; align-items: center; gap: 8px;
  border: 15px solid transparent;
  border-image: var(--ui-pill) 5 fill / 15px / 0 stretch;
  image-rendering: pixelated;
  padding: 0 2px;
  min-height: 44px;
  cursor: copy;
}
.ca-pill .ca-label { font-family: var(--font-pixel); font-size: 13px; color: var(--ink-soft); }
.ca-pill code { font-family: ui-monospace, Menlo, monospace; font-size: 14px; color: var(--ink); }
.ca-pill .ca-copy { font-size: 16px; color: #5a6aa8; }
.ca-pill:hover { filter: brightness(1.05); }
.ca-buy {
  font-family: var(--font-pixel); font-size: 14px;
  color: var(--cream-text); text-shadow: var(--text-outline); text-decoration: underline;
}
.hud .btn[data-action="deposit"] { min-height: 46px; font-size: 16px; }
.deposit-panel { display: flex; flex-direction: column; gap: 10px; }
@media (max-width: 760px) { .hud-crop { order: 0; margin-left: 0; width: 100%; } }

/* Unit labels on the top-bar boxes, so gems and XP can't be mixed up. */
.hud .pill small.unit { font-family: var(--font-pixel); font-size: 12px; color: var(--ink-soft); margin-left: -2px; }

/* Potions. */
img.px.grade-2 { filter: drop-shadow(0 0 3px #8ad4ff); }
img.px.grade-3 { filter: drop-shadow(0 0 4px #ffe070) drop-shadow(0 0 2px #ffe070); }
.recipe { display: flex; flex-direction: column; gap: 4px; padding: 6px 0; }
.recipe .row { justify-content: space-between; }
.or { text-align: center; color: var(--ink-soft); font-size: 16px; }
.stage.cauldron { position: relative; animation: wobble .5s steps(2) infinite; }
.stage.cauldron .bubbles i {
  position: absolute; bottom: 40%; width: 10px; height: 10px; border: 2px solid var(--outline);
  background: #a6f0a0; border-radius: 50%; animation: bubble 1.1s steps(6) infinite;
}
.stage.cauldron .bubbles i:nth-child(1) { left: 38%; animation-delay: 0s; }
.stage.cauldron .bubbles i:nth-child(2) { left: 50%; animation-delay: .3s; }
.stage.cauldron .bubbles i:nth-child(3) { left: 58%; animation-delay: .6s; }
.stage.cauldron .bubbles i:nth-child(4) { left: 45%; animation-delay: .85s; }
.stage.fizzled img { filter: grayscale(1) brightness(.7); }
.grade-glow-2 { background: radial-gradient(circle, rgba(90,180,240,.7), transparent 66%); border-radius: 50%; }
.grade-glow-3 { background: radial-gradient(circle, rgba(242,201,76,.95), transparent 70%); border-radius: 50%; }
@keyframes wobble { 50% { transform: rotate(-4deg) translateY(-2px); } }
@keyframes bubble { 0% { transform: translateY(0); opacity: 1; } 100% { transform: translateY(-70px); opacity: 0; } }

/* History. */
b.up { color: #2f8a3a; }
b.down { color: #b8402e; }

/* Sound toggle in the top bar. */
.hud .sound-btn { font-family: var(--font-pixel); font-size: 13px; color: var(--ink-soft); cursor: pointer; padding: 0 6px; }

/* Treasure chest opening. */
.treasure .chest-stage {
  position: relative; width: 220px; height: 200px;
  display: flex; align-items: center; justify-content: center;
}
.treasure .chest-img { position: relative; z-index: 2; }
.treasure .rattling .chest-img { animation: rattle .12s steps(2) infinite; }
.treasure .rays {
  position: absolute; inset: -20px; z-index: 1; opacity: 0;
  background: repeating-conic-gradient(from 0deg, rgba(255, 230, 128, .55) 0 10deg, transparent 10deg 24deg);
  -webkit-mask: radial-gradient(circle, #000 20%, transparent 68%);
          mask: radial-gradient(circle, #000 20%, transparent 68%);
}
.treasure .open .rays { opacity: 1; animation: spin-rays 6s linear infinite, fade-in .3s ease-out; }
.treasure .open .chest-img { animation: chest-pop .45s steps(5); }
.treasure .sparkles i {
  position: absolute; z-index: 3; left: 50%; top: 48%; width: 8px; height: 8px; opacity: 0;
  background: #fff6c0; box-shadow: 0 0 0 2px #f2c94c;
  transform: rotate(45deg);
}
.treasure .open .sparkles i { animation: sparkle .9s ease-out forwards; }
.treasure .open .sparkles i:nth-child(1) { --dx: -90px; --dy: -70px; }
.treasure .open .sparkles i:nth-child(2) { --dx: 80px; --dy: -80px; animation-delay: .05s; }
.treasure .open .sparkles i:nth-child(3) { --dx: -110px; --dy: 0; animation-delay: .1s; }
.treasure .open .sparkles i:nth-child(4) { --dx: 105px; --dy: 10px; animation-delay: .12s; }
.treasure .open .sparkles i:nth-child(5) { --dx: -50px; --dy: -110px; animation-delay: .08s; }
.treasure .open .sparkles i:nth-child(6) { --dx: 40px; --dy: -115px; animation-delay: .15s; }
.treasure .open .sparkles i:nth-child(7) { --dx: -80px; --dy: 60px; animation-delay: .2s; }
.treasure .open .sparkles i:nth-child(8) { --dx: 85px; --dy: 65px; animation-delay: .18s; }
.treasure .open .sparkles i:nth-child(9) { --dx: 0; --dy: -125px; animation-delay: .1s; }
.treasure .open .sparkles i:nth-child(10) { --dx: 0; --dy: 90px; animation-delay: .25s; }
.treasure-loot { display: flex; flex-direction: column; align-items: center; gap: 10px; animation: pop .4s steps(4) .25s both; }
.loot-gems { display: flex; align-items: center; gap: 6px; font-family: var(--font-pixel); font-size: 26px; }
.loot-gems span { font-size: 16px; color: var(--ink-soft); }
.loot-prize { display: flex; align-items: center; gap: 10px; font-size: 22px; }
@keyframes rattle { 0% { transform: translate(-3px, 0) rotate(-3deg); } 100% { transform: translate(3px, -2px) rotate(3deg); } }
@keyframes chest-pop { 0% { transform: scale(.8); } 60% { transform: scale(1.18) translateY(-8px); } 100% { transform: scale(1); } }
@keyframes spin-rays { to { transform: rotate(360deg); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes sparkle {
  0% { opacity: 1; transform: translate(-50%, -50%) rotate(45deg) scale(.4); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(45deg) scale(1.2); }
}

.chest-table th .muted { display: block; font-size: 15px; font-weight: normal; }

.odds tr.pending td { color: var(--ink-soft); }

.odds tr.total td { border-top: 2px solid var(--outline); border-bottom: 0; }

/* Farm switcher. */
.farm-bar { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; justify-content: space-between; margin: 0 8px 6px; }
.farm-title { color: var(--cream-text); text-shadow: var(--text-outline); font-size: 20px; }
.farm-title b { font-family: var(--font-pixel); font-weight: 500; font-size: 18px; }
.farm-tabs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.farm-tab {
  position: relative; min-width: 34px; min-height: 34px; padding: 0 2px;
  border: 10px solid transparent; border-image: var(--ui-cream) 5 fill / 10px / 0 stretch; image-rendering: pixelated;
  font-family: var(--font-pixel); font-size: 13px; color: var(--ink);
}
.farm-tab.active { border-image-source: var(--ui-blue); color: #fff; text-shadow: var(--text-outline); }
.farm-tab .ready-dot { position: absolute; top: -8px; right: -8px; width: 9px; height: 9px; background: #6cc04a; border: 2px solid var(--outline); }
