.fp1-profile-frame {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 24;
}

.fp1-profile-frame > img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: fill;
}

:is(#v105-home-profile-button, #v105-profile-preview)[data-free-pass-frame] > :is(
  .v160-generated-profile-frame,
  .v161-pass-profile-frame,
  .v175-illustrated-profile-frame,
  .v197-mastery-profile-frame
) {
  display: none !important;
}

:is(#home-screen, #v105-profile-editor, #matching-screen, #v186-online-root) [data-free-pass-title],
[data-free-pass-title] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .38em;
  width: fit-content;
  max-width: 100%;
  padding: .12em .5em;
  border: 1px solid var(--fp1-title-mid, #9b6b49);
  border-radius: .25em;
  box-sizing: border-box;
  color: var(--fp1-title-light, #f1d197);
  background: linear-gradient(160deg, var(--fp1-title-base, #2e2029), #13131c 75%);
  box-shadow: inset 0 0 0 1px rgb(255 236 197 / 11%);
  text-shadow: 0 1px 2px #000;
  font-weight: 650;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

[data-free-pass-title]::before,
[data-free-pass-title]::after {
  content: "♦";
  flex: none;
  color: var(--fp1-title-mid, #9b6b49);
  font-size: .8em;
}

[data-free-pass-title="free-pass-title-moon-witness"] {
  --fp1-title-light: #e9ddff;
  --fp1-title-mid: #a88bc9;
  --fp1-title-base: #36264e;
}

[data-free-pass-title="free-pass-title-moon-witness"]::before,
[data-free-pass-title="free-pass-title-moon-witness"]::after {
  content: "☾";
}

[data-free-pass-title="free-pass-title-black-joker"] {
  --fp1-title-light: #ffdbab;
  --fp1-title-mid: #c58c61;
  --fp1-title-base: #522a38;
}

[data-free-pass-title="free-pass-title-black-joker"]::before,
[data-free-pass-title="free-pass-title-black-joker"]::after {
  content: "♠";
}

[data-free-pass-title="halloween-pass-dead"] {
  --fp1-title-light: #ffe2a2;
  --fp1-title-mid: #db9c51;
  --fp1-title-base: #4b2745;
}

/* This frame covers the square portrait slot on each existing surface. */
body :is(#home-screen #v105-home-profile-button, #v105-profile-editor #v105-profile-preview)[data-free-pass-frame="halloween-pass-candy-frame"] > .v105-profile-emblem,
#matching-screen .v167-match-portrait[data-free-pass-frame="halloween-pass-candy-frame"]:has(> .fp1-profile-frame),
#v186-online-root .v186-person > .v191-room-profile-portrait:has(> .v191-room-profile-frame[src$="/candy-frame.webp"]) {
  --fp1-candy-opening: 13.3%;
  position: relative !important;
  isolation: isolate;
  overflow: visible !important;
  padding: 0 !important;
  border: 0 !important;
  clip-path: none !important;
  background: none !important;
  box-shadow: none !important;
}

body :is(#home-screen #v105-home-profile-button, #v105-profile-editor #v105-profile-preview)[data-free-pass-frame="halloween-pass-candy-frame"] > .v105-profile-emblem::before,
body :is(#home-screen #v105-home-profile-button, #v105-profile-editor #v105-profile-preview)[data-free-pass-frame="halloween-pass-candy-frame"] > .v105-profile-emblem::after,
#matching-screen .v167-match-portrait[data-free-pass-frame="halloween-pass-candy-frame"]:has(> .fp1-profile-frame)::before {
  display: none !important;
}

body :is(#home-screen #v105-home-profile-button, #v105-profile-editor #v105-profile-preview)[data-free-pass-frame="halloween-pass-candy-frame"] > .v105-profile-emblem > img,
#matching-screen .v167-match-portrait[data-free-pass-frame="halloween-pass-candy-frame"]:has(> .fp1-profile-frame) > :is(img, .v167-match-image-shade, .v167-match-image-fallback),
#v186-online-root .v186-person > .v191-room-profile-portrait:has(> .v191-room-profile-frame[src$="/candy-frame.webp"]) > img:not(.v191-room-profile-frame) {
  position: absolute !important;
  inset: var(--fp1-candy-opening) !important;
  width: calc(100% - 2 * var(--fp1-candy-opening)) !important;
  height: calc(100% - 2 * var(--fp1-candy-opening)) !important;
  box-sizing: border-box;
  clip-path: none !important;
  border: 0 !important;
  border-radius: 8% !important;
}

body :is(#home-screen #v105-home-profile-button, #v105-profile-editor #v105-profile-preview)[data-free-pass-frame="halloween-pass-candy-frame"] > .v105-profile-emblem > .fp1-profile-frame > img,
#matching-screen .v167-match-portrait[data-free-pass-frame="halloween-pass-candy-frame"]:has(> .fp1-profile-frame) > .fp1-profile-frame > img,
#v186-online-root .v186-person > .v191-room-profile-portrait > .v191-room-profile-frame[src$="/candy-frame.webp"] {
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: fill !important;
  border: 0 !important;
  border-radius: 0 !important;
  clip-path: none !important;
  background: none !important;
  filter: none !important;
}

/* Halloween exchange-ticket artwork uses the existing icon slots. */
#v226-player-hub .rare-ticket-present-icon,
#home-screen #rare-skin-ticket-entry .rare-ticket-icon,
#rare-skin-ticket-panel .rare-ticket-seal {
  background: url("../assets/halloween-pass/ticket-icon.webp") center / contain no-repeat;
  border-color: transparent;
  color: transparent;
  font-size: 0 !important;
}
#rare-skin-ticket-panel .rare-ticket-seal {
  flex: 0 0 37px;
  height: 37px;
}

/* The rewards tab owns vertical scrolling. The road takes its natural height,
   including captions and the horizontal scrollbar, above the pass footer. */
#v137-battle-pass.v205-reward-details-ready.v201-paid-pass #v137-panel-rewards.v137-panel:not([hidden]) {
  display: block !important;
  height: 100%;
  min-height: 0;
  box-sizing: border-box;
  overflow: hidden auto !important;
  scroll-padding-block: 8px;
  container-type: size;
}

#v137-battle-pass.v205-reward-details-ready #v137-panel-rewards > :is(.v137-panel-heading, .v137-track-legend, .v162-route-console) {
  display: none !important;
}

#v137-battle-pass #v137-panel-rewards .v137-reward-scroll:has(.v205-reward-card) {
  min-height: 0;
  height: auto !important;
  max-height: none !important;
  padding-block: 5px 8px;
  overflow: auto hidden !important;
  scrollbar-gutter: auto;
  touch-action: pan-x pan-y pinch-zoom;
}

#v137-battle-pass #v137-reward-road:has(.v205-reward-card) {
  height: auto;
  min-height: 0;
  padding-block: 0 6px;
}

#v137-panel-rewards #v137-reward-road .v137-tier-column:has(.v205-reward-card) {
  gap: 5px;
}

#v137-panel-rewards #v137-reward-road:has(.v205-reward-card) .v137-tier-node {
  min-height: 37px;
  flex-basis: 37px;
}

#v137-panel-rewards #v137-reward-road:has(.v205-reward-card)::before {
  top: 18.5px;
}

#v137-panel-rewards #v137-reward-road .v205-reward-card {
  box-sizing: border-box;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  min-height: 0 !important;
  height: auto;
  padding: 10px 10px 9px !important;
}

#v137-panel-rewards #v137-reward-road .v205-reward-card .v137-reward-state {
  position: static;
  margin-top: 6px;
  padding-top: 5px;
  color: #c7bba4;
  font-size: 10px;
  line-height: 1.4;
  white-space: normal;
  overflow-wrap: anywhere;
}

#v137-panel-rewards #v137-reward-road .v205-reward-card:focus-visible,
#v205-pass-reward-detail button:focus-visible {
  outline: 2px solid #ffe8ad;
  outline-offset: -3px;
}

/* The two milestones have a wider, full-colour gallery. The size is based on
   the actual rewards panel, which can be smaller than the game viewport. */
#v137-panel-rewards #v137-reward-road .is-v205-rare-skin-tier {
  --v205-face-height: 176px;
  --v205-face-height: clamp(135px, calc(100cqh - 163px), 222px);
  width: min(84vw, calc(var(--v205-face-height) * 1.44 + 36px));
  max-width: 360px;
}

#v137-panel-rewards #v137-reward-road .is-v205-rare-skin-tier > .v164-milestone-banner {
  display: none;
}

#v137-panel-rewards #v137-reward-road .is-v205-rare-skin {
  --rare-edge: #d4a96b;
  --rare-wash: #502725;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "art art" "character type" "name name" "state state";
  align-content: start;
  min-width: 0;
  padding: 10px 10px 9px !important;
  border-color: var(--rare-edge);
  background: radial-gradient(ellipse at 50% 0, var(--rare-wash), transparent 77%), #130e15;
  filter: none !important;
  box-shadow: inset 0 0 0 3px #0b090e, inset 0 0 0 4px color-mix(in srgb, var(--rare-edge) 28%, transparent);
}

#v137-panel-rewards #v137-reward-road .is-v205-rare-skin[data-v205-character-id="benito-riana"] {
  --rare-edge: #cf9bc8;
  --rare-wash: #48263f;
}

#v137-panel-rewards #v137-reward-road .is-v205-rare-skin .v200-reward-preview {
  grid-area: art;
  height: auto;
  padding-block: 3px 7px;
}

#v137-panel-rewards #v137-reward-road .is-v205-rare-skin .v200-preview-caption,
#v137-panel-rewards #v137-reward-road .is-v205-rare-skin .v162-trial-mark {
  display: none;
}

#v137-panel-rewards #v137-reward-road .is-v205-rare-skin .v200-preview-skin-face {
  width: min(calc((100% - 8px) / 2), calc(var(--v205-face-height) * .718));
  gap: 4px;
}

#v137-panel-rewards #v137-reward-road .is-v205-rare-skin .v200-preview-skin-face img,
#v205-pass-reward-detail .v200-preview-skin-face img {
  width: 100%;
  height: auto;
  aspect-ratio: .718;
  object-fit: contain;
  box-sizing: border-box;
  display: block;
  border: 1px solid #baaa86;
  border-radius: 4px;
  background: #0b080e;
}

#v137-panel-rewards #v137-reward-road .is-v205-rare-skin .v200-preview-skin-face small,
#v205-pass-reward-detail .v200-preview-skin-face small {
  color: #e3d6be;
  font-size: 11px;
  line-height: 1.3;
}

#v137-panel-rewards #v137-reward-road .is-v205-rare-skin .v205-reward-character {
  grid-area: character;
  color: #efe2ce;
  font-size: 12px;
  font-weight: 600;
}

#v137-panel-rewards #v137-reward-road .is-v205-rare-skin .v137-reward-type {
  grid-area: type;
  align-self: center;
  margin: 0;
  color: var(--rare-edge);
  font-weight: 700;
  line-height: 1.4;
  font-family: inherit;
  font-size: 10px;
  letter-spacing: .04em;
}

#v137-panel-rewards #v137-reward-road .is-v205-rare-skin .v137-reward-name {
  grid-area: name;
  color: #ffedc6;
  margin-top: 1px;
  font-size: clamp(15px, 1.2vw, 19px);
  line-height: 1.3;
}

#v137-panel-rewards #v137-reward-road .is-v205-rare-skin .v137-reward-state {
  grid-area: state;
}

/* The detail sheet is above the clipped shell. Its contents form one vertical
   scroll area, so even on a short screen the last action is reachable. */
#v205-pass-reward-detail {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  box-sizing: border-box;
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
           max(10px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background: rgb(5 4 10 / 82%);
  color: #f0dfc7;
}

#v205-pass-reward-detail[hidden],
#v205-pass-reward-detail [hidden] { display: none !important; }

#v205-pass-reward-detail .v205-reward-detail-panel {
  box-sizing: border-box;
  width: min(100%, 480px);
  max-height: 100%;
  min-height: 0;
  min-width: 0;
  overflow: hidden auto;
  overscroll-behavior: contain;
  touch-action: pan-y pinch-zoom;
  padding: clamp(14px, 2vw, 28px);
  border: 1px solid #ae8b64;
  border-radius: 10px;
  background: radial-gradient(ellipse at top left, #402536, transparent 62%), #141019;
  box-shadow: inset 0 0 0 3px #100d14, inset 0 0 0 4px #d4ae7329, 0 16px 60px #000b;
  scrollbar-color: #ad895e #17111b;
  scrollbar-width: thin;
}

#v205-pass-reward-detail.is-v205-rare-skin .v205-reward-detail-panel { width: min(100%, 640px); }

#v205-pass-reward-detail .v205-reward-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

#v205-pass-reward-detail .v205-reward-detail-close,
#v205-pass-reward-detail .v205-reward-detail-action {
  box-sizing: border-box;
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid #997b5d;
  border-radius: 4px;
  color: #f7e6c3;
  background: #211923;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

#v205-pass-reward-detail .v205-reward-detail-close {
  flex: none;
  min-width: 44px;
  padding: 6px 10px;
}

#v205-pass-reward-detail .v205-reward-detail-title {
  margin: 2px 0 0;
  color: #fff0cd;
  font-size: clamp(20px, 3vw, 30px);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

#v205-pass-reward-detail .v205-reward-detail-type {
  margin: 0;
  color: #d8b48a;
  font-size: 13px;
}

#v205-pass-reward-detail .v205-reward-detail-preview {
  margin-block: 12px;
  padding: 10px;
  border-block: 1px solid #ac90563d;
  background: radial-gradient(ellipse at center, #53334358, #130f18);
}

#v205-pass-reward-detail .v200-reward-preview {
  height: auto;
  min-height: 100px;
  gap: 8px;
}

#v205-pass-reward-detail .v200-preview-skin-pair { gap: clamp(8px, 2vw, 20px); }

#v205-pass-reward-detail .v200-preview-skin-face {
  width: min(calc((100% - clamp(8px, 2vw, 20px)) / 2), 27dvh, 224px);
  gap: 6px;
}

#v205-pass-reward-detail .v200-reward-preview > img {
  width: auto;
  min-width: 0;
  height: clamp(86px, 25dvh, 180px);
  object-fit: contain;
}

#v205-pass-reward-detail :is(.v205-reward-detail-description, .v205-reward-detail-requirement, .v205-reward-detail-status) {
  display: block;
  margin: 6px 0;
  font-size: 14px;
  line-height: 1.55;
  color: #e0d3bf;
}

#v205-pass-reward-detail .v205-reward-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

#v205-pass-reward-detail .v205-reward-detail-actions:not(:has(button:not([hidden]))) { display: none; }

#v205-pass-reward-detail .v205-reward-detail-action:is(.is-primary, .is-trial) {
  background: linear-gradient(135deg, #66405a, #382235);
  border-color: #c49d77;
}

#v205-pass-reward-detail button:disabled { opacity: .55; cursor: default; }

#v205-pass-reward-detail .v205-reward-detail-character {
  margin: 3px 0 0;
  font-size: 14px;
  color: #e6c8b6;
}

#v205-pass-reward-detail .v205-reward-detail-tier {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  color: #d9b687;
}

@media (min-width: 620px) and (max-height: 560px) {
  #v205-pass-reward-detail.is-v205-rare-skin .v205-reward-detail-panel {
    width: min(100%, 780px);
    padding: 12px 18px;
  }
  #v205-pass-reward-detail.is-v205-rare-skin .v205-reward-detail-body {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    align-items: center;
    gap: 16px;
  }
  #v205-pass-reward-detail.is-v205-rare-skin .v205-reward-detail-preview {
    margin-block: 6px;
  }
}
