:root {
  --bg: #060709;
  --s1: #0E1013;
  --s2: #15181D;
  --s3: #1d2128;
  --line: rgba(244, 235, 221, .09);
  --cream: #F4EBDD;
  --muted: #A8A29A;
  --red: #E84338;
  --red-press: #C8362D;
  --gold: #E9C46A;
  --gold2: #F5C04B;
  --gold3: #D2B77A;
  --mint: #5EE7B2;
  --violet: #8B5CF6;
  --stone: #B9B2A6;
  --r: 14px;
  --font: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --tabh: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--cream); }
html.locked, html.locked body { overflow: hidden; }
body {
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(90% 50% at 50% -10%, rgba(232, 67, 56, .12), transparent 70%),
    radial-gradient(60% 40% at 100% 0%, rgba(233, 196, 106, .06), transparent 70%),
    var(--bg);
  background-attachment: fixed;
}
a { color: var(--gold); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
img { max-width: 100%; }
img.fade { opacity: 0; transition: opacity .25s ease-out; }
img.fade.ok { opacity: 1; }
.img-gone { display: none; }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.15; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 26px; } h2 { font-size: 19px; } h3 { font-size: 16px; }
p { margin: 0 0 .7em; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.stack > * + * { margin-top: 12px; }
.boot { padding: 40vh 0; text-align: center; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- layout ---------- */
#app { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top));
  background: rgba(6, 7, 9, .9);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--cream); flex: none; }
.brand-name { font-weight: 600; font-size: 15px; letter-spacing: -.01em; white-space: nowrap; }
.emblem { width: 36px; height: 36px; object-fit: contain; display: block; flex: none; }
.emblem.crown-fb svg, .land-king.crown-fb svg { width: 100%; height: 100%; display: block; }
@media (max-width: 440px) { .topbar .brand-name { display: none; } }
.topbar .stats { display: flex; gap: 6px; margin-left: auto; align-items: center; min-width: 0; }
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  height: 30px; padding: 0 9px; border-radius: 999px; background: var(--s2); color: var(--cream);
  font: 500 13px var(--mono); white-space: nowrap; border: 1px solid var(--line);
}
.pill .pi { display: inline-flex; }
button.pill { cursor: pointer; font: 500 13px var(--mono); }
.pill .lbl { font-family: var(--font); color: var(--muted); font-size: 11px; }
@media (max-width: 360px) { .pill .lbl { display: none; } .pill { padding: 0 7px; } }
.icon-btn {
  flex: none; background: var(--s2); border: 1px solid var(--line); border-radius: 999px; width: 32px; height: 32px; padding: 0;
  display: inline-grid; place-items: center; cursor: pointer; color: var(--cream);
}
.icon-btn svg { display: block; }
.tabs { display: flex; }
.tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--muted); font-size: 11px; font-weight: 500; padding: 7px 4px 6px;
}
.tabs a .ti { display: inline-flex; line-height: 1; }
.tabs a.on { color: var(--cream); }
.tabs a.on .ti { color: var(--red); filter: drop-shadow(0 0 6px rgba(232, 67, 56, .6)); }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: rgba(10, 11, 14, .96);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); padding-bottom: var(--safe-b);
}
.toptabs { display: none; }
main.view {
  max-width: 1100px; margin: 0 auto; outline: none;
  padding: 14px 16px calc(var(--tabh) + var(--safe-b) + 26px);
}
.view-in { animation: viewIn .22s ease-out both; }
@keyframes viewIn { from { opacity: 0; transform: translate3d(0, 6px, 0); } }
body.bare .tabbar, body.bare .topbar, body.booting .tabbar, body.booting .toptabs { display: none; }
body.bare main.view { padding-bottom: 36px; }
@media (min-width: 820px) {
  .tabbar { display: none; }
  .toptabs { display: flex; margin-left: 14px; gap: 2px; }
  .toptabs a { flex-direction: row; gap: 6px; font-size: 14px; padding: 7px 12px; border-radius: 999px; }
  .toptabs a .ti svg { width: 18px; height: 18px; }
  .toptabs a.on { background: var(--s2); }
  main.view { padding: 26px 24px 56px; }
}

.offline-bar {
  position: sticky; top: 52px; z-index: 19; display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap;
  padding: 7px 14px; font-size: 13px; color: #ffd9d4; text-align: center;
  background: rgba(120, 24, 18, .92); border-bottom: 1px solid rgba(232, 67, 56, .5);
}
.offline-bar[hidden] { display: none; }
.offline-bar .link { color: #fff; font-weight: 600; text-decoration: underline; padding: 2px 4px; font-size: 13px; }
body.bare .offline-bar { top: 0; }

/* ---------- surfaces ---------- */
.box {
  background: linear-gradient(180deg, rgba(255, 255, 255, .018), transparent 60%), var(--s1);
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px;
}
.box + .box { margin-top: 14px; }
.box h2 { display: flex; align-items: center; gap: 8px; }
.grid2 { display: grid; gap: 14px; }
.grid2 > .box + .box { margin-top: 0; }
@media (min-width: 820px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.bar { height: 8px; border-radius: 99px; background: var(--s3); overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--red), var(--gold2)); border-radius: 99px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--s3); font-size: 12px; }
.hash { font: 12px/1.5 var(--mono); word-break: break-all; color: var(--gold3); cursor: pointer; background: none; border: 0; padding: 0; text-align: left; }
.err-box { margin-top: 20vh; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 18px; border-radius: 12px; border: 0;
  background: var(--s2); color: var(--cream); font-weight: 600; font-size: 15px; line-height: 1.2;
  cursor: pointer; text-align: center; text-decoration: none;
  transition: transform .08s, background-color .15s, opacity .15s;
  -webkit-user-select: none; user-select: none; touch-action: manipulation;
}
.btn:active { transform: scale(.97); }
.btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.btn.primary { background: var(--red); color: #fff; }
.btn.primary:active { background: var(--red-press); }
.btn.gold { background: linear-gradient(180deg, var(--gold2), var(--gold3)); color: #1a1408; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.block { display: flex; width: 100%; }
.btn.sm { min-height: 34px; padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.btn.soft { opacity: .55; }  /* "not possible right now" look — still tappable, explains on tap */
.btn.discord { background: #5865F2; color: #fff; }
.btn.discord:active { background: #4752c4; }
.btn .sub { font: 500 12px var(--mono); opacity: .8; }
.link { background: none; border: 0; color: var(--gold); cursor: pointer; padding: 6px; font-size: 14px; }
input.field, select.field, textarea.field {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 10px;
  background: var(--bg); border: 1px solid rgba(244, 235, 221, .14); outline: none; font-size: 16px;
}
input.field:focus, select.field:focus { border-color: var(--gold3); }
input.field::placeholder { color: #6f6a63; }

/* ---------- segmented tabs ---------- */
.seg { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button {
  flex: none; border: 1px solid var(--line); background: var(--s1); border-radius: 999px;
  padding: 7px 13px; font-size: 13px; font-weight: 500; cursor: pointer; color: var(--muted);
}
.seg button.on { background: var(--cream); color: var(--bg); border-color: var(--cream); }

/* ---------- toasts ---------- */
#toasts {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 100;
  bottom: calc(var(--tabh) + var(--safe-b) + 14px);
  display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); pointer-events: none;
}
html.locked #toasts, body.bare #toasts { bottom: auto; top: calc(env(safe-area-inset-top, 0px) + 54px); }
.toast {
  background: #1a1d23; border: 1px solid var(--line); border-left: 3px solid var(--gold);
  padding: 11px 14px; border-radius: 12px; font-size: 14px; box-shadow: 0 8px 30px rgba(0, 0, 0, .55);
  animation: toastIn .22s ease-out; pointer-events: auto; cursor: pointer;
}
.toast.err { border-left-color: var(--red); }
.toast.ok { border-left-color: var(--mint); }
.toast.out { opacity: 0; transition: opacity .3s; }
@keyframes toastIn { from { opacity: 0; transform: translate3d(0, 10px, 0); } }
@media (min-width: 820px) { #toasts { bottom: 24px; } }

/* ---------- modal + sheet ---------- */
.scrim {
  position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .74);
  display: flex; align-items: center; justify-content: center; padding: 16px;
  animation: fadeIn .18s ease-out;
}
.scrim.closing { opacity: 0; transition: opacity .18s; }
.scrim.sheet-wrap { align-items: flex-end; padding: 0; }
.modal {
  background: var(--s1); border: 1px solid var(--line); border-radius: 18px;
  max-width: 420px; width: 100%; max-height: 92vh; max-height: 92dvh; overflow-y: auto; padding: 18px;
  position: relative; overscroll-behavior: contain;
}
.sheet {
  position: relative;
  background: var(--s1); border-top: 1px solid var(--line); border-radius: 20px 20px 0 0;
  width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto; padding: 22px 18px calc(20px + var(--safe-b));
  animation: sheetUp .24s cubic-bezier(.2, .8, .2, 1);
}
.sheet::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 4px; background: var(--s3); margin: -10px auto 14px; }
.sheet h2 { padding-right: 36px; }
.modal .x, .sheet .x { position: absolute; top: 10px; right: 10px; z-index: 5; }
.sheet-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.sheet-actions .btn { flex: 1; min-width: 130px; }
@media (min-width: 560px) { .scrim.sheet-wrap { align-items: center; padding: 16px; } .sheet { border-radius: 18px; border: 1px solid var(--line); } .sheet::before { display: none; } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes sheetUp { from { transform: translate3d(0, 100%, 0); } }

.empty { padding: 30px 10px; text-align: center; color: var(--muted); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--s3); object-fit: cover; flex: none; }
.avatar.initials { display: inline-grid; place-items: center; font: 600 13px var(--font); color: #0b0c0e; background: var(--av, var(--gold)); }
.avatar.xl { width: 64px; height: 64px; font-size: 28px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th, table.t td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t th { color: var(--muted); font-weight: 500; }
table.t td.n, table.t th.n { text-align: right; font-family: var(--mono); }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* mock / demo mode (owner rule 2026-10-20): a fixed banner so fake data is never taken for the live event */
body.demo { --demo-h: calc(26px + env(safe-area-inset-top, 0px)); padding-top: var(--demo-h); }
.demo-banner {
  position: fixed; left: 0; right: 0; top: 0; z-index: 300; height: var(--demo-h, 26px); box-sizing: border-box;
  padding: env(safe-area-inset-top, 0px) 12px 0; display: flex; align-items: center; justify-content: center;
  background: repeating-linear-gradient(-45deg, #f5c04b 0 12px, #e8b23c 12px 24px); color: #15100a;
  font: 700 12px/1 var(--font); letter-spacing: .06em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .45); pointer-events: none;
}
.test-banner { background: repeating-linear-gradient(-45deg, #e84338 0 12px, #c8362d 12px 24px); color: #fff; }
body.demo .topbar { top: var(--demo-h); padding-top: 8px; }
body.demo .offline-bar { top: calc(52px + var(--demo-h)); }
body.demo.bare .offline-bar { top: var(--demo-h); }
body.demo .stage { top: var(--demo-h); bottom: 0; height: auto; }

/* mock-mode dev button */
.mock-fab {
  position: fixed; left: 10px; bottom: calc(var(--tabh) + var(--safe-b) + 12px); z-index: 45;
  font: 600 10px var(--mono); letter-spacing: .1em; color: #111; background: var(--mint);
  border: 0; border-radius: 99px; padding: 7px 10px; cursor: pointer; box-shadow: 0 4px 14px rgba(0, 0, 0, .5); opacity: .85;
}
body.bare .mock-fab { bottom: 12px; }
@media (min-width: 820px) { .mock-fab { bottom: 14px; } }

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