:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f1f3f5);
  --section: var(--tg-theme-section-bg-color, var(--bg));
  --text: var(--tg-theme-text-color, #111111);
  --hint: var(--tg-theme-hint-color, #8a8f98);
  --link: var(--tg-theme-link-color, #2481cc);
  --btn: var(--tg-theme-button-color, #2ea44f);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --accent: var(--tg-theme-accent-text-color, var(--btn));
  --danger: var(--tg-theme-destructive-text-color, #e5484d);
  --soil: #7a5230;
  --soil-dark: #5c3d22;
  --c-common: #9ca3af;
  --c-rare: #3b82f6;
  --c-epic: #a855f7;
  --c-legendary: #f59e0b;
  --c-mythic: #ef4444;
  --radius: 14px;
  --tabbar-h: 62px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg2);
  color: var(--text);
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  user-select: none;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
img { -webkit-user-drag: none; }
.hidden { display: none !important; }
.ico { width: 20px; height: 20px; vertical-align: middle; }
.muted { color: var(--hint); font-size: 13px; }

/* ------------------------------------------------------------ top bar --- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: var(--bg);
  border-bottom: 1px solid color-mix(in srgb, var(--hint) 20%, transparent);
}
.pill {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px;
  background: var(--bg2); font-weight: 700;
}
.lvl { flex: 1; }
.lvl-label { font-size: 12px; color: var(--hint); margin-bottom: 4px; display: flex; justify-content: space-between; }
.bar { height: 8px; border-radius: 6px; background: var(--bg2); overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--btn); border-radius: 6px; transition: width .4s; }

/* -------------------------------------------------------------- screen --- */
main { padding: 14px 14px calc(var(--tabbar-h) + 20px + env(safe-area-inset-bottom)); }
h2 { font-size: 18px; margin: 4px 0 12px; }
.card {
  background: var(--section); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px;
}
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.btn {
  padding: 9px 14px; border-radius: 10px; font-weight: 600;
  background: var(--bg2); color: var(--text);
  transition: transform .08s, opacity .2s;
}
.btn:active { transform: scale(.96); }
.btn.primary { background: var(--btn); color: var(--btn-text); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.loading { text-align: center; padding: 80px 0; color: var(--hint); }
.spinner {
  width: 36px; height: 36px; margin: 0 auto 12px; border-radius: 50%;
  border: 4px solid var(--bg); border-top-color: var(--btn);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.rarity { font-size: 12px; font-weight: 700; }
.r-common { color: var(--c-common); }
.r-rare { color: var(--c-rare); }
.r-epic { color: var(--c-epic); }
.r-legendary { color: var(--c-legendary); }
.r-mythic { color: var(--c-mythic); }

/* ------------------------------------------------------------- items ---- */
.item { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.item + .item { border-top: 1px solid color-mix(in srgb, var(--hint) 15%, transparent); }
.item > img { width: 44px; height: 44px; flex: none; }
.item .name { font-weight: 600; }
.item .qty { font-weight: 700; font-size: 16px; }
.item.disabled { filter: grayscale(1); color: var(--hint); }
.item.disabled img { opacity: .55; }
.item .btns { display: flex; gap: 6px; }

/* ------------------------------------------------------------- chests --- */
.chest-card { text-align: center; }
.chest-card.elite { background: linear-gradient(160deg, color-mix(in srgb, var(--c-epic) 25%, var(--section)), var(--section)); }
.chest-card h3 { margin: 6px 0 2px; }
.odds { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 10px 0; }
.odds span { font-size: 12px; padding: 3px 8px; border-radius: 999px; background: var(--bg2); font-weight: 600; }
.pity { margin: 6px 0 10px; }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

/* --------------------------------------------------------- collection --- */
.coll { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.coll-item { background: var(--section); border-radius: var(--radius); padding: 10px 6px; text-align: center; border-bottom: 3px solid var(--rc, var(--hint)); }
.coll-item img { width: 52px; height: 52px; }
.coll-item.unknown img { filter: brightness(0) opacity(.35); }
.coll-item .name { font-size: 13px; font-weight: 600; margin-top: 4px; }
.coll-item .muted { font-size: 11px; }

/* ------------------------------------------------------------ profile --- */
.profile-head { display: flex; align-items: center; gap: 12px; }
.profile-head img { width: 56px; height: 56px; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 12px; }
.stat { background: var(--bg2); border-radius: 10px; padding: 8px 10px; }
.stat b { display: block; font-size: 17px; }
.seg { display: flex; gap: 6px; }
.seg .btn.on { background: var(--btn); color: var(--btn-text); }
.top-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.top-row .rank { width: 28px; text-align: center; font-weight: 700; color: var(--hint); }
.top-row.me { color: var(--accent); font-weight: 700; }
.switch { width: 46px; height: 28px; border-radius: 14px; background: var(--hint); position: relative; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch.on { background: var(--btn); }
.switch.on::after { transform: translateX(18px); }

/* ------------------------------------------------------------- tabbar --- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 6;
  display: flex; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg);
  border-top: 1px solid color-mix(in srgb, var(--hint) 20%, transparent);
}
.tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--hint); }
.tabbar button.active { color: var(--accent); }
.tab-ico { font-size: 22px; line-height: 1; }
.tab-txt { font-size: 11px; font-weight: 600; }

/* -------------------------------------------------------------- sheet --- */
/* One bottom sheet for everything: an opaque, non-scrolling shell (handle, close, sticky
   header) around a body that scrolls on its own — nothing ever draws over the map. */
.sheet-backdrop { position: fixed; inset: 0; z-index: 10; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; animation: fade .2s; overflow: hidden; }
.sheet {
  position: relative; width: 100%; max-height: 70vh; max-height: 70dvh; display: flex; flex-direction: column;
  background: var(--section); border-radius: 18px 18px 0 0; overflow: hidden;
  box-shadow: 0 -6px 24px rgba(0,0,0,.28); animation: up .25s ease-out;
}
.sheet-top { flex: none; position: relative; padding: 8px 16px 0; touch-action: none; }
.sheet-top .sheet-grip { margin: 0 auto 6px; }
.sheet-x { position: absolute; top: 6px; right: 8px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(120,124,150,.16); color: inherit; font-size: 16px; line-height: 34px; padding: 0; cursor: pointer; }
.sheet-head { padding-right: 36px; }
.sheet-head:empty { display: none; }
.sheet-head h2 { margin: 0 0 8px; font-size: 18px; }
.sheet-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: 4px 16px calc(16px + env(safe-area-inset-bottom)); }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

/* -------------------------------------------------------------- toast --- */
.toast {
  position: fixed; left: 50%; top: calc(var(--top-h, 52px) + 54px); z-index: 30;
  transform: translateX(-50%); max-width: 90%;
  background: rgba(20,20,20,.9); color: #fff; padding: 10px 16px; border-radius: 12px;
  font-size: 14px; text-align: center; animation: fade .2s;
}

/* ----------------------------------------------------- chest overlay --- */
.chest-overlay {
  --glow: #ffffff;
  position: fixed; inset: 0; z-index: 20;
  background: radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--glow) 35%, #111) 0%, #0b0b10 70%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  overflow: hidden; animation: fade .25s;
}
.chest-img { width: 160px; height: 160px; position: relative; z-index: 2; filter: drop-shadow(0 0 0 var(--glow)); transition: filter .4s; }
.chest-overlay.shaking .chest-img { animation: shake .5s ease-in-out infinite; filter: drop-shadow(0 0 18px var(--glow)); }
.chest-overlay.charging .chest-img { animation: shake .18s linear infinite; filter: drop-shadow(0 0 40px var(--glow)) drop-shadow(0 0 70px var(--glow)); }
.chest-overlay.opened .chest-img { animation: pop .45s ease-in forwards; }
@keyframes shake {
  0%,100% { transform: rotate(0) translateX(0); }
  20% { transform: rotate(-7deg) translateX(-4px); }
  40% { transform: rotate(6deg) translateX(4px); }
  60% { transform: rotate(-5deg) translateX(-3px); }
  80% { transform: rotate(4deg) translateX(2px); }
}
@keyframes pop { 0% { transform: scale(1); opacity: 1; } 60% { transform: scale(1.35); opacity: 1; } 100% { transform: scale(.2); opacity: 0; } }

.fx-rays {
  position: absolute; width: 200vmax; height: 200vmax; opacity: 0;
  background: repeating-conic-gradient(from 0deg, color-mix(in srgb, var(--glow) 40%, transparent) 0 8deg, transparent 8deg 24deg);
  -webkit-mask: radial-gradient(circle, #000 0, transparent 45%); mask: radial-gradient(circle, #000 0, transparent 45%);
  transition: opacity .6s;
}
.chest-overlay.opened .fx-rays { opacity: 1; animation: spin 14s linear infinite; }
.chest-overlay.r-mythic-fx .fx-rays { background: repeating-conic-gradient(#ef4444 0 6deg, transparent 6deg 15deg, #f59e0b 15deg 21deg, transparent 21deg 30deg, #a855f7 30deg 36deg, transparent 36deg 45deg); }

.fx-particles { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.fx-p {
  position: absolute; left: 50%; top: 45%;
  width: var(--s, 8px); height: var(--s, 8px); border-radius: 50%;
  background: var(--c, var(--glow)); box-shadow: 0 0 8px var(--c, var(--glow));
  animation: burst var(--d, 1.1s) cubic-bezier(.15,.7,.3,1) forwards;
}
.fx-p.star { border-radius: 2px; transform: rotate(45deg); }
@keyframes burst {
  0% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.2); opacity: 0; }
}

.reveal { position: absolute; z-index: 4; text-align: center; color: #fff; animation: reveal .5s cubic-bezier(.2,1.6,.4,1); padding: 0 24px; }
.reveal-img { width: 140px; height: 140px; filter: drop-shadow(0 0 22px var(--glow)); animation: float 3s ease-in-out infinite; }
.reveal-rarity { font-size: 14px; font-weight: 800; letter-spacing: 3px; text-transform: uppercase; color: var(--glow); text-shadow: 0 0 12px var(--glow); }
.reveal-name { font-size: 24px; font-weight: 800; margin-top: 6px; }
.reveal-qty { font-size: 18px; opacity: .85; margin: 4px 0 18px; }
.reveal-pity { font-size: 13px; color: var(--c-legendary); margin: -10px 0 14px; }
.reveal .btn { min-width: 180px; }
@keyframes reveal { from { transform: scale(.3); opacity: 0; } }

/* ---------------------------------------------------------------- map --- */
.map-wrap {
  position: fixed; left: 0; right: 0; z-index: 1;
  top: var(--top-h, 52px);
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  background: radial-gradient(ellipse at 50% 40%, #a6d98a 0%, #6fae4c 55%, #4e8a37 100%);
  overflow: hidden;
}
#map-canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.map-fx { position: absolute; inset: 0; pointer-events: none; }
.map-pop {
  position: absolute; transform: translate(-50%, -50%);
  display: flex; align-items: center; gap: 4px;
  font-weight: 800; font-size: 17px; color: #fff; white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0,0,0,.7), 0 0 2px rgba(0,0,0,.6);
  animation: map-pop 1.3s ease-out both;
}
.map-pop img { width: 26px; height: 26px; }
.map-pop.xp { color: #ffe066; font-size: 15px; }
@keyframes map-pop {
  0% { transform: translate(-50%, -20%) scale(.4); opacity: 0; }
  15% { transform: translate(-50%, -60%) scale(1.15); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(-50%, -260%) scale(1); opacity: 0; }
}
.map-hud { position: absolute; inset: 0; padding: 10px 12px; pointer-events: none; display: flex; flex-direction: column; justify-content: flex-end; }
.map-hud > * { pointer-events: auto; }
.hud-top { position: absolute; top: 10px; right: 12px; display: flex; gap: 8px; }
.hud-btn {
  background: var(--bg); color: var(--text);
  box-shadow: 0 2px 8px rgba(0,0,0,.25); border-radius: 12px; padding: 9px 12px;
}
.hud-main { width: 100%; box-shadow: 0 3px 10px rgba(0,0,0,.3); padding: 12px; font-size: 16px; }
.hud-info {
  position: absolute; top: 10px; left: 12px; font-size: 12px; font-weight: 600;
  background: rgba(0,0,0,.35); color: #fff; padding: 4px 10px; border-radius: 999px;
}
.mode-bar {
  background: var(--bg); border-radius: 16px; padding: 10px 12px;
  box-shadow: 0 3px 14px rgba(0,0,0,.3);
}
.mode-bar .mode-title { font-weight: 700; }
.mode-bar .mode-hint { font-size: 12px; color: var(--hint); margin: 2px 0 8px; }
.mode-bar .btns { display: flex; gap: 8px; }
.mode-bar .btns .btn { flex: 1; }
.btn.danger { color: var(--danger); }
.shop-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.shop-item > img { width: 52px; height: 52px; object-fit: contain; }
.shop-section { font-size: 13px; font-weight: 700; color: var(--hint); text-transform: uppercase; margin: 14px 0 2px; }

/* --------------------------------------------------------------- juice --- */
.fly-icon {
  position: fixed; z-index: 40; width: 28px; height: 28px; margin: -14px 0 0 -14px; pointer-events: none;
  transition: transform .6s cubic-bezier(.5, -0.3, .7, .4), opacity .6s ease-in;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.35));
}
.bump { animation: bump .35s ease-out; }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.22); } 100% { transform: scale(1); } }
.hud-btn:active, .hud-main:active { transform: scale(.94); }

/* =================================================== Kenney UI skin ===
   Images come from manifest.json "skin" as --skin-* CSS variables (set by app.js
   with versioned URLs). Buttons are 9-sliced from Kenney's @2x rectangles
   (4px outline + 8px depth lip at 2x -> slice 20 20 28). Panels are drawn by a
   ::before layer so they can be darkened in Telegram's dark theme without
   touching the text. */
:root { --skin-ink: #3d405b; }

.skinned .btn {
  background: none; border-radius: 0; color: var(--skin-ink);
  border-style: solid; border-width: 0;
  border-image: var(--skin-btn-grey) 20 20 28 fill / 10px 10px 14px stretch;
  padding: 10px 14px 13px; font-weight: 800; letter-spacing: .2px;
}
.skinned .btn.small { padding: 7px 11px 10px; }
.skinned .btn:active { transform: translateY(2px) scale(.98); }
.skinned .seg .btn.on { background: none; }
.skinned .btn.primary, .skinned .seg .btn.on { border-image-source: var(--skin-btn-green); color: #fff; text-shadow: 0 1px 0 rgba(0,70,40,.55); }
.skinned .btn.yellow { border-image-source: var(--skin-btn-yellow); color: #5a3d00; }
.skinned .btn.blue { border-image-source: var(--skin-btn-blue); color: #fff; text-shadow: 0 1px 0 rgba(0,40,90,.5); }
.skinned .btn.danger { border-image-source: var(--skin-btn-red); color: #fff; text-shadow: 0 1px 0 rgba(90,0,0,.45); }
.skinned .btn[disabled] { opacity: .5; filter: grayscale(.7); }
.skinned .hud-btn { box-shadow: none; filter: drop-shadow(0 3px 4px rgba(0,0,0,.25)); }
.skinned .hud-main { box-shadow: none; filter: drop-shadow(0 4px 6px rgba(0,0,0,.3)); font-size: 17px; }

/* panels */
.skinned .card, .skinned .mode-bar, .skinned .sheet, .skinned .coll-item, .skinned .stat {
  position: relative; isolation: isolate; background: none; box-shadow: none;
}
.skinned .card::before, .skinned .mode-bar::before, .skinned .sheet::before, .skinned .coll-item::before, .skinned .stat::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  border-style: solid; border-width: 0;
  border-image: var(--skin-panel) 20 fill / 12px stretch;
}
/* sheets: solid panel colour (the 9-slice art can't be rounded or follow a scrolling body) */
.skinned .sheet { border-radius: 18px 18px 0 0; background: #e3e5ee; }
.skinned .sheet::before { display: none; }
.skinned.dark .sheet { background: #24263a; }
.skinned .stat::before { border-image-width: 9px; opacity: .85; }
.skinned .coll-item { border-bottom: 0; padding-bottom: 14px; }
.skinned .coll-item::after { content: ""; position: absolute; left: 14px; right: 14px; bottom: 6px; height: 4px; border-radius: 2px; background: var(--rc, var(--hint)); }
.skinned .mode-bar { filter: drop-shadow(0 4px 10px rgba(0,0,0,.3)); }
/* light panels: always dark ink */
.skinned:not(.dark) .card, .skinned:not(.dark) .mode-bar, .skinned:not(.dark) .sheet,
.skinned:not(.dark) .coll-item, .skinned:not(.dark) .stat { color: var(--skin-ink); --hint: #6f7390; }
/* dark theme: same art, darkened, light text */
.skinned.dark .card::before, .skinned.dark .mode-bar::before, .skinned.dark .sheet::before,
.skinned.dark .coll-item::before, .skinned.dark .stat::before { filter: brightness(.3) saturate(1.4); }
.skinned.dark .card, .skinned.dark .mode-bar, .skinned.dark .sheet, .skinned.dark .coll-item, .skinned.dark .stat { color: #f1f2f8; --hint: #a9adc4; }
.skinned .item + .item { border-top-color: rgba(120,124,150,.25); }

/* top bar: coin counter + XP bar */
.skinned .pill {
  background: none; border-style: solid; border-width: 0;
  border-image: var(--skin-bar-track) 20 fill / 10px stretch;
  padding: 6px 14px 6px 8px; color: var(--skin-ink);
}
.skinned .pill .ico { width: 26px; height: 26px; }
/* numbers: same bold UI font, tabular so counters don't jiggle */
#coins span, .lvl-label span:last-child, .num, .qty { font-variant-numeric: tabular-nums; }
#coins span { font-size: 19px; font-weight: 800; letter-spacing: .2px; }
.lvl-label span:last-child { font-weight: 700; color: var(--text); }
.skinned .bar { height: 16px; background: none; border-radius: 0; border-style: solid; border-width: 0; border-image: var(--skin-bar-track) 20 fill / 8px stretch; }
.skinned .bar-fill { min-width: 16px; background: none; border-radius: 0; border-style: solid; border-width: 0; border-image: var(--skin-bar-fill) 20 fill / 8px stretch; }

/* tab bar */
.skinned .tabbar { padding-left: 4px; padding-right: 4px; }
.skinned .tabbar button { position: relative; isolation: isolate; margin: 6px 2px 4px; color: var(--hint); }
.skinned .tabbar button::before {
  content: ""; position: absolute; inset: 0; z-index: -1; opacity: 0; transition: opacity .15s;
  border-style: solid; border-width: 0; border-image: var(--skin-tab-active) 20 20 28 fill / 9px 9px 12px stretch;
}
.skinned .tabbar button.active::before { opacity: 1; }
.skinned .tabbar button.active { color: #5a3d00; }
.skinned .tab-ico img { width: 30px; height: 30px; object-fit: contain; display: block; filter: drop-shadow(0 1px 1px rgba(0,0,0,.25)); }
.skinned .tabbar button:not(.active) .tab-ico img { opacity: .8; }

/* toggles: Kenney check boxes */
.skinned .switch { width: 36px; height: 36px; border-radius: 0; background: var(--skin-check-off) center / contain no-repeat; }
.skinned .switch.on { background-image: var(--skin-check-on); }
.skinned .switch::after { display: none; }

.skinned .chest-img { width: 190px; height: 170px; object-fit: contain; }
.skinned .reveal-img { width: 150px; height: 150px; object-fit: contain; }
.skinned .shop-item > img, .skinned .item > img { object-fit: contain; }

/* ============================================================ chests v2 === */
.chests-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.chests-head h2 { margin: 0; }
.chest-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
@media (max-width: 330px) { .chest-grid { grid-template-columns: 1fr; } }
.chest-card { text-align: center; padding: 12px 10px; margin: 0; display: flex; flex-direction: column; align-items: center; }
.chest-card h3 { margin: 4px 0 2px; font-size: 16px; }
.chest-desc { font-size: 12px; min-height: 2.6em; margin-bottom: 8px; }
.chest-sprite { position: relative; width: 100%; height: 108px; display: flex; align-items: center; justify-content: center; }
.chest-sprite img { position: relative; z-index: 1; width: 112px; height: 100px; object-fit: contain; animation: float 3s ease-in-out infinite; }
.chest-sprite.wobble img { animation: wobble .55s ease-out; }
@keyframes wobble {
  0% { transform: rotate(0) scale(1); } 20% { transform: rotate(-9deg) scale(1.06, .94); } 40% { transform: rotate(7deg) scale(.96, 1.05); }
  60% { transform: rotate(-4deg); } 80% { transform: rotate(2deg); } 100% { transform: rotate(0) scale(1); }
}
/* premium: purple/gold glow behind the chest + gold rim */
.chest-card.elite::after {
  content: ""; position: absolute; inset: 1px; z-index: -1; pointer-events: none; border-radius: 8px;
  box-shadow: inset 0 0 0 2px rgba(255, 196, 60, .85), 0 0 14px rgba(168, 85, 247, .45);
  animation: rim 2.6s ease-in-out infinite;
}
@keyframes rim { 50% { box-shadow: inset 0 0 0 2px rgba(255, 220, 110, 1), 0 0 22px rgba(168, 85, 247, .7); } }
.chest-glow {
  position: absolute; left: 50%; top: 50%; width: 130px; height: 110px; transform: translate(-50%, -50%);
  border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(255, 214, 90, .75) 0%, rgba(168, 85, 247, .45) 45%, transparent 72%);
  animation: glow 2.4s ease-in-out infinite;
}
@keyframes glow { 0%, 100% { opacity: .55; transform: translate(-50%, -50%) scale(.92); } 50% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); } }

/* ~48px price buttons with a small inline icon */
.btn.price { width: 100%; min-height: 48px; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 16px; margin-top: auto; }
.ico20, .btn .ico20 { width: 20px; height: 20px; flex: none; object-fit: contain; animation: none; }
.skinned .btn.gold { border-image-source: var(--skin-btn-yellow); color: #5a3800; text-shadow: 0 1px 0 rgba(255,255,255,.4); }
.skinned .btn.short { border-image-source: var(--skin-btn-grey); color: #a1262d; font-size: 14px; }
.btn.gold:not(.skinned *) { background: #f5b400; color: #4a2f00; }

.pity-card { margin: 10px 0 0; padding: 10px 14px 12px; }
.pity-card .row { font-size: 13px; margin-bottom: 6px; }
.skinned .bar.thin, .bar.thin { height: 10px; border-image-width: 5px; }
.skinned .bar.thin .bar-fill { min-width: 10px; border-image-width: 5px; }
.chest-note { text-align: center; font-size: 12px; margin: 10px 4px 0; }

.odds-table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 4px 0 10px; }
.odds-table th { text-align: left; font-size: 12px; color: var(--hint); font-weight: 700; padding: 6px 4px; }
.odds-table td { padding: 8px 4px; font-weight: 700; border-top: 1px solid rgba(120,124,150,.22); font-variant-numeric: tabular-nums; }
.odds-table td:not(:first-child), .odds-table th:not(:first-child) { text-align: right; }

/* reward screen actions */
.reveal-btns { display: flex; gap: 10px; justify-content: center; }
.reveal .reveal-btns .btn { min-width: 0; flex: 1; max-width: 170px; min-height: 48px; }
.reveal-close {
  position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 14px; z-index: 5;
  width: 40px; height: 40px; border-radius: 50%; font-size: 18px; color: #fff; background: rgba(255,255,255,.14);
}
.top-seg { margin-bottom: 10px; }
.top-seg .btn:first-child { flex: 0 0 auto; }
.top-seg .btn:last-child { flex: 1; }

/* avatars: letter circle underneath, photo on top when it loads */
.ava { position: relative; flex: none; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; overflow: hidden; color: #fff; font-weight: 800; line-height: 1;
  text-shadow: 0 1px 2px rgba(0,0,0,.25); box-shadow: 0 0 0 2px rgba(255,255,255,.85), 0 1px 3px rgba(0,0,0,.25); }
.ava img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.top-row .ava { margin-right: 2px; }

/* ------------------------------------------------------------- social --- */
.guest-bar { margin: 0 0 auto; padding: 10px 12px; }
.guest-bar .row { gap: 10px; }
.guest-bar .muted { font-size: 12px; }
.guest-btns { display: flex; gap: 8px; margin-top: 8px; }
.guest-btns .btn { flex: 1; }
.friend-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.friend-row + .friend-row { border-top: 1px solid rgba(120,124,150,.22); }
.friend-row .grow { min-width: 0; }
.friend-row .grow b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-row .btns { display: flex; gap: 6px; flex: none; }
.can-help { color: #1f9d55; font-weight: 700; }
.top-row[data-act] { cursor: pointer; }
.chests-head .btns { display: flex; gap: 6px; }
.map-pop .split { font-size: 12px; font-weight: 700; color: #eaffd8; }

/* land chunks */
.chunk-preview { display: flex; justify-content: center; padding: 6px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px 3px 4px; border-radius: 999px; background: rgba(120,124,150,.16); font-weight: 700; font-size: 13px; }
.chip img { width: 26px; height: 26px; object-fit: contain; }

/* small land sheet: map stays visible behind it */
.sheet-backdrop.light { background: rgba(0,0,0,.3); }
.sheet { transition: transform .12s ease-out; }
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: rgba(120,124,150,.45); margin: -6px auto 8px; }
.chunk-msg { font-weight: 700; font-size: 16px; margin: 4px 0 8px; }
.chunk-facts { gap: 8px; margin: 2px 0 10px; }
.chunk-facts b { display: flex; align-items: center; gap: 4px; font-size: 16px; }

/* ---------------------------------------------------------------- mine --- */
.mine-wrap {
  position: fixed; left: 0; right: 0; z-index: 1;
  top: var(--top-h, 52px); bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  background: #0b0705; overflow: hidden;
}
#mine-canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.mine-top { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; gap: 8px; align-items: flex-start; }
.mine-floors { flex: 1; flex-wrap: wrap; }
.mine-floors .btn.locked { opacity: .85; filter: grayscale(.6); }
.mine-picks { flex: none; }
.mine-hint { margin: auto auto 10px; max-width: 92%; text-align: center; font-size: 12px; font-weight: 600;
  color: rgba(255,240,220,.85); background: rgba(0,0,0,.45); border-radius: 999px; padding: 5px 12px; }
.descend { position: fixed; inset: 0; z-index: 25; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 40%, #2a1d12 0%, #050302 70%); opacity: 0; transition: opacity .35s; }
.descend.in { opacity: 1; }
.descend.out { opacity: 0; }
.descend-inner { text-align: center; color: #f3e3c8; font-weight: 800; font-size: 18px; }
.descend-inner img { width: 84px; height: 84px; animation: dig .5s ease-in-out infinite alternate; }
.descend.in .descend-inner { animation: sink .8s ease-in forwards; }
@keyframes dig { from { transform: rotate(-25deg); } to { transform: rotate(20deg) translateY(6px); } }
@keyframes sink { from { transform: translateY(-30px); } to { transform: translateY(40px); } }
.chip.lack { color: #b3261e; }
.res-cost { margin: 6px 0 10px; }
.barn-tabs .btn { flex: 1; }

/* plant mastery */
.mastery { margin-top: 4px; font-size: 12px; }
.mastery .bar { margin: 3px 6px 0; }
.mbonus { color: #1f9d55; font-weight: 800; }
.coll-item.frame-bronze { outline: 3px solid #c47a3a; outline-offset: -2px; border-radius: 12px; box-shadow: 0 0 8px rgba(196,122,58,.55); }
.coll-item.frame-silver { outline: 3px solid #aeb8c6; outline-offset: -2px; border-radius: 12px; box-shadow: 0 0 10px rgba(174,184,198,.8); }
.coll-item.frame-gold { outline: 3px solid #f0b62e; outline-offset: -2px; border-radius: 12px; box-shadow: 0 0 14px rgba(240,182,46,.9); }

/* breeding / varieties */
.tier-badge { display: inline-block; font-size: 11px; font-weight: 800; color: #6b3fd6; background: rgba(140,90,255,.14); border-radius: 999px; padding: 1px 6px; margin-left: 4px; vertical-align: middle; }
.tier-badge.corner { position: absolute; top: 6px; right: 6px; margin: 0; }
.breed-line { font-size: 12px; margin-top: 3px; }
.breed-card { padding: 10px 12px; font-size: 14px; }
.line-head { font-weight: 800; margin: 14px 2px 6px; }
.coll-line { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.coll-line .coll-item { padding: 8px 4px 12px; }
.coll-line .coll-item img { width: 40px; height: 40px; }
.coll-line .name { font-size: 11px; }
.coll-hint { font-size: 10px; line-height: 1.25; color: var(--hint); margin-top: 3px; }

.coll-item.secret { --rc: rgba(120,124,150,.4); }
.coll-item.secret .reveal-btn { margin-top: 6px; padding: 3px 8px 6px; font-size: 11px; display: inline-flex; align-items: center; gap: 2px; }
.coll-item.secret .reveal-btn .ico20 { width: 14px; height: 14px; }

/* bushes & fruit trees */
.per-head { gap: 12px; align-items: center; }
.per-head h2 { margin: 0 0 2px; }
.per-ico { width: 64px; height: 64px; object-fit: contain; flex: none; }
.coll-section { margin-top: 18px; }
.odds-table.small { font-size: 12px; }
.odds-table.small th { font-weight: 600; }
.chest-card.sapling { background: linear-gradient(160deg, color-mix(in srgb, #4caf50 18%, var(--section)), var(--section)); }

/* watering + genetics */
.hud-actions { display: flex; gap: 8px; width: 100%; pointer-events: none; }
.hud-actions > * { pointer-events: auto; }
.hud-actions .hud-main { flex: 1; width: auto; }
.hud-water { flex: 0 0 auto; padding: 12px 14px; font-size: 15px; background: #d9efff; color: #12507f; box-shadow: 0 3px 10px rgba(0,0,0,.25); }
.water-btn { margin-bottom: 8px; background: #e3f3ff; color: #12507f; }
.genes { display: inline-flex; flex-wrap: wrap; gap: 3px; vertical-align: middle; }
.gb { font-size: 11px; line-height: 16px; padding: 0 5px; border-radius: 999px; background: rgba(0,0,0,.06); color: var(--hint, #888); font-variant-numeric: tabular-nums; }
.gb.up { background: rgba(34,160,80,.15); color: #1a8a43; font-weight: 700; }
.gb.down { background: rgba(220,60,60,.13); color: #c0392b; font-weight: 700; }
.gene-card { padding: 8px 12px; }
.gene-row { display: grid; grid-template-columns: 24px 1fr auto; align-items: baseline; gap: 2px 6px; padding: 4px 0; border-bottom: 1px solid rgba(0,0,0,.05); }
.gene-row:last-child { border-bottom: 0; }
.gene-row .ge { grid-column: 2 / 4; font-size: 12px; }
.gene-row .gv { font-variant-numeric: tabular-nums; font-weight: 700; }
.gene-row.up .gv, td.up { color: #1a8a43; }
.gene-row.down .gv, td.down { color: #c0392b; }
.cdot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(0,0,0,.25); vertical-align: -1px; margin: 0 1px; }
.cdot.unknown { background: rgba(0,0,0,.08); font-size: 9px; line-height: 11px; text-align: center; color: #999; }
.coll-colors { font-size: 11px; margin-top: 2px; }
.strain-tools { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin: 4px 0 8px; }
.strain-tools select { margin-left: 4px; padding: 4px 6px; border-radius: 8px; border: 1px solid rgba(0,0,0,.15); background: var(--section, #fff); color: inherit; font: inherit; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.species-row { cursor: pointer; }
.species-row .chev { font-size: 18px; opacity: .6; padding: 0 4px; }
.strain-list { margin: 0 0 8px 14px; padding-left: 8px; border-left: 2px solid rgba(0,0,0,.08); }
.strain-row.picked { outline: 2px solid #6b3fd6; border-radius: 10px; }
.strain-row .name .cdot { margin-left: 4px; }
.strains-btn { margin-top: 4px; }
.breed-spot { background: linear-gradient(160deg, rgba(120,90,255,.12), var(--section, #fff)); }
.breed-pair { margin-top: 6px; }
.breed-pair .ico20 { width: 20px; height: 20px; object-fit: contain; vertical-align: middle; }
.num-input, .name-input { padding: 8px 10px; border-radius: 10px; border: 1px solid rgba(0,0,0,.15); font: inherit; background: var(--section, #fff); color: inherit; }
.num-input { width: 80px; }
.wide-btns { display: flex; gap: 8px; }
.wide-btns .btn { flex: 1; }
.cmp td, .cmp th { font-variant-numeric: tabular-nums; }

/* planting picker */
.pick-plot { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 13px; margin: -2px 0 6px; }
.water-chip { padding: 3px 10px; background: #e3f3ff; color: #12507f; }
.linkbtn { border: 0; background: none; padding: 0; font: inherit; color: inherit; cursor: pointer; text-align: left; }
.pick-plot .linkbtn { font-weight: 600; }
.pick-break { font-size: 13px; margin-bottom: 6px; max-height: 26vh; overflow-y: auto; }
.pick-break .card { margin: 6px 0 0; }
.pick-tools { display: flex; align-items: center; gap: 8px; padding: 2px 0 8px; border-bottom: 1px solid rgba(120,124,150,.22); }
.pick-tools .chips.scroll-x { flex: 1; min-width: 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.pick-tools .chips.scroll-x::-webkit-scrollbar { display: none; }
.pick-tools .chips .btn { flex: none; white-space: nowrap; }
.sort-toggle { flex: none; white-space: nowrap; }
.pick-row { display: flex; align-items: center; gap: 10px; min-height: 64px; padding: 6px 0; border-bottom: 1px solid rgba(120,124,150,.16);
  -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
.pick-row.locked { color: var(--hint); }
.pick-row.locked img { filter: grayscale(1); opacity: .6; }
.pick-ico { position: relative; flex: none; width: 46px; height: 46px; }
.pick-ico img { width: 46px; height: 46px; object-fit: contain; }
.mbadge { position: absolute; right: -4px; bottom: -2px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: #6b3fd6; color: #fff;
  font-size: 11px; font-weight: 800; line-height: 18px; text-align: center; box-shadow: 0 0 0 2px var(--section); }
.pick-main { flex: 1; min-width: 0; }
.pick-name { display: flex; align-items: center; gap: 6px; font-weight: 700; min-width: 0; }
.pick-name .rdot { flex: none; margin-right: 0; }
.pick-name .nm { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strains-link { flex: none; font-size: 12px; color: #6b3fd6; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: rgba(107,63,214,.1); }
.pick-sub { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick-sub .linkbtn { color: #6b3fd6; font-weight: 700; }
.rdot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.pick-qty { flex: none; font-weight: 700; font-variant-numeric: tabular-nums; }
.pick-why { flex: none; font-size: 12px; }
.pick-strains { margin: 0 0 4px 22px; padding-left: 10px; border-left: 2px solid rgba(107,63,214,.25); }
.pick-strain { display: flex; align-items: center; gap: 8px; padding: 5px 0; }
.ico28 { width: 28px; height: 28px; object-fit: contain; flex: none; }
.unavail-toggle { margin: 10px 0 2px; }
.pick-hint { text-align: center; margin-top: 10px; }

/* barn */
.barn-head { position: sticky; top: var(--top-h, 52px); z-index: 4; margin: -14px -14px 10px; padding: 10px 14px 8px;
  background: var(--bg); border-bottom: 1px solid color-mix(in srgb, var(--hint) 18%, transparent); }
.bh-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.bh-row h2 { margin: 0; flex: 1; min-width: 0; }
.bval { font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sell-everything { flex: none; white-space: nowrap; }
.barn-head .barn-tabs { margin: 0 0 8px; }
.bh-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.bh-chips::-webkit-scrollbar { display: none; }
.bh-chips > * { flex: none; white-space: nowrap; }
.btn.sel { padding: 0; }
.btn.sel select { appearance: none; -webkit-appearance: none; border: 0; background: none; color: inherit; font: inherit; font-weight: 600; padding: 6px 26px 6px 12px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 14px) 52%, calc(100% - 9px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
.chip-x { background: rgba(107,63,214,.12); color: #6b3fd6; }
.c16 { width: 16px; height: 16px; vertical-align: -3px; }
.blist { padding: 2px 12px; }
.brow, .bsub { display: flex; align-items: center; gap: 10px; min-height: 64px; padding: 6px 0; border-bottom: 1px solid rgba(120,124,150,.16); cursor: pointer; }
.blist > .brow:last-child, .bsubs > :last-child { border-bottom: 0; }
.bsub { min-height: 52px; }
.bi { width: 44px; height: 44px; object-fit: contain; flex: none; }
.bm { flex: 1; min-width: 0; }
.bl1, .bl2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bl1 { font-weight: 700; display: flex; align-items: center; gap: 4px; min-width: 0; }
.bl1 .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.bl1 .bq, .bl1 .nb, .bl1 .cdot { flex: none; }
.bl1 .lbl { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.bl2 { font-size: 12px; color: var(--hint); margin-top: 2px; }
.bl2 .lbl { font-size: 12px; }
.bbtns { flex: none; display: flex; gap: 6px; }
.bbtns .btn { padding: 7px 10px; }
.bsubs { margin-left: 22px; padding-left: 10px; border-left: 2px solid rgba(107,63,214,.22); border-bottom: 1px solid rgba(120,124,150,.16); }
.gt { font-weight: 700; margin-right: 6px; font-variant-numeric: tabular-nums; }
.gt.up { color: #1a8a43; }
.gt.down { color: #c0392b; }
.weak-btn { margin: 6px 0 8px; }
.pick-info { margin: 0 0 8px; }
.fl-h { font-size: 14px; margin: 14px 0 6px; }
.stepper { display: flex; align-items: center; gap: 6px; margin: 12px 0 4px; }
.stepper .num-input { width: 64px; text-align: center; }
.stepper .grow { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.detail-facts { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 8px 0; font-size: 14px; }
.h2sub { font-size: 13px; font-weight: 600; color: var(--hint); margin-left: 4px; }
.sheet-head h2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-head .ico28 { vertical-align: -6px; }

/* strain rarity */
.rk-up { color: #1a8a43; font-weight: 800; flex: none; }
.rk-down { color: #c0392b; font-weight: 800; }
.nm.r-common, .lbl.r-common, h2.r-common { color: inherit; }
.coll-best { font-size: 11px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.coll-item.has-best { box-shadow: 0 0 0 2px var(--rc), 0 0 12px color-mix(in srgb, var(--rc) 45%, transparent); }
.coll-item[data-act="species-page"] { cursor: pointer; }
.sp-strain { padding: 8px 0; border-bottom: 1px solid rgba(120,124,150,.16); }
.sp-strain[data-act] { cursor: pointer; }
.sp-strain.lost { opacity: 1; color: var(--hint); }
.sp-strain .bl2 { white-space: normal; }
.rbadge { flex: none; font-size: 11px; font-weight: 800; padding: 0 6px; border-radius: 999px; color: var(--rc); background: color-mix(in srgb, var(--rc) 14%, transparent); }
.lost-tag { flex: none; font-size: 11px; font-weight: 700; padding: 0 6px; border-radius: 999px; background: rgba(120,124,150,.18); color: var(--hint); }
.wide-input { width: 100%; box-sizing: border-box; margin: 4px 0; }
.grow-tag { background: rgba(34,160,80,.15); color: #1a8a43; }
