

:root {
  --ink: #120c06;
  --night: #0d120a;
  --bark: #2a1d10;
  --bark2: #1b130a;
  --moss: #4f6b2a;
  --moss2: #34481b;
  --leaf: #93d05a;
  --cream: #f4e6c3;
  --sand: #d8c39a;
  --gold: #f5c04a;
  --gold2: #c98a16;
  --amber: #ff9a3c;
  --sky: #6fc8ff;
  --red: #ff6b5a;
  --top: 56px;
  --dock: 0px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --px: Field, 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--night); color: var(--cream); font-family: var(--px); -webkit-font-smoothing: none; font-smooth: never; }
body { overflow: hidden; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
button, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img, canvas { image-rendering: pixelated; image-rendering: crisp-edges; }
h1, h2, h3, h4, p { margin: 0; }
small { font-size: 12px; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* bevelled pixel surfaces */
.bevel, .chip, .btn, .iconbtn, .altar, .sheet, .modal, .toast, .battle-bar, .battle-top, .tierbar, .seal-pill {
  border: 3px solid #000;
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, .12), inset 0 -4px 0 rgba(0, 0, 0, .35), 0 6px 0 rgba(0, 0, 0, .35);
}

/* boot */
.boot { position: fixed; inset: 0; z-index: 200; display: grid; place-content: center; gap: 14px; justify-items: center; background: var(--night); transition: opacity .4s; }
.boot.done { opacity: 0; pointer-events: none; }
.boot p { color: var(--sand); font-size: 14px; letter-spacing: .1em; }
.boot-ant { display: flex; gap: 6px; }
.boot-ant i { width: 14px; height: 14px; background: var(--gold); animation: hop 0.9s steps(3) infinite; }
.boot-ant i:nth-child(2) { animation-delay: .15s; background: var(--amber); }
.boot-ant i:nth-child(3) { animation-delay: .3s; background: var(--leaf); }
@keyframes hop { 50% { transform: translateY(-10px); } }

/* top bar */
.topbar { position: fixed; z-index: 30; left: 0; right: 0; top: 0; height: calc(var(--top) + var(--sat)); padding: var(--sat) 14px 0; display: flex; align-items: center; gap: 16px;
  background: linear-gradient(rgba(8, 6, 3, .62), rgba(8, 6, 3, .3) 70%, rgba(8, 6, 3, 0)); }
.topbar .tabs a, .brand { text-shadow: 0 2px 0 #000, 0 0 8px rgba(0, 0, 0, .8); }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-size: 20px; letter-spacing: .12em; white-space: nowrap; text-shadow: 0 2px 0 #000, 0 0 6px rgba(0, 0, 0, .7); }
.brand-mark { flex: none; width: 44px; height: 24px; image-rendering: pixelated; filter: drop-shadow(0 2px 0 #000); } /* bold pixel ant at 2x; the coin logo is the $蚁巢 token icon */
.back { display: none; align-items: center; gap: 6px; height: 36px; padding: 0 14px 0 10px; font-size: 15px; color: var(--cream); background: rgba(20, 14, 7, .78); border: 3px solid #000;
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, .12), inset 0 -4px 0 rgba(0, 0, 0, .35), 0 4px 0 rgba(0, 0, 0, .35); }
.back .arrow { font-size: 22px; line-height: 1; color: var(--gold); margin-top: -2px; }
.back:hover { background: rgba(40, 28, 12, .9); }
body:not([data-screen='lobby']) .brand { display: none; }
body:not([data-screen='lobby']) .back { display: inline-flex; }
.tabs { display: flex; gap: 2px; margin-left: 8px; }
.tabs a { white-space: nowrap; padding: 8px 12px; color: var(--cream); text-decoration: none; font-size: 15px; border: 2px solid transparent; }
.tabs a:hover { color: var(--cream); }
.tabs a.on { color: var(--gold); border-color: #000; background: rgba(20, 14, 6, .55); box-shadow: inset 0 -3px 0 var(--gold); }
.chips { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 12px; background: rgba(20, 14, 7, .78); font-size: 14px; white-space: nowrap; }
.chip small { color: var(--sand); }
.chip.block b { font-variant-numeric: tabular-nums; color: var(--sky); }
.chip.pool b { color: var(--gold); font-variant-numeric: tabular-nums; }
.chip .dot { width: 8px; height: 8px; background: var(--leaf); box-shadow: 0 0 8px var(--leaf); animation: blink 0.75s steps(2) infinite; }
@keyframes blink { 50% { opacity: .35; } }
.coin { width: 16px; height: 16px; background: radial-gradient(circle, var(--gold2) 0 30%, var(--gold) 31% 62%, #6b4300 63% 72%, transparent 73%); }
.chip.lang { gap: 4px; padding: 0 10px; font-size: 13px; }
.chip.lang i { font-style: normal; color: var(--sand); opacity: .6; }
.chip.lang b { color: var(--sand); opacity: .7; font-weight: 400; }
.chip.lang b.on { color: var(--gold); opacity: 1; font-weight: 700; }
.chip.pool .pool-k { color: var(--sand); }
.chip.wallet { background: var(--gold); color: var(--ink); font-weight: 700; }
.chip.wallet.on { background: rgba(26, 18, 9, .9); color: var(--cream); }
.chip.wallet.on b { color: var(--gold); }
.iconbtn { width: 36px; height: 36px; display: grid; place-items: center; background: rgba(20, 14, 7, .78); font-size: 18px; color: var(--gold); padding: 0; }
.iconbtn.off .ic-sound { opacity: .4; }

/* buttons */
.btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 10px; padding: 11px 18px; font-size: 16px; font-weight: 700; letter-spacing: .04em; overflow: hidden; transition: transform .06s; }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: inset 0 3px 0 rgba(255, 255, 255, .12), inset 0 -2px 0 rgba(0, 0, 0, .35), 0 2px 0 rgba(0, 0, 0, .35); }
.btn:disabled { filter: grayscale(.8) brightness(.7); cursor: default; }
.btn.big { padding: 15px 26px; font-size: 20px; }
.btn-gold { background: linear-gradient(#ffd769, var(--gold) 55%, #e39a1c); color: var(--ink); }
.btn-moss { background: linear-gradient(#6f8e3a, var(--moss) 60%, var(--moss2)); color: var(--cream); text-shadow: 0 2px 0 rgba(0, 0, 0, .5); }
.btn-ghost { background: rgba(20, 14, 7, .7); color: var(--sand); }
.sweep::after { content: ''; position: absolute; top: 0; bottom: 0; width: 30%; left: -45%; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .55), transparent); transform: skewX(-20deg); animation: sweep 2.8s ease-in-out infinite; }
.sweep:disabled::after { display: none; }
@keyframes sweep { 60%, 100% { left: 125%; } }

/* pixel icons (pure CSS) */
[class^='ic-'] { display: inline-block; width: 20px; height: 20px; flex: none; background: currentColor; }
.ic-cocoon { -webkit-mask: radial-gradient(ellipse 45% 50% at 50% 50%, #000 98%, transparent) ; mask: radial-gradient(ellipse 40% 50% at 50% 50%, #000 98%, transparent); }
.ic-sword { clip-path: polygon(80% 0, 100% 0, 100% 20%, 40% 75%, 50% 85%, 40% 95%, 30% 85%, 15% 100%, 0 85%, 15% 70%, 5% 60%, 15% 50%, 25% 60%); }
.ic-home { clip-path: polygon(50% 0, 100% 45%, 85% 45%, 85% 100%, 15% 100%, 15% 45%, 0 45%); }
.ic-grid { -webkit-mask: conic-gradient(#000 0 0) 0 0/45% 45% no-repeat, conic-gradient(#000 0 0) 100% 0/45% 45% no-repeat, conic-gradient(#000 0 0) 0 100%/45% 45% no-repeat, conic-gradient(#000 0 0) 100% 100%/45% 45% no-repeat;
  mask: conic-gradient(#000 0 0) 0 0/45% 45% no-repeat, conic-gradient(#000 0 0) 100% 0/45% 45% no-repeat, conic-gradient(#000 0 0) 0 100%/45% 45% no-repeat, conic-gradient(#000 0 0) 100% 100%/45% 45% no-repeat; }
.ic-fuse { clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); }
.ic-sound { width: 18px; height: 18px; clip-path: polygon(0 35%, 30% 35%, 60% 5%, 60% 95%, 30% 65%, 0 65%); }

/* screens */
main { position: fixed; inset: 0; }
.screen { position: absolute; inset: 0; display: none; padding-top: calc(var(--top) + var(--sat)); padding-bottom: calc(var(--dock) + var(--sab)); overflow: hidden; overflow: clip; background-color: var(--night); background-size: cover; background-position: center; image-rendering: pixelated; }
.screen.on { display: block; animation: screenIn .35s ease-out; }
/* Screen backgrounds live here, not in script: the published (packed) site resolves stylesheet URLs only. */
#lobby, #nest { background-image: url(../assets/grove-lobby.png); }
#draw, #colony, #fuse { background-image: url(../assets/grove-nursery.png); }
@keyframes screenIn { from { opacity: 0; transform: scale(1.015); } }
.screen::before { content: ''; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(120% 90% at 50% 40%, transparent 45%, rgba(0, 0, 0, .55)); }

/* dock (mobile) */
.dock { display: none; }

/* modal */
.modal { padding: 22px 22px 20px; width: min(420px, calc(100vw - 32px)); max-height: calc(100dvh - 40px); overflow: auto; color: var(--cream); background: linear-gradient(#2a1d0f, #1a1209); }
.modal.wide { width: min(760px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(6, 4, 2, .7); }
.modal[open] { animation: pop .25s cubic-bezier(.2, 1.3, .4, 1); }
@keyframes pop { from { transform: scale(.92); opacity: 0; } }
.modal small { color: var(--gold); letter-spacing: .14em; }
.modal h3 { font-size: 24px; color: var(--gold); margin: 4px 0 8px; }
.modal .x { position: absolute; right: 10px; top: 8px; border: 0; background: none; color: var(--sand); font-size: 26px; }
.muted { color: var(--sand); font-size: 14px; }
.qr { width: 196px; height: 196px; margin: 14px auto; background: #fff; border: 3px solid #000; display: grid; padding: 12px; }
.qr canvas { width: 100%; height: 100%; }
.pair { text-align: center; color: var(--sand); }
.pair b { color: var(--gold); font-size: 22px; letter-spacing: .12em; margin-left: 6px; }
.mock-note { margin-top: 12px; font-size: 12px; color: var(--amber); text-align: center; }

/* toast */
.toast { position: fixed; z-index: 120; pointer-events: none; left: 50%; top: calc(var(--sat) + var(--top) + 10px); transform: translate(-50%, -140%); opacity: 0; padding: 12px 18px; background: #1f160b; color: var(--cream); font-size: 15px; transition: .25s; max-width: calc(100vw - 32px); }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.err { color: #ffd2c8; background: #3a140d; }


@media (max-width: 1120px) {
  .chip.block { display: none; }
  .tabs a { padding: 8px 8px; }
}
@media (max-width: 860px) {
  :root { --top: 50px; --dock: 0px; }
  .tabs { display: none; }
  .brand b { font-size: 17px; }
  .chip.block { display: none; }
  .chip { height: 32px; padding: 0 9px; font-size: 13px; }
  .iconbtn { width: 32px; height: 32px; }
  /* floating pixel hotbar: same bevel as the other panels */
  .dock { position: fixed; z-index: 30; left: 8px; right: 8px; bottom: calc(8px + var(--sab)); height: calc(var(--dock) - 10px); padding: 0 4px; display: flex; gap: 2px;
    background: linear-gradient(rgba(34, 24, 11, .86), rgba(16, 11, 5, .9)); border: 3px solid #000;
    box-shadow: inset 0 2px 0 rgba(255, 222, 150, .22), inset 0 -3px 0 rgba(0, 0, 0, .4), 0 6px 0 rgba(0, 0, 0, .3), 0 0 22px rgba(0, 0, 0, .45); }
  .dock a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--cream); text-decoration: none; font-size: 12px; text-shadow: 0 2px 0 #000, 0 0 6px rgba(0, 0, 0, .8); }
  .dock a.on { color: var(--gold); margin: 5px 0; background: rgba(245, 192, 74, .14); border: 2px solid #000; box-shadow: inset 0 3px 0 var(--gold); }
}
@media (max-width: 480px) {
  .topbar { gap: 8px; padding-left: 10px; padding-right: 10px; }
  .chips { gap: 5px; }
  .brand b { display: none; }
  .chip.pool small, .chip.wallet small { display: none; }
  .chip.lang { padding: 0 7px; }
  .chip.pool .pool-k { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* pixel icons (js/icons.js) */
.pi { display: inline-block; flex: none; width: 22px; height: 22px; filter: drop-shadow(0 2px 0 rgba(0, 0, 0, .35)); }
.pi svg { display: block; width: 100%; height: 100%; }
.pi.sm { width: 16px; height: 16px; }
.pi.lg { width: 40px; height: 40px; }
.dock .pi { width: 22px; height: 22px; }
.dock a:not(.on) .pi { filter: grayscale(.6) brightness(.85); }

/* loading: skeleton bars and the boot loader's hop dots, small */
.skel { display: block; max-width: 100%; margin: 4px 0; background: linear-gradient(90deg, rgba(255, 255, 255, .06) 25%, rgba(245, 192, 74, .16) 50%, rgba(255, 255, 255, .06) 75%); background-size: 300% 100%; animation: skel 1.3s steps(12) infinite; }
.skel-block { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.skel-row { display: flex; gap: 10px; margin: 6px 0; }
.skel-img { aspect-ratio: 1200 / 630; height: auto; background: linear-gradient(90deg, rgba(255, 255, 255, .05) 25%, rgba(245, 192, 74, .14) 50%, rgba(255, 255, 255, .05) 75%); background-size: 300% 100%; animation: skel 1.3s steps(12) infinite; }
@keyframes skel { from { background-position: 100% 0; } to { background-position: 0 0; } }
.dots { display: inline-flex; gap: 3px; margin-left: 8px; vertical-align: middle; }
.dots i { width: 5px; height: 5px; background: currentColor; animation: hop-s .9s steps(3) infinite; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes hop-s { 50% { transform: translateY(-4px); } }
.is-busy { cursor: progress; }
@media (prefers-reduced-motion: reduce) { .skel, .skel-img, .dots i { animation: none; } }

/* the hidden attribute always wins over a component display rule */
[hidden] { display: none !important; }

/* the toast as a top-layer popover: undo the browser's popover box (centred, full inset, light colours) */
.toast[popover] { bottom: auto; right: auto; margin: 0; /* top-centre, under the top bar */ overflow: visible; width: max-content; height: auto; }
.toast[popover]::backdrop { display: none; }
