/* Site-wide rank mascot — bottom-right floating companion, see js/mascot.js.
   The viewer's own pet (js/pets.js, rank-coloured, pet art styles at the end
   of this file) hopping about the corner; tap it for the pet picker. Only
   ever shows your own, never anyone else's, so it can't clutter no matter
   how many guildmates use it. */
.rank-mascot {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

.rank-mascot.ready {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* The editor/counter-editor's #paletteDock (css/style.css's .palette-dock,
   toggled open via js/editor.js + js/counter.js) is also fixed to the
   bottom-right area of the viewport, and on short screens its own last row
   (ตัวละคร/สัตว์เลี้ยง/แหวน/เซ็ตไอเกม items) lands right under this widget's
   100–150px corner footprint (z-index 500 > the dock's 200, so it's the
   dock's content that gets hidden). Simplest fix: get out of the way
   entirely while the dock is actually open — the dock already occupies
   that whole strip, and nobody needs the mascot mid-edit. Scoped to
   ".palette-dock" existing AND not collapsed, rather than always hiding
   near an editor page, so it still shows once the dock is tucked away.
   (js/mascot.js appends .rank-mascot as the last child of body, after the
   dock — so this has to be a body-level :has(), not a ~ sibling selector,
   to match regardless of DOM order.) */
body:has(.palette-dock:not(.collapsed)) .rank-mascot {
  display: none;
}

/* Pet picker (js/mascot.js renderPetPopover) — opens straight from a tap
   on the mascot. 5 grades + 9 rank colours, each unlocked by rank. Drawn
   in the black theme (home.css's --h-* tokens, with literal fallbacks for
   the old-theme pages that don't define them). */
.rank-mascot-pet-popover {
  display: none;
  flex-direction: column;
  gap: 12px;
  width: 300px;
  padding: 16px;
  border-radius: 22px;
  background: rgba(12, 12, 12, .92);
  border: 1px solid var(--h-line, rgba(250, 250, 250, .1));
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .05);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--h-fg, #fafafa);
  font-family: 'Anuphan', 'Inter', sans-serif;
  transform-origin: 85% 100%;
  transition: opacity .22s ease, translate .32s cubic-bezier(.23, 1, .32, 1), scale .32s cubic-bezier(.23, 1, .32, 1), display .32s allow-discrete;
}
.rank-mascot.pet-open .rank-mascot-pet-popover { display: flex; }
@starting-style {
  .rank-mascot.pet-open .rank-mascot-pet-popover { opacity: 0; translate: 0 10px; scale: .96; }
}
.rank-mascot.pet-left .rank-mascot-pet-popover { transform-origin: 15% 100%; }

.mascot-pop-head { display: flex; flex-direction: column; gap: 2px; }
.mascot-pop-kicker {
  font: 500 10px 'JetBrains Mono', monospace; letter-spacing: .22em; text-transform: uppercase;
  color: var(--h-muted, #a3a3a3);
}
.mascot-pop-title { font-size: 20px; font-weight: 800; line-height: 1.2; letter-spacing: -.01em; }
.mascot-pop-hint { margin: 2px 0 0; font-size: 12px; line-height: 1.5; color: var(--h-muted, #a3a3a3); }

.mascot-pet-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.mascot-pet-card {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px; border-radius: 14px; cursor: pointer;
  background: var(--h-mcard-bg, #141414); border: 1px solid var(--h-line, rgba(250, 250, 250, .1));
  color: inherit; font: inherit;
  transition: border-color .2s, translate .25s cubic-bezier(.23, 1, .32, 1), background .2s;
}
.mascot-pet-card:hover:not(:disabled) { translate: 0 -2px; border-color: var(--frame-color, #fafafa); background: #1a1a1a; }
.mascot-pet-card:focus-visible { outline: 1px solid var(--h-fg, #fafafa); outline-offset: 2px; }
.mascot-pet-card.is-on { border-color: var(--frame-color, #fafafa); box-shadow: 0 0 0 1px var(--frame-color, #fafafa), 0 0 16px var(--frame-glow, transparent); }
.mascot-pet-card.is-locked { cursor: not-allowed; }
.mascot-pet-card.is-locked .mascot-pet-art { filter: grayscale(1) brightness(.35); }
.mascot-pet-art { display: block; width: 54px; height: 54px; pointer-events: none; }
/* Previews stand still: no flip, no pet-state motion from the wrap. */
.mascot-pet-art .rank-mascot-char { transform: none; filter: none; }
.mascot-pet-art .pet-core, .mascot-pet-art .pet-jelly, .mascot-pet-art .pet-hover { animation: none !important; translate: none !important; scale: none !important; rotate: none !important; }
.mascot-pet-name { font-size: 11px; font-weight: 700; line-height: 1.25; text-align: center; }
.mascot-pet-req { font: 500 10px 'Inter', 'Anuphan', sans-serif; color: var(--h-muted, #a3a3a3); }

.mascot-pet-sub { font-size: 12px; font-weight: 700; color: var(--h-muted, #a3a3a3); }
.mascot-pet-colors { display: grid; grid-template-columns: repeat(9, 1fr); gap: 6px; }
.mascot-pet-swatch {
  aspect-ratio: 1; width: 100%; padding: 0; border-radius: 50%; cursor: pointer;
  background: var(--sw); border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .35);
  transition: scale .15s;
}
.mascot-pet-swatch:hover:not(:disabled) { scale: 1.15; }
.mascot-pet-swatch.is-on { border-color: var(--h-fg, #fff); box-shadow: 0 0 10px var(--sw); }
.mascot-pet-swatch:disabled { cursor: not-allowed; opacity: .22; }
/* Star Cat: every swatch is locked, but its rank colour still shows as the one in use. */
.mascot-pet-swatch.is-on:disabled { opacity: 1; }

/* ---- Pop-out cards (js/mascot.js showDrop) ------------------------------
   Point gains fan out of the mascot's head as cards, like the Gallery cards
   on syahrilarfianalmazril.my.id/blog. .is-in shows the layer, .is-open
   pops the cards up and out (each card's --x/--y/--r come from FAN in the
   JS), .is-out tucks them back in before it fades. */
.mascot-drop {
  position: absolute;
  right: 8px; /* keeps the right card clear of the screen edge */
  bottom: calc(100% - 12px);
  width: 250px;
  height: 180px;
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
  transition: opacity .3s ease, visibility 0s linear .45s;
  font-family: 'Anuphan', 'Inter', sans-serif;
  z-index: 2;
}
.mascot-drop.is-in { visibility: visible; opacity: 1; cursor: pointer; transition-delay: 0s; }
.mascot-drop.is-out { opacity: 0; transition-delay: .3s, .3s; }
/* The picker already fills the space above the head. */
.rank-mascot.pet-open .mascot-drop { opacity: 0; }
.rank-mascot.pet-open .mascot-drop .md-card { pointer-events: none; }

.md-cards { position: absolute; inset: 0; }
.md-card {
  --rim: rgba(255, 255, 255, .16);
  --rim-w: 1px;
  --lift: 1;
  position: absolute;
  left: 50%; bottom: 0;
  width: 98px; height: 146px;
  margin-left: -49px;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  gap: 1px;
  padding: 0 8px 10px;
  border-radius: 14px;
  isolation: isolate;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% 26%, color-mix(in srgb, var(--frame-color, #a3a3a3) 34%, transparent), transparent 70%),
    linear-gradient(180deg, #262626, #0f0f0f);
  box-shadow: 0 12px 26px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .08);
  transform-origin: 50% 100%;
  translate: 0 60px;
  rotate: 0deg;
  scale: .4;
  opacity: 0;
  pointer-events: none;
  transition: translate .6s cubic-bezier(.34, 1.4, .64, 1), rotate .6s cubic-bezier(.34, 1.4, .64, 1), scale .5s cubic-bezier(.34, 1.4, .64, 1), opacity .25s ease;
  transition-delay: calc(var(--i, 0) * 70ms + 60ms);
}
/* The rim: a masked layer so it can be a gradient (and spin, below). */
.md-card::before {
  content: ""; position: absolute; inset: 0; z-index: 2; border-radius: inherit; pointer-events: none;
  padding: var(--rim-w);
  background: var(--rim);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}
.md-card > * { position: relative; z-index: 1; }
.mascot-drop.is-open .md-card { translate: var(--x) var(--y); rotate: var(--r); scale: var(--lift); opacity: 1; pointer-events: auto; }
.mascot-drop.is-out .md-card { transition-delay: calc(var(--i, 0) * 40ms); }
/* Hovering the fan spreads the cards a touch more, like the reference. */
.mascot-drop.is-open:hover .md-card { translate: calc(var(--x) * 1.12) calc(var(--y) - 8px); }
.md-card-art { position: absolute !important; top: 16px; left: 50%; width: 66px; height: 66px; margin-left: -33px; pointer-events: none; }
.md-card-art .rank-mascot-char { transform: none; }
.md-card-tier {
  position: absolute !important; top: 7px; left: 8px;
  font: 800 8px/1 'JetBrains Mono', monospace; letter-spacing: .12em; text-transform: uppercase;
  color: rgba(250, 250, 250, .55);
}
.md-card-name {
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 12px; font-weight: 700; color: #fafafa; line-height: 1.3;
}
.md-card-delta { font: 900 17px/1.1 'Inter', sans-serif; letter-spacing: -.01em; color: var(--h-lime, #bef264); }
.md-card-meta { font-size: 10px; line-height: 1.3; color: #a3a3a3; text-align: center; }

/* ---- Card grades, plain → holographic (data-rarity from showDrop) ------
   normal: matte, thin grey rim. rare: the rank colour glows along the rim.
   legend: gold foil rim + one light sweep. legend+: a spinning ember rim
   and a sweep that keeps coming back. legend++ (Star Cat): a slightly
   bigger holographic card — spinning rainbow rim, starfield, a rainbow
   sheen drifting across it and twinkling sparkles. */
@property --md-ang { syntax: '<angle>'; initial-value: 0deg; inherits: false; }
@keyframes md-spin { to { --md-ang: 360deg; } }
@keyframes md-sweep { 0% { translate: -130% 0; } 60%, 100% { translate: 130% 0; } }

/* Light sweep (legend and up) */
.md-card:is([data-rarity="legend"], [data-rarity="legendPlus"], [data-rarity="legendPlusPlus"])::after {
  content: ""; position: absolute; inset: 0; z-index: 3; pointer-events: none;
  background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, .34) 48%, transparent 64%);
  translate: -130% 0;
}
.mascot-drop.is-open .md-card[data-rarity="legend"]::after { animation: md-sweep 1.4s ease-out .7s 1; }
.mascot-drop.is-open .md-card[data-rarity="legendPlus"]::after { animation: md-sweep 2.4s ease-in-out .6s infinite; }

.md-card[data-rarity="rare"] {
  --rim: linear-gradient(160deg, var(--frame-color, #a3a3a3), rgba(255, 255, 255, .08) 55%, var(--frame-color, #a3a3a3));
  --rim-w: 1.5px;
  box-shadow: 0 12px 26px rgba(0, 0, 0, .5), 0 0 16px var(--frame-glow, transparent);
}

.md-card[data-rarity="legend"] {
  --rim: linear-gradient(150deg, #fef3c7, #d97706 30%, #fde68a 55%, #92400e 80%, #fef3c7);
  --rim-w: 2px;
  background:
    radial-gradient(120% 80% at 50% 26%, rgba(253, 230, 138, .28), transparent 70%),
    linear-gradient(180deg, #2a2114, #0f0c07);
  box-shadow: 0 12px 26px rgba(0, 0, 0, .5), 0 0 18px rgba(251, 191, 36, .28);
}
.md-card[data-rarity="legend"] .md-card-tier { color: #fcd34d; }

.md-card[data-rarity="legendPlus"] {
  --rim: conic-gradient(from var(--md-ang), #fb923c, #f43f5e, #fde047, #f97316, #fb923c);
  --rim-w: 2px;
  --lift: 1.03;
  background:
    radial-gradient(120% 80% at 50% 26%, rgba(249, 115, 22, .32), transparent 70%),
    radial-gradient(90% 50% at 50% 110%, rgba(244, 63, 94, .3), transparent 70%),
    linear-gradient(180deg, #2a1410, #0f0707);
  box-shadow: 0 12px 26px rgba(0, 0, 0, .5), 0 0 22px rgba(249, 115, 22, .38);
}
.md-card[data-rarity="legendPlus"]::before { animation: md-spin 3s linear infinite; }
.md-card[data-rarity="legendPlus"] .md-card-tier { color: #fdba74; }

.md-card[data-rarity="legendPlusPlus"] {
  --rim: conic-gradient(from var(--md-ang), #f472b6, #a78bfa, #38bdf8, #34d399, #fde047, #fb923c, #f472b6);
  --rim-w: 2.5px;
  --lift: 1.08;
  background:
    radial-gradient(1px 1px at 18% 22%, #fff, transparent),
    radial-gradient(1px 1px at 78% 16%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 66% 44%, #e0e7ff, transparent),
    radial-gradient(1px 1px at 30% 58%, #fff, transparent),
    radial-gradient(1px 1px at 86% 70%, #c7d2fe, transparent),
    radial-gradient(1.5px 1.5px at 12% 80%, #fff, transparent),
    radial-gradient(120% 70% at 50% 28%, rgba(139, 92, 246, .55), transparent 72%),
    radial-gradient(80% 60% at 90% 100%, rgba(56, 189, 248, .3), transparent 70%),
    linear-gradient(180deg, #1e1446, #090616);
  box-shadow: 0 14px 30px rgba(0, 0, 0, .55), 0 0 26px rgba(167, 139, 250, .55), 0 0 44px rgba(56, 189, 248, .22);
}
.md-card[data-rarity="legendPlusPlus"]::before { animation: md-spin 2.4s linear infinite; }
/* Holographic sheen instead of the plain sweep. */
.md-card[data-rarity="legendPlusPlus"]::after {
  inset: -40%;
  translate: none;
  background: linear-gradient(115deg, transparent 25%, rgba(244, 114, 182, .28) 38%, rgba(56, 189, 248, .28) 46%, rgba(253, 224, 71, .26) 54%, transparent 66%);
  background-size: 220% 220%;
  mix-blend-mode: color-dodge;
  animation: md-holo 3.2s ease-in-out infinite;
}
@keyframes md-holo { 0%, 100% { background-position: 0% 0%; } 50% { background-position: 100% 100%; } }
.md-card[data-rarity="legendPlusPlus"] .md-card-tier {
  background: linear-gradient(90deg, #f472b6, #a78bfa, #38bdf8, #fde047);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.md-card[data-rarity="legendPlusPlus"] .md-card-name {
  background: linear-gradient(90deg, #fbcfe8, #e0e7ff, #bae6fd);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.md-card[data-rarity="legendPlusPlus"] .md-card-meta { color: #c4b5fd; }
.md-spark {
  position: absolute !important; z-index: 4 !important; width: 9px; height: 9px; pointer-events: none;
  background: #fff;
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  filter: drop-shadow(0 0 3px #c4b5fd);
  opacity: 0;
  animation: md-twinkle 1.8s ease-in-out infinite;
}
.md-spark:nth-child(1) { top: 10px; right: 10px; }
.md-spark:nth-child(2) { top: 48px; left: 9px; width: 6px; height: 6px; animation-delay: .6s; }
.md-spark:nth-child(3) { top: 76px; right: 14px; width: 7px; height: 7px; animation-delay: 1.2s; }
@keyframes md-twinkle { 0%, 100% { opacity: 0; scale: .3; rotate: 0deg; } 50% { opacity: 1; scale: 1; rotate: 45deg; } }

@media (prefers-reduced-motion: reduce) {
  .rank-mascot-pet-popover { transition: opacity .2s ease, display .2s allow-discrete; translate: none; scale: 1; }
  .mascot-drop, .mascot-drop.is-in { transition: opacity .2s ease, visibility 0s linear .2s; }
  .md-card { transition: opacity .2s ease; transition-delay: 0s; translate: var(--x) var(--y); rotate: var(--r); scale: var(--lift); }
  .md-card::before, .md-card::after, .md-spark { animation: none !important; }
  .md-spark { opacity: .8; }
  .mascot-drop.is-open:hover .md-card { translate: var(--x) var(--y); }
}

/* No circle/card chrome here on purpose — just the art floating free, so it
   reads as a character standing in the corner rather than a UI button. */
.rank-mascot-btn {
  position: relative;
  width: 150px;
  height: 150px;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.rank-mascot-btn:hover {
  transform: scale(1.05);
}

/* Rank aura — glow behind the mascot, strength/size set per-tier by
   js/mascot.js's render() (--aura-opacity/--aura-scale). Painted first
   (::before, no z-index needed) so it sits behind the badge/character
   images that follow it in the DOM. */
.rank-mascot-btn::before {
  content: "";
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  /* Soft edge from the gradient itself — a blur(12px) here was re-rendered
     every frame the pet animates, for a glow that already fades out. */
  background: radial-gradient(circle closest-side, var(--frame-color, var(--accent)) 0%, transparent 100%);
  opacity: var(--aura-opacity, 0.25);
  transform: scale(var(--aura-scale, 1));
  pointer-events: none;
  animation: rank-mascot-aura-pulse 2.6s ease-in-out infinite;
}

@keyframes rank-mascot-aura-pulse {
  0%, 100% { opacity: var(--aura-opacity, 0.25); }
  50% { opacity: calc(var(--aura-opacity, 0.25) * 0.55); }
}

@media (prefers-reduced-motion: reduce) {
  .rank-mascot-btn::before { animation: none; }
}

/* The pet's <svg> (js/pets.js) */
.rank-mascot-char {
  position: relative;
  width: 100%;
  height: 100%;
  /* No drop-shadow: the svg's own .pet-shadow ellipse grounds the pet, and a
     filter over an svg that animates inside is redrawn every frame. */
  transform: scaleX(var(--pet-face, 1));
  transition: transform 0.2s ease, filter 0.6s ease;
}

/* ---- Desktop pet (js/mascot.js initPet) --------------------------------
   The wrap carries data-pet = idle | walk (hopping) | sleep | drag | fall, plus the
   short-lived pet-waking / pet-landing classes. Motion uses the individual
   translate/rotate/scale properties so it stacks with the button's own
   hover transform and the character's left/right flip above.
   In the left half of the screen the wrap is anchored by `left` instead
   (.pet-left): the picker and the pop-out cards mirror
   so they open toward the middle of the screen. */
.rank-mascot.pet-left { align-items: flex-start; --flip: -1; }
.rank-mascot.pet-left .rank-mascot-zzz { right: auto; left: 0; }
.rank-mascot.pet-left .mascot-drop { right: auto; left: 8px; transform-origin: 30% 100%; }

.rank-mascot-btn {
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  transform-origin: 50% 100%;
}
.rank-mascot-btn img { -webkit-user-drag: none; pointer-events: none; }

/* Hopping: js/mascot.js walk() drives the arc through the wrap's bottom
   offset and the jelly squash/stretch through --sq, frame by frame. */
.rank-mascot[data-pet="walk"] .rank-mascot-btn { scale: calc(1 + var(--sq, 0)) calc(1 - var(--sq, 0)); }

.rank-mascot[data-pet="drag"] .rank-mascot-btn {
  cursor: grabbing;
  transform-origin: 50% 12%;
  scale: 1.06;
  animation: pet-dangle 0.9s ease-in-out infinite;
}
@keyframes pet-dangle {
  0%, 100% { rotate: -9deg; }
  50% { rotate: 9deg; }
}

.rank-mascot[data-pet="fall"] .rank-mascot-btn { scale: 0.94 1.08; }

.rank-mascot.pet-landing .rank-mascot-btn { animation: pet-land 0.36s ease-out; }
@keyframes pet-land {
  0% { scale: 1.16 0.82; }
  55% { scale: 0.95 1.06; }
  100% { scale: 1 1; }
}

/* Floaty pets dropped from high up warp to the floor (js/mascot.js warp()):
   stretch into a streak of light, then pop back out of it on the ground. */
.rank-mascot.pet-warp-out .rank-mascot-btn { transform-origin: 50% 60%; animation: pet-warp-out .3s ease-in forwards; }
.rank-mascot.pet-warp-in .rank-mascot-btn { transform-origin: 50% 60%; animation: pet-warp-in .45s cubic-bezier(.3, 1.5, .5, 1); }
.rank-mascot.pet-warp-out .mascot-lv { opacity: 0; }
@keyframes pet-warp-out {
  0% { scale: .94 1.08; opacity: 1; filter: none; }
  45% { scale: .6 1.35; opacity: 1; filter: brightness(1.8); }
  100% { scale: .04 1.7; opacity: 0; filter: brightness(3); }
}
@keyframes pet-warp-in {
  0% { scale: .04 1.7; opacity: 0; filter: brightness(3); }
  45% { scale: 1.18 .84; opacity: 1; filter: brightness(1.6); }
  100% { scale: 1 1; opacity: 1; filter: none; }
}
.pet-warp-ring {
  position: fixed;
  z-index: 501;
  aspect-ratio: 3 / 1;
  translate: -50% -50%;
  border-radius: 50%;
  border: 2px solid #ddd6fe;
  box-shadow: 0 0 14px #a78bfa, inset 0 0 10px #a78bfa;
  pointer-events: none;
  animation: pet-warp-ring .55s ease-out forwards;
}
@keyframes pet-warp-ring {
  0% { scale: .15; opacity: 1; }
  100% { scale: 1.35; opacity: 0; }
}

.rank-mascot.pet-waking .rank-mascot-btn { animation: pet-wake 0.6s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes pet-wake {
  0% { translate: 0 0; scale: 1.08 0.9; }
  40% { translate: 0 -22px; scale: 0.95 1.05; }
  100% { translate: 0 0; scale: 1 1; }
}

.rank-mascot[data-pet="sleep"] .rank-mascot-btn { animation: pet-breathe 3.2s ease-in-out infinite; }
.rank-mascot[data-pet="sleep"] .rank-mascot-btn::before { opacity: calc(var(--aura-opacity, 0.25) * 0.35); animation: none; }
@keyframes pet-breathe {
  0%, 100% { scale: 1 1; rotate: 0deg; }
  50% { scale: 1.02 0.965; rotate: 1.5deg; }
}

/* Floating "z z Z" over the head while asleep. */
.rank-mascot-zzz {
  position: absolute;
  right: 0;
  bottom: 94px;
  width: 150px;
  height: 60px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
  font: 900 18px 'Inter', 'Anuphan', sans-serif;
  color: #fff; /* literal: readable over both themes thanks to the shadow */
  text-shadow: 0 0 2px rgba(0, 0, 0, 0.9), 0 2px 8px rgba(0, 0, 0, 0.6);
}
.rank-mascot[data-pet="sleep"] .rank-mascot-zzz { opacity: 1; }
.rank-mascot-zzz span {
  position: absolute;
  left: 58%;
  bottom: 0;
  opacity: 0;
}
.rank-mascot[data-pet="sleep"] .rank-mascot-zzz span { animation: pet-z 2.7s ease-out infinite; }
.rank-mascot-zzz span:nth-child(2) { font-size: 22px; animation-delay: 0.9s !important; }
.rank-mascot-zzz span:nth-child(3) { font-size: 27px; animation-delay: 1.8s !important; }
@keyframes pet-z {
  0% { opacity: 0; translate: 0 0; scale: 0.6; }
  20% { opacity: 1; }
  100% { opacity: 0; translate: 26px -52px; scale: 1.1; }
}

@media (prefers-reduced-motion: reduce) {
  .rank-mascot .rank-mascot-btn { animation: none !important; }
  .rank-mascot[data-pet="sleep"] .rank-mascot-zzz span { animation: none; opacity: 1; }
  .rank-mascot-zzz span:nth-child(2) { translate: 12px -18px; }
  .rank-mascot-zzz span:nth-child(3) { translate: 26px -40px; }
}

/* Hide and peek (js/mascot.js peekIn): off the screen, then poking in
   from an edge, turned so its head points into the screen — the rotate and
   slide come from a Web Animation on the button, pivoting on its middle. */
.rank-mascot.pet-peeking .rank-mascot-btn { transform-origin: 50% 50%; }
/* Off the screen: its aura reaches back in past the edge, so it goes too. */
.rank-mascot[data-pet="hidden"] .rank-mascot-btn { visibility: hidden; }
.rank-mascot.pet-peeking .pet-shadow { display: none; }
.rank-mascot .mascot-lv { transition: opacity .25s ease; }
.rank-mascot.pet-peeking .mascot-lv, .rank-mascot[data-pet="hidden"] .mascot-lv,
.rank-mascot.pet-act-cheer .mascot-lv { opacity: 0; }

/* Work pages (castle / counter / teams, js/mascot.js PET_WORK_PAGE): the pet
   hides off the screen and a small copy of it peeking up from the bottom
   edge calls it back. A "!" means something came in while it was away. Point-gain cards stay quiet
   while it's hidden, since they'd pop out at the screen edge. */
.rank-mascot.pet-work[data-pet="hidden"] .mascot-drop { display: none; }
.pet-work-call {
  position: fixed; z-index: 499; right: 22px; bottom: 0;
  width: 58px; height: 40px; padding: 0; border: 0; background: none;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  animation: pet-call-in .5s cubic-bezier(.3, 1.4, .5, 1) both;
}
.pet-work-call[hidden] { display: none; }
/* Head and eyes show; the rest is cut off at the screen edge (clip only at the bottom, so the glow and gear above stay soft). */
.pet-work-call .pwc-art {
  position: absolute; inset: 0; display: block; clip-path: inset(-40px -30px 0 -30px);
}
.pet-work-call .rank-mascot-char {
  position: absolute; left: -3px; bottom: -13px; width: 64px; height: 64px;
  transform-origin: 50% 100%;
  animation: pet-call-bob 3.2s ease-in-out infinite;
  transition: bottom .2s ease;
  filter: drop-shadow(0 -1px 6px var(--frame-glow, rgba(255, 255, 255, .15)));
}
.pet-work-call:hover .rank-mascot-char, .pet-work-call:focus-visible .rank-mascot-char { bottom: -8px; }
.pet-work-call:focus-visible { outline: 1px solid rgba(255, 255, 255, .4); outline-offset: 2px; border-radius: 8px; }
/* Something came in while it hid: a little "!" over its head. */
.pet-work-call.has-news::after {
  content: "!"; position: absolute; left: 50%; top: -20px; translate: -50% 0;
  width: 16px; height: 16px; border-radius: 50%;
  display: grid; place-items: center;
  font: 800 11px/1 'Anuphan', sans-serif; color: #0a0a0a; background: #fafafa;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .45);
  animation: pet-call-news 1.6s ease-in-out infinite;
}
@keyframes pet-call-in { from { translate: 0 100%; } to { translate: 0 0; } }
@keyframes pet-call-bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 2px; } }
@keyframes pet-call-news { 0%, 100% { translate: -50% 0; } 50% { translate: -50% -3px; } }
@media (prefers-reduced-motion: reduce) {
  .pet-work-call, .pet-work-call .rank-mascot-char, .pet-work-call.has-news::after { animation: none !important; }
}

/* Dragging the pet on a work page: the strip at the right edge where
   letting go sends it into hiding (js/mascot.js nearEdge). Faint while
   dragging, bright once it's close enough. */
.pet-edge-hint {
  position: fixed; z-index: 498; top: 0; right: 0; bottom: 0; width: 72px;
  display: block;
  background: linear-gradient(to left, rgba(250, 250, 250, .08), transparent);
  border-right: 2px solid rgba(250, 250, 250, .2);
  opacity: 0; pointer-events: none; transition: opacity .2s ease, background .2s ease, border-color .2s ease;
}
.pet-edge-hint span {
  /* Follows the drag, just above the pet (js/mascot.js --hint-y). */
  position: absolute; left: 50%; top: var(--hint-y, 16vh); translate: -50% 0;
  writing-mode: vertical-rl; font: 700 12px/1 'Anuphan', sans-serif; letter-spacing: .04em;
  color: rgba(250, 250, 250, .7);
}
.pet-edge-hint.is-drag { opacity: .55; }
.pet-edge-hint.is-near { opacity: 1; background: linear-gradient(to left, rgba(250, 250, 250, .16), transparent); border-color: rgba(250, 250, 250, .6); }
@media (max-width: 640px) { .pet-edge-hint { width: 48px; } }

/* What it says — while peeking, when caught, or reacting. Fixed to the
   page (js/mascot.js say()); the tail points back at the pet. */
.pet-say {
  position: fixed; z-index: 501; left: 0; top: 0;
  max-width: min(15rem, calc(100vw - 16px)); padding: 8px 13px;
  border-radius: 16px; background: #fafafa; color: #0a0a0a;
  font: 700 13px/1.45 'Anuphan', sans-serif;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
  pointer-events: none;
  opacity: 0; scale: .6;
  transition: opacity .2s ease, scale .25s cubic-bezier(.3, 1.6, .5, 1);
}
.pet-say[hidden] { display: none; }
/* A bubble that goes somewhere (js/mascot.js react's detail.href): clickable, with an arrow. */
.pet-say.is-link { pointer-events: auto; cursor: pointer; }
.pet-say.is-link::after { content: " →"; font-weight: 800; }
.pet-say.is-link:hover { background: #fff7e6; }
.pet-say.is-on { opacity: 1; scale: 1; }
.pet-say::before {
  content: ""; position: absolute; width: 10px; height: 10px; background: inherit;
  rotate: 45deg; border-radius: 2px;
}
.pet-say[data-side="top"] { transform-origin: 50% 100%; }
.pet-say[data-side="top"]::before { bottom: -4px; left: calc(50% - 5px); }
.pet-say[data-side="left"] { transform-origin: 100% 50%; }
.pet-say[data-side="left"]::before { right: -4px; top: calc(50% - 5px); }
.pet-say[data-side="right"] { transform-origin: 0 50%; }
.pet-say[data-side="right"]::before { left: -4px; top: calc(50% - 5px); }

/* Idle acts (js/mascot.js idleAct) — the body moves via .pet-core, so the
   jelly wobble and the hop squash underneath keep going. */
.pet-act-yawn .pet-core { transform-origin: 50% 100%; animation: pet-yawn 1.7s ease-in-out; }
@keyframes pet-yawn {
  0%, 100% { scale: 1 1; rotate: 0deg; }
  30%, 70% { scale: .96 1.07; rotate: -4deg; }
}
.pet-act-stretch .pet-core { transform-origin: 50% 100%; animation: pet-stretch 1.5s ease-in-out; }
@keyframes pet-stretch {
  0%, 100% { scale: 1 1; }
  25% { scale: 1.13 .85; }
  55% { scale: .9 1.14; }
  78% { scale: 1.04 .97; }
}
.pet-act-look .pet-core { transform-origin: 50% 100%; animation: pet-look 2.2s ease-in-out; }
@keyframes pet-look { 0%, 100% { rotate: 0deg; } 20%, 45% { rotate: 4deg; } 65%, 85% { rotate: -3deg; } }
.pet-act-shake .pet-core { transform-origin: 50% 90%; animation: pet-shake .9s ease-in-out; }
@keyframes pet-shake {
  0%, 100% { rotate: 0deg; scale: 1 1; }
  10% { rotate: -9deg; scale: 1.04 .97; }
  25% { rotate: 9deg; }
  40% { rotate: -8deg; }
  55% { rotate: 7deg; }
  70% { rotate: -4deg; }
  85% { rotate: 2deg; }
}
/* holding gear: raises it and waves it about (small turns — a pair like
   sword + shield sits either side of the body, so it pivots as one) */
.pet-act-play .pet-hand { transform-box: fill-box; transform-origin: 50% 50%; animation: pet-swing 1.6s ease-in-out; }
@keyframes pet-swing {
  0%, 100% { translate: 0 0; rotate: 0deg; }
  18% { translate: 0 -7px; rotate: -7deg; }
  40% { translate: 0 -9px; rotate: 8deg; }
  62% { translate: 0 -6px; rotate: -5deg; }
  82% { translate: 0 -2px; rotate: 3deg; }
}
.pet-act-play .pet-core { transform-origin: 50% 100%; animation: pet-look 1.6s ease-in-out; }
/* wearing a hat: pushes it back into place */
.pet-act-hat .pet-hat { animation: pet-hat-fix 1.3s ease-in-out; }
@keyframes pet-hat-fix {
  0%, 100% { rotate: 0deg; translate: 0 0; }
  25% { rotate: -14deg; translate: -2px -5px; }
  55% { rotate: 9deg; translate: 1px -2px; }
  80% { rotate: -3deg; translate: 0 0; }
}

/* Reactions (js/mascot.js react): coins in (happy), your own points (hop),
   a trophy (cheer, holding up .pet-sign), war day (hype). */
.rank-mascot.pet-act-happy .rank-mascot-btn { animation: pet-happy 2.6s ease-out; }
@keyframes pet-happy {
  0%, 100% { translate: 0 0; scale: 1 1; }
  6% { translate: 0 0; scale: 1.12 .88; }
  20% { translate: 0 -30px; scale: .94 1.07; }
  34% { translate: 0 0; scale: 1.1 .9; }
  46% { translate: 0 -20px; scale: .96 1.05; }
  58% { translate: 0 0; scale: 1.06 .95; }
  68% { translate: 0 0; scale: 1 1; }
}
.rank-mascot.pet-act-hop .rank-mascot-btn { animation: pet-hop .9s ease-out; }
@keyframes pet-hop {
  0%, 100% { translate: 0 0; scale: 1 1; }
  15% { translate: 0 0; scale: 1.1 .9; }
  45% { translate: 0 -22px; scale: .95 1.06; }
  75% { translate: 0 0; scale: 1.07 .94; }
}
.rank-mascot.pet-act-cheer .rank-mascot-btn { animation: pet-cheer 3.6s ease-in-out; }
@keyframes pet-cheer {
  0%, 100% { translate: 0 0; scale: 1 1; }
  4% { translate: 0 0; scale: 1.12 .88; }
  13% { translate: 0 -34px; scale: .94 1.07; }
  22% { translate: 0 0; scale: 1.08 .92; }
  28% { translate: 0 0; scale: 1 1; }
  40%, 64%, 88% { translate: 0 -5px; }
  52%, 76% { translate: 0 0; }
}
.rank-mascot.pet-act-hype .rank-mascot-btn { animation: pet-hype .6s ease-in-out 5; }
@keyframes pet-hype {
  0%, 100% { translate: 0 0; scale: 1.06 .94; rotate: 0deg; }
  25% { rotate: -5deg; }
  50% { translate: 0 -16px; scale: .96 1.05; rotate: 0deg; }
  75% { rotate: 5deg; }
}

/* The trophy placard held up over the head. */
.pet-sign {
  position: absolute; z-index: 2; left: 50%; top: -8%;
  width: 30%;
  display: flex; flex-direction: column; align-items: center;
  translate: -50% 0;
  pointer-events: none;
  animation: pet-sign-up .4s cubic-bezier(.3, 1.6, .5, 1) both;
}
.pet-sign.is-out { animation: pet-sign-down .3s ease-in both; }
.pet-sign-board {
  display: grid; place-items: center;
  width: 100%; aspect-ratio: 1;
  border-radius: 9px;
  background: #111;
  border: 2px solid var(--sign-color);
  color: var(--sign-color);
  box-shadow: 0 0 12px color-mix(in srgb, var(--sign-color) 55%, transparent), 0 4px 10px rgba(0, 0, 0, .5);
  animation: pet-sign-wave 1.2s ease-in-out .4s infinite;
}
.pet-sign-board svg { width: 72%; height: 72%; }
.pet-sign-stick { width: 3px; height: 16px; border-radius: 2px; background: #a8a29e; }
@keyframes pet-sign-up { from { translate: -50% 40%; scale: .3; opacity: 0; } to { translate: -50% 0; scale: 1; opacity: 1; } }
@keyframes pet-sign-down { to { translate: -50% 40%; scale: .3; opacity: 0; } }
@keyframes pet-sign-wave { 0%, 100% { rotate: -6deg; } 50% { rotate: 6deg; } }

/* To-do placard (js/mascot.js renderTodo): today's raid / ลอยกระทง still
   waiting, held over the head above the level gauge on every page but home.
   Each line is a link. Steps aside while the pet hides, peeks, cheers or the
   picker / point cards are open. */
.pet-todo {
  position: absolute; z-index: 2; right: 0; bottom: 176px; width: 150px;
  display: flex; flex-direction: column; align-items: center;
  pointer-events: none;
  transition: opacity .25s ease, bottom .4s cubic-bezier(.3, 1.4, .5, 1);
  animation: pet-todo-up .45s cubic-bezier(.3, 1.6, .5, 1) .6s both;
}
.rank-mascot.pet-left .pet-todo { right: auto; left: 0; }
.rank-mascot.pet-floaty .pet-todo { bottom: 190px; }
.rank-mascot.pet-tall-gear .pet-todo { bottom: max(176px, calc(184px - (var(--gear-top) - 4) * 1.25px)); }
.rank-mascot:has(.mascot-lv[hidden]) .pet-todo { bottom: 142px; }
.pet-todo-board {
  display: flex; flex-direction: column; gap: 2px; padding: 5px;
  border: 1px solid rgba(250, 250, 250, .14); border-radius: 10px;
  background: #0d0d0d; box-shadow: 0 6px 16px rgba(0, 0, 0, .5);
  transform-origin: 50% 100%;
  animation: pet-todo-sway 3.2s ease-in-out 1.1s infinite;
  pointer-events: auto;
}
.pet-todo-stick { width: 2px; height: 10px; background: #525252; }
.pet-todo-item {
  display: flex; align-items: center; gap: 7px; padding: 4px 9px 4px 7px; border-radius: 6px;
  color: #e5e5e5; font: 600 12px/1.3 'Anuphan', system-ui, sans-serif; text-decoration: none; white-space: nowrap;
  transition: background-color .2s;
}
.pet-todo-item::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--todo-c); animation: pet-todo-dot 1.6s ease-in-out infinite; }
.pet-todo-item.is-rd { --todo-c: #f43f5e; }
.pet-todo-item.is-lk { --todo-c: #facc15; }
.pet-todo-item:hover { background: #262626; }
.pet-todo-item:focus-visible { outline: 2px solid #bef264; outline-offset: 1px; }
.rank-mascot[data-pet="hidden"] .pet-todo, .rank-mascot[data-pet="drag"] .pet-todo, .rank-mascot.pet-peeking .pet-todo,
.rank-mascot.pet-act-cheer .pet-todo, .rank-mascot.pet-open .pet-todo, .rank-mascot:has(.mascot-drop.is-in) .pet-todo { opacity: 0; }
.rank-mascot[data-pet="hidden"] .pet-todo-board, .rank-mascot[data-pet="drag"] .pet-todo-board, .rank-mascot.pet-peeking .pet-todo-board,
.rank-mascot.pet-act-cheer .pet-todo-board, .rank-mascot.pet-open .pet-todo-board, .rank-mascot:has(.mascot-drop.is-in) .pet-todo-board { pointer-events: none; }
.rank-mascot[data-pet="sleep"] .pet-todo { opacity: .55; }
@keyframes pet-todo-up { from { opacity: 0; translate: 0 14px; scale: .6; } }
@keyframes pet-todo-sway { 0%, 100% { rotate: -2deg; } 50% { rotate: 2deg; } }
@keyframes pet-todo-dot { 50% { opacity: .35; } }

@media (prefers-reduced-motion: reduce) {
  .pet-todo, .pet-todo-board, .pet-todo-item::before { animation: none; }
  .pet-sign, .pet-sign.is-out, .pet-sign-board { animation: none; }
  .pet-say { transition: opacity .2s ease; scale: 1; }
}

@media (max-width: 640px) {
  .rank-mascot { right: 10px; bottom: 10px; }
  .rank-mascot-btn { width: 100px; height: 100px; }
  .rank-mascot-pet-popover { width: min(290px, calc(100vw - 20px)); }
  .mascot-pet-art { width: 44px; height: 44px; }
  .mascot-drop { scale: .82; transform-origin: 70% 100%; bottom: calc(100% - 14px); }
  .rank-mascot-zzz { width: 100px; bottom: 63px; font-size: 14px; }
  .rank-mascot-zzz span:nth-child(2) { font-size: 17px; }
  .rank-mascot-zzz span:nth-child(3) { font-size: 21px; }
}

/* Achievement-unlock popup (js/mascot.js's queueAchievementPopup) — personal
   only, never broadcast to other viewers (achievement data is public via
   /ranking/data, but a center-screen interrupt for every OTHER member's
   unlock too would be way too disruptive across a whole guild; the existing
   point-gain mascot speech bubble already covers that lighter "someone else
   did a thing" ambient case). Deliberately bigger/more interrupting than
   css/style.css's .streak-card (dead-center, dim backdrop, no auto-hide) —
   an achievement is a rare milestone (20 total) where the daily T-coin card
   is a routine, so it earns the bigger "stop and look at this" moment. */
.achv-unlock-overlay {
  position: fixed;
  inset: 0;
  z-index: 20000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  padding: 20px;
}

.achv-unlock-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.achv-unlock-card {
  position: relative;
  width: min(340px, 100%);
  background: var(--card-bg);
  border: 2px solid var(--achv-color, #cd7f32);
  border-radius: 20px;
  padding: 28px 24px 24px;
  text-align: center;
  color: var(--text);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--achv-color, #cd7f32) 18%, transparent),
              0 12px 32px rgba(0, 0, 0, 0.4);
  transform: scale(0.85);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.achv-unlock-overlay.show .achv-unlock-card {
  transform: scale(1);
}

.achv-unlock-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
}

.achv-unlock-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--achv-color, #cd7f32);
  text-transform: uppercase;
  margin-bottom: 14px;
}

.achv-unlock-icon {
  font-size: 52px;
  line-height: 1;
  margin-bottom: 12px;
  filter: drop-shadow(0 0 10px var(--achv-color, #cd7f32));
}

/* Hugeicons line icon (js/mascot.js ACHV_ICON_SVG) in the tier colour. */
.achv-unlock-icon .achv-ico {
  display: block;
  margin: 0 auto;
  color: var(--achv-color, #cd7f32);
}

.achv-unlock-name {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 8px;
}

.achv-unlock-tier {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--achv-color, #cd7f32);
  color: #1e1608;
  margin-bottom: 12px;
}

.achv-unlock-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}

/* "Updates" tab on the left edge — the way into the announcement doc
   (js/mascot.js initUpdatesTab). Lives here rather than home.css because
   mascot.css is on every page, old theme included; colours are literal for
   the same reason. index.html keeps it all the time; other pages only get
   it while an announcement is unread. */
.side-tab {
  position: fixed; left: 0; top: 50%; transform: translateY(-50%); z-index: 40;
  display: flex; align-items: center; gap: 12px; overflow: hidden;
  background: #fff; color: #000 !important; text-decoration: none;
  padding: 34px 12px; border-radius: 0 22px 22px 0;
  font: 900 10px 'Inter', 'Anuphan', sans-serif; letter-spacing: .45em; text-transform: uppercase;
  writing-mode: vertical-rl; box-shadow: 0 20px 40px rgba(0, 0, 0, .35);
  transition: padding .4s cubic-bezier(.23, 1, .32, 1), opacity .4s, translate .4s;
}
.side-tab:hover { padding-left: 20px; }
.side-tab:focus-visible { outline: 2px solid #bef264; outline-offset: 3px; }
.side-tab .dot-new {
  flex-shrink: 0; width: 7px; height: 7px; border-radius: 50%; background: #f43f5e;
  box-shadow: 0 0 0 4px rgba(244, 63, 94, .2); animation: side-tab-pulse 1.6s infinite;
}
@keyframes side-tab-pulse { 50% { box-shadow: 0 0 0 8px rgba(244, 63, 94, 0); } }
/* Unread: a rose glow around the tab, a light band sweeping down it, and
   a small slide-out every few seconds so it catches the eye without
   flashing. */
.side-tab.is-new {
  box-shadow: 0 20px 40px rgba(0, 0, 0, .35), 0 0 0 1px rgba(244, 63, 94, .35), 0 0 26px rgba(244, 63, 94, .35);
  animation: side-tab-nudge 4.5s cubic-bezier(.23, 1, .32, 1) 1s infinite;
}
.side-tab.is-new::after {
  content: ''; position: absolute; left: 0; right: 0; top: -60%; height: 50%; pointer-events: none;
  background: linear-gradient(transparent, rgba(244, 63, 94, .22), transparent);
  animation: side-tab-sweep 2.6s ease-in-out infinite;
}
.side-tab.is-new:hover { animation-play-state: paused; }
@keyframes side-tab-nudge { 0%, 78%, 100% { translate: 0 0; } 84% { translate: 7px 0; } 90% { translate: 0 0; } 95% { translate: 4px 0; } }
@keyframes side-tab-sweep { 0% { top: -60%; } 70%, 100% { top: 110%; } }
.side-tab.is-leaving { opacity: 0; translate: -100% 0; pointer-events: none; }

/* Unread-announcement bar across the top of every page (js/mascot.js
   showUpdatesBar). Normal flow, so it scrolls away; home.css's fixed
   .topbar steps down under it until the page scrolls. */
.upd-bar {
  position: relative; z-index: 51; display: flex; align-items: center; justify-content: center;
  height: 34px; padding: 0 44px; background: #fff;
  font: 500 13px 'Anuphan', sans-serif;
}
/* White bar, black text: the same inverted look as the .side-tab Updates tab
   below, so it stands out on the black theme and reads as "the Updates thing".
   The red dot is the only colour. */
.upd-bar-link {
  display: inline-flex; align-items: center; gap: 8px; min-width: 0; height: 100%;
  color: #404040 !important; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: color .2s;
}
.upd-bar-link b { font-weight: 700; color: #000; }
.upd-bar-link:hover { color: #000 !important; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(0, 0, 0, .35); }
.upd-bar-dot { flex-shrink: 0; width: 7px; height: 7px; border-radius: 50%; background: #f43f5e; animation: side-tab-pulse 1.6s infinite; }
.upd-bar-close {
  position: absolute; right: 0; top: 0; width: 44px; height: 100%;
  border: 0; background: transparent; color: #737373; font-size: 12px; cursor: pointer;
  transition: color .2s;
}
.upd-bar-close:hover { color: #000; }
.upd-bar-close:focus-visible, .upd-bar-link:focus-visible { outline: 1px solid rgba(0, 0, 0, .4); outline-offset: -3px; }
@media (prefers-reduced-motion: reduce) { .upd-bar-dot { animation: none; } }
html.upd-bar-on .topbar:not(.scrolled) { top: 34px; }
.topbar .nav a.has-new { position: relative; }
.nav-dot-new {
  position: absolute; top: 50%; right: -12px; translate: 0 -50%; width: 6px; height: 6px; border-radius: 50%;
  background: #f43f5e; pointer-events: none;
}

/* Phone: narrower. index.html's always-there tab hides once read (it would
   sit over the content); an unread one stays so a new announcement is
   still seen on a phone. */
@media (max-width: 600px) {
  .side-tab { padding: 22px 7px; gap: 8px; font-size: 8.5px; letter-spacing: .35em; border-radius: 0 16px 16px 0; }
  .side-tab:hover { padding-left: 7px; }
  .side-tab:not(.is-new) { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .side-tab, .side-tab.is-new, .side-tab.is-new::after, .side-tab .dot-new { animation: none; transition: none; }
  .side-tab.is-new::after { display: none; }
}

/* ---- Pet art (js/pets.js) -------------------------------------------------
   The mascot is a collectible pet drawn as inline SVG. Its states key off the
   wrap's data-pet (idle / walk / drag / fall / sleep, set by initPet in
   js/mascot.js) and .pet-dizzy. Normal → Legend+ take the rank colour from
   --frame-color; Legend++ (Star Cat) has fixed colours (its aura is
   always the owner's rank colour, never a picked one). */
.pet-svg { overflow: visible; }
/* fill-box only on the parts CSS animates — on everything it would shift
   the pivot of plain SVG transform attributes (the shine, the rim). */
.pet-core, .pet-jelly, .pet-tip, .pet-eye, .pet-spiral, .pet-hat, .pet-shadow, .pet-star,
.pet-ember, .pet-twinkle, .pet-tail, .pet-hover, .pet-sprout, .pet-angel-wing, .pet-bubble,
.pet-beam, .pet-fire, .pet-horn, .pet-dust, .pet-mote, .pet-aura-glow, .pet-magic-spin { transform-box: fill-box; }
.rank-mascot[data-pet="sleep"] .rank-mascot-char { filter: brightness(.8) saturate(.8); }
.rank-mascot.pet-floaty .rank-mascot-zzz { bottom: 118px; }

.pet-eyes-sleep, .pet-eyes-dizzy, .pet-eyes-held, .pet-eyes-happy,
.pet-mouth-o, .pet-mouth-wave, .pet-mouth-sleep, .pet-stars { display: none; }

/* Faces for the corner pet's acts and reactions (js/mascot.js): a yawn
   shuts its eyes round an open mouth; being happy squints them to ^ ^. */
.pet-act-yawn .pet-eyes-open, .pet-act-yawn .pet-mouth-smile { display: none; }
.pet-act-yawn .pet-eyes-sleep, .pet-act-yawn .pet-mouth-o { display: inline; }
.pet-act-happy .pet-eyes-open, .pet-act-hop .pet-eyes-open,
.pet-act-cheer .pet-eyes-open, .pet-act-hype .pet-eyes-open { display: none; }
.pet-act-happy .pet-eyes-happy, .pet-act-hop .pet-eyes-happy,
.pet-act-cheer .pet-eyes-happy, .pet-act-hype .pet-eyes-happy { display: inline; }
.pet-act-cheer .pet-mouth-smile, .pet-act-hype .pet-mouth-smile { display: none; }
.pet-act-cheer .pet-mouth-o, .pet-act-hype .pet-mouth-o { display: inline; }
.pet-act-yawn .pet-breath-face, .pet-act-happy .pet-breath-face, .pet-act-hop .pet-breath-face,
.pet-act-cheer .pet-breath-face, .pet-act-hype .pet-breath-face,
.pet-act-yawn .pet-eye-spark, .pet-act-happy .pet-eye-spark, .pet-act-hop .pet-eye-spark,
.pet-act-cheer .pet-eye-spark, .pet-act-hype .pet-eye-spark { display: none; }

[data-pet="sleep"] .pet-eyes-open, [data-pet="sleep"] .pet-mouth-smile { display: none; }
[data-pet="sleep"] .pet-eyes-sleep, [data-pet="sleep"] .pet-mouth-sleep { display: inline; }

[data-pet="drag"] .pet-eyes-open, [data-pet="fall"] .pet-eyes-open,
[data-pet="drag"] .pet-mouth-smile, [data-pet="fall"] .pet-mouth-smile { display: none; }
[data-pet="drag"] .pet-eyes-held, [data-pet="fall"] .pet-eyes-held,
[data-pet="drag"] .pet-mouth-o, [data-pet="fall"] .pet-mouth-o { display: inline; }

.pet-dizzy .pet-eyes-open, .pet-dizzy .pet-mouth-smile { display: none; }
.pet-dizzy .pet-eyes-dizzy, .pet-dizzy .pet-mouth-wave, .pet-dizzy .pet-stars { display: inline; }

/* idle life: blink + a slow jelly wobble */
.pet-eye { transform-origin: center; animation: pet-blink 4.6s infinite; }
@keyframes pet-blink { 0%, 93%, 100% { transform: scaleY(1); } 95.5% { transform: scaleY(.1); } }
.pet-jelly { transform-origin: 50% 100%; animation: pet-wobble 3.4s ease-in-out infinite; }
@keyframes pet-wobble { 0%, 100% { scale: 1 1; } 50% { scale: 1.025 .975; } }
.pet-tip { transform-origin: 50% 100%; animation: pet-tip 3.4s ease-in-out infinite; }
@keyframes pet-tip { 0%, 100% { rotate: -5deg; } 50% { rotate: 7deg; } }
[data-pet="walk"] .pet-jelly, [data-pet="drag"] .pet-jelly, [data-pet="fall"] .pet-jelly { animation: none; }
[data-pet="walk"] .pet-tip { animation-duration: .62s; }

/* floor shadow stays on the ground while the body is in the air
   (--lift-u = height above the floor in viewBox units, from initPet) */
.pet-shadow {
  transform-origin: center;
  translate: 0 calc(var(--lift-u, 0) * 1px);
  scale: calc(1 - min(var(--lift-u, 0), 40) / 90);
  opacity: calc(1 - min(var(--lift-u, 0), 40) / 70);
}
[data-pet="drag"] .pet-shadow, [data-pet="fall"] .pet-shadow { opacity: 0; }

/* held: tip flails */
[data-pet="drag"] .pet-tip { animation-duration: .4s; }

/* sleep: melts a little, tip droops, hat slips */
[data-pet="sleep"] .pet-jelly { animation: none; scale: 1.05 .93; transition: scale .8s; }
[data-pet="sleep"] .pet-tip { animation: none; rotate: -35deg; }
[data-pet="sleep"] .pet-hat { rotate: -12deg; translate: -3px 3px; }

/* Dev Droppy's coffee break (js/mascot.js data-pet="coffee", js/pets.js
   .dev-mug): the takeaway cup only shows while resting. Every 7s the cup
   lifts to its mouth for a sip with ^^ eyes; once it falls asleep the
   empty cup lies on its side. */
.dev-mug, .dev-mug-empty { display: none; }
[data-pet="coffee"] .dev-mug, [data-pet="sleep"] .dev-mug { display: inline; }
[data-pet="sleep"] .dev-mug-full { display: none; }
[data-pet="sleep"] .dev-mug-empty { display: inline; }
.rank-mascot[data-pet="coffee"] .rank-mascot-btn { animation: pet-breathe 3.2s ease-in-out infinite; }
[data-pet="coffee"] .dev-mug-full { transform-box: view-box; transform-origin: 104px 107px; animation: dev-sip 7s ease-in-out infinite; }
@keyframes dev-sip {
  0%, 66% { translate: 0 0; rotate: 0deg; }
  76%, 90% { translate: -30px -6px; rotate: -32deg; }
  98%, 100% { translate: 0 0; rotate: 0deg; }
}
[data-pet="coffee"] .pet-eyes-open, [data-pet="coffee"] .pet-mouth-smile { animation: dev-sip-open 7s steps(1, end) infinite; }
[data-pet="coffee"] .pet-eyes-happy { display: inline; animation: dev-sip-happy 7s steps(1, end) infinite; }
@keyframes dev-sip-open { 0% { opacity: 1; } 75% { opacity: 0; } 91% { opacity: 1; } }
@keyframes dev-sip-happy { 0% { opacity: 0; } 75% { opacity: 1; } 91% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  [data-pet="coffee"] .dev-mug-full, [data-pet="coffee"] .pet-eyes-open, [data-pet="coffee"] .pet-mouth-smile { animation: none; }
  [data-pet="coffee"] .pet-eyes-happy { display: none; }
}
.pet-hat { transform-origin: 50% 100%; transition: rotate .5s, translate .5s; }

/* dizzy (after a big drop): sway, spinning spiral eyes, stars round the head */
.pet-dizzy .pet-core { transform-origin: 50% 100%; animation: pet-sway 1.1s ease-in-out infinite; }
@keyframes pet-sway { 0%, 100% { rotate: -6deg; } 50% { rotate: 6deg; } }
.pet-spiral { transform-origin: center; animation: pet-spin .7s linear infinite; }
@keyframes pet-spin { to { rotate: 360deg; } }
.pet-star { animation: pet-orbit 1.3s linear infinite; }
.pet-star:nth-child(2) { animation-delay: -.433s; }
.pet-star:nth-child(3) { animation-delay: -.866s; }
@keyframes pet-orbit {
  0%    { translate: 30px 0;     scale: 1;    opacity: 1; }
  12.5% { translate: 21px 6px;   scale: 1.1; }
  25%   { translate: 0 8px;      scale: 1.2; }
  37.5% { translate: -21px 6px;  scale: 1.1; }
  50%   { translate: -30px 0;    scale: 1; }
  62.5% { translate: -21px -6px; scale: .85; opacity: .55; }
  75%   { translate: 0 -8px;     scale: .75; opacity: .45; }
  87.5% { translate: 21px -6px;  scale: .85; opacity: .55; }
  100%  { translate: 30px 0;     scale: 1;    opacity: 1; }
}

/* shared glitter */
.pet-twinkle { transform-origin: center; animation: pet-twinkle 1.8s ease-in-out infinite; }
@keyframes pet-twinkle { 0%, 100% { opacity: .25; scale: .45; } 50% { opacity: 1; scale: 1; } }
.pet-ember { animation: pet-ember 2.1s linear infinite; }
@keyframes pet-ember { 0% { translate: 0 0; opacity: 0; } 15% { opacity: 1; } 100% { translate: 5px -26px; opacity: 0; } }

/* Rare (Sprout Droppy): sprout sways, bubbles rise inside */
.pet-sprout { transform-origin: 50% 100%; animation: pet-sprout 2.6s ease-in-out infinite; }
@keyframes pet-sprout { 0%, 100% { rotate: -6deg; } 50% { rotate: 7deg; } }
[data-pet="walk"] .pet-sprout, [data-pet="drag"] .pet-sprout { animation-duration: .45s; }
[data-pet="sleep"] .pet-sprout { animation: none; rotate: -24deg; }
.pet-bubble { animation: pet-bubble 3.2s ease-in infinite; }
@keyframes pet-bubble { 0% { translate: 0 0; opacity: 0; } 20% { opacity: .9; } 100% { translate: 2px -40px; opacity: 0; } }

/* Legend (Angel Droppy): soft wings lift and spread from the root */
.pet-angel-wing { transform-origin: 95% 55%; animation: pet-angel 2.4s cubic-bezier(.45, 0, .55, 1) infinite; }
@keyframes pet-angel {
  0%, 100% { rotate: 0deg; scale: 1 1; }
  35% { rotate: 9deg; scale: .94 1.04; }
  60% { rotate: -4deg; scale: 1.03 .98; }
}
[data-pet="walk"] .pet-angel-wing, [data-pet="drag"] .pet-angel-wing, [data-pet="fall"] .pet-angel-wing { animation-duration: .5s; }
[data-pet="sleep"] .pet-angel-wing { animation: none; rotate: 12deg; scale: .92 .92; transition: rotate .8s, scale .8s; }

/* ค่ายตัดไม้'s axe (js/pets.js lumber_axe): chops from the grip, the group's own
   origin (view-box, not fill-box). Asleep it rests still, leaning on the pet. */
.pet-axe-swing { animation: pet-axe 1.3s infinite; }
@keyframes pet-axe {
  0%, 100% { rotate: -38deg; }
  35% { rotate: 14deg; }
  45% { rotate: 8deg; }
}
[data-pet="sleep"] .pet-axe-swing { animation: none; rotate: 18deg; }

/* Legend+ (Dragon Droppy): every 5.5s it shuts its eyes (^ ^), opens up and
   breathes fire — pet-beam grows the flame from the mouth, pet-roar swaps
   the face in step with it */
.pet-beam { transform-origin: 100% 50%; animation: pet-beam 5.5s ease-out infinite; }
@keyframes pet-beam { 0%, 72% { scale: 0 .4; opacity: 0; } 76% { scale: 1 1; opacity: 1; } 86% { scale: 1 .85; opacity: 1; } 92%, 100% { scale: 1 0; opacity: 0; } }
[data-pet="sleep"] .pet-beam, [data-pet="drag"] .pet-beam, [data-pet="fall"] .pet-beam, .pet-dizzy .pet-beam { display: none; }
.pet-fire { transform-origin: 100% 50%; animation: pet-fire .18s ease-in-out infinite alternate; }
.pet-fire-core { animation-duration: .13s; }
@keyframes pet-fire { from { scale: 1 .9; } to { scale: 1.06 1.1; } }
.pet-breath-face { opacity: 0; animation: pet-roar 5.5s linear infinite; }
@keyframes pet-roar { 0%, 68% { opacity: 0; } 70%, 91% { opacity: 1; } 93%, 100% { opacity: 0; } }
.pet-breather .pet-eyes-open, .pet-breather .pet-mouth-smile { animation: pet-roar-hide 5.5s linear infinite; }
@keyframes pet-roar-hide { 0%, 68% { opacity: 1; } 70%, 91% { opacity: 0; } 93%, 100% { opacity: 1; } }
[data-pet="sleep"] .pet-breath-face, [data-pet="drag"] .pet-breath-face,
[data-pet="fall"] .pet-breath-face, .pet-dizzy .pet-breath-face { display: none; }
.pet-horn { transform-origin: 80% 100%; }
[data-pet="drag"] .pet-horn, [data-pet="fall"] .pet-horn { animation: pet-horn .3s ease-in-out infinite alternate; }
@keyframes pet-horn { from { rotate: -5deg; } to { rotate: 5deg; } }

/* Legend+ / Legend++: tail wags from its root */
.pet-tail { transform-origin: 0% 100%; animation: pet-tail 1.6s ease-in-out infinite; }
@keyframes pet-tail { 0%, 100% { rotate: -6deg; } 50% { rotate: 8deg; } }
[data-pet="sleep"] .pet-tail { animation-duration: 4s; }

/* Legend++ (Star Cat) hovers high instead of sitting, with a violet glow
   hugging its silhouette (inside the rank-coloured aura), a magic circle on
   the floor, a light pillar + motes off it, stardust, a shooting star now
   and then and a sparkle in its eyes */
.pet-hover { animation: pet-hover 2.8s ease-in-out infinite; }
@keyframes pet-hover { 0%, 100% { translate: 0 -22px; } 50% { translate: 0 -15px; } }
[data-pet="sleep"] .pet-hover { animation-duration: 5s; }
.pet-floaty-art .pet-shadow { display: none; }
.pet-floaty-art,
.rank-mascot .pet-floaty-art { filter: drop-shadow(0 0 2px rgba(196, 181, 253, .55)) drop-shadow(0 0 8px rgba(139, 92, 246, .45)); }
.rank-mascot[data-pet="sleep"] .pet-floaty-art { filter: drop-shadow(0 0 2px rgba(196, 181, 253, .3)) drop-shadow(0 0 6px rgba(139, 92, 246, .25)) brightness(.85); }
.pet-magic { translate: 0 calc(var(--lift-u, 0) * 1px); animation: pet-magic-pulse 2.8s ease-in-out infinite; transition: opacity .3s; }
@keyframes pet-magic-pulse { 0%, 100% { opacity: .75; } 50% { opacity: 1; } }
.pet-magic-spin { transform-origin: center; animation: pet-magic-spin 14s linear infinite; }
@keyframes pet-magic-spin { to { rotate: 360deg; } }
[data-pet="sleep"] .pet-magic { animation: none; opacity: .45; }
[data-pet="sleep"] .pet-magic-spin { animation-duration: 40s; }
[data-pet="drag"] .pet-magic, [data-pet="fall"] .pet-magic { opacity: 0; }
.pet-pillar { animation: pet-pillar 2.8s ease-in-out infinite; }
@keyframes pet-pillar { 0%, 100% { opacity: .45; } 50% { opacity: .85; } }
[data-pet="sleep"] .pet-pillar { animation: none; opacity: .3; }
.pet-mote { animation: pet-mote 3.2s ease-out infinite; }
@keyframes pet-mote { 0% { translate: 0 0; opacity: 0; scale: .6; } 20% { opacity: 1; } 100% { translate: 0 -50px; opacity: 0; scale: 1.1; } }
.pet-aura-glow { transform-origin: center; animation: pet-aura 4s ease-in-out infinite; }
@keyframes pet-aura { 0%, 100% { scale: .92; opacity: .55; } 50% { scale: 1.06; opacity: .9; } }
[data-pet="sleep"] .pet-aura-glow { animation-duration: 8s; }
.pet-meteor { opacity: 0; animation: pet-meteor 6.5s ease-in infinite; }
@keyframes pet-meteor { 0%, 76% { opacity: 0; translate: 0 0; } 79% { opacity: 1; translate: 0 0; } 93% { opacity: 1; translate: -96px 18px; } 97%, 100% { opacity: 0; translate: -110px 21px; } }
.pet-dust { animation: pet-dust 2s ease-in infinite; }
@keyframes pet-dust { 0% { translate: 0 -6px; opacity: 0; scale: 1; } 20% { opacity: 1; } 100% { translate: 0 10px; opacity: 0; scale: .4; } }
[data-pet="sleep"] .pet-meteor, [data-pet="sleep"] .pet-mote, [data-pet="sleep"] .pet-dust, [data-pet="drag"] .pet-dust,
[data-pet="sleep"] .pet-eye-spark, [data-pet="drag"] .pet-eye-spark, [data-pet="fall"] .pet-eye-spark, .pet-dizzy .pet-eye-spark { display: none; }

@media (prefers-reduced-motion: reduce) {
  .pet-svg * { animation: none !important; }
}

/* ---- Level thermometer (js/mascot.js renderLevel) ---------------------
   A little mercury gauge floating over the head, for pets hatched from the
   egg gacha. Bulb = the level number, tube = level / 30 in the pet's rank
   colour (--frame-color), with bubbles drifting through the liquid. The
   dashed stretch past the liquid is spare copies saved toward the next
   level; once there are enough (.is-ready) the bulb bobs with an arrow.
   Lv.MAX (.is-max) boils rainbow with a puff of steam, and a level gained
   since the last visit (.is-leveling) pops a "LEVEL UP!". It rides along
   with the pet: sinks with each hop's squash (--sq), swings when carried,
   and dims while asleep. Hover the pet or the gauge for the details. */
.mascot-lv {
  --lv-c: var(--frame-color, #a3a3a3);
  position: absolute;
  right: 0;
  bottom: 142px;
  width: 150px;
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
  transition: opacity .3s ease, translate .12s linear, bottom .4s cubic-bezier(.3, 1.4, .5, 1);
  z-index: 1;
}
.mascot-lv[hidden] { display: none; }
.rank-mascot.pet-left .mascot-lv { right: auto; left: 0; }
.rank-mascot.pet-floaty .mascot-lv { bottom: 156px; }
/* Back gear / a hat: --gear-top (js/pets.js gearTop) is how high it
   reaches in the pet's 120-unit frame (1.25px each on the 150px button).
   The gauge sits 4 units above that, never lower than usual; floaty pets
   hover up to 22 units higher, so their gear does too. A short hat or
   Ryan's sword leaves it where it was, Jave's dragon lifts it the most. */
.rank-mascot.pet-tall-gear .mascot-lv { bottom: max(142px, calc(150px - (var(--gear-top) - 4) * 1.25px)); }
.rank-mascot.pet-tall-gear.pet-floaty .mascot-lv { bottom: max(156px, calc(150px - (var(--gear-top) - 26) * 1.25px)); }

/* Limit-break stars under the bulb; gold ring while at the current cap. */
.mlv-star {
  position: absolute; left: 50%; top: 100%; translate: -50% -5px;
  padding: 1px 4px; border-radius: 999px; background: #0a0a0a; border: 1px solid rgba(250, 204, 21, .6);
  font: 800 8.5px/1.2 'Inter', sans-serif; color: #facc15; white-space: nowrap;
}
.mlv-star[hidden] { display: none; }
.mascot-lv.is-cap .mlv-bulb { box-shadow: 0 0 0 1.5px #facc15, 0 0 12px rgba(250, 204, 21, .7), 0 3px 8px rgba(0, 0, 0, .45); }
.mlv-bulb {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  padding: 0 4px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 34% 30%, rgba(255, 255, 255, .55), transparent 38%),
    var(--lv-c);
  border: 2px solid #0a0a0a;
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .5), 0 0 12px var(--frame-glow, transparent), 0 3px 8px rgba(0, 0, 0, .45);
  pointer-events: auto;
}
.mlv-bulb b {
  font: 900 11px/1 'Inter', sans-serif;
  color: #0a0a0a;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.mlv-tube {
  position: relative;
  width: 62px;
  height: 10px;
  margin-left: -5px;
  border-radius: 0 999px 999px 0;
  background:
    repeating-linear-gradient(90deg, transparent 0 calc(100% / 3 - 1px), rgba(255, 255, 255, .22) calc(100% / 3 - 1px) calc(100% / 3)),
    rgba(10, 10, 10, .78);
  border: 1.5px solid rgba(255, 255, 255, .5);
  border-left: none;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .45);
  overflow: hidden;
  pointer-events: auto;
}
/* Liquid: rises from empty on first show (@starting-style) and on every
   level-up, since --lv drives the width. */
.mlv-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: calc(var(--lv, 0) * 100%);
  background: linear-gradient(180deg, rgba(255, 255, 255, .45), transparent 45%), var(--lv-c);
  box-shadow: 0 0 8px var(--lv-c);
  border-radius: 0 3px 3px 0;
  overflow: hidden;
  transition: width 1.1s cubic-bezier(.3, 1.5, .5, 1), rotate .12s linear;
  transform-origin: 0 50%;
}
@starting-style { .mlv-fill { width: 0; } }
.mlv-fill i {
  position: absolute;
  left: 0;
  top: 50%;
  width: 3px;
  height: 3px;
  margin-top: -1.5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .8);
  animation: mlv-bubble 2.6s linear infinite;
}
.mlv-fill i:nth-child(2) { width: 2px; height: 2px; animation-delay: -.9s; animation-duration: 2.1s; top: 30%; }
.mlv-fill i:nth-child(3) { animation-delay: -1.7s; animation-duration: 3.2s; top: 68%; }
@keyframes mlv-bubble {
  0% { translate: 0 0; opacity: 0; }
  15% { opacity: .9; }
  50% { translate: 30px -1px; }
  100% { translate: 62px 1px; opacity: 0; }
}
.mlv-next {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--lv, 0) * 100%);
  width: calc(var(--lv-next, 0) * 100%);
  background: repeating-linear-gradient(90deg, var(--lv-c) 0 2px, transparent 2px 4px);
  opacity: .55;
  transition: left 1.1s cubic-bezier(.3, 1.5, .5, 1), width .6s ease;
}

/* Hover tip */
.mlv-tip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  translate: -50% 4px;
  white-space: nowrap;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(10, 10, 10, .92);
  border: 1px solid rgba(255, 255, 255, .18);
  color: #fafafa;
  font: 600 11px/1.4 'Anuphan', 'Inter', sans-serif;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, translate .2s ease;
}
.mascot-lv:hover .mlv-tip,
.rank-mascot:has(.rank-mascot-btn:hover) .mlv-tip { opacity: 1; translate: -50% 0; }
.rank-mascot:has(.rank-mascot-btn:hover) .mlv-bulb,
.mascot-lv:hover .mlv-bulb { animation: mlv-wiggle .5s ease; }
@keyframes mlv-wiggle {
  0%, 100% { rotate: 0deg; }
  30% { rotate: -14deg; scale: 1.12; }
  65% { rotate: 10deg; }
}

/* Enough spare copies to level up: the bulb bobs with a little arrow. */
.mascot-lv.is-ready .mlv-bulb { animation: mlv-bob 1.4s ease-in-out infinite; }
.mascot-lv.is-ready .mlv-bulb::after {
  content: "";
  position: absolute;
  top: -9px;
  left: 50%;
  margin-left: -4px;
  border: 4px solid transparent;
  border-bottom: 5px solid var(--h-lime, #a3e635);
  border-top: none;
  filter: drop-shadow(0 0 3px var(--h-lime, #a3e635));
  animation: mlv-arrow 1.4s ease-in-out infinite;
}
@keyframes mlv-bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -2px; } }
@keyframes mlv-arrow { 0%, 100% { translate: 0 0; opacity: .6; } 50% { translate: 0 -3px; opacity: 1; } }

/* Lv.MAX: rainbow boil + steam. */
.mascot-lv.is-max .mlv-bulb,
.mascot-lv.is-max .mlv-fill {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .45), transparent 45%),
    linear-gradient(90deg, #f43f5e, #fb923c, #facc15, #a3e635, #38bdf8, #a855f7, #f43f5e) 0 0 / 200% 100%;
  animation: mlv-rainbow 3s linear infinite;
}
.mascot-lv.is-max .mlv-bulb b { font-size: 9px; letter-spacing: .02em; }
.mascot-lv.is-max::before,
.mascot-lv.is-max::after {
  content: "";
  position: absolute;
  bottom: 12px;
  left: calc(50% + 20px);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .55);
  filter: blur(1px);
  animation: mlv-steam 2.4s ease-out infinite;
}
.mascot-lv.is-max::after { left: calc(50% - 4px); animation-delay: -1.2s; }
@keyframes mlv-rainbow { to { background-position: 0 0, -200% 0; } }
@keyframes mlv-steam {
  0% { translate: 0 0; scale: .6; opacity: 0; }
  25% { opacity: .8; }
  100% { translate: 5px -18px; scale: 1.6; opacity: 0; }
}

/* Level gained since the last visit: burst + "LEVEL UP!" */
.mlv-pop {
  position: absolute;
  bottom: 100%;
  left: 50%;
  translate: -50% 0;
  font: 900 12px/1 'Inter', sans-serif;
  letter-spacing: .08em;
  color: var(--h-lime, #a3e635);
  text-shadow: 0 0 2px #000, 0 0 10px var(--h-lime, #a3e635);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
}
.mascot-lv.is-leveling .mlv-pop { animation: mlv-pop 2s cubic-bezier(.2, 1.4, .4, 1) forwards; }
.mascot-lv.is-leveling .mlv-tip { opacity: 0; }
.mascot-lv.is-leveling .mlv-bulb { animation: mlv-burst .7s cubic-bezier(.3, 1.8, .5, 1); }
@keyframes mlv-pop {
  0% { opacity: 0; translate: -50% 8px; scale: .5; }
  18% { opacity: 1; translate: -50% -6px; scale: 1.15; }
  70% { opacity: 1; translate: -50% -12px; scale: 1; }
  100% { opacity: 0; translate: -50% -22px; scale: .95; }
}
@keyframes mlv-burst {
  0% { scale: 1; }
  40% { scale: 1.35; }
  100% { scale: 1; }
}

/* Rides along with the pet. */
.rank-mascot[data-pet="walk"] .mascot-lv { translate: 0 calc(var(--sq, 0) * 120px); }
.rank-mascot[data-pet="walk"] .mlv-fill { rotate: calc(var(--sq, 0) * -40deg); }
.rank-mascot[data-pet="drag"] .mascot-lv { transform-origin: 50% 400%; animation: mlv-swing .9s ease-in-out infinite; }
@keyframes mlv-swing { 0%, 100% { rotate: 7deg; } 50% { rotate: -7deg; } }
.rank-mascot[data-pet="sleep"] .mascot-lv { opacity: .3; translate: 0 6px; }
.rank-mascot[data-pet="sleep"] .mlv-fill i { animation-play-state: paused; }
.rank-mascot.pet-dizzy .mlv-bulb { animation: mlv-dizzy .8s ease-in-out 2; }
@keyframes mlv-dizzy { 0%, 100% { rotate: 0deg; } 25% { rotate: -20deg; } 75% { rotate: 20deg; } }
/* Out of the way of the picker and the pop-out cards. */
.rank-mascot.pet-open .mascot-lv,
.rank-mascot:has(.mascot-drop.is-in) .mascot-lv { opacity: 0; }

@media (max-width: 640px) {
  .mascot-lv { width: 100px; bottom: 92px; scale: .85; }
  .rank-mascot.pet-floaty .mascot-lv { bottom: 104px; }
  .rank-mascot.pet-tall-gear .mascot-lv { bottom: max(92px, calc(100px - (var(--gear-top) - 4) * .833px)); }
  .rank-mascot.pet-tall-gear.pet-floaty .mascot-lv { bottom: max(104px, calc(100px - (var(--gear-top) - 26) * .833px)); }
}
@media (prefers-reduced-motion: reduce) {
  .mascot-lv, .mascot-lv *, .mascot-lv::before, .mascot-lv::after { animation: none !important; }
  .mlv-fill, .mlv-next { transition: none; }
  .mlv-fill i, .mascot-lv.is-max::before, .mascot-lv.is-max::after { display: none; }
  .rank-mascot[data-pet="walk"] .mascot-lv, .rank-mascot[data-pet="walk"] .mlv-fill { translate: none; rotate: none; }
  .mascot-lv.is-leveling .mlv-pop { opacity: 1; }
}

/* Limit-break stars (js/pets.js Pets.lv.starsHtml): five small stars under
   a pet's level. Breaks 1-5 light them gold; breaks 6-10 add a second,
   glowing frame round them one by one. Shop cards and my-items sheets. */
.pet-stars-row { display: flex; gap: 3px; margin-top: 6px; }
.pet-stars-row b {
  --star: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  width: 15px; height: 15px; flex: none; display: grid; place-items: center; clip-path: var(--star); background: transparent;
}
.pet-stars-row i { width: 13px; height: 13px; clip-path: var(--star); background: rgba(255, 255, 255, .14); }
.pet-stars-row i.is-on { background: linear-gradient(180deg, #fef08a, #f59e0b); }
.pet-stars-row b:has(i.is-on) { filter: drop-shadow(0 0 2px rgba(250, 204, 21, .6)); }
.pet-stars-row b.is-framed { width: 19px; height: 19px; background: linear-gradient(180deg, #fff7d6, #e879f9 55%, #7c3aed); filter: drop-shadow(0 0 3px rgba(232, 121, 249, .8)); }
.pet-stars-row b.is-framed i { width: 12px; height: 12px; }
.pet-break-btn { background: linear-gradient(90deg, #fde047, #f59e0b) !important; color: #1c1917 !important; }

/* Judas Droppy's landing current (js/pets.js .pet-zap on its floor): hidden,
   then on every touchdown (js/mascot.js pet-touchdown) forked bolts crack
   out from its feet, flicker and fade, a few sparks jumping up. */
.pet-zap { opacity: 0; pointer-events: none; }
.pet-zap-ring { transform-box: fill-box; transform-origin: 50% 70%; }
.pet-touchdown .pet-zap { animation: pet-zap .5s ease-out; }
.pet-touchdown .pet-zap-ring { animation: pet-zap-grow .5s cubic-bezier(.2, .8, .3, 1); }
.pet-touchdown .pet-zap-spark { animation: pet-zap-spark .5s ease-out; }
@keyframes pet-zap { 0% { opacity: 1; } 15% { opacity: .35; } 25% { opacity: 1; } 100% { opacity: 0; } }
@keyframes pet-zap-grow { from { scale: .6; } to { scale: 1.05; } }
@keyframes pet-zap-spark { from { translate: 0 0; } to { translate: 0 -10px; } }
@media (prefers-reduced-motion: reduce) { .pet-touchdown .pet-zap { animation: none; } }

/* New หมายเหตุทีมศัตรู cards (js/enemy-notes-notify.js) — stacked over the
   bottom-right corner above the mascot, on every page. They stay until
   clicked (opens that enemy team) or closed with ×. Code logins have no
   mascot, so nothing here depends on it. */
.en-notify {
  position: fixed; right: 20px; bottom: 150px; z-index: 501;
  display: flex; flex-direction: column; align-items: stretch; gap: 8px;
  width: min(320px, calc(100vw - 32px));
  pointer-events: none;
}
.en-notify > * { pointer-events: auto; }
.en-notify-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 0 4px; font: 600 12px 'Anuphan', sans-serif; color: rgba(255, 255, 255, .7);
  text-shadow: 0 1px 6px rgba(0, 0, 0, .8);
}
.en-notify-bar button {
  background: rgba(20, 20, 20, .9); border: 1px solid rgba(255, 255, 255, .14); color: #ddd;
  border-radius: 999px; padding: 3px 10px; font: 500 11.5px 'Anuphan', sans-serif; cursor: pointer;
}
.en-notify-bar button:hover { color: #fff; border-color: rgba(255, 255, 255, .3); }
.en-notify-card {
  position: relative; display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 34px 12px 12px; border-radius: 16px; cursor: pointer;
  background: rgba(18, 18, 18, .96); border: 1px solid rgba(255, 255, 255, .14);
  box-shadow: 0 14px 36px rgba(0, 0, 0, .55);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  animation: en-notify-in .45s cubic-bezier(.23, 1, .32, 1) backwards;
  transition: border-color .2s, transform .2s;
}
.en-notify-card:nth-of-type(2) { animation-delay: .06s; }
.en-notify-card:nth-of-type(3) { animation-delay: .12s; }
.en-notify-card:hover, .en-notify-card:focus-visible { border-color: rgba(255, 255, 255, .35); transform: translateX(-3px); outline: none; }
.en-notify-card.is-alert { border-color: rgba(244, 63, 94, .5); background: linear-gradient(90deg, rgba(244, 63, 94, .16), rgba(18, 18, 18, .96) 70%); }
.en-notify-ico {
  position: relative; display: grid; place-items: center; flex: none;
  width: 30px; height: 30px; border-radius: 10px; background: rgba(255, 255, 255, .08); color: #fff;
}
.en-notify-ico::after { /* unread ping */
  content: ""; position: absolute; top: -3px; right: -3px; width: 9px; height: 9px; border-radius: 50%;
  background: #facc15; box-shadow: 0 0 0 0 rgba(250, 204, 21, .6); animation: en-notify-ping 1.8s infinite;
}
.en-notify-card.is-alert .en-notify-ico { color: #f43f5e; background: rgba(244, 63, 94, .14); }
.en-notify-card.is-alert .en-notify-ico::after { background: #f43f5e; box-shadow: 0 0 0 0 rgba(244, 63, 94, .6); }
.en-notify-ico svg { width: 15px; height: 15px; }
.en-notify-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-family: 'Anuphan', sans-serif; }
.en-notify-kicker { font-size: 11px; font-weight: 700; color: rgba(255, 255, 255, .55); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.en-notify-card.is-alert .en-notify-kicker { color: #fb7185; }
.en-notify-text { font-size: 13.5px; line-height: 1.45; color: #fff; overflow-wrap: anywhere; }
.en-notify-meta { font-size: 11px; color: rgba(255, 255, 255, .45); }
.en-notify-x {
  position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 8px;
  display: grid; place-items: center; background: none; border: 0; cursor: pointer;
  color: rgba(255, 255, 255, .45); font-size: 17px; line-height: 1;
}
.en-notify-x:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.en-notify-more { text-align: right; padding: 0 4px; font: 500 11.5px 'Anuphan', sans-serif; color: rgba(255, 255, 255, .6); text-shadow: 0 1px 6px rgba(0, 0, 0, .8); }
@keyframes en-notify-in { from { opacity: 0; transform: translateX(24px) scale(.97); } }
@keyframes en-notify-ping { 70% { box-shadow: 0 0 0 7px rgba(0, 0, 0, 0); } 100% { box-shadow: 0 0 0 0 rgba(0, 0, 0, 0); } }
@media (max-width: 640px) {
  .en-notify { right: 10px; bottom: 120px; }
}
@media (prefers-reduced-motion: reduce) {
  .en-notify-card, .en-notify-ico::after { animation: none; }
}
/* Out of the way while an editor's palette dock is open, same as the mascot. */
body:has(.palette-dock:not(.collapsed)) .en-notify { display: none; }

/* ฉายา (js/titles.js): a small coloured label in the muted line under a
   name, before the rank name. Icon tells where it came from (crown =
   season, 滅 = Demon Slayer collab, star = ซุ้มสอยดาว), colour tells the place. */
.ttl {
  display: inline-flex; align-items: center; gap: 5px; vertical-align: -1px;
  font: 800 13px 'Anuphan', 'Inter', sans-serif; letter-spacing: .04em; color: var(--ttl-c); white-space: nowrap;
}
.ttl-ico { width: 12px; height: 12px; flex: none; display: inline-grid; place-items: center; color: var(--ttl-ico); }
.ttl-ico svg { width: 100%; height: 100%; }
.ttl-ico--kanji { font: 700 12px 'Noto Serif JP', serif; line-height: 1; letter-spacing: 0; }
.ttl-sep { color: #525252; margin: 0 6px; }
.ttl--gold   { --ttl-c: #fde68a; --ttl-ico: #facc15; }
.ttl--silver { --ttl-c: #e4e4e7; --ttl-ico: #d4d4d8; }
.ttl--bronze { --ttl-c: #f6c9a0; --ttl-ico: #d98a52; }
.ttl--demon  { --ttl-c: #fca5a5; --ttl-ico: #ef4444; }
/* บาเอลสั่ง: one lavender-to-dusk text (Bael's jelly colours) for all three
   places, the hanging spider's metal tells the place; the winner's text has a
   slow sheen. The finisher title (bael0) is plain lavender. */
.ttl--bael1 { --ttl-ico: #facc15; } .ttl--bael2 { --ttl-ico: #d4d4d8; } .ttl--bael3 { --ttl-ico: #d98a52; } .ttl--bael0 { --ttl-ico: #8f8ee6; --ttl-c: #c9bbfb; }
.ttl--bael1 .ttl-t, .ttl--bael2 .ttl-t, .ttl--bael3 .ttl-t {
  background: linear-gradient(90deg, #f5f0ff, #c9bbfb 40%, #8f8ee6 80%, #c9bbfb); background-size: 220% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.ttl--bael1 .ttl-t { animation: ttl-bael-sheen 5s linear infinite; }
@keyframes ttl-bael-sheen { to { background-position: -220% 0; } }
@media (prefers-reduced-motion: reduce) { .ttl--bael1 .ttl-t { animation: none; } }

/* ฉายา chips in the mascot's picker (js/mascot.js renderTitleChips). */
.mascot-titles { display: flex; flex-wrap: wrap; gap: 6px; }
.mascot-title-chip {
  display: inline-flex; align-items: center; padding: 6px 10px; border-radius: 999px;
  border: 1px solid #2a2a2a; background: none; cursor: pointer;
  font: 600 12px 'Anuphan', sans-serif; color: #a3a3a3;
}
.mascot-title-chip:hover { border-color: #525252; }
.mascot-title-chip.is-on { border-color: #e5e5e5; background: rgba(255, 255, 255, .06); color: #f5f5f5; }
.mascot-title-chip .ttl { font-size: 12px; }
