:root {
  --chat-size: 20px;
  --bg-alpha: .72;
  --yt: #ff3b3b;
  --tw: #a970ff;
  --kick: #53fc18;
  --tt: #25f4ee;
}
html, body { margin: 0; height: 100%; background: transparent; overflow: hidden; }
body {
  font-family: "Segoe UI", system-ui, sans-serif; color: #fff;
  display: flex; flex-direction: column; font-size: var(--chat-size);
}
/* Chat fills the space above the footer; newest message sits right above it. */
#chat {
  flex: 1; min-height: 0; overflow: hidden;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 0; padding: 10px; --gap: 6px;
}

.footer {
  flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: .4em .9em;
  margin: 0 10px 10px; padding: .4em .8em; border-radius: 10px;
  background: rgba(10, 12, 16, calc(var(--bg-alpha) + .1)); text-shadow: 0 1px 2px rgba(0,0,0,.6);
  font-weight: 700; font-size: .9em;
}
/* Never squash the name or split a number; wrap the row instead if the source is narrow. */
.footer-text { flex: 0 0 auto; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.footer-platforms { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: .4em .8em; margin-left: auto; }
.footer-item { flex: none; white-space: nowrap; display: inline-flex; align-items: center; gap: .35em; font-variant-numeric: tabular-nums; }
.footer-item .picon { width: 1.2em; height: 1.2em; }
.footer-item .picon svg { width: 1.2em; height: 1.2em; }
.footer-total { padding-left: .8em; border-left: 1px solid rgba(255,255,255,.25); }
.msg {
  display: flex; gap: .45em; align-items: flex-start; line-height: 1.5;
  background: rgba(10, 12, 16, var(--bg-alpha)); border-radius: 10px; padding: .35em .6em;
  text-shadow: 0 1px 2px rgba(0,0,0,.6); overflow-wrap: anywhere;
  animation: in .25s ease-out;
  margin-top: var(--gap);
  transition: opacity .28s ease-in, transform .28s ease-in, max-height .35s ease, margin-top .35s ease, padding-top .35s ease, padding-bottom .35s ease;
}
.msg.out { opacity: 0; transform: translateX(-28px) scale(.97); }
/* After fading, shrink the space it took so the remaining messages glide into place. */
.msg.collapse { max-height: 0 !important; margin-top: 0; padding-top: 0; padding-bottom: 0; border-width: 0; overflow: hidden; }
@keyframes in { from { opacity: 0; transform: translateY(8px); } }
.time { flex: none; opacity: .65; font-size: .8em; line-height: 1.875; font-variant-numeric: tabular-nums; }
.picon { flex: none; width: 1.15em; height: 1.5em; display: flex; align-items: center; }
.picon svg { width: 1.15em; height: 1.15em; display: block; }
.avatar { flex: none; width: 1.5em; height: 1.5em; border-radius: 50%; object-fit: cover; }
.avatar.ph { display: flex; align-items: center; justify-content: center; font-size: .75em; width: 2em; height: 2em; font-weight: 700; }
.body { min-width: 0; flex: 1; }
.badge { display: inline-flex; align-items: center; gap: .2em; vertical-align: -.2em; height: 1.2em; margin-right: .3em; }
.badge img { height: 1.1em; width: auto; display: block; }
.badge-text {
  font-size: .62em; font-weight: 800; padding: 0 .45em; border-radius: 4px; line-height: 1.6;
  background: rgba(255,255,255,.18); text-shadow: none;
}
.badge-owner .badge-text { background: #e9435d; }
.badge-mod .badge-text { background: #00ad03; }
.badge-vip .badge-text { background: #e005b9; }
.badge-sub .badge-text { background: #2f6fde; }
.badge-level { background: rgba(95,144,239,.55); border-radius: 4px; padding: 0 .3em 0 .2em; }
.badge-level .badge-text { background: none; padding: 0; }
.name { font-weight: 700; }
.sep { opacity: .7; }
.amount { margin-left: .5em; font-weight: 800; color: #ffd166; }
.subtitle { opacity: .8; font-size: .85em; }
.emote { height: 1.5em; vertical-align: middle; margin: -.2em .08em; }
.kind-paid { box-shadow: inset 4px 0 0 #ffd166; }
.kind-member { box-shadow: inset 4px 0 0 #3ccf6e; }

/* ---------- desktop game overlay window (only when opened from the app, never in OBS) */
.ow-bar, .ow-grip { display: none; }
body.desktop:not(.locked) { outline: 2px dashed rgba(255,255,255,.35); outline-offset: -2px; border-radius: 8px; }
body.desktop:not(.locked) .ow-bar {
  display: flex; align-items: center; gap: 8px; flex: none;
  margin: 6px 6px 0; padding: 4px 6px 4px 10px; border-radius: 8px;
  background: rgba(10, 12, 16, .85); font-size: 12px; font-weight: 600; color: rgba(255,255,255,.8);
  -webkit-app-region: drag; cursor: move; user-select: none;
}
.ow-bar span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ow-lock {
  -webkit-app-region: no-drag; cursor: pointer; border: 0; border-radius: 6px; padding: 3px 10px;
  background: #7aa2ff; color: #0b0d12; font: inherit; font-weight: 700;
}
body.desktop:not(.locked) .ow-grip {
  display: block; position: fixed; right: 2px; bottom: 2px; width: 18px; height: 18px; cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, rgba(255,255,255,.6) 50%, rgba(255,255,255,.6) 60%, transparent 60%, transparent 70%, rgba(255,255,255,.6) 70%, rgba(255,255,255,.6) 80%, transparent 80%);
  -webkit-app-region: no-drag; z-index: 10;
}

/* ---------- phone layout (/tiktok): for viewers on small portrait screens */
/* Everything scales with the width of the source, so it stays readable at any size. */
body.phone { font-weight: 600; }
.phone #chat { --gap: .35em; padding: .5em; }
.phone .msg {
  gap: .4em; padding: .4em .6em; border-radius: .6em; line-height: 1.3;
  /* outline-style shadow keeps white text readable over bright video */
  text-shadow: 0 0 3px #000, 0 2px 4px rgba(0,0,0,.9);
  border: 1px solid rgba(255,255,255,.08);
}
.phone .picon { width: 1.3em; height: 1.3em; }
.phone .picon svg { width: 1.3em; height: 1.3em; filter: drop-shadow(0 1px 2px rgba(0,0,0,.7)); }
.phone .avatar { width: 1.3em; height: 1.3em; box-shadow: 0 0 0 2px rgba(255,255,255,.85); }
.phone .avatar.ph { width: 1.73em; height: 1.73em; font-size: .75em; }
.phone .name { font-weight: 800; }
.phone .sep { display: none; }
/* name on its own line, message underneath: easier to read on a phone */
.phone .line { display: flex; flex-wrap: wrap; align-items: center; column-gap: .25em; }
.phone .line .text { flex-basis: 100%; font-weight: 600; color: #fff; }
.phone .badge { height: 1em; margin-right: 0; }
.phone .badge img { height: .95em; }
.phone .emote { height: 1.4em; }

.phone .footer {
  justify-content: center; margin: 0 .5em .5em; padding: .45em .7em; border-radius: .6em;
  font-size: .95em; text-shadow: 0 0 3px #000, 0 2px 4px rgba(0,0,0,.9);
  background: rgba(10, 12, 16, calc(var(--bg-alpha) + .15)); /* ~50% with the 35% default */
}
.phone .footer-text { width: 100%; text-align: center; font-size: 1.05em; letter-spacing: .02em; }
.phone .footer-platforms { margin-left: 0; justify-content: center; }
.phone .footer-item .picon, .phone .footer-item .picon svg { width: 1.25em; height: 1.25em; }
.phone .footer-count { font-weight: 800; }
/* TikTok layout footer = "Name  👥 total" on one centered line (no per-platform counts). */
.phone .footer-text { width: auto; }
.phone .footer-platforms { margin-left: 0; }
.phone .footer-total { border-left: 0; padding-left: 0; }
