@font-face { font-family: Poppins; font-weight: 700; font-display: swap; src: url(../fonts/Poppins-Bold.woff2) format("woff2"); }
@font-face { font-family: Poppins; font-weight: 600; font-display: swap; src: url(../fonts/Poppins-SemiBold.woff2) format("woff2"); }
@font-face { font-family: Poppins; font-weight: 500; font-display: swap; src: url(../fonts/Poppins-Medium.woff2) format("woff2"); }
@font-face { font-family: "Be Vietnam Pro"; font-weight: 700; font-display: swap; src: url(../fonts/BeVietnamPro-Bold.woff2) format("woff2"); }
@font-face { font-family: "Be Vietnam Pro"; font-weight: 500; font-display: swap; src: url(../fonts/BeVietnamPro-Medium.woff2) format("woff2"); }

:root {
  --ink: #0a0f1f;
  --paper: #fffdf6;
  --paper-2: #f2eee2;
  --gold: #ffd257;
  --gold-deep: #e9a92a;
  --sky: #070b1a;
  --text: #f4f7ff;
  --muted: #b9c6e4;
  --line: 3px;
  --shadow: 4px 4px 0 var(--ink);
  --r: 16px;
  --font: Poppins, "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", "Noto Sans", "Noto Sans Thai", "Noto Sans Khmer", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--sky); color: var(--text); font-family: var(--font); overflow: hidden; }
body { -webkit-font-smoothing: antialiased; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#scene:active { cursor: grabbing; }
a { color: inherit; }
button { font: inherit; color: inherit; }

/* ---------------------------------------------------------------- buttons, in the comic-panel style of the channel */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border: var(--line) solid var(--ink); border-radius: 999px;
  background: var(--paper); color: var(--ink); font-weight: 700; font-size: 15px; cursor: pointer; box-shadow: var(--shadow);
  transition: transform .08s, box-shadow .08s; white-space: nowrap; }
.btn:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); }
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn.primary { background: var(--gold); }
.btn:focus-visible, .seg button:focus-visible, .rows button:focus-visible, .close:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.btn.icon { padding: 9px 13px; font-size: 16px; }
.btn.gift { background: var(--gold); }
a.btn { text-decoration: none; color: var(--ink) !important; }
.link { background: none; border: 0; padding: 0; color: #1d4fd8; font-weight: 600; text-decoration: underline; cursor: pointer; font-size: inherit; }

/* ---------------------------------------------------------------- top bar */
.topbar { position: fixed; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center;
  padding: max(14px, env(safe-area-inset-top)) 18px 0; pointer-events: none; z-index: 5; }
.topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; letter-spacing: .06em; font-size: 18px;
  text-shadow: 0 2px 0 var(--ink), 0 0 12px rgba(0,0,0,.6); }
.brand img { border-radius: 50%; box-shadow: 0 0 0 3px var(--ink); }
.tools { display: flex; gap: 10px; }
.tools .btn span { font-size: 14px; }

/* ---------------------------------------------------------------- intro */
#intro { position: fixed; left: 0; right: 0; bottom: 96px; text-align: center; z-index: 4; pointer-events: none; padding: 0 16px;
  transition: opacity .5s, transform .5s; }
#intro .cta { pointer-events: auto; }
#intro .kicker { margin: 0 0 4px; font-weight: 700; letter-spacing: .14em; font-size: clamp(12px, 1.6vw, 16px); color: var(--gold);
  text-shadow: 0 2px 0 var(--ink); }
#intro h1 { margin: 0; font-size: clamp(60px, 9.5vw, 132px); line-height: .95; font-weight: 700; letter-spacing: -.02em; color: #fff;
  -webkit-text-stroke: clamp(4px, .8vw, 9px) var(--ink); paint-order: stroke fill; text-shadow: 0 8px 0 var(--ink); font-variant-numeric: tabular-nums; }
#intro .sub { margin: 14px auto 18px; max-width: 640px; font-size: clamp(15px, 1.9vw, 19px); line-height: 1.45; font-weight: 600;
  text-shadow: 0 2px 0 var(--ink), 0 0 18px rgba(0,0,0,.85); opacity: 0; transform: translateY(8px); transition: opacity .4s .1s, transform .4s .1s; }
#intro .cta { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; opacity: 0; transition: opacity .4s .35s; }
body.counted #intro .sub, body.counted #intro .cta { opacity: 1; transform: none; }
body.intro-done #intro { opacity: 0; transform: translateY(-20px); }
body.intro-done #intro .cta { pointer-events: none; }

/* ---------------------------------------------------------------- dock */
.short { display: none; }
.dock { position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; gap: 10px;
  align-items: center; z-index: 5; flex-wrap: nowrap; }
.seg { display: inline-flex; border: var(--line) solid var(--ink); border-radius: 999px; overflow: hidden; box-shadow: var(--shadow); background: var(--paper); }
.seg button { border: 0; background: transparent; color: var(--ink); font-weight: 700; font-size: 15px; padding: 10px 16px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--gold); }
body.panel-open .dock { opacity: 0; pointer-events: none; }

/* ---------------------------------------------------------------- panel */
#panel { position: fixed; z-index: 6; top: 76px; right: 18px; bottom: 18px; width: min(400px, calc(100vw - 36px)); background: var(--paper);
  color: var(--ink); border: var(--line) solid var(--ink); border-radius: var(--r); box-shadow: 6px 6px 0 var(--ink); display: flex; flex-direction: column;
  animation: pop .22s cubic-bezier(.2,1.4,.4,1); }
@keyframes pop { from { transform: scale(.92); opacity: 0; } }
#panel-body { overflow-y: auto; padding: 22px 22px 26px; overscroll-behavior: contain; }
.close { position: absolute; top: 10px; right: 10px; width: 38px; height: 38px; border-radius: 50%; border: var(--line) solid var(--ink);
  background: var(--paper); color: var(--ink); font-weight: 700; cursor: pointer; z-index: 2; box-shadow: 2px 2px 0 var(--ink); }
#panel h2 { margin: 0 0 8px; font-size: 26px; line-height: 1.1; padding-right: 40px; }
#panel .card h2 { padding-right: 0; }
#panel h3 { margin: 18px 0 8px; font-size: 16px; }
#panel p { margin: 0 0 10px; font-size: 15px; line-height: 1.5; font-weight: 500; }
#panel a { color: #1d4fd8; font-weight: 600; }
.lede { color: #3b4357; }
.small { font-size: 13px !important; }

.card .hero { position: relative; display: grid; place-items: center; margin: -6px 0 6px; }
.card .bigball { width: 200px; height: 200px; animation: bounce .6s cubic-bezier(.2,1.6,.4,1); filter: drop-shadow(0 10px 6px rgba(0,0,0,.22)); }
.card .bigflag { font-size: 120px; line-height: 200px; }
@keyframes bounce { from { transform: translateY(18px) scale(.8); } }
.badge { position: absolute; bottom: 0; background: var(--gold); border: var(--line) solid var(--ink); border-radius: 999px; padding: 4px 14px;
  font-weight: 700; font-size: 14px; letter-spacing: .04em; box-shadow: 2px 2px 0 var(--ink); }
.tier-top1000 .badge { background: var(--paper-2); }
.thanks { text-align: center; font-size: 40px !important; margin: 10px 0 4px !important; color: #fff; -webkit-text-stroke: 7px var(--ink);
  paint-order: stroke fill; letter-spacing: .01em; overflow-wrap: anywhere; }
.who { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 14px; text-align: center; }
.avatar { width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--ink); flex: none; }
.handle { font-size: 19px; font-weight: 700; color: var(--ink) !important; text-decoration: none; overflow-wrap: anywhere; }
.handle:hover { text-decoration: underline; }
.name { font-size: 13px; color: #5a6275; }
.cname { font-size: 22px; font-weight: 700; }
.note { background: #fff3c9; border: 2px solid var(--ink); border-radius: 10px; padding: 10px 12px; }
.quote { margin: 14px 0; padding: 12px 14px; background: #eef3ff; border: 2px solid var(--ink); border-radius: 12px; position: relative; }
.quote p { font-size: 16px !important; font-weight: 600 !important; margin: 0 0 6px !important; overflow-wrap: anywhere; }
.quote footer { font-size: 12.5px; color: #4b5470; }
.why { font-size: 13.5px !important; color: #3b4357; border-top: 2px dashed #cfc8b4; padding-top: 10px; margin-top: 14px !important; }
.sign { font-weight: 700 !important; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.bar { height: 12px; border: 2px solid var(--ink); border-radius: 999px; background: var(--paper-2); overflow: hidden; margin: 0 0 12px; }
.bar i { display: block; height: 100%; background: var(--gold); }
.more { color: #5a6275; font-size: 13px !important; }
.giftbox { display: flex; align-items: center; gap: 12px; width: 100%; margin-top: 16px; padding: 12px 14px; text-align: left; cursor: pointer;
  background: #fff3c9; color: var(--ink); border: 2px solid var(--ink); border-radius: 12px; box-shadow: 3px 3px 0 var(--ink); font-size: 14px; line-height: 1.4; }
.giftbox:hover { background: #ffeaa6; }
.giftbox .g { font-size: 30px; line-height: 1; }
.gift-hero { font-size: 72px; line-height: 1; text-align: center; margin: 4px 0 10px; }
.gift h2 { text-align: center; padding: 0 !important; }
.steps { margin: 6px 0 14px; padding-left: 22px; }
.steps li { margin: 0 0 8px; font-size: 15px; line-height: 1.5; }

.tabs { display: flex; gap: 8px; margin: 6px 0 12px; }
.tab { border: 2px solid var(--ink); background: var(--paper); border-radius: 999px; padding: 6px 12px; font-weight: 700; cursor: pointer; color: var(--ink); }
.tab[aria-pressed="true"] { background: var(--ink); color: var(--gold); }
.rows { list-style: none; margin: 8px 0 0; padding: 0; }
.rows li + li { border-top: 1px solid #e3ddcc; }
.rows button { display: grid; grid-template-columns: auto 52px 1fr auto; align-items: center; gap: 8px; width: 100%; padding: 6px 4px;
  background: none; border: 0; color: var(--ink); text-align: left; cursor: pointer; border-radius: 8px; }
.rows button:hover { background: #f4eedb; }
.rows .rk { font-weight: 700; font-size: 13px; color: #5a6275; font-variant-numeric: tabular-nums; }
.rows .nm { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.rows .nm small { display: block; font-size: 12px; font-weight: 500; color: #5a6275; }
.rows .ct { font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.rows .empty { padding: 14px 4px; color: #5a6275; }
.search { display: flex; align-items: center; gap: 8px; border: var(--line) solid var(--ink); border-radius: 12px; padding: 8px 12px; background: #fff; box-shadow: 3px 3px 0 var(--ink); }
.search input { border: 0; outline: 0; font: inherit; font-size: 16px; flex: 1; min-width: 0; background: transparent; color: var(--ink); }

.ico { display: inline-block; width: var(--s); height: var(--s); background-image: url(../img/atlas_64.webp); background-repeat: no-repeat; flex: none; }
.ico-emoji { background: none; font-size: calc(var(--s) * .7); line-height: var(--s); text-align: center; }

/* ---------------------------------------------------------------- hover tag, toast, loader */
#tip { position: fixed; left: 0; top: 0; z-index: 7; pointer-events: none; display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px;
  background: var(--paper); color: var(--ink); border: 2px solid var(--ink); border-radius: 999px; box-shadow: 3px 3px 0 var(--ink); max-width: 320px; }
#tip b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
#tip small { display: block; font-size: 12px; color: #4b5470; font-weight: 600; }
#toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 8; background: var(--ink); color: var(--gold);
  border-radius: 999px; padding: 10px 18px; font-weight: 700; max-width: 90vw; overflow-wrap: anywhere; }
#loader { position: fixed; inset: 0; z-index: 9; display: grid; place-content: center; gap: 14px; text-align: center; background: var(--sky);
  transition: opacity .5s; font-weight: 600; color: var(--muted); padding: 16px; }
#loader .track { width: 220px; height: 10px; border: 2px solid #33406a; border-radius: 99px; margin: 0 auto; overflow: hidden; }
#loader i { display: block; height: 100%; width: 0; background: var(--gold); transition: width .3s; }
body.ready #loader { opacity: 0; pointer-events: none; }

/* ---------------------------------------------------------------- phones */
@media (max-width: 760px) {
  .brand span { font-size: 15px; }
  .tools .btn span { display: none; }
  #intro { bottom: 110px; }
  .dock { left: 12px; right: 12px; transform: none; justify-content: center; gap: 6px; }
  .dock .btn, .seg button { font-size: 13px; padding: 8px 10px; }
  .long { display: none; } .short { display: inline; }
  body:not(.intro-done) .dock { opacity: 0; pointer-events: none; }
  #panel { top: auto; left: 0; right: 0; bottom: 0; width: 100%; max-height: 62vh; border-radius: 18px 18px 0 0; border-bottom: 0;
    box-shadow: 0 -4px 0 var(--ink); animation: slideup .25s cubic-bezier(.2,1.2,.4,1); padding-bottom: env(safe-area-inset-bottom); }
  @keyframes slideup { from { transform: translateY(40%); } }
  .card .bigball { width: 150px; height: 150px; }
  .thanks { font-size: 32px !important; }
}
@media (max-width: 440px) {
  .brand span { display: none; }                 /* the logo alone: four buttons + the word ran 44 px off a 375 px phone */
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
