:root {
  --bg: #060608;
  --ink: #ecf7e6;
  --dim: #95a08f;
  --lime: #c3ff5c;
  --lime-dim: rgba(195, 255, 92, .18);
  --lav: #b9a3ff;
  --coral: #ff7a6b;
  --panel: #0e0f13;
  --panel-2: #15161c;
  --line: rgba(195, 255, 92, .16);
  --sl: max(12px, env(safe-area-inset-left));
  --sr: max(12px, env(safe-area-inset-right));
  --st: max(8px, env(safe-area-inset-top));
  --sb: max(6px, env(safe-area-inset-bottom));
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink);
  font: 15px/1.4 ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
button, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
a { color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; margin: 0; }
:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }

#app { position: fixed; inset: 0; overflow: hidden; display: grid;
  grid-template: "top" auto "stage" minmax(0, 1fr) "controls" auto "foot" auto / 100%;
  padding: var(--st) var(--sr) var(--sb) var(--sl);
  background: radial-gradient(90% 60% at 50% 45%, rgba(195, 255, 92, .06), transparent 65%), var(--bg); }

/* Top bar */
.top { grid-area: top; display: flex; align-items: center; gap: 8px; min-height: 48px; }
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; padding: 4px 2px; border-radius: 8px; }
.logo { width: 24px; height: 16px; fill: var(--lime); display: block; }
.word { font-weight: 700; font-size: 19px; letter-spacing: -.02em; }
.spacer { flex: 1; }
.holder { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px 3px 6px; border-radius: 999px; font-size: 12px; font-weight: 600;
  color: #120c22; background: var(--lav); }
.holder svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.tally { display: inline-flex; align-items: center; gap: 5px; color: var(--dim); font-size: 13px; padding: 0 4px; }
.tally svg { width: 16px; height: 16px; fill: none; stroke: var(--lime); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.tally b { color: var(--ink); font-weight: 600; min-width: 1ch; }
.tally.pop b { animation: pop .3s ease-out; display: inline-block; }
@keyframes pop { 40% { transform: scale(1.35); color: var(--lime); } }
.icon { width: 44px; height: 44px; display: inline-grid; place-items: center; padding: 0; border-radius: 14px; position: relative;
  background: var(--panel); border: 1px solid var(--line); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.icon svg { width: 21px; height: 21px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon:hover { border-color: rgba(195, 255, 92, .45); }
.icon.small { width: 44px; height: 44px; border-radius: 12px; }
.icon.small svg { width: 17px; height: 17px; }
.dot { position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--lime); }
.dot.holder-dot { background: var(--lav); }

/* The pair: two faces and VS. Stacked on portrait, side by side when the stage is wider than tall. */
.stage { grid-area: stage; position: relative; container-type: size; min-height: 0; display: grid; place-items: center; }
.pair { --gap: 14px; --s: min(100cqw, calc((100cqh - var(--gap)) / 2), 520px);
  position: relative; display: grid; grid-template: "a" var(--s) "b" var(--s) / var(--s); gap: var(--gap); }
@container (orientation: landscape) {
  .pair { --s: min(calc((100cqw - var(--gap) * 3) / 2), 100cqh, 520px); grid-template: "a b" var(--s) / var(--s) var(--s); --gap: 22px; }
}
.face { position: relative; padding: 0; border: 0; border-radius: 20px; cursor: pointer; overflow: hidden;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, .025) 0 1px, transparent 1px 2%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .025) 0 1px, transparent 1px 2%), #0b0b0d;
  box-shadow: 0 0 0 1px var(--line), 0 14px 40px rgba(0, 0, 0, .55);
  transition: transform .18s ease, box-shadow .18s ease, opacity .2s ease, filter .2s ease;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
#faceA { grid-area: a; }
#faceB { grid-area: b; }
.face img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; image-rendering: pixelated; pointer-events: none;
  user-select: none; -webkit-user-select: none; -webkit-user-drag: none; }
.face .frame { position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 1;
  box-shadow: inset 0 0 0 2px transparent; transition: box-shadow .18s ease; }
.face:disabled { cursor: default; }
@media (hover: hover) {
  .face:not(:disabled):hover { transform: translateY(-3px); box-shadow: 0 0 0 1px rgba(195, 255, 92, .5), 0 18px 46px rgba(0, 0, 0, .6); }
}
.face:focus-visible { outline: 3px solid var(--lime); outline-offset: 3px; }
.face.win { transform: scale(1.03); box-shadow: 0 0 0 3px var(--lime), 0 0 46px rgba(195, 255, 92, .35); }
.face.win .frame { box-shadow: inset 0 0 0 2px var(--lime); }
.face.lose { opacity: .35; filter: grayscale(.7); transform: scale(.96); }
.face.enter { animation: enter .26s ease-out both; }
@keyframes enter { from { opacity: 0; transform: scale(.94); } }
.face.empty { visibility: hidden; }

.vs { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 2; width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800; font-size: 17px; letter-spacing: .04em; color: #0b1100; background: var(--lime);
  box-shadow: 0 0 0 5px var(--bg), 0 0 30px rgba(195, 255, 92, .4); pointer-events: none; }
.vs.beat { animation: beat .35s ease-out; }
@keyframes beat { 45% { transform: translate(-50%, -50%) scale(1.18); } }

.status { position: absolute; inset: auto 0 50% 0; transform: translateY(50%); margin: 0; text-align: center; color: var(--dim); font-size: 14px; pointer-events: none; }
.status:empty { display: none; }

/* Skip */
.controls { grid-area: controls; position: relative; display: flex; justify-content: center; padding: 10px 0 2px; }
.skip { min-height: 44px; min-width: 120px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 20px;
  border-radius: 999px; background: var(--panel); border: 1px solid var(--line); color: var(--dim); cursor: pointer; font-size: 14px; font-weight: 600;
  -webkit-tap-highlight-color: transparent; }
.skip svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.skip:hover { color: var(--ink); border-color: rgba(195, 255, 92, .45); }
.toast { position: absolute; left: 50%; bottom: calc(100% + 4px); transform: translate(-50%, 6px); margin: 0; padding: 7px 12px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--line); font-size: 13px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 5; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast.warn { border-color: rgba(255, 122, 107, .5); }
.toast b { color: var(--lime); }
.toast.warn b { color: var(--coral); }

.foot { grid-area: foot; text-align: center; font-size: 12px; color: var(--dim); padding: 6px 0 2px; }
.foot a { color: var(--lime); text-decoration: none; display: inline-block; padding: 4px 2px; }
.foot a:hover { text-decoration: underline; }

/* Sheets */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); z-index: 40; }
.sheet { position: fixed; z-index: 50; left: 0; right: 0; bottom: 0; max-height: calc(100% - var(--st) - 24px); display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-bottom: 0; border-radius: 22px 22px 0 0;
  padding: 6px var(--sr) var(--sb) var(--sl); box-shadow: 0 -20px 60px rgba(0, 0, 0, .6); animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(24px); opacity: 0; } }
@media (min-width: 700px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; width: min(560px, calc(100% - 48px)); max-height: min(780px, calc(100% - 48px));
    transform: translate(-50%, -50%); border-radius: 22px; border-bottom: 1px solid var(--line); padding: 8px 18px 14px; animation: fade .2s ease-out; }
  @keyframes fade { from { opacity: 0; } }
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0 6px; }
.sheet-head h2 { margin: 0; font-size: 17px; }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; min-height: 0; padding-bottom: 8px; -webkit-overflow-scrolling: touch; }
.sheet h3 { font-size: 13px; margin: 14px 0 6px; color: var(--dim); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.lead { margin: 4px 0 12px; }
.tiny { font-size: 12px; color: var(--dim); margin: 8px 0; }
.center { text-align: center; }
.err { color: var(--coral); min-height: 1em; }

.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--bg); border: 1px solid var(--line); margin-bottom: 8px; }
.tabs button { flex: 1; min-height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--dim); font-size: 13px; font-weight: 600; cursor: pointer; padding: 0 6px; }
.tabs button[aria-selected="true"] { background: var(--lime); color: #0b1100; }
.filter select { width: 100%; min-height: 44px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); padding: 0 12px; font-size: 14px; }
.round { color: var(--dim); }

.rising .strip { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: thin; }
.rising a { flex: 0 0 auto; width: 76px; text-decoration: none; text-align: center; font-size: 12px; border-radius: 12px; padding: 4px; }
.rising img { width: 68px; height: 68px; display: block; border-radius: 10px; image-rendering: pixelated; background: #0b0b0d; box-shadow: 0 0 0 1px var(--line); margin: 0 auto 3px; }
.rising b { color: var(--lime); display: block; }

.board { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; }
.board a { display: grid; grid-template-columns: 32px 52px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 6px 8px 6px 4px; border-radius: 12px;
  text-decoration: none; min-height: 64px; }
.board a:hover { background: var(--panel-2); }
.board .rk { text-align: right; color: var(--dim); font-weight: 700; font-size: 13px; }
.board li:nth-child(-n+3) .rk { color: var(--lime); }
.board img { width: 52px; height: 52px; border-radius: 10px; image-rendering: pixelated; background: #0b0b0d; box-shadow: 0 0 0 1px var(--line); }
.board .nm { min-width: 0; display: grid; }
.board .nm b, .board .nm small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board small { color: var(--dim); font-size: 12px; }
.board .sc { text-align: right; display: grid; }
.board .sc b { color: var(--ink); }
.board .sc b.up { color: var(--lime); }
.board .vsline { color: var(--coral); }

.how { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 6px; }
.how summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-size: 13px; color: var(--dim); }
.how b { color: var(--ink); font-weight: 600; }

.wallets { display: grid; gap: 8px; }
.wallet-row { display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 12px; min-height: 52px; padding: 8px 12px; border-radius: 14px;
  background: var(--panel-2); border: 1px solid var(--line); cursor: pointer; text-align: left; }
.wallet-row:hover { border-color: rgba(195, 255, 92, .45); }
.wallet-row img, .wallet-row .wc { width: 32px; height: 32px; border-radius: 8px; }
.wallet-row .wc { display: grid; place-items: center; background: var(--bg); }
.wallet-row .wc svg { width: 20px; height: 20px; fill: none; stroke: var(--lime); stroke-width: 2; stroke-linecap: round; }
.wallet-row small { color: var(--dim); font-size: 12px; }
.wallet-row[aria-busy="true"] { opacity: .7; }
.who { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.addr { font-weight: 700; }
.chip { min-height: 44px; padding: 0 16px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); cursor: pointer; margin-top: 12px; }
.mine { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.mine li { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.mine img { width: 52px; height: 52px; border-radius: 10px; image-rendering: pixelated; background: #0b0b0d; box-shadow: 0 0 0 1px var(--line); }
.mine .nm { display: grid; min-width: 0; }
.mine .nm b, .mine .nm small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mine small { color: var(--dim); font-size: 12px; }
.mine button { min-height: 44px; padding: 0 12px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); cursor: pointer; font-size: 12px; font-weight: 600; }
.mine button[aria-pressed="true"] { background: var(--lav); color: #120c22; border-color: var(--lav); }
.mine button:disabled:not([aria-pressed="true"]) { opacity: .45; cursor: default; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
