:root {
  color-scheme: dark;
  --bg: #0a100c; --panel: #111a14; --panel-2: #18241c; --line: #233529;
  --text: #e8f4ea; --muted: #89a290; --accent: #22dd27; --accent-2: #6bf06f;
  --on-accent: #041506; --selected: #14351a;
  --green: #35d07f; --red: #ff5d6c; --gold: #f5b942;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 "Segoe UI", system-ui, sans-serif; }
header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 20px; height: 64px;
  background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; color: var(--text); text-decoration: none; }
.logo img { display: block; width: 40px; height: 40px; }
nav { position: fixed; top: 64px; bottom: 0; left: 0; width: 210px; display: flex; flex-direction: column; gap: 4px; padding: 16px 10px; background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; }
.nav-title { color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; padding: 10px 12px 4px; }
nav a { display: flex; align-items: center; gap: 12px; color: var(--muted); text-decoration: none; font-weight: 600; padding: 10px 12px; border-radius: 8px; }
nav a:hover, nav a.active { color: var(--text); background: var(--panel-2); }
nav a.active span { color: var(--accent); }
.balance { display: flex; align-items: center; gap: 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 4px 4px 4px 14px; }
.balance b { color: var(--green); }
.balance button { padding: 5px 12px; }
.profile-button { width: 44px; height: 44px; padding: 0; border-radius: 50%; border: 2px solid var(--accent); overflow: hidden; display: grid; place-items: center; }
.profile-button img { width: 100%; height: 100%; object-fit: cover; }
.profile-button:hover:not(:disabled), .profile-button[aria-expanded="true"] { box-shadow: 0 0 0 4px rgba(34, 221, 39, .2); }
.menu { position: fixed; top: 70px; right: 12px; z-index: 10; width: min(300px, calc(100vw - 24px)); max-height: calc(100vh - 82px); overflow-y: auto; display: flex; flex-direction: column; padding: 8px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 18px 50px rgba(0, 0, 0, .55); transform-origin: top right; animation: pop .18s ease-out; }
.menu button { display: flex; align-items: center; gap: 16px; width: 100%; text-align: left; background: transparent; border: 0; border-radius: 10px; }
.menu button:hover:not(:disabled) { background: rgba(255, 255, 255, .06); filter: none; }
.menu hr { width: calc(100% - 16px); border: 0; border-top: 1px solid var(--line); margin: 6px 8px; }
.menu .menu-user { padding: 10px; gap: 14px; }
.menu-name { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.menu-name b { overflow: hidden; text-overflow: ellipsis; }
.menu-name small { color: var(--muted); font-weight: 400; font-size: 14px; }
.menu .menu-entry { padding: 12px 16px; font-size: 16px; }
.menu-entry span { flex: 1; }
.menu-entry small { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 20px; padding: 1px 8px; }
.icon { flex: 0 0 auto; width: 22px; height: 22px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.menu-entry:hover:not(:disabled) .icon { stroke: var(--accent); }
.avatar.large { width: 58px; height: 58px; overflow: hidden; }
.avatar.huge { width: 80px; height: 80px; font-size: 26px; border-color: var(--accent); }
.profile-head { display: flex; align-items: center; gap: 18px; }
.profile-head h2 { margin: 0; font-size: 22px; }
.stats.two { grid-template-columns: repeat(2, 1fr); margin: 0; }
.stat b.win, .win { color: var(--green); }
.stat b.loss, .loss { color: var(--red); }
.history { display: flex; flex-direction: column; gap: 8px; }
.entry { display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: left; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; font-weight: 400; }
.entry > div { display: flex; flex-direction: column; min-width: 0; }
.entry > div:first-child span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.entry .muted { font-size: 13px; }
.entry-side { align-items: flex-end; flex-shrink: 0; }
.badge { font-size: 12px; font-weight: 700; color: var(--green); }
.badge.pending { color: var(--gold); }
.badge.failed { color: var(--red); }
.setting { display: flex; justify-content: space-between; align-items: center; gap: 16px; background: var(--panel-2); border-radius: 10px; padding: 14px 16px; cursor: pointer; }
.setting > span { display: flex; flex-direction: column; }
.setting input { width: 22px; height: 22px; accent-color: var(--accent); }
#account { display: flex; align-items: center; gap: 10px; }
.header-right { display: flex; align-items: center; gap: 10px; }
/* the owner's betting lock switch: red and to the right while betting is locked */
.owner-lock { position: relative; display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 7px 12px; font-size: 13px; font-weight: 700; cursor: pointer; user-select: none; }
.owner-lock input { position: absolute; opacity: 0; width: 1px; height: 1px; padding: 0; }
.owner-lock i { position: relative; flex: 0 0 auto; width: 36px; height: 20px; border-radius: 20px; background: var(--line); transition: background-color .2s; }
.owner-lock i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .2s; }
.owner-lock input:checked + i { background: var(--red); }
.owner-lock input:checked + i::after { transform: translateX(16px); }
.owner-lock input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.owner-lock input:disabled + i { opacity: .5; }
.owner-lock.locked { border-color: var(--red); color: var(--red); }
.lock-note { margin: 0 0 14px; padding: 10px 16px; border: 1px solid var(--red); border-radius: 10px; background: rgba(255, 93, 108, .12); font-weight: 600; }
@media (max-width: 600px) { .owner-lock span { display: none; } .owner-lock { padding: 7px 8px; } }
main { max-width: 1150px; margin-left: max(210px, calc((100vw - 1150px) / 2 + 105px)); padding: 20px 20px 60px; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 32px 0 12px; }
.muted { color: var(--muted); }

button {
  font: inherit; font-weight: 600; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 16px; cursor: pointer;
}
button:hover:not(:disabled) { filter: brightness(1.2); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 700; }
button.danger { color: var(--red); }
input {
  font: inherit; width: 100%; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
}

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.stat b { display: block; font-size: 22px; }
.stat span { color: var(--muted); font-size: 13px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.buttons { display: flex; gap: 8px; flex-wrap: wrap; }

.rows { display: flex; flex-direction: column; gap: 10px; }
.row {
  display: grid; grid-template-columns: 240px 1fr auto 120px; align-items: center; gap: 16px;
  background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 10px; padding: 10px 16px;
}
.row.pending { border-left-color: var(--gold); }
.row.done { border-left-color: var(--line); }
.players { display: flex; align-items: center; gap: 10px; }
.player { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 92px; font-size: 12px; overflow: hidden; }
.player span:last-child { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player.lost { opacity: .4; }
.avatar { position: relative; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; background: var(--panel-2); border: 2px solid var(--line); font-weight: 700; font-size: 17px; }
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.avatar.small { width: 32px; height: 32px; font-size: 13px; }
.side { position: absolute; right: -5px; bottom: -4px; display: grid; place-items: center; width: 19px; height: 19px; border-radius: 50%; font-size: 10px; font-weight: 800; color: #10121a; }
.heads { background: var(--gold); }
.tails { background: var(--red); }
.vs { color: var(--muted); font-weight: 800; font-size: 12px; }
.thumbs { display: flex; gap: 6px; overflow: hidden; }
.thumb { flex: 0 0 auto; display: grid; place-items: center; width: 48px; height: 48px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; font-size: 13px; font-weight: 700; color: var(--accent-2); }
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.value { text-align: right; }
.value b { display: block; color: var(--green); font-size: 17px; }
.value span { color: var(--muted); font-size: 12px; }
.empty { text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 12px; padding: 32px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); grid-auto-rows: max-content; gap: 8px; align-content: start; }
.grid-note { grid-column: 1 / -1; text-align: center; padding: 24px 0; }
.item { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; background: var(--panel-2); border: 2px solid var(--line); border-radius: 10px; padding: 10px 8px; font-weight: 400; }
.item .thumb { width: 84px; height: 84px; background: transparent; border: 0; font-size: 20px; }
.item.selected { border-color: var(--accent); background: var(--selected); }
.item.selected::after { content: "✔"; position: absolute; top: 5px; right: 5px; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-size: 12px; font-weight: 800; }
.item .name { max-width: 100%; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.browser { display: flex; flex-direction: column; gap: 8px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters input { flex: 1; min-width: 160px; }
select { font: inherit; font-weight: 600; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; cursor: pointer; }
.wallet { display: flex; flex-direction: column; gap: 12px; }
.wallet p { margin: 0; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--bg); border-radius: 10px; padding: 4px; }
.tabs button { border-color: transparent; background: transparent; color: var(--muted); }
.tabs button.selected { background: var(--accent); color: var(--on-accent); }
button.big { padding: 10px 40px; }
button.selected { border-color: var(--accent); }
.side-counts { display: flex; align-items: center; gap: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 14px; }
.side-counts span { display: flex; align-items: center; gap: 6px; }
.dot { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; font-size: 10px; font-weight: 800; font-style: normal; color: #10121a; }
.item .price { color: var(--green); font-weight: 700; }
.item .tag { font-size: 11px; color: var(--gold); }

dialog { width: min(720px, calc(100vw - 24px)); max-height: 88vh; padding: 0; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; }
dialog::backdrop { background: rgba(2, 8, 4, .78); }
dialog[open] { display: flex; flex-direction: column; overflow: hidden; }
#modalBody { padding: 22px; display: flex; flex-direction: column; gap: 14px; min-height: 0; overflow-y: auto; }
#modalBody > * { flex-shrink: 0; }
#modalBody > .wallet, #modalBody > .browser { flex: 0 1 auto; min-height: 0; }
.wallet > * { flex-shrink: 0; }
.wallet > .browser { flex: 0 1 auto; min-height: 0; }
dialog .browser .grid { flex: 0 1 auto; min-height: 110px; overflow-y: auto; }
dialog .modal-foot { position: sticky; bottom: -22px; z-index: 1; background: var(--panel); border-top: 1px solid var(--line); margin: 0 -22px -22px; padding: 14px 22px; }
.wallet > .modal-foot { position: static; margin-bottom: 0; margin: 0; padding: 14px 0 0; }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.picker { max-height: 340px; overflow-y: auto; }
.sides { display: flex; gap: 8px; }
.sides button.selected { border-color: var(--accent); background: var(--selected); }
.code { background: var(--bg); border: 1px dashed var(--accent); border-radius: 10px; padding: 14px; font-family: Consolas, monospace; font-size: 16px; text-align: center; user-select: all; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 4px 20px; margin-top: 16px; }
.hash { font-family: Consolas, monospace; font-size: 12px; color: var(--muted); word-break: break-all; }

/* ---- 3D coin ---- */
.coin-stage { position: relative; width: 92px; height: 92px; perspective: 600px; }
.coin-toss { width: 100%; height: 100%; transform-style: preserve-3d; }
.coin { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; will-change: transform; }
.coin .face, .coin .rim { position: absolute; inset: 0; border-radius: 50%; }
.coin .face { display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; backface-visibility: hidden; color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, .28); }
.coin .face::before { content: ""; position: absolute; inset: 7px; border-radius: 50%; border: 2px dashed rgba(255, 255, 255, .6); }
.coin .face::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: linear-gradient(125deg, rgba(255, 255, 255, .45), transparent 40% 62%, rgba(0, 0, 0, .22)); box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .3); }
.coin .face span { font-size: 38px; font-weight: 900; }
.coin .face small { margin-top: 3px; font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .14em; }
.coin .face.heads { background: radial-gradient(circle at 35% 30%, #ffe08a, #f2ac27 55%, #b8750c); transform: translateZ(6px); }
.coin .face.tails { background: radial-gradient(circle at 35% 30%, #ff9aa4, #ee4a5c 55%, #a91f33); transform: rotateY(180deg) translateZ(6px); }
.coin .rim { background: #9d8a5c; box-shadow: inset 0 0 0 2px #e6d7a8; }
.coin .rim:nth-of-type(even) { background: #6f603d; box-shadow: inset 0 0 0 2px #a9976a; }
.coin .rim:nth-of-type(1) { transform: translateZ(-5px); }
.coin .rim:nth-of-type(2) { transform: translateZ(-4px); }
.coin .rim:nth-of-type(3) { transform: translateZ(-3px); }
.coin .rim:nth-of-type(4) { transform: translateZ(-2px); }
.coin .rim:nth-of-type(5) { transform: translateZ(-1px); }
.coin .rim:nth-of-type(6) { transform: translateZ(0); }
.coin .rim:nth-of-type(7) { transform: translateZ(1px); }
.coin .rim:nth-of-type(8) { transform: translateZ(2px); }
.coin .rim:nth-of-type(9) { transform: translateZ(3px); }
.coin .rim:nth-of-type(10) { transform: translateZ(4px); }
.coin .rim:nth-of-type(11) { transform: translateZ(5px); }
.coin-shadow { position: absolute; left: 12%; right: 12%; bottom: -13px; height: 10px; border-radius: 50%; background: rgba(0, 0, 0, .55); filter: blur(4px); }
.coin-stage.landed::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid var(--accent); opacity: 0; pointer-events: none; }
.coin-stage.tossing.landed::after { animation: land-ring .7s ease-out; }

/* The spin and the up-and-down toss run on separate elements so each can have its own timing. */
.coin.flip-0 { animation: flip-heads 3.2s cubic-bezier(.22, .62, .18, 1) forwards; }
.coin.flip-1 { animation: flip-tails 3.2s cubic-bezier(.22, .62, .18, 1) forwards; }
.tossing .coin-toss { animation: toss 3.2s linear; }
.tossing .coin-shadow { animation: toss-shadow 3.2s linear; }
@keyframes flip-heads { from { transform: rotateY(0); } to { transform: rotateY(2160deg); } }
@keyframes flip-tails { from { transform: rotateY(0); } to { transform: rotateY(2340deg); } }
@keyframes toss {
  0% { transform: translateY(0) rotateX(0) scale(1); animation-timing-function: cubic-bezier(.2, .7, .4, 1); }
  42% { transform: translateY(-24px) rotateX(24deg) scale(1.2); animation-timing-function: cubic-bezier(.55, 0, .85, .45); }
  80% { transform: translateY(0) rotateX(0) scale(1); animation-timing-function: ease-out; }
  88% { transform: translateY(-7px) rotateX(-5deg) scale(1.03); animation-timing-function: ease-in; }
  100% { transform: translateY(0) rotateX(0) scale(1); }
}
@keyframes toss-shadow {
  42% { transform: scale(.55); opacity: .35; }
  80%, 100% { transform: scale(1); opacity: 1; }
}
@keyframes land-ring { from { opacity: .9; transform: scale(.9); } to { opacity: 0; transform: scale(1.35); } }


#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--accent); border-radius: 10px; padding: 10px 18px; opacity: 0; pointer-events: none; transition: opacity .2s; }
#toast.show { opacity: 1; }
#toast.error { border-color: var(--red); }

/* ---- coinflip screen ---- */
dialog.match { width: min(600px, calc(100vw - 16px)); max-height: 94vh; background: #0f1912; }
dialog.match #modalBody { padding: 0; gap: 0; }
dialog.match .modal-head { padding: 12px 16px 0; background: #16261b; }
dialog.match .modal-head h2 { font: 600 12px Consolas, monospace; color: var(--muted); border: 1px solid var(--line); border-radius: 30px; padding: 4px 12px; }
dialog.match .modal-head button { background: transparent; border: 0; font-size: 20px; color: var(--muted); }
.match-top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 10px; padding: 8px 16px 20px; background: linear-gradient(#16261b, #121e16); }
.fighter { display: flex; flex-direction: column; align-items: center; gap: 18px; min-width: 0; transition: opacity .3s; }
.portrait-wrap { position: relative; }
.portrait { display: grid; place-items: center; width: 96px; height: 96px; overflow: hidden; background: var(--bg); border: 4px solid var(--line); border-radius: 18px; font-size: 30px; font-weight: 800; color: var(--muted); transition: border-color .3s, box-shadow .3s; }
.portrait img { width: 100%; height: 100%; object-fit: cover; }
.chip-holder { position: absolute; left: 50%; bottom: -15px; transform: translateX(-50%); display: grid; place-items: center; width: 42px; height: 32px; background: #121e16; border-radius: 20px; }
.chip { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; border: 2px dashed rgba(255, 255, 255, .85); font-size: 13px; font-weight: 900; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .6); }
.fighter-name { max-width: 100%; font-size: 15px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.fighter.lost { opacity: .38; }
.fighter.won .portrait { border-color: var(--accent); box-shadow: 0 0 34px rgba(34, 221, 39, .55); }
.versus { display: grid; place-items: center; width: 96px; height: 96px; margin-top: 30px; border-radius: 50%; background: rgba(255, 255, 255, .035); border: 3px solid var(--line); font-size: 30px; font-weight: 900; color: var(--muted); }

.versus.flipping { background: transparent; border-color: transparent; }
.stakes { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stake { min-width: 0; }
.stake + .stake { border-left: 1px solid var(--line); }
.stake-total { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 14px; border-bottom: 1px solid var(--line); }
.stake-total b { display: flex; align-items: center; gap: 10px; font-size: 19px; }
.currency { width: 1.05em; height: 1.05em; }
.chance { font-size: 13px; font-weight: 600; color: var(--muted); background: var(--panel-2); border-radius: 30px; padding: 4px 12px; }
.stake-items { display: flex; flex-direction: column; gap: 8px; min-height: 70px; max-height: 176px; overflow-y: auto; padding: 10px; }
.stake-items p { margin: auto; }
.stake-item { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 14px; }
.stake-item .thumb { width: 48px; height: 48px; border-width: 2px; border-radius: 10px; }
.stake-item > div:last-child { display: flex; flex-direction: column; min-width: 0; }
.stake-item b { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.stake-item span { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.match-foot { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 16px 10px; text-align: center; }
.match-foot p { margin: 0; font-size: 15px; color: var(--muted); }
.match-foot strong { color: var(--text); }
.match-foot .buttons { justify-content: center; }
.match-foot > .buttons button { min-width: 130px; padding: 9px 22px; border-radius: 10px; font-size: 15px; }
.match-foot button.danger { background: rgba(255, 93, 108, .14); border-color: rgba(255, 93, 108, .35); }
.match-foot .verdict { font-size: 17px; }
.fair { max-width: 100%; font-size: 13px; color: var(--muted); }
.fair summary { cursor: pointer; opacity: .7; }
.fair .hash { margin-top: 8px; }
.fair .buttons { margin-top: 10px; align-items: center; }
@media (max-width: 600px) {
  .match-top { gap: 6px; padding: 14px 8px 28px; }
  .portrait { width: 80px; height: 80px; border-radius: 16px; }
  .versus { width: 76px; height: 76px; margin-top: 8px; font-size: 24px; }
  .coin-stage { width: 66px; height: 66px; }
  .coin .face span { font-size: 28px; }
  .coin .face small { display: none; }
  .coin .face::before { inset: 5px; }
  .fighter-name { font-size: 14px; }
  .stake-total { padding: 10px; }
  .stake-total b { font-size: 18px; gap: 6px; }
  .chance { font-size: 11px; padding: 3px 7px; }
  .stake-items { padding: 8px; }
  .stake-item { flex-direction: column; gap: 4px; text-align: center; }
  .stake-item > div:last-child { max-width: 100%; align-items: center; }
}

/* ---- inventory action bar, always at the bottom ---- */
#page-inventory { padding-bottom: 84px; }
.actionbar { position: fixed; left: 210px; right: 0; bottom: 0; z-index: 4; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 20px; background: rgba(17, 26, 20, .94); backdrop-filter: blur(10px); border-top: 1px solid var(--line); box-shadow: 0 -10px 30px rgba(0, 0, 0, .35); animation: slide-up .35s ease-out; }
#toast { z-index: 20; }

/* ---- motion and polish ---- */
body { background-image: radial-gradient(900px 420px at 70% -120px, rgba(34, 221, 39, .13), transparent 70%); background-attachment: fixed; }
button { transition: transform .12s, box-shadow .2s, border-color .2s, background-color .2s, filter .2s; }
button:active:not(:disabled) { transform: scale(.96); }
button.primary:hover:not(:disabled) { box-shadow: 0 4px 22px rgba(34, 221, 39, .45); transform: translateY(-1px); }
nav a { transition: background-color .2s, color .2s, padding-left .2s; }
nav a:hover { padding-left: 17px; }
nav a.active { box-shadow: inset 3px 0 0 var(--accent); }
.logo img { transition: transform .25s; filter: drop-shadow(0 0 8px rgba(34, 221, 39, .45)); }
.logo:hover img { transform: rotate(-8deg) scale(1.1); }
.stat { transition: transform .2s, border-color .2s; }
.stat:hover { transform: translateY(-2px); border-color: rgba(34, 221, 39, .5); }
.row { transition: transform .18s, box-shadow .18s, background-color .18s; }
.row:hover { transform: translateY(-2px); background: #15211a; box-shadow: 0 10px 26px rgba(0, 0, 0, .35); }
.row.enter { animation: rise .4s ease-out backwards; }
.row.pending { animation: waiting 1.8s ease-in-out infinite; }
.item:hover:not(:disabled) { transform: translateY(-3px); border-color: rgba(34, 221, 39, .6); box-shadow: 0 8px 20px rgba(0, 0, 0, .35); }
.item .thumb img { transition: transform .2s; }
.item:hover:not(:disabled) .thumb img { transform: scale(1.1); }
.item.selected::after { animation: pop .2s ease-out; }
main section:not([hidden]) > :not(.actionbar) { animation: rise .42s ease-out backwards; }
main section > :nth-child(2) { animation-delay: .05s !important; }
main section > :nth-child(3) { animation-delay: .1s !important; }
main section > :nth-child(n+4):not(.actionbar) { animation-delay: .15s !important; }
dialog[open] { animation: dialog-in .24s cubic-bezier(.2, .9, .3, 1.15); }
dialog[open]::backdrop { animation: fade .24s ease-out; }
dialog::backdrop { backdrop-filter: blur(4px); }
.wallet, .history { animation: fade .25s ease-out; }
.verdict:not(:empty) { animation: rise .35s ease-out; }
#toast { transition: opacity .2s, transform .25s; transform: translate(-50%, 14px); }
#toast.show { transform: translate(-50%, 0); }
.skeleton { height: 52px; border-radius: 10px; background: linear-gradient(100deg, var(--panel-2) 30%, #233529 50%, var(--panel-2) 70%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.skeleton.tall { height: 220px; }

/* Closing plays the opening motion backwards. Keep the length in step with CLOSE_MS in app.js. */
dialog.closing[open] { animation: dialog-out .2s ease-in forwards; pointer-events: none; }
dialog.closing[open]::backdrop { animation: fade-out .2s ease-in forwards; }
.menu.closing { animation: pop-out .2s ease-in forwards; pointer-events: none; }

@keyframes dialog-out { to { opacity: 0; transform: translateY(18px) scale(.96); } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes pop-out { to { opacity: 0; transform: scale(.9); } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes slide-up { from { opacity: 0; transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.9); } }
@keyframes dialog-in { from { opacity: 0; transform: translateY(18px) scale(.96); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes waiting { 50% { box-shadow: 0 0 0 3px rgba(245, 185, 66, .22); } }

/* Animations are shortened rather than removed, so "animation finished" events still fire. */
body.calm *, body.calm *::before, body.calm *::after, body.calm ::backdrop { animation-duration: .01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, ::backdrop { animation-duration: .01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media (max-width: 860px) {
  header { padding: 0 12px; }
  nav { position: static; width: auto; flex-direction: row; overflow-x: auto; padding: 8px; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav-title, .logo span { display: none; }
  .actionbar { left: 0; padding: 10px 12px; }
  .actionbar .big { padding: 10px 20px; }
  #page-inventory { padding-bottom: 120px; }
  nav a { white-space: nowrap; padding: 8px 12px; }
  main { margin: 0 auto; padding: 14px 12px 60px; }
  .row { grid-template-columns: 1fr auto; }
  .thumbs { grid-column: 1 / -1; grid-row: 2; }
  .stat b { font-size: 17px; }
}
