/* ---------------------------------------------------------------------------
   Chelsea particle styles: backgrounds per style and the style picker.
   Grounds stay dark and romantic so additive glows read.
   --------------------------------------------------------------------------- */

/* Rose petals: deep velvet crimson. */
body.theme-chelsea.style-roses {
  --accent: #ff3d63;
  --accent-soft: #ffb3c1;
  --chip-border: rgba(255, 150, 170, 0.38);
  background:
    radial-gradient(60% 40% at 50% 105%, rgba(160, 0, 40, 0.28) 0%, rgba(160, 0, 40, 0) 70%),
    radial-gradient(120% 90% at 50% 42%, #3d0a18 0%, #1c040b 45%, #0a0105 100%);
}

/* Starry night: midnight blue with a static field of tiny stars. */
body.theme-chelsea.style-starry {
  --accent: #ffc94a;
  --accent-soft: #ffe7a3;
  --ink: #f3ecd8;
  --chip-bg: rgba(255, 215, 106, 0.10);
  --chip-bg-hover: rgba(255, 215, 106, 0.22);
  --chip-border: rgba(255, 233, 168, 0.36);
  --chip-border-hover: rgba(255, 233, 168, 0.7);
  background:
    radial-gradient(70% 50% at 50% 110%, rgba(60, 90, 200, 0.35) 0%, rgba(60, 90, 200, 0) 70%),
    radial-gradient(40% 30% at 78% 16%, rgba(255, 215, 120, 0.12) 0%, rgba(255, 215, 120, 0) 70%),
    linear-gradient(180deg, #03051a 0%, #0a1240 55%, #14205a 100%);
}

body.theme-chelsea.style-starry::before,
body.theme-chelsea.style-neon::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

body.theme-chelsea.style-starry::before {
  background-image:
    radial-gradient(1px 1px at 12% 18%, rgba(255, 255, 255, 0.8) 50%, transparent 51%),
    radial-gradient(1px 1px at 34% 8%, rgba(255, 240, 200, 0.7) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 58% 24%, rgba(255, 255, 255, 0.75) 50%, transparent 51%),
    radial-gradient(1px 1px at 81% 36%, rgba(200, 220, 255, 0.7) 50%, transparent 51%),
    radial-gradient(1px 1px at 22% 62%, rgba(255, 255, 255, 0.6) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 90% 70%, rgba(255, 240, 200, 0.6) 50%, transparent 51%),
    radial-gradient(1px 1px at 46% 84%, rgba(255, 255, 255, 0.5) 50%, transparent 51%),
    radial-gradient(1px 1px at 6% 90%, rgba(200, 220, 255, 0.55) 50%, transparent 51%);
  background-size: 420px 420px;
  opacity: 0.8;
  animation: chs-twinkle 5s ease-in-out infinite alternate;
}

@keyframes chs-twinkle {
  from { opacity: 0.45; }
  to { opacity: 0.9; }
}

/* Butterflies: dusky garden twilight with a warm low glow. */
body.theme-chelsea.style-butterflies {
  --accent: #8fd8ff;
  --accent-soft: #cfeaff;
  --chip-border: rgba(180, 220, 255, 0.36);
  background:
    radial-gradient(70% 40% at 50% 108%, rgba(255, 170, 110, 0.18) 0%, rgba(255, 170, 110, 0) 70%),
    radial-gradient(120% 90% at 50% 45%, #1f2b4f 0%, #141633 45%, #07060f 100%);
}

/* Cherry blossom: twilight plum with a pale moon glow (particles paint over). */
body.theme-chelsea.style-sakura {
  --accent: #ff8fbf;
  --accent-soft: #ffd3e6;
  background:
    radial-gradient(22% 18% at 80% 18%, rgba(255, 230, 240, 0.18) 0%, rgba(255, 230, 240, 0) 70%),
    linear-gradient(180deg, #171033 0%, #2a1840 50%, #3d1c3f 100%);
}

/* Fireworks: clear night sky over a faint city-warm horizon. */
body.theme-chelsea.style-fireworks {
  --accent: #ffd23f;
  --accent-soft: #ffe9a0;
  --chip-border: rgba(255, 230, 160, 0.34);
  background:
    radial-gradient(90% 30% at 50% 104%, rgba(255, 110, 80, 0.2) 0%, rgba(255, 110, 80, 0) 70%),
    linear-gradient(180deg, #02030c 0%, #0a0b24 62%, #1c0d26 100%);
}

/* Bokeh dream: soft lavender haze. */
body.theme-chelsea.style-bokeh {
  --accent: #d7b8ff;
  --accent-soft: #eadcff;
  --chip-border: rgba(215, 184, 255, 0.36);
  background:
    radial-gradient(50% 40% at 25% 30%, rgba(255, 170, 200, 0.12) 0%, rgba(255, 170, 200, 0) 70%),
    radial-gradient(50% 40% at 75% 70%, rgba(150, 190, 255, 0.1) 0%, rgba(150, 190, 255, 0) 70%),
    radial-gradient(120% 90% at 50% 40%, #2a1b3d 0%, #150e24 50%, #07050d 100%);
}

/* Neon love: ink black with cyan and magenta corners and a retro floor grid. */
body.theme-chelsea.style-neon {
  --accent: #ff2bd6;
  --accent-soft: #7ff6ff;
  --ink: #e8f8ff;
  --chip-bg: rgba(0, 240, 255, 0.08);
  --chip-bg-hover: rgba(255, 43, 214, 0.2);
  --chip-border: rgba(0, 240, 255, 0.4);
  --chip-border-hover: rgba(255, 43, 214, 0.75);
  background:
    radial-gradient(60% 50% at 0% 100%, rgba(0, 240, 255, 0.14) 0%, rgba(0, 240, 255, 0) 70%),
    radial-gradient(60% 50% at 100% 0%, rgba(255, 43, 214, 0.16) 0%, rgba(255, 43, 214, 0) 70%),
    #06020d;
}

body.theme-chelsea.style-neon::before {
  top: auto;
  height: 38%;
  background-image:
    linear-gradient(rgba(255, 43, 214, 0.5) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 240, 255, 0.45) 1px, transparent 1px);
  background-size: 48px 48px;
  background-position: center top;
  transform: perspective(300px) rotateX(58deg);
  transform-origin: 50% 100%;
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 70%);
  mask-image: linear-gradient(180deg, transparent 0%, #000 70%);
  opacity: 0.22;
}

/* Galaxy: violet core fading into deep space. */
body.theme-chelsea.style-galaxy {
  --accent: #b18cff;
  --accent-soft: #d9c7ff;
  --chip-border: rgba(190, 160, 255, 0.36);
  background:
    radial-gradient(30% 24% at 50% 50%, rgba(200, 140, 255, 0.2) 0%, rgba(200, 140, 255, 0) 70%),
    radial-gradient(120% 90% at 50% 50%, #2b1450 0%, #120a2e 42%, #04030d 100%);
}

/* Candy hearts: warm cocoa-plum so pastel candies pop (particles paint over). */
body.theme-chelsea.style-candy {
  --accent: #ff9ec7;
  --accent-soft: #fff3a6;
  background:
    radial-gradient(120% 90% at 50% 40%, #3a1838 0%, #221028 50%, #0e0612 100%);
}

/* Diamonds: cool blue-steel velvet. */
body.theme-chelsea.style-diamonds {
  --accent: #a8e6ff;
  --accent-soft: #e8f7ff;
  --ink: #e6f2ff;
  --chip-bg: rgba(168, 230, 255, 0.08);
  --chip-bg-hover: rgba(168, 230, 255, 0.2);
  --chip-border: rgba(200, 235, 255, 0.36);
  --chip-border-hover: rgba(200, 235, 255, 0.7);
  background:
    radial-gradient(40% 30% at 50% 30%, rgba(170, 220, 255, 0.1) 0%, rgba(170, 220, 255, 0) 70%),
    radial-gradient(120% 90% at 50% 35%, #1e2c44 0%, #0f1628 50%, #05070f 100%);
}

/* Love letters: rosewood evening. */
body.theme-chelsea.style-letters {
  --accent: #ff6fa8;
  --accent-soft: #ffd1e3;
  background:
    radial-gradient(120% 90% at 50% 40%, #3b1022 0%, #210815 50%, #0c0308 100%);
}

/* Fireflies: summer forest night. */
body.theme-chelsea.style-fireflies {
  --accent: #ffe26a;
  --accent-soft: #fff5b8;
  --ink: #f4f1d6;
  --chip-bg: rgba(255, 226, 106, 0.08);
  --chip-bg-hover: rgba(255, 226, 106, 0.2);
  --chip-border: rgba(255, 240, 170, 0.34);
  --chip-border-hover: rgba(255, 240, 170, 0.7);
  background:
    radial-gradient(80% 40% at 50% 108%, rgba(40, 110, 60, 0.35) 0%, rgba(40, 110, 60, 0) 70%),
    radial-gradient(120% 90% at 50% 55%, #0f2a22 0%, #0a1a14 45%, #030806 100%);
}

/* Snowy kisses: wintry blue-plum. */
body.theme-chelsea.style-kisses {
  --accent: #ff4f8b;
  --accent-soft: #ffe4ef;
  background:
    radial-gradient(60% 30% at 50% 105%, rgba(220, 230, 255, 0.1) 0%, rgba(220, 230, 255, 0) 70%),
    radial-gradient(120% 90% at 50% 30%, #2a2340 0%, #161229 50%, #07060f 100%);
}

/* Rainbow love: deep aubergine. */
body.theme-chelsea.style-rainbow {
  --accent: #ffe14d;
  --accent-soft: #ffc2e6;
  background:
    radial-gradient(120% 90% at 50% 45%, #2a0d2e 0%, #150619 50%, #070209 100%);
}

/* ---------------------------------------------------------------------------
   Style picker (bottom right)
   --------------------------------------------------------------------------- */
.chs-picker {
  position: fixed;
  right: calc(14px + env(safe-area-inset-right, 0px));
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  z-index: 3;
  font-family: var(--ui-font);
  color: var(--ink);
}

/* Open, the sheet sits on the modal layer above activity HUDs and boards (z4). */
.chs-picker.is-open { z-index: 5; }

.chs-picker[hidden],
.chs-panel[hidden] { display: none !important; }

.chs-fab {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 52px;
  height: 52px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--chip-border);
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0) 60%),
    rgba(18, 6, 20, 0.5);
  color: var(--ink);
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 6px 22px -8px var(--accent), 0 0 0 0 rgba(0, 0, 0, 0);
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.2s ease, border-color 0.25s ease, box-shadow 0.3s ease;
}

.chs-fab:hover { transform: translateY(-2px) scale(1.05); border-color: var(--chip-border-hover); }
.chs-fab:active { transform: scale(0.95); }
.chs-fab:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 3px; }
.chs-picker.is-open .chs-fab {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06), 0 6px 26px -6px var(--accent);
}

.chs-fab-emoji { display: block; transition: transform 0.3s ease; }
.chs-picker.is-open .chs-fab-emoji { transform: rotate(-12deg) scale(1.08); }
.chs-fab.chs-pop .chs-fab-emoji { animation: chs-pop 0.55s cubic-bezier(0.3, 1.6, 0.5, 1); }

@keyframes chs-pop {
  0% { transform: scale(0.4) rotate(-30deg); }
  60% { transform: scale(1.25) rotate(8deg); }
  100% { transform: scale(1) rotate(0); }
}

.chs-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 12px);
  width: min(330px, calc(100vw - 28px));
  max-height: min(560px, calc(100vh - 110px));
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 10px 12px 12px;
  border-radius: 22px;
  border: 1px solid var(--chip-border);
  background: rgba(16, 6, 20, 0.8);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 18px 50px -12px rgba(0, 0, 0, 0.7), 0 0 40px -18px var(--accent);
  transform-origin: 100% 100%;
  animation: chs-panel-in 0.22s ease-out;
  scrollbar-width: thin;
  scrollbar-color: var(--chip-border) transparent;
}

@keyframes chs-panel-in {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

.chs-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 8px 4px;
}

.chs-title {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  opacity: 0.8;
}

.chs-close {
  appearance: none;
  -webkit-appearance: none;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  padding: 0;
  border-radius: 50%;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  font: 400 22px/1 var(--ui-font);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.chs-close:hover { background: var(--chip-bg-hover); border-color: var(--chip-border); }
.chs-close:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 2px; }

.chs-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.chs-chip {
  appearance: none;
  -webkit-appearance: none;
  min-height: 78px;
  padding: 9px 4px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  font: 600 14px/1.1 var(--ui-font);
  text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.18s ease, box-shadow 0.25s ease;
}

.chs-chip:hover { background: var(--chip-bg-hover); border-color: var(--chip-border); transform: translateY(-1px); }
.chs-chip:active { transform: scale(0.96); }
.chs-chip:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 2px; }

.chs-chip[aria-checked="true"] {
  border-color: var(--accent);
  background: var(--chip-bg-hover);
  box-shadow: inset 0 0 0 1px var(--accent), 0 0 18px -6px var(--accent);
}

.chs-swatch {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #ff3d8c, #ffc7e0);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.22), 0 3px 12px -3px rgba(0, 0, 0, 0.5);
  transition: transform 0.25s ease;
}

.chs-chip:hover .chs-swatch,
.chs-chip[aria-checked="true"] .chs-swatch { transform: rotate(-8deg) scale(1.06); }

.chs-chip-emoji {
  font-size: 21px;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}

.chs-chip-label { letter-spacing: 0.02em; }

.chs-toast {
  position: absolute;
  right: 0;
  bottom: calc(100% + 12px);
  padding: 8px 14px 7px;
  border-radius: 999px;
  border: 1px solid var(--chip-border);
  background: rgba(16, 6, 20, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--ink);
  font: 600 15px/1 var(--ui-font);
  letter-spacing: 0.04em;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.chs-toast.is-on { opacity: 1; transform: none; }
.chs-picker.is-open .chs-toast { display: none; }

/* Phones: the button sits beside the next button; the panel is a bottom sheet
   floating above the caption. */
@media (max-width: 560px) {
  .chs-picker {
    right: calc(12px + env(safe-area-inset-right, 0px));
    bottom: calc(44px + env(safe-area-inset-bottom, 0px));
  }
  .chs-fab { width: 46px; height: 46px; font-size: 22px; }
  .chs-panel {
    position: fixed;
    left: calc(8px + env(safe-area-inset-left, 0px));
    right: calc(8px + env(safe-area-inset-right, 0px));
    bottom: calc(146px + env(safe-area-inset-bottom, 0px));
    width: auto;
    max-height: calc(100vh - 216px);
    border-radius: 24px;
    transform-origin: 50% 100%;
  }
  .chs-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .chs-chip { min-height: 72px; padding: 8px 2px 7px; font-size: 12.5px; border-radius: 14px; }
  .chs-swatch { width: 36px; height: 36px; }
  .chs-chip-emoji { font-size: 19px; }
}

@supports (height: 100dvh) {
  @media (max-width: 560px) {
    .chs-panel { max-height: calc(100dvh - 216px); }
  }
}

@media (max-width: 380px) {
  .chs-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Narrow and short (small landscape phones, split screen): the sheet would be
   squeezed to a sliver above the caption, so let it use the full height and
   stop just above the button. */
@media (max-width: 560px) and (max-height: 460px) {
  .chs-picker { bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  .chs-panel {
    bottom: calc(70px + env(safe-area-inset-bottom, 0px));
    max-height: calc(100vh - 130px);
  }
  .chs-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .chs-chip { min-height: 62px; padding: 6px 2px; gap: 4px; }
  .chs-swatch { width: 30px; height: 30px; }
}

@supports (height: 100dvh) {
  @media (max-width: 560px) and (max-height: 460px) {
    .chs-panel { max-height: calc(100dvh - 130px); }
  }
}

/* Landscape phones: short screens get a wide panel beside the button. */
@media (max-height: 460px) and (min-width: 561px) {
  .chs-panel {
    right: calc(100% + 10px);
    bottom: 0;
    /* 100vw - 200px keeps the panel's left edge clear of the Play button
       (bottom-left, z4) on small landscape phones such as 568x320. */
    width: min(520px, calc(100vw - 200px));
    max-height: calc(100vh - 90px);
    transform-origin: 100% 100%;
  }
  .chs-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
  .chs-chip { min-height: 64px; padding: 6px 2px; gap: 4px; font-size: 12.5px; }
  .chs-swatch { width: 32px; height: 32px; }
  .chs-chip-emoji { font-size: 17px; }
}

@media (max-height: 460px) and (min-width: 561px) and (max-width: 720px) {
  .chs-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  body.theme-chelsea.style-starry::before { animation: none; }
  .chs-panel,
  .chs-fab.chs-pop .chs-fab-emoji { animation: none; }
  .chs-fab,
  .chs-chip,
  .chs-swatch,
  .chs-toast,
  .chs-fab-emoji { transition: none; }
}
