/* ═══════════════════════════════════════════════════════════════════════════
   rect360 — Application components
   Chat, reward reveal, purchase modal, tutorial, plot effects
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --rx-bg:        #0d1117;
  --rx-surface:   #161b22;
  --rx-surface-2: #21262d;
  --rx-border:    #30363d;
  --rx-border-2:  #484f58;
  --rx-text:      #e6edf3;
  --rx-muted:     #8b949e;
  --rx-accent:    #58a6ff;
  --rx-purple:    #a371f7;
  --rx-green:     #3fb950;
  --rx-gold:      #f0a500;
  --rx-red:       #f85149;
}

body.light-mode {
  --rx-bg:        #ffffff;
  --rx-surface:   #f6f8fa;
  --rx-surface-2: #eaeef2;
  --rx-border:    #d0d7de;
  --rx-border-2:  #afb8c1;
  --rx-text:      #1f2328;
  --rx-muted:     #656d76;
}

/* ═══════════════════════════════════════════════════════════════════════════
   1. CHAT
   ═══════════════════════════════════════════════════════════════════════════ */

/* .chat-jump is positioned relative to the chat box */
.chatbox { position: fixed; }

/* The unread badge on the chat button. Full opacity on purpose: a waiting
   message is the one time this control should insist on being seen. */
#chatboxToggle.has-unread {
  opacity: 1;
  color: #ffffff;
  border-color: #f85149;
  animation: rx-unread 1.6s ease-in-out infinite;
}
/* The light theme used to repaint the icon near-black here. That dated from
   when the button had a pale background; against the brand-purple button it
   turned the bubble into a black smudge the moment a message arrived — exactly
   when it most needed to read clearly. Both themes now keep it white. */
body.light-mode #chatboxToggle.has-unread { color: #ffffff; }
@keyframes rx-unread {
  0%,100% { box-shadow: 0 0 0 0 rgba(248,81,73,.35); }
  50%     { box-shadow: 0 0 0 7px rgba(248,81,73,0); }
}

/* GIF picker: the layout was updated when the search box was added.
   The width is CAPPED to the viewport: the flat `320px !important` used to beat
   the mobile override in the page stylesheet, so on a 280-320 px phone the box
   ran off the right edge (the last column of GIFs could not be reached) and on a
   375 px one it sat glued to the left with a gap on the right. The height is
   capped the same way so the picker cannot outgrow a landscape phone. */
#gifPicker {
  padding: 0 !important;
  max-height: min(320px, calc(100vh - 150px)) !important;
  max-height: min(320px, calc(100dvh - 150px)) !important;  /* mobile: excludes the browser bar */
  width: min(320px, calc(100vw - 24px)) !important;
  text-align: left !important;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.rx-chat-head-actions {
  display: flex; align-items: center; gap: 2px;
  z-index: 1; position: relative;
}
.rx-chat-iconbtn {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent;
  color: rgba(255,255,255,.72);
  border-radius: 7px; cursor: pointer;
  font-size: 13px;
  transition: background .15s, color .15s, transform .12s;
}
.rx-chat-iconbtn:hover { background: rgba(255,255,255,.14); color: #fff; transform: translateY(-1px); }
.rx-chat-iconbtn.is-off { color: #ff9b94; }
/* Finger-sized on a touch screen (28px is well under the ~44px a thumb needs).
   The header keeps its height: the extra size comes out of the button's own box. */
@media (hover: none) {
  .rx-chat-iconbtn { width: 38px; height: 38px; font-size: 15px; }
  .rx-chat-head-actions { gap: 0; margin: -5px -4px -5px 0; }
}

/* Expanded chat */
.chatbox.is-expanded { width: min(560px, calc(100vw - 32px)) !important; }
.chatbox.is-expanded .chatbox-body { height: min(62vh, 560px) !important; }

/* On mobile the chat is already full width; "expand" switches to full screen.
   (The old rule SHRANK the width below 100vw — that was the bug.) */
@media (max-width: 768px) {
  .chatbox.is-expanded {
    width: 100vw !important;
    max-width: 100vw;
    border-radius: 0;
  }
  .chatbox.is-expanded .chatbox-body {
    height: calc(100vh - 112px) !important;
    height: calc(100dvh - 112px) !important;
  }
}

/* When the chat expands, the GIF box should expand with it */
.chatbox.is-expanded ~ #gifPicker,
body.chat-expanded #gifPicker {
  width: min(540px, calc(100vw - 24px)) !important;
  max-height: min(420px, calc(100vh - 150px)) !important;
  max-height: min(420px, calc(100dvh - 150px)) !important;
}

/* ── Body ────────────────────────────────────────────────────────────────── */
.chatbox-body { scroll-behavior: smooth; position: relative; }

/* Message bubble */
.chat-message {
  display: flex; gap: 9px;
  padding: 7px 8px;
  border-radius: 10px;
  transition: background .18s;
  animation: rx-msg-in .32s cubic-bezier(.2,.9,.3,1.1) both;
}
@keyframes rx-msg-in {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
.chat-message:hover { background: rgba(255,255,255,.04); }
body.light-mode .chat-message:hover { background: rgba(0,0,0,.035); }

/* Conversation divider: a thin line above the block when a new person's
   messages begin. (In a column-reverse layout the last element in the DOM is
   the topmost one on screen; no divider is drawn for it.) */
.chat-message:not(.is-grouped):not(:last-child) {
  border-top: 1px solid rgba(139,148,158,.16);
  border-radius: 0 0 10px 10px;
  padding-top: 10px;
  margin-top: 3px;
}
body.light-mode .chat-message:not(.is-grouped):not(:last-child) {
  border-top-color: rgba(31,35,40,.1);
}

/* Consecutive messages from the same person: the avatar is not repeated */
.chat-message.is-grouped { padding-top: 1px; padding-bottom: 1px; }
.chat-message.is-grouped .chat-avatar { visibility: hidden; height: 0; }
.chat-message.is-grouped .chat-author { display: none; }

.chat-avatar {
  width: 30px; height: 30px; border-radius: 9px;
  flex-shrink: 0; object-fit: cover;
  border: 1px solid var(--rx-border);
  cursor: pointer;
  transition: transform .18s, border-color .18s;
}
.chat-avatar:hover { transform: scale(1.09); border-color: var(--rx-accent); }

.chat-avatar--letter {
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px;
  color: #fff;
  background: linear-gradient(135deg, #30363d, #484f58);
}
.chat-avatar--system { background: linear-gradient(135deg, #6200ea, #a371f7); }

.chat-main { flex: 1; min-width: 0; }

.chat-author {
  display: flex; align-items: baseline; gap: 7px;
  margin-bottom: 1px;
}
.chat-author-name {
  font-size: 12.5px; font-weight: 700;
  color: var(--rx-accent);
  cursor: pointer;
  max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-author-name:hover { text-decoration: underline; }
.chat-message--system .chat-author-name { color: var(--rx-purple); }
.chat-message--me .chat-author-name { color: var(--rx-green); }

.chat-time { font-size: 10.5px; color: var(--rx-muted); flex-shrink: 0; }

.chat-text {
  font-size: 13px; line-height: 1.5;
  color: var(--rx-text);
  word-break: break-word;
}
.chat-text a { color: var(--rx-accent); text-decoration: none; }
.chat-text a:hover { text-decoration: underline; }
.chat-text img { border-radius: 8px; }
.chat-message--system .chat-text { color: var(--rx-purple); font-weight: 600; }

/* Message actions (reply / copy) */
.chat-actions {
  display: flex; gap: 2px;
  opacity: 0; pointer-events: none;
  transition: opacity .15s;
  align-self: flex-start;
}
.chat-message:hover .chat-actions { opacity: 1; pointer-events: auto; }
.chat-act {
  width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent;
  color: var(--rx-muted); cursor: pointer;
  border-radius: 6px; font-size: 11px;
  transition: background .14s, color .14s;
}
.chat-act:hover { background: var(--rx-surface-2); color: var(--rx-text); }
/* A touch screen never produces :hover, so reply/copy were permanently
   invisible AND unclickable on a phone. There they are always shown, and the
   buttons are grown to a finger-sized target.
   This block must sit AFTER the .chat-act rule above: a media query adds no
   specificity, so the plain 24px rule would otherwise win on source order. */
@media (hover: none) {
  .chat-actions { opacity: 1; pointer-events: auto; }
  .chat-act { width: 34px; height: 34px; font-size: 13px; }
}

/* Quote (reply) */
.chat-quote {
  border-left: 2px solid var(--rx-purple);
  padding: 2px 0 2px 7px;
  margin-bottom: 4px;
  font-size: 11.5px;
  color: var(--rx-muted);
  opacity: .85;
  cursor: pointer;
  border-radius: 0 4px 4px 0;
  transition: background .15s;
}
.chat-quote:hover { background: rgba(163,113,247,.1); }
.chat-quote b { color: var(--rx-purple); }
.chat-quote span { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }

/* Highlighted message (when the quote is clicked) */
.chat-message.is-flash { animation: rx-flash 1.4s ease; }
@keyframes rx-flash {
  0%, 100% { background: transparent; }
  15%      { background: rgba(163,113,247,.28); }
}

/* New-message divider */
.chat-divider {
  display: flex; align-items: center; gap: 8px;
  margin: 6px 2px;
  font-size: 10.5px; font-weight: 700;
  color: var(--rx-red);
  text-transform: uppercase; letter-spacing: .06em;
}
.chat-divider::before, .chat-divider::after {
  content: ''; flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, var(--rx-red), transparent);
}

/* Typing indicator */
.chat-typing {
  display: none; align-items: center; gap: 7px;
  padding: 4px 10px 6px;
  font-size: 11.5px; color: var(--rx-muted);
}
.chat-typing.is-on { display: flex; }
.chat-typing i { width: 5px; height: 5px; border-radius: 50%; background: var(--rx-muted); animation: rx-typing 1.3s infinite; }
.chat-typing i:nth-child(2) { animation-delay: .17s; }
.chat-typing i:nth-child(3) { animation-delay: .34s; }
@keyframes rx-typing { 0%,60%,100% { opacity:.25; transform:translateY(0);} 30% { opacity:1; transform:translateY(-3px);} }

/* Empty state */
.chat-empty {
  text-align: center; padding: 28px 16px;
  color: var(--rx-muted); font-size: 12.5px;
}
.chat-empty-icon { font-size: 30px; opacity: .35; display: block; margin-bottom: 8px; }

/* Jump-to-bottom button */
.chat-jump {
  position: absolute; left: 50%; bottom: 10px;
  transform: translateX(-50%) translateY(14px);
  display: flex; align-items: center; gap: 6px;
  padding: 6px 13px;
  background: var(--rx-purple); color: #fff;
  border: none; border-radius: 20px;
  font-size: 11.5px; font-weight: 700; cursor: pointer;
  box-shadow: 0 5px 18px rgba(163,113,247,.45);
  opacity: 0; pointer-events: none;
  transition: opacity .22s, transform .22s;
  z-index: 5;
}
.chat-jump.is-on { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0); }

/* ── Reply bar ───────────────────────────────────────────────────────────── */
.chat-reply-bar {
  display: none; align-items: center; gap: 8px;
  padding: 7px 10px;
  background: var(--rx-surface-2);
  border-top: 1px solid var(--rx-border);
  font-size: 11.5px; color: var(--rx-muted);
}
.chat-reply-bar.is-on { display: flex; }
.chat-reply-bar .rb-txt { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-reply-bar b { color: var(--rx-purple); }
.chat-reply-bar button {
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent; color: var(--rx-muted);
  cursor: pointer; font-size: 12px; line-height: 1; padding: 0;
  border-radius: 6px; flex-shrink: 0;
}
.chat-reply-bar button:hover { color: var(--rx-red); }

/* ── Bottom bar ──────────────────────────────────────────────────────────── */
/* The character counter sits ABOVE the input as a small chip; it never
   overlaps the emoji/GIF buttons. */
.chat-counter {
  position: absolute; right: 10px; bottom: calc(100% + 6px);
  font-size: 10px; color: var(--rx-muted);
  background: var(--rx-surface);
  border: 1px solid var(--rx-border);
  padding: 2px 8px;
  border-radius: 10px;
  pointer-events: none; opacity: 0; transition: opacity .2s;
  z-index: 6;
}
.chat-counter.is-on { opacity: 1; }
.chat-counter.is-warn { color: var(--rx-gold); }
.chat-counter.is-over { color: var(--rx-red); font-weight: 700; }

/* ── GIF picker ──────────────────────────────────────────────────────────── */
#gifPicker { display: none; }
.rx-gif-search {
  display: flex; gap: 6px; padding: 8px; position: sticky; top: 0;
  background: inherit; z-index: 2;
  border-bottom: 1px solid var(--rx-border);
}
.rx-gif-search input {
  flex: 1; min-width: 0;
  padding: 7px 10px; font-size: 12.5px;
  border-radius: 8px; border: 1px solid var(--rx-border);
  background: var(--rx-bg); color: var(--rx-text);
  outline: none;
}
.rx-gif-search input:focus { border-color: var(--rx-accent); }
.rx-gif-close {
  width: 30px; flex-shrink: 0; align-self: stretch;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent;
  color: var(--rx-muted);
  /* The &times; character sat too high because of the font metrics; the FA
     icon is perfectly centred in its own box. */
  font-size: 13px; line-height: 1;
  cursor: pointer; border-radius: 6px;
  transition: color .15s, background .15s;
}
.rx-gif-close:hover { color: var(--rx-red); background: var(--rx-surface-2); }
.rx-gif-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 6px; padding: 8px;
  min-height: 120px;
}
.rx-gif-grid img {
  width: 100%; height: 92px; object-fit: cover;
  border-radius: 8px; cursor: pointer;
  transition: transform .16s, outline-color .16s;
  outline: 2px solid transparent;
}
.rx-gif-grid img:hover { transform: scale(1.04); outline-color: var(--rx-accent); }

/* The "Loading…" / "No results" messages should sit in the middle of the box.
   Previously they landed in a single grid cell and appeared left-aligned. */
.rx-gif-state {
  grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 120px;
  padding: 20px 12px;
  text-align: center;
  color: var(--rx-muted);
  font-size: 12.5px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   2. PLOT EFFECTS (sale / image arrival)
   ═══════════════════════════════════════════════════════════════════════════ */

.rectangle { position: relative; }

/* A sold plot: the electric frame */
.rectangle.rx-striking {
  z-index: 60 !important;
  animation: rx-strike-shake .55s cubic-bezier(.36,.07,.19,.97) 2;
}
.rectangle.rx-striking::before {
  content: '';
  position: absolute; inset: -3px;
  border: 2px solid #7ee0ff;
  border-radius: 3px;
  box-shadow: 0 0 14px #7ee0ff, 0 0 30px rgba(126,224,255,.7), inset 0 0 14px rgba(126,224,255,.5);
  animation: rx-strike-pulse .16s steps(2) infinite;
  pointer-events: none;
  z-index: 2;
}
@keyframes rx-strike-pulse { 0% { opacity: 1; } 100% { opacity: .35; } }

/* In the light theme the cyan glow was lost on the white background; a dark blue is used */
body.light-mode .rectangle.rx-striking::before {
  border-color: #0969da;
  box-shadow: 0 0 14px rgba(9,105,218,.85), 0 0 30px rgba(9,105,218,.5), inset 0 0 14px rgba(9,105,218,.35);
}
body.light-mode .rx-sold-badge {
  color: #ffffff;
  background: rgba(9,105,218,.35);
  text-shadow: 0 0 8px #0969da;
}
@keyframes rx-strike-shake {
  0%,100% { transform: translate(0,0); }
  20% { transform: translate(-2px, 1px); }
  40% { transform: translate(2px, -1px); }
  60% { transform: translate(-1px, -2px); }
  80% { transform: translate(1px, 2px); }
}

/* The image fading in */
.rectangle img.rx-fade-in {
  animation: rx-img-reveal 1.1s cubic-bezier(.2,.8,.3,1) both;
}
@keyframes rx-img-reveal {
  0%   { opacity: 0; transform: scale(1.28); filter: brightness(3.2) blur(7px) saturate(0); }
  45%  { opacity: 1; filter: brightness(1.8) blur(2px) saturate(.6); }
  100% { opacity: 1; transform: scale(1);    filter: none; }
}

/* The badge for a freshly sold plot */
.rx-sold-badge {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 800; letter-spacing: .05em;
  color: #fff;
  background: rgba(126,224,255,.16);
  text-shadow: 0 0 8px #7ee0ff;
  pointer-events: none;
  z-index: 3;
  animation: rx-sold-badge 2.4s ease forwards;
}
@keyframes rx-sold-badge {
  0%   { opacity: 0; transform: scale(.6); }
  18%  { opacity: 1; transform: scale(1.12); }
  30%  { transform: scale(1); }
  75%  { opacity: 1; }
  100% { opacity: 0; }
}

/* The live event ticker ("Plot X has been sold") */
.rx-ticker {
  position: fixed; left: 50%; top: 14px;
  transform: translateX(-50%) translateY(-140%);
  display: flex; align-items: center; gap: 9px;
  max-width: calc(100vw - 24px);
  flex-wrap: wrap; justify-content: center; text-align: center;
  padding: 9px 18px;
  background: linear-gradient(135deg, rgba(13,17,23,.96), rgba(30,20,60,.96));
  border: 1px solid #7ee0ff;
  border-radius: 999px;
  color: #e6edf3; font-size: 13px; font-weight: 600;
  box-shadow: 0 8px 30px rgba(126,224,255,.28);
  backdrop-filter: blur(8px);
  z-index: 100012;
  transition: transform .5s cubic-bezier(.2,.9,.3,1.3), opacity .4s;
  opacity: 0;
  pointer-events: none;
}
.rx-ticker.is-on { transform: translateX(-50%) translateY(0); opacity: 1; pointer-events: auto; }
.rx-ticker .tk-bolt { color: #7ee0ff; animation: rx-bolt-flicker .9s infinite; }
@keyframes rx-bolt-flicker { 0%,100% { opacity:1; } 45% { opacity:.35; } }
.rx-ticker .tk-link {
  color: #7ee0ff; text-decoration: underline; cursor: pointer;
  font-weight: 700;
}

/* ═══════════════════════════════════════════════════════════════════════════
   3. REWARD REVEAL (box opening / rarity)
   ═══════════════════════════════════════════════════════════════════════════ */

.rx-gift-stage {
  position: fixed; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  /* `safe` keeps the top of the card on screen when it is taller than the
     viewport; plain centring would push it off through the top, where it can
     never be scrolled back into view. */
  align-items: safe center;
  background: radial-gradient(circle at 50% 45%, rgba(20,12,45,.9), rgba(1,4,9,.96));
  backdrop-filter: blur(7px);
  z-index: 100020;   /* the plot image viewer is at 99999 — the stage sits above it too */
  opacity: 0;
  transition: opacity .4s ease;
  /* A legendary card with a claim box is ~470px tall: on a landscape phone (360px)
     or a small portrait screen it used to be cut off at BOTH ends, taking the
     "Awesome!" button with it and leaving no way to close the reveal. */
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 0;
  -webkit-overflow-scrolling: touch;
}
.rx-gift-stage.is-on { display: flex; opacity: 1; }

/* The stage content arrives with a slight zoom */
.rx-gift-inner {
  text-align: center;
  width: min(420px, calc(100vw - 40px));
  flex-shrink: 0;          /* it scrolls inside the stage rather than being squashed */
  margin: auto 0;          /* centred while it fits, flush to the top when it does not */
  transform: scale(.92) translateY(12px);
  opacity: 0;
  transition: transform .5s cubic-bezier(.2,1.1,.3,1), opacity .4s ease;
}
.rx-gift-stage.is-on .rx-gift-inner { transform: none; opacity: 1; }

/* The box: drops from above, bounces, then starts shaking */
.rx-gift-box {
  font-size: 92px; line-height: 1;
  display: inline-block;
  filter: drop-shadow(0 10px 26px rgba(0,0,0,.6));
  animation: rx-box-drop .6s cubic-bezier(.25,1.4,.4,1) both,
             rx-box-shake .55s ease-in-out .7s infinite;
  cursor: default;
  will-change: transform;
}
@keyframes rx-box-drop {
  0%   { transform: translateY(-80px) scale(.7); opacity: 0; }
  60%  { transform: translateY(8px)  scale(1.05); opacity: 1; }
  80%  { transform: translateY(-3px) scale(.99); }
  100% { transform: translateY(0)    scale(1); }
}
@keyframes rx-box-shake {
  0%,100% { transform: rotate(0deg) scale(1); }
  25%  { transform: rotate(-8deg) scale(1.04); }
  75%  { transform: rotate(8deg)  scale(1.04); }
}
/* The burst: it first contracts inwards (anticipation), then scatters in a flash */
.rx-gift-box.is-burst { animation: rx-box-burst .55s cubic-bezier(.45,1.3,.6,1) forwards; }
@keyframes rx-box-burst {
  0%   { transform: scale(1) rotate(0deg);      opacity: 1; filter: brightness(1); }
  25%  { transform: scale(.8) rotate(-6deg);    opacity: 1; filter: brightness(1.3); }
  100% { transform: scale(2.5) rotate(8deg);    opacity: 0; filter: brightness(2.6) blur(6px); }
}

.rx-gift-hint {
  margin-top: 16px; color: #8b949e; font-size: 13px; letter-spacing: .04em;
  animation: rx-hint-pulse 1.4s ease-in-out infinite;
}
@keyframes rx-hint-pulse { 0%,100% { opacity: .55; } 50% { opacity: 1; } }

/* Reward card */
.rx-gift-card {
  display: none;
  padding: 30px 26px 24px;
  border-radius: 20px;
  background: linear-gradient(160deg, rgba(22,27,34,.97), rgba(13,17,23,.99));
  border: 2px solid var(--rar-color, #58a6ff);
  box-shadow: 0 0 44px var(--rar-glow, rgba(88,166,255,.42)),
              0 26px 70px rgba(0,0,0,.7),
              inset 0 1px 0 rgba(255,255,255,.06);
  position: relative;
  overflow: hidden;
}
.rx-gift-card.is-on {
  display: block;
  animation: rx-card-in .7s cubic-bezier(.2,1.15,.3,1) both;
}
@keyframes rx-card-in {
  0%   { opacity: 0; transform: scale(.7) translateY(30px); filter: blur(6px); }
  60%  { opacity: 1; transform: scale(1.03) translateY(-4px); filter: blur(0); }
  100% { opacity: 1; transform: scale(1) translateY(0); filter: none; }
}

/* The light beam rotating inside the card */
.rx-gift-card::before {
  content: '';
  position: absolute; inset: -50%;
  background: conic-gradient(from 0deg, transparent 0deg, var(--rar-glow, rgba(88,166,255,.3)) 25deg, transparent 55deg,
                             transparent 180deg, var(--rar-glow, rgba(88,166,255,.3)) 205deg, transparent 235deg);
  animation: rx-card-rays 7s linear infinite;
  pointer-events: none;
}
@keyframes rx-card-rays { to { transform: rotate(360deg); } }
.rx-gift-card > * { position: relative; z-index: 1; }

.rx-gift-rarity {
  display: inline-block;
  padding: 4px 13px;
  border-radius: 999px;
  font-size: 10.5px; font-weight: 800;
  letter-spacing: .13em; text-transform: uppercase;
  background: var(--rar-color, #58a6ff);
  color: #06080c;
  margin-bottom: 14px;
  box-shadow: 0 0 18px var(--rar-glow, rgba(88,166,255,.5));
}

.rx-gift-icon {
  font-size: 68px; line-height: 1;
  margin-bottom: 12px;
  filter: drop-shadow(0 0 20px var(--rar-glow, rgba(88,166,255,.6)));
  animation: rx-icon-float 2.6s ease-in-out infinite;
}
@keyframes rx-icon-float { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-9px) } }

.rx-gift-label { font-size: 12px; color: #8b949e; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 4px; }
.rx-gift-name {
  font-size: 25px; font-weight: 800; color: #fff;
  margin-bottom: 6px; line-height: 1.25; word-break: break-word;
  text-shadow: 0 0 22px var(--rar-glow, rgba(88,166,255,.5));
}
.rx-gift-sub { font-size: 12.5px; color: #8b949e; margin-bottom: 20px; }
.rx-gift-sub b { color: var(--rar-color, #58a6ff); }

.rx-gift-btn {
  width: 100%;
  padding: 13px;
  border: none; border-radius: 12px;
  background: linear-gradient(135deg, var(--rar-color, #58a6ff), var(--rar-color-2, #a371f7));
  color: #06080c; font-weight: 800; font-size: 14.5px;
  cursor: pointer; font-family: inherit;
  transition: transform .14s, box-shadow .18s, filter .18s;
  box-shadow: 0 6px 22px var(--rar-glow, rgba(88,166,255,.4));
}
.rx-gift-btn:hover { transform: translateY(-2px); filter: brightness(1.1); box-shadow: 0 10px 30px var(--rar-glow, rgba(88,166,255,.55)); }
.rx-gift-btn:active { transform: translateY(0); }

/* Rarity colours */
.rar-common    { --rar-color: #8b949e; --rar-color-2: #b1bac4; --rar-glow: rgba(139,148,158,.42); }
.rar-uncommon  { --rar-color: #3fb950; --rar-color-2: #56d364; --rar-glow: rgba(63,185,80,.45); }
.rar-rare      { --rar-color: #58a6ff; --rar-color-2: #79c0ff; --rar-glow: rgba(88,166,255,.5); }
.rar-epic      { --rar-color: #a371f7; --rar-color-2: #d2a8ff; --rar-glow: rgba(163,113,247,.55); }
.rar-legendary { --rar-color: #f0a500; --rar-color-2: #ffd700; --rar-glow: rgba(240,165,0,.62); }

/* ═══════════════════════════════════════════════════════════════════════════
   4. PURCHASE MODAL
   ═══════════════════════════════════════════════════════════════════════════ */

.rx-buy-preview {
  display: flex; align-items: center; justify-content: center;
  gap: 14px;
  padding: 16px 0 6px;
}
.rx-buy-plot {
  width: 62px; height: 62px;
  border-radius: 10px;
  border: 2px dashed rgba(255,255,255,.42);
  background: rgba(255,255,255,.09);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800; color: #fff;
  letter-spacing: .04em;
  animation: rx-plot-pulse 2.1s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes rx-plot-pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(255,255,255,.28); }
  50%     { box-shadow: 0 0 0 12px rgba(255,255,255,0); }
}
.rx-buy-arrow { font-size: 20px; color: rgba(255,255,255,.55); animation: rx-arrow-slide 1.5s ease-in-out infinite; }
@keyframes rx-arrow-slide { 0%,100% { transform: translateX(0); opacity:.55 } 50% { transform: translateX(5px); opacity:1 } }
.rx-buy-you {
  width: 62px; height: 62px; border-radius: 10px;
  background: linear-gradient(135deg, #6200ea, #a371f7);
  display: flex; align-items: center; justify-content: center;
  font-size: 27px; flex-shrink: 0;
  box-shadow: 0 6px 22px rgba(98,0,234,.5);
}

.rx-buy-perks {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 8px; margin: 14px 0 4px;
  /* Keeps a closed card from stretching and looking "open" when its row neighbour expands */
  align-items: start;
}
/* The perk cards are clickable accordions: opening one reveals a short
   description. The open description areas are kept the same height (based on
   the longest text). */
.rx-buy-perk {
  display: flex; flex-direction: column; align-items: stretch;
  padding: 9px 10px;
  border-radius: 9px;
  background: var(--rx-surface-2);
  border: 1px solid var(--rx-border);
  font-size: 11.5px; color: var(--rx-text);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.rx-buy-perk:hover { border-color: var(--rx-border-2); }
.rx-buy-perk:focus-visible { outline: 2px solid var(--rx-accent); outline-offset: 2px; }
.rx-buy-perk .pk-head { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.rx-buy-perk .pk-head > i:first-child { color: var(--rx-purple); font-size: 13px; flex-shrink: 0; }
.rx-buy-perk .pk-caret {
  margin-left: auto;
  font-size: 9px; color: var(--rx-muted);
  transition: transform .25s ease;
}
.rx-buy-perk.is-open .pk-caret { transform: rotate(180deg); }
.rx-buy-perk .pk-desc {
  overflow: hidden;
  height: 0;
  opacity: 0;
  margin-top: 0;
  font-size: 10.5px; font-weight: 400;
  color: var(--rx-muted); line-height: 1.5;
  transition: height .28s ease, opacity .22s ease, margin-top .28s ease;
}
/* A fixed open height: regardless of its row, ALL FOUR cards open to the same
   size (based on the longest description). */
.rx-buy-perk.is-open .pk-desc {
  height: 66px;
  opacity: 1;
  margin-top: 6px;
}

.rx-price-tag {
  display: inline-flex; align-items: baseline; gap: 4px;
  font-weight: 800;
}
.rx-price-tag .pv { font-size: 22px; color: var(--rx-green); }
.rx-price-tag .pc { font-size: 13px; color: var(--rx-muted); }

.rx-stock-line {
  display: flex; align-items: center; gap: 8px;
  font-size: 11.5px; color: var(--rx-muted);
  margin: 12px 0 0;
  /* The bottom separator is no longer here: the social-proof line (#modalSold)
     was inserted below the occupancy line, and the separator (.rx-modal-sep) is
     drawn BELOW that. */
}

/* The line separating the occupancy + social-proof block from the email field */
.rx-modal-sep {
  border: none;
  border-top: 1px solid var(--rx-border);
  margin: 14px 0 18px;
}
.rx-stock-line > span:first-of-type { white-space: nowrap; }
.rx-stock-bar {
  flex: 1; height: 5px; border-radius: 3px;
  background: var(--rx-surface-2); overflow: hidden;
}
.rx-stock-fill {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, #3fb950, #f0a500, #f85149);
  /* Slower, and no longer front-loaded. At .7s with a cubic-bezier whose first
     control point is (.2,.8) the bar was ~80% full within the first fifth of the
     run, so the eye only ever caught the tail — it read as "already full" rather
     than as filling up. 1.8s with a gentler curve lets the growth be seen.
     The .18s delay lets the dialog finish opening first, so the fill is not
     competing with the modal's own fade-in. */
  transition: width 1.8s cubic-bezier(.32,.72,.35,1) .18s;
}

/* ═══════════════════════════════════════════════════════════════════════════
   5. TUTORIAL (spotlight)
   ═══════════════════════════════════════════════════════════════════════════ */

/* The dimming mask DOES NOT BLOCK CLICKS.
   It used to have pointer-events:auto in the .is-on state; because the SVG
   rectangle covered the whole screen, tasks such as "click an empty plot" could
   not be completed (the hole was only visual and did not let clicks through). */
.rx-tut-mask {
  position: fixed; inset: 0;
  z-index: 100030;
  pointer-events: none;
  opacity: 0;
  transition: opacity .4s;
}
.rx-tut-mask.is-on { opacity: 1; }
.rx-tut-mask svg { width: 100%; height: 100%; display: block; }
.rx-tut-hole { transition: all .55s cubic-bezier(.3,1,.35,1); }

.rx-tut-ring {
  position: fixed;
  border: 2px solid var(--rx-purple);
  border-radius: 5px;
  /* The glow points outwards; the ring sits on the element's edge */
  box-shadow: 0 0 0 2px rgba(163,113,247,.18), 0 0 22px rgba(163,113,247,.5);
  pointer-events: none;
  z-index: 100031;
  opacity: 0;
  transition: all .55s cubic-bezier(.3,1,.35,1);
}
.rx-tut-ring.is-on { opacity: 1; animation: rx-ring-pulse 1.7s ease-in-out infinite; }
@keyframes rx-ring-pulse {
  0%,100% { box-shadow: 0 0 0 3px rgba(163,113,247,.22), 0 0 26px rgba(163,113,247,.55); }
  50%     { box-shadow: 0 0 0 8px rgba(163,113,247,.08), 0 0 38px rgba(163,113,247,.75); }
}

.rx-tut-card {
  position: fixed;
  width: min(370px, calc(100vw - 24px));
  /* On a short screen (phone in landscape, small window) the card used to grow
     past the bottom edge with no way to reach the buttons; it scrolls now. */
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);   /* mobile: the bar that shows/hides is excluded */
  overflow-y: auto;
  overscroll-behavior: contain;
  background: linear-gradient(165deg, #1c2333, #12161f);
  border: 1px solid #30363d;
  border-radius: 16px;
  padding: 18px 20px 16px;
  color: #e6edf3;
  box-shadow: 0 24px 64px rgba(0,0,0,.66);
  z-index: 100032;
  opacity: 0; transform: translateY(14px) scale(.97);
  transition: opacity .35s, transform .35s cubic-bezier(.2,.9,.3,1.2), top .5s cubic-bezier(.3,1,.35,1), left .5s cubic-bezier(.3,1,.35,1);
  pointer-events: none;
  visibility: hidden;   /* while closed it cannot be focused / screen readers skip it */
}
.rx-tut-card.is-on { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; visibility: visible; }

.rx-tut-top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.rx-tut-mascot {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(135deg, #6200ea, #a371f7);
  display: flex; align-items: center; justify-content: center;
  font-size: 19px; flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(98,0,234,.45);
  animation: rx-mascot-bob 2.4s ease-in-out infinite;
}
@keyframes rx-mascot-bob { 0%,100% { transform: translateY(0) rotate(0) } 50% { transform: translateY(-4px) rotate(-6deg) } }
.rx-tut-title { font-size: 14.5px; font-weight: 700; flex: 1; }
.rx-tut-skip {
  border: none; background: transparent; color: #8b949e;
  font-size: 11.5px; cursor: pointer; padding: 3px 6px; border-radius: 6px;
  transition: color .15s, background .15s;
}
.rx-tut-skip:hover { color: #f85149; background: rgba(248,81,73,.1); }

.rx-tut-text {
  font-size: 13.5px; line-height: 1.62; color: #c9d1d9;
  min-height: 44px; margin-bottom: 14px;
}
.rx-tut-text .rx-caret {
  display: inline-block; width: 2px; height: 1em;
  background: var(--rx-purple); vertical-align: -2px;
  animation: rx-caret 1s steps(2) infinite;
}
@keyframes rx-caret { 50% { opacity: 0; } }

.rx-tut-foot { display: flex; align-items: center; gap: 10px; }
.rx-tut-dots { display: flex; gap: 5px; flex: 1; }
.rx-tut-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #30363d;
  transition: background .3s, width .3s, transform .3s;
  cursor: pointer;
}
.rx-tut-dot.is-done { background: #484f58; }
.rx-tut-dot.is-now  { background: var(--rx-purple); width: 20px; border-radius: 4px; }

.rx-tut-btn {
  padding: 8px 18px;
  border: none; border-radius: 9px;
  background: linear-gradient(135deg, #6200ea, #7c3aed);
  color: #fff; font-weight: 700; font-size: 13px;
  cursor: pointer; font-family: inherit;
  transition: transform .13s, box-shadow .18s, opacity .18s;
  box-shadow: 0 4px 14px rgba(98,0,234,.4);
  display: inline-flex; align-items: center; gap: 7px;
}
.rx-tut-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 7px 20px rgba(98,0,234,.55); }
.rx-tut-btn:disabled { opacity: .45; cursor: default; }
.rx-tut-btn--back {
  background: transparent; box-shadow: none;
  border: 1px solid #30363d; color: #8b949e; padding: 8px 12px;
}
.rx-tut-btn--back:hover:not(:disabled) { border-color: #484f58; color: #e6edf3; box-shadow: none; }

/* The "try it yourself" task */
.rx-tut-task {
  display: none;
  align-items: center; gap: 8px;
  padding: 8px 11px; margin-bottom: 12px;
  border-radius: 9px;
  background: rgba(240,165,0,.1);
  border: 1px solid rgba(240,165,0,.32);
  font-size: 12px; color: #f0a500; font-weight: 600;
}
.rx-tut-task.is-on { display: flex; }
.rx-tut-task.is-done { background: rgba(63,185,80,.1); border-color: rgba(63,185,80,.35); color: #3fb950; }

body.light-mode .rx-tut-card { background: linear-gradient(165deg,#fff,#f6f8fa); border-color: #d0d7de; color: #1f2328; }
body.light-mode .rx-tut-text { color: #424a53; }

/* Touch screens: every control becomes big enough for a finger. "Skip" and the
   arrows are ~21-31px tall, well under the ~44px a thumb needs. This is keyed
   off the INPUT, not the width: a tablet and a landscape phone are 740-768px
   wide, so the width breakpoint below never reached them even though they are
   driven entirely by touch. */
@media (hover: none) {
  .rx-tut-skip { padding: 11px 12px; margin: -11px -8px -11px 0; font-size: 12px; }
  .rx-tut-btn { min-height: 44px; }
  .rx-tut-btn--back { min-width: 44px; justify-content: center; }
  .rx-tut-dot { width: 9px; height: 9px; }
  .rx-tut-dot.is-now { width: 22px; }
}

/* Small screens: the card also takes up less room — it used to eat a third of a
   phone screen. */
@media (max-width: 600px) {
  .rx-tut-card { padding: 14px 15px 12px; border-radius: 14px; }
  .rx-tut-top { gap: 9px; margin-bottom: 8px; }
  .rx-tut-mascot { width: 34px; height: 34px; border-radius: 10px; font-size: 17px; }
  .rx-tut-title { font-size: 14px; }
  .rx-tut-text { font-size: 13px; line-height: 1.55; min-height: 40px; margin-bottom: 12px; }
  /* The hit area grows without the layout shifting: the padding is pulled back
     in with a negative margin. */
  .rx-tut-skip {
    padding: 11px 12px; margin: -11px -8px -11px 0;
    font-size: 12px;
  }
  .rx-tut-task { padding: 9px 11px; margin-bottom: 10px; }
  .rx-tut-foot { gap: 8px; }
  .rx-tut-btn { min-height: 42px; padding: 8px 16px; font-size: 13px; }
  .rx-tut-btn--back { min-width: 44px; padding: 8px 12px; justify-content: center; }
  /* The row of dots gives way to the buttons: it shrinks and wraps onto a
     second line rather than pushing "Next" past the edge of the card. On a
     320 px screen the ten dots of the dashboard tour used to do exactly that. */
  .rx-tut-dots {
    gap: 5px; flex-wrap: wrap; row-gap: 5px;
    min-width: 0; align-content: center;
  }
  .rx-tut-dot { width: 8px; height: 8px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   6. MISCELLANEOUS
   ═══════════════════════════════════════════════════════════════════════════ */

/* Plot audio indicator */
.rx-audio-chip {
  position: fixed; right: 16px; bottom: 16px;
  display: none; align-items: center; gap: 9px;
  padding: 9px 14px;
  background: rgba(22,27,34,.95);
  border: 1px solid var(--rx-border);
  border-radius: 999px;
  color: var(--rx-text); font-size: 12.5px;
  box-shadow: 0 8px 26px rgba(0,0,0,.45);
  backdrop-filter: blur(8px);
  z-index: 100005;
}
.rx-audio-chip.is-on { display: flex; animation: rx-msg-in .35s both; }
body.light-mode .rx-audio-chip {
  background: rgba(255,255,255,.97);
  box-shadow: 0 8px 26px rgba(0,0,0,.16);
}
.rx-audio-chip button {
  width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent; color: var(--rx-muted);
  cursor: pointer; font-size: 13px; padding: 0; border-radius: 5px;
  flex-shrink: 0;
  transition: color .15s;
}
.rx-audio-chip button:hover { color: var(--rx-accent); }

/* Paused: the equalizer bars freeze and fade */
.rx-audio-chip.is-paused .rx-eq i {
  animation-play-state: paused;
  opacity: .35;
}

/* Equalizer bar animation */
.rx-eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.rx-eq i {
  display: block; width: 3px; border-radius: 1px;
  background: var(--rx-green);
  animation: rx-eq 0.9s ease-in-out infinite;
}
.rx-eq i:nth-child(1) { height: 6px;  animation-delay: 0s; }
.rx-eq i:nth-child(2) { height: 12px; animation-delay: .18s; }
.rx-eq i:nth-child(3) { height: 8px;  animation-delay: .36s; }
.rx-eq i:nth-child(4) { height: 13px; animation-delay: .12s; }
@keyframes rx-eq { 0%,100% { transform: scaleY(.35) } 50% { transform: scaleY(1) } }

/* Hidden YouTube player: audio only, the video is never shown */
#rxYtHost {
  position: fixed;
  width: 1px; height: 1px;
  left: -9999px; top: -9999px;
  opacity: 0; pointer-events: none;
}

/* Focus visibility (accessibility) */
button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--rx-accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  /* The occupancy bar and the live counter jump straight to their value */
  .rx-stock-fill { transition: none !important; }
  .rectangle.rx-striking, .rectangle.rx-striking::before,
  .rx-gift-box, .rx-gift-icon, .rx-gift-hint, .rx-tut-mascot, .rx-eq i,
  .rx-buy-plot, .rx-buy-arrow, .rx-gift-card::before {
    animation: none !important;
  }
  .rx-gift-inner { transition: none !important; }
  .chat-message { animation: none !important; }
}

/* Small screens */
@media (max-width: 640px) {
  .rx-buy-perks { grid-template-columns: 1fr; }
  .rx-gift-box { font-size: 68px; }
  .rx-gift-name { font-size: 21px; }
  /* The music chip becomes a mini player bar centred at the bottom instead of a
     corner badge, so it does not overlap the plot card's content. */
  .rx-audio-chip {
    left: 12px; right: 12px; bottom: 10px;
    justify-content: center;
  }
  .rx-audio-chip #audioChipText,
  .rx-audio-chip span:nth-child(2) {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    min-width: 0;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   SHORT VIEWPORTS (a phone held sideways, a small browser window)
   Height — not width — is the scarce resource here, so these rules key off it.
   Everything that is sized for a tall screen (the reveal box, the decorative
   modal headers, the fixed corner badges) is pulled in so the primary controls
   stay on screen.
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-height: 560px) {
  .rx-gift-stage { padding: 12px 0; }
  .rx-gift-box  { font-size: 56px; }
  .rx-gift-hint { margin-top: 10px; font-size: 12px; }
  .rx-gift-card { padding: 18px 20px 16px; border-radius: 16px; }
  .rx-gift-icon { font-size: 42px; margin-bottom: 8px; }
  .rx-gift-rarity { margin-bottom: 9px; }
  .rx-gift-name { font-size: 20px; }
  .rx-gift-sub  { margin-bottom: 12px; }
  .rx-gift-claim { padding: 11px; margin-bottom: 14px; }
  .rx-gift-btn  { padding: 11px; font-size: 13.5px; }

  /* The music player bar and the chat tab share the bottom edge; on a short
     screen they are both pulled tight against it. */
  .rx-audio-chip { bottom: 8px; padding: 7px 12px; }
}
