/* Sweet Swap styles. Colors come from the active theme as CSS variables
   (see js/themes/*.js); sizes scale with --ui for "Bigger pieces & text". */

:root {
  --font: 'Fredoka', 'Nunito', ui-rounded, 'Arial Rounded MT Bold', system-ui, sans-serif;
  --ui: 1;
  --bg-top: #ffdce8;
  --bg-bottom: #fff1d6;
  --dots: rgba(255, 255, 255, .55);
  --text: #5b2e45;
  --text-soft: #9a6b80;
  --on-bg: #5b2e45;
  --on-bg-soft: #9a6b80;
  --panel: #fffaf6;
  --panel-edge: #ffd3e1;
  --accent: #ff5c8a;
  --accent-dark: #d0336a;
  --accent2: #48c9a3;
  --accent2-dark: #24977a;
  --neutral: #fff0e0;
  --neutral-dark: #e3c3a6;
  --board: rgba(255, 255, 255, .5);
  --board-edge: #fff;
  --tile1: rgba(255, 244, 248, .85);
  --tile2: rgba(255, 228, 238, .85);
  --jelly1: rgba(255, 105, 170, .42);
  --jelly2: rgba(214, 40, 130, .62);
  --star: #ffc93c;
  --path: #ffb3cb;
}

html.big { --ui: 1.2; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html {
  height: 100%;
  font-size: calc(16px * var(--ui));
  background: var(--bg-bottom);
}

body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: var(--font);
  font-weight: 500;
  color: var(--text);
  background: linear-gradient(var(--bg-top), var(--bg-bottom));
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  transition: background .4s;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(var(--dots) 2.5px, transparent 3px), radial-gradient(var(--dots) 1.5px, transparent 2px);
  background-size: 34px 34px, 34px 34px;
  background-position: 0 0, 17px 17px;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.screen {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  animation: screen-in .35s ease both;
}

[hidden] { display: none !important; }

.icon { display: inline-grid; place-items: center; line-height: 0; }
.icon svg { width: 1.3em; height: 1.3em; }

/* ---- buttons ------------------------------------------------------------ */

.btn {
  --b: var(--accent);
  --bd: var(--accent-dark);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  min-height: 3.3rem;
  padding: .7rem 1.5rem;
  border: 0;
  border-radius: 999px;
  font-family: inherit;
  font-size: 1.2rem;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .18);
  background: var(--b);
  box-shadow: 0 5px 0 var(--bd), 0 9px 18px rgba(0, 0, 0, .14);
  cursor: pointer;
  transition: transform .08s, box-shadow .08s, filter .15s;
}
.btn::after {
  content: '';
  position: absolute;
  left: 12%;
  right: 12%;
  top: 5px;
  height: 38%;
  border-radius: 999px;
  background: linear-gradient(rgba(255, 255, 255, .5), rgba(255, 255, 255, 0));
  pointer-events: none;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--bd), 0 3px 8px rgba(0, 0, 0, .14); }
.btn.secondary { --b: var(--accent2); --bd: var(--accent2-dark); }
.btn.neutral { --b: var(--neutral); --bd: var(--neutral-dark); color: var(--text); text-shadow: none; }
.btn.big { min-height: 4rem; font-size: 1.5rem; }
.btn.danger { color: #c0392b; }
.btn .icon svg { width: 1.35em; height: 1.35em; }
.btn-stack { display: flex; flex-direction: column; line-height: 1.05; text-align: left; }
.btn-stack small { font-size: .8rem; font-weight: 500; opacity: .9; }

.icon-btn {
  flex-shrink: 0;
  width: 3.1rem;
  height: 3.1rem;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--text);
  background: var(--panel);
  box-shadow: 0 4px 0 var(--panel-edge), 0 6px 14px rgba(0, 0, 0, .1);
  cursor: pointer;
}
.icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--panel-edge); }
.icon-btn .icon svg { width: 1.6rem; height: 1.6rem; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .35rem .9rem .35rem .6rem;
  border-radius: 999px;
  background: var(--panel);
  box-shadow: 0 3px 0 var(--panel-edge);
  font-weight: 600;
  font-size: 1.1rem;
}
.star-chip .icon { color: var(--star); filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .2)); }

/* ---- home --------------------------------------------------------------- */

.home-screen {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 1.25rem;
  text-align: center;
}
.home-inner {
  margin: auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.6rem;
  padding: 3.4rem 0 1.5rem;
}
.home-top { position: absolute; top: .9rem; left: 1rem; right: 1rem; z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: .6rem; }
.account-chip { color: var(--text); text-decoration: none; max-width: 60%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.account-chip .icon { color: var(--accent); }
.account-initial { display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--accent); color: #fff; font-size: .9rem; }
.plus-pill { padding: .05rem .5rem; border-radius: 999px; background: var(--accent); color: #fff; font-size: .75rem; }
.edition-card.locked .edition-swatch { filter: saturate(.85); }
.edition-card.locked .edition-name, .edition-card.locked .edition-meta { opacity: .85; }
.plus-ribbon { display: inline-flex; align-items: center; gap: .2rem; background: var(--accent2); box-shadow: 0 3px 0 var(--accent2-dark); }
.plus-ribbon .icon svg { width: .85rem; height: .85rem; }
.upsell-modal .upsell-pieces { display: flex; justify-content: center; gap: .3rem; padding: .7rem; border-radius: 1rem; margin-bottom: .6rem; }
.upsell-piece { width: 3.2rem; height: 3.2rem; background-size: contain; background-repeat: no-repeat; }
.upsell-list { list-style: none; padding: 0; margin: .4rem 0 .8rem; text-align: left; display: grid; gap: .35rem; font-size: 1.05rem; }
.upsell-list li { display: flex; gap: .5rem; align-items: center; }
.upsell-list .icon { color: var(--accent2-dark); }
.plan-options { display: grid; gap: .5rem; }
.plan-option { display: flex; justify-content: space-between; align-items: center; padding: .75rem 1rem; border-radius: 1rem; border: 3px solid var(--neutral-dark); background: #fff; font: 600 1.05rem var(--font); color: var(--text); cursor: pointer; }
.plan-option.on { border-color: var(--accent); background: var(--neutral); }
.plan-save { font-size: .8rem; padding: .1rem .5rem; border-radius: 999px; background: var(--accent2); color: #fff; }
.upsell-trial { margin: .6rem 0 0; font-weight: 600; color: var(--text-soft); }
.setting-link { color: var(--text); text-decoration: none; }
.link-arrow { transform: rotate(180deg); color: var(--text-soft); }
.about a { color: var(--accent-dark); }
.logo-pieces { display: flex; justify-content: center; gap: .35rem; margin-bottom: .4rem; }
.logo-piece {
  width: 3.4rem;
  height: 3.4rem;
  background-size: contain;
  background-repeat: no-repeat;
  animation: bob 2.6s ease-in-out infinite;
}
.logo-title {
  margin: 0;
  font-size: clamp(3.2rem, 15vw, 6rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: .01em;
}
.logo-title span {
  display: inline-block;
  color: var(--c);
  text-shadow: 0 .06em 0 var(--cd), 0 .12em .25em rgba(0, 0, 0, .18);
  -webkit-text-stroke: .02em rgba(255, 255, 255, .6);
  animation: wave 3.2s ease-in-out infinite;
  animation-delay: calc(var(--i) * .12s);
}
.logo-title .space { width: .3em; }
.logo-sub {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: .5rem;
  margin-top: .5rem;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--on-bg-soft);
}
.season-badge {
  padding: .15rem .6rem;
  border-radius: 999px;
  font-size: .75rem;
  letter-spacing: .06em;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 2px 0 var(--accent-dark);
  animation: throb 1.8s ease-in-out infinite;
}
.editions { width: min(34rem, 100%); }
.editions-title { margin: 0 0 .7rem; font-size: 1.3rem; font-weight: 700; color: var(--on-bg); }
.edition-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .8rem; }
@media (min-width: 560px) { .edition-grid { grid-template-columns: repeat(3, 1fr); } }
.edition-card {
  position: relative;
  padding: .5rem .5rem .6rem;
  border: 0;
  border-radius: 1.2rem;
  font-family: inherit;
  text-align: left;
  color: var(--text);
  background: var(--panel);
  box-shadow: 0 4px 0 var(--panel-edge), 0 8px 18px rgba(0, 0, 0, .1), inset 0 0 0 3px transparent;
  cursor: pointer;
}
.edition-card:active { transform: translateY(3px); }
.edition-card.on { box-shadow: 0 4px 0 var(--panel-edge), 0 8px 18px rgba(0, 0, 0, .1), inset 0 0 0 4px var(--accent); }
.edition-swatch { display: flex; justify-content: center; gap: .1rem; padding: .55rem .2rem; border-radius: .85rem; }
.edition-piece { width: 2.1rem; height: 2.1rem; background-size: contain; background-repeat: no-repeat; }
.edition-name { margin: .45rem .2rem 0; font-size: 1.05rem; font-weight: 700; line-height: 1.15; }
.edition-meta { display: flex; justify-content: space-between; align-items: center; margin: .15rem .2rem 0; font-size: .85rem; color: var(--text-soft); }
.edition-stars { display: inline-flex; align-items: center; gap: .15rem; font-weight: 700; color: var(--text); }
.edition-stars .icon { color: var(--star); }
.edition-stars .icon svg { width: 1rem; height: 1rem; }
.season-ribbon {
  position: absolute;
  top: -.55rem;
  right: -.3rem;
  z-index: 1;
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 3px 0 var(--accent-dark);
  transform: rotate(4deg);
}
.menu { display: flex; flex-direction: column; gap: 1.15rem; width: min(21rem, 100%); }
.home-footer { display: flex; align-items: center; gap: .4rem; color: var(--on-bg-soft); font-size: 1rem; }
.home-footer .icon, .about-love .icon { color: var(--accent); }

.menu-row { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.menu-row .btn { padding: .6rem .7rem; font-size: 1.05rem; gap: .35rem; min-height: 3.8rem; }
.menu-row .btn-stack small { font-size: .72rem; }
.btn.done { --b: var(--accent2-dark); }
.btn.advent { --b: #2f9e44; --bd: #1b5e20; background: repeating-linear-gradient(-45deg, #2f9e44 0 14px, #37b24d 14px 28px); }
.btn-emoji { font-size: 1.5rem; line-height: 1; }

.birthday-banner {
  display: flex;
  align-items: center;
  gap: .7rem;
  width: min(21rem, 100%);
  padding: .6rem 1rem;
  border: 0;
  border-radius: 1.2rem;
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  text-align: left;
  background: linear-gradient(120deg, #f06595, #9775fa, #4dabf7);
  background-size: 200% 100%;
  box-shadow: 0 5px 0 #c2255c, 0 10px 24px rgba(0, 0, 0, .15);
  cursor: pointer;
  animation: shimmer-bg 4s ease-in-out infinite, throb 2.4s ease-in-out infinite;
}
.birthday-banner small { font-size: .85rem; font-weight: 600; opacity: .95; }
.birthday-banner-cake { font-size: 2.2rem; line-height: 1; }
.birthday-card { width: min(24rem, 100%); }
.birthday-cake svg { display: block; width: 70%; margin: -.2rem auto .2rem; }
.birthday-cake .flame { transform-box: fill-box; transform-origin: 50% 100%; animation: flicker .5s ease-in-out infinite alternate; }
.birthday-title { margin: .2rem 0 .7rem; font-size: 2.1rem; line-height: 1.05; color: var(--accent-dark); }
.birthday-line { margin: .5rem 0; font-size: 1.1rem; line-height: 1.45; }
.birthday-signature { display: flex; justify-content: center; align-items: center; gap: .4rem; margin: .9rem 0 0; font-size: 1.2rem; font-weight: 700; color: var(--accent-dark); }
.birthday-signature .icon { color: var(--accent); }

.daily-intro { margin-bottom: .8rem; }
.daily-date { font-size: 1.15rem; font-weight: 600; color: var(--text-soft); }
.daily-streak { margin-top: .5rem; font-size: 1.1rem; font-weight: 700; }
.week-strip { display: flex; justify-content: center; gap: .35rem; margin-top: .6rem; }
.week-day { display: flex; flex-direction: column; align-items: center; gap: .15rem; color: var(--text-soft); font-size: .8rem; font-weight: 600; }
.week-dot { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%; background: var(--neutral); box-shadow: inset 0 0 0 2px var(--neutral-dark); color: #fff; }
.week-dot .icon svg { width: 1.1rem; height: 1.1rem; stroke-width: 3.5; }
.week-day.done .week-dot { background: var(--accent2); box-shadow: none; }
.week-day.today .week-dot { box-shadow: inset 0 0 0 3px var(--accent); }
.week-day.today.done .week-dot { box-shadow: inset 0 0 0 3px var(--accent2-dark); }

.advent-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 1rem 2rem; }
.advent-message { width: min(30rem, 100%); margin: .3rem auto 1rem; text-align: center; font-size: 1.1rem; line-height: 1.4; font-weight: 600; color: var(--on-bg); }
.advent-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: .5rem; width: min(30rem, 100%); margin: 0 auto; }
.advent-door {
  position: relative;
  aspect-ratio: 1;
  max-width: 100%;
  border: 0;
  border-radius: .9rem;
  display: grid;
  place-items: center;
  font-family: inherit;
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #e03148, #a11a2e);
  box-shadow: 0 4px 0 #7a1020, inset 0 0 0 3px rgba(255, 255, 255, .35);
  text-shadow: 0 2px 0 rgba(0, 0, 0, .2);
  cursor: pointer;
}
.advent-door:nth-child(3n) { background: linear-gradient(135deg, #2f9e44, #1b5e20); box-shadow: 0 4px 0 #134516, inset 0 0 0 3px rgba(255, 255, 255, .35); }
.advent-door:nth-child(4n) { background: linear-gradient(135deg, #f59f00, #b36b00); box-shadow: 0 4px 0 #7a4a00, inset 0 0 0 3px rgba(255, 255, 255, .35); }
.advent-door.big { background: linear-gradient(135deg, #ffd43b, #e0a800); box-shadow: 0 4px 0 #9c7500, inset 0 0 0 3px rgba(255, 255, 255, .6); }
.advent-door.locked { filter: saturate(.35) brightness(.95); opacity: .75; }
.advent-door.opened { background: #fffdf7; box-shadow: 0 4px 0 var(--panel-edge), inset 0 0 0 3px var(--panel-edge); }
.advent-door.today { animation: throb 1.4s ease-in-out infinite; box-shadow: 0 4px 0 #7a1020, 0 0 0 4px #ffd43b; }
.door-emoji { font-size: 1.9rem; }
.door-lock { position: absolute; right: .25rem; bottom: .25rem; opacity: .85; }
.door-lock svg { width: .9rem !important; height: .9rem !important; }
.advent-surprise { margin: .8rem auto .2rem; padding: .8rem; border-radius: 1.2rem; background: var(--neutral); }
.advent-emoji { font-size: 3.6rem; line-height: 1.1; animation: star-pop .6s cubic-bezier(.2, 1.6, .5, 1); }
.advent-text { margin-top: .3rem; font-size: 1.2rem; font-weight: 700; }

/* ---- top bar -------------------------------------------------------------- */

.topbar { display: flex; align-items: center; gap: .8rem; padding: .8rem 1rem .4rem; }
.topbar h2 { flex: 1; margin: 0; text-align: center; font-size: 1.6rem; font-weight: 700; color: var(--on-bg); line-height: 1.1; }
.topbar-spacer { width: 3.1rem; }

/* ---- level map ------------------------------------------------------------ */

.map-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: .5rem 0 2rem; }
.map-path { position: relative; width: min(26rem, 100%); margin: 0 auto; }
.map-row { position: relative; height: 6.4rem; }
.map-link { position: absolute; left: 0; top: 50%; width: 100%; height: 100%; pointer-events: none; }
.map-link svg { display: block; overflow: visible; }
.map-link line { stroke: var(--path); stroke-width: 9; stroke-linecap: round; stroke-dasharray: .1 19; }
.level-node {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 4.4rem;
  height: 4.4rem;
  border: 0;
  border-radius: 50%;
  font-family: inherit;
  font-size: 1.7rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .18);
  background: radial-gradient(circle at 34% 28%, rgba(255, 255, 255, .6), transparent 42%), var(--accent);
  box-shadow: 0 5px 0 var(--accent-dark), 0 10px 20px rgba(0, 0, 0, .16), inset 0 0 0 4px rgba(255, 255, 255, .5);
  cursor: pointer;
  z-index: 1;
}
.level-node.done {
  background: radial-gradient(circle at 34% 28%, rgba(255, 255, 255, .6), transparent 42%), var(--accent2);
  box-shadow: 0 5px 0 var(--accent2-dark), 0 10px 20px rgba(0, 0, 0, .16), inset 0 0 0 4px rgba(255, 255, 255, .5);
}
.level-node.locked {
  color: #fff;
  background: #d8cfd4;
  box-shadow: 0 5px 0 #b6acb2, inset 0 0 0 4px rgba(255, 255, 255, .45);
}
.level-node.locked .icon svg { width: 1.5rem; height: 1.5rem; }
.level-node.current { animation: node-pulse 1.8s ease-in-out infinite; }
.level-node.current::before {
  content: '';
  position: absolute;
  inset: -.55rem;
  border-radius: 50%;
  border: 4px dashed var(--accent);
  animation: spin 9s linear infinite;
}
.node-stars {
  position: absolute;
  left: 50%;
  top: calc(100% - .2rem);
  transform: translateX(-50%);
  display: flex;
}
.node-stars .icon svg, .mini-stars .icon svg { width: 1.25rem; height: 1.25rem; }
.node-stars .icon, .mini-stars .icon { color: rgba(0, 0, 0, .15); }
.node-stars .icon.lit, .mini-stars .icon.lit { color: var(--star); filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .25)); }
.map-decor {
  position: absolute;
  top: 50%;
  font-size: 2.3rem;
  transform: translate(-50%, -50%) rotate(-10deg);
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .12));
  animation: bob 4s ease-in-out infinite;
}
.chapter-banner {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: fit-content;
  margin: .9rem auto 1.2rem;
  padding: .45rem 1.6rem .55rem;
  border-radius: 1.2rem;
  background: var(--panel);
  box-shadow: 0 4px 0 var(--panel-edge), 0 8px 18px rgba(0, 0, 0, .08);
  font-size: 1.25rem;
  font-weight: 700;
}
.chapter-banner small { font-size: .8rem; font-weight: 600; color: var(--text-soft); text-transform: uppercase; letter-spacing: .1em; }

/* ---- game ----------------------------------------------------------------- */

.game-screen { padding: .6rem .7rem .7rem; gap: .55rem; }
.hud { display: flex; align-items: center; gap: .6rem; }
.hud-mid {
  flex: 1;
  min-width: 0;
  padding: .3rem .9rem .5rem;
  border-radius: 1.3rem;
  text-align: center;
  background: var(--panel);
  box-shadow: 0 4px 0 var(--panel-edge);
}
.hud-title { font-size: .9rem; font-weight: 600; color: var(--text-soft); line-height: 1.2; }
.score-num { font-size: 1.45rem; font-weight: 700; line-height: 1.1; }
.score-bar { position: relative; height: .75rem; margin: .3rem .5rem .15rem; border-radius: 999px; background: rgba(0, 0, 0, .08); }
.score-fill { height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--accent2), var(--accent)); transition: width .5s ease; }
.star-mark { position: absolute; top: 50%; transform: translate(-50%, -50%); color: #fff; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .35)); }
.star-mark .icon svg { width: 1.45rem; height: 1.45rem; }
.star-mark.lit { color: var(--star); }
.star-mark.lit .icon { animation: star-pop .45s cubic-bezier(.2, 1.6, .5, 1); }
.moves {
  flex-shrink: 0;
  width: 4.6rem;
  height: 4.6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 1.3rem;
  color: #fff;
  background: radial-gradient(circle at 30% 25%, rgba(255, 255, 255, .45), transparent 45%), var(--accent);
  box-shadow: 0 4px 0 var(--accent-dark);
  text-shadow: 0 2px 0 rgba(0, 0, 0, .15);
}
.moves.relax { background: radial-gradient(circle at 30% 25%, rgba(255, 255, 255, .45), transparent 45%), var(--accent2); box-shadow: 0 4px 0 var(--accent2-dark); }
.moves-num { font-size: 2rem; font-weight: 700; line-height: 1; }
.best-num { font-size: 1.1rem; }
.moves-label { font-size: .78rem; font-weight: 600; opacity: .95; }
.moves.low { animation: throb 1s ease-in-out infinite; }

.goals { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; min-height: 0; }
.goals:empty { display: none; }
.goal {
  display: flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .8rem .2rem .3rem;
  border-radius: 999px;
  background: var(--panel);
  box-shadow: 0 3px 0 var(--panel-edge);
  font-size: 1.25rem;
  font-weight: 700;
}
.goal.done { color: var(--accent2-dark); }
.goal-count { display: inline-flex; min-width: 1.2rem; justify-content: center; }
.goal-count .icon svg { stroke-width: 3.5; }
.goal-icon { width: 2.1rem; height: 2.1rem; flex-shrink: 0; background-size: contain; background-repeat: no-repeat; background-position: center; }
.jelly-icon { border-radius: 28%; background: var(--jelly2); box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .6); transform: scale(.8); }
.score-icon { display: grid; place-items: center; color: var(--star); }
.score-icon .icon svg { width: 1.9rem; height: 1.9rem; filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .25)); }

.board-wrap { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; }
.board { position: relative; touch-action: none; }
.board::before {
  content: '';
  position: absolute;
  inset: -10px;
  border-radius: 22px;
  background: var(--board);
  box-shadow: inset 0 0 0 4px var(--board-edge), 0 14px 34px rgba(0, 0, 0, .12);
}
.tiles, .pieces, .fx-layer { position: absolute; inset: 0; }
.pieces { clip-path: inset(0 -40px -40px -40px); }
.fx-layer { pointer-events: none; z-index: 3; }
.tile { position: absolute; left: 0; top: 0; width: var(--cell); height: var(--cell); }
.tile::before, .tile::after { content: ''; position: absolute; inset: 1.5px; border-radius: 24%; }
.tile::before { background: var(--tile1); }
.tile.alt::before { background: var(--tile2); }
.tile::after { transition: background-color .35s, box-shadow .35s; }
.tile.jelly1::after { background: var(--jelly1); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .5); }
.tile.jelly2::after { background: var(--jelly2); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .6), inset 0 0 0 5px rgba(255, 255, 255, .15); }

.piece, .crate { position: absolute; left: 0; top: 0; width: var(--cell); height: var(--cell); will-change: transform; }
.piece-img { position: absolute; inset: 6%; background-size: contain; background-repeat: no-repeat; background-position: center; }
.crate { background-size: 94%; background-repeat: no-repeat; background-position: center; }
.crate.firework { animation: fuse 1.4s ease-in-out infinite; }
.lock { position: absolute; left: 0; top: 0; z-index: 2; width: var(--cell); height: var(--cell); background-size: 100%; background-repeat: no-repeat; pointer-events: none; }
.lock-icon { border-radius: 25%; background-color: var(--neutral-dark); }
.exit {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--cell);
  height: var(--cell);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  color: var(--accent2);
  pointer-events: none;
}
.exit .icon { transform: translateY(78%) rotate(-90deg); filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .25)); animation: nudge 1.4s ease-in-out infinite; }
.exit .icon svg { width: calc(var(--cell) * .42); height: calc(var(--cell) * .42); stroke-width: 3.5; }
.piece.selected .piece-img { animation: selected .8s ease-in-out infinite; }
.piece.hint .piece-img { animation: hint 1.1s ease-in-out infinite; }
.piece.special:not(.hint):not(.selected) .piece-img { animation: shimmer 1.6s ease-in-out infinite; }
.piece.rainbow:not(.hint):not(.selected) .piece-img { animation: shimmer 1.6s ease-in-out infinite, wobble 3s ease-in-out infinite; }
html.no-effects .piece.special .piece-img { animation: none; }

.game-footer { display: flex; justify-content: center; gap: .8rem; }
.game-footer .btn { min-height: 2.9rem; padding: .45rem 1.2rem; font-size: 1.05rem; }

/* Wide screens (tablets, landscape phones): HUD on the left, board on the right. */
@media (min-aspect-ratio: 5/4) {
  .game-screen {
    display: grid;
    grid-template-columns: minmax(14rem, 21rem) 1fr;
    grid-template-rows: auto auto 1fr;
    column-gap: 1rem;
    align-content: start;
  }
  .hud { grid-column: 1; grid-row: 1; }
  .goals { grid-column: 1; grid-row: 2; align-content: flex-start; }
  .game-footer { grid-column: 1; grid-row: 3; align-self: end; flex-direction: column; }
  .board-wrap { grid-column: 2; grid-row: 1 / span 3; height: 100%; }
}

/* ---- effects ---------------------------------------------------------------- */

.sparkle { position: absolute; border-radius: 50%; box-shadow: 0 0 8px currentColor; pointer-events: none; }
.float-text {
  position: absolute;
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 2px 0 var(--c), 0 -1px 0 var(--c), 2px 0 0 var(--c), -2px 0 0 var(--c), 0 4px 8px rgba(0, 0, 0, .25);
}
.beam {
  position: absolute;
  pointer-events: none;
  border-radius: 999px;
  background: linear-gradient(transparent, rgba(255, 255, 255, .95) 35%, #fff 50%, rgba(255, 255, 255, .95) 65%, transparent);
  box-shadow: 0 0 18px rgba(255, 255, 255, .9);
}
.beam.vertical { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .95) 35%, #fff 50%, rgba(255, 255, 255, .95) 65%, transparent); }
.ring { position: absolute; border-radius: 50%; border: 6px solid #fff; box-shadow: 0 0 20px #fff, inset 0 0 20px #fff; pointer-events: none; }
.flash { position: absolute; inset: -10px; border-radius: 22px; background: #fff; pointer-events: none; }
.big-word {
  position: absolute;
  left: 50%;
  top: 45%;
  z-index: 6;
  width: max-content;
  max-width: 94vw;
  font-size: clamp(2rem, 9vw, 3.8rem);
  font-weight: 700;
  line-height: 1.05;
  text-align: center;
  color: #fff;
  pointer-events: none;
  text-shadow: 0 4px 0 var(--accent-dark), 0 -2px 0 var(--accent-dark), 3px 0 0 var(--accent-dark), -3px 0 0 var(--accent-dark), 0 10px 24px rgba(0, 0, 0, .25);
}
.confetti { position: fixed; top: -24px; z-index: 100; border-radius: 3px; pointer-events: none; }

/* ---- modals ----------------------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(50, 25, 40, .45);
  animation: fade-in .2s ease both;
}
.modal-backdrop.closing { animation: fade-out .2s ease both; pointer-events: none; }
.modal {
  width: min(25rem, 100%);
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  padding: 1.4rem 1.3rem 1.4rem;
  border-radius: 1.8rem;
  text-align: center;
  background: var(--panel);
  box-shadow: 0 8px 0 var(--panel-edge), 0 24px 60px rgba(0, 0, 0, .28);
  animation: pop-in .38s cubic-bezier(.2, 1.4, .5, 1) both;
}
.modal-title { margin: 0 0 .7rem; font-size: 2rem; font-weight: 700; color: var(--accent-dark); line-height: 1.1; }
.modal-text { margin: .2rem 0 .8rem; font-size: 1.15rem; line-height: 1.4; }
.modal-buttons { display: flex; flex-direction: column; gap: .85rem; margin-top: 1.2rem; }
.goal-list { display: flex; flex-direction: column; gap: .5rem; text-align: left; }
.goal-line {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .45rem .8rem .45rem .5rem;
  border-radius: 1rem;
  background: var(--neutral);
  font-size: 1.15rem;
  font-weight: 600;
}
.goal-line span { flex: 1; }
.goal-line.done { color: var(--accent2-dark); }
.goal-line .goal-icon { width: 2.4rem; height: 2.4rem; }
.intro-moves { margin-top: .7rem; font-size: 1.1rem; font-weight: 600; color: var(--text-soft); }
.tip {
  display: flex;
  gap: .6rem;
  align-items: flex-start;
  margin-top: .9rem;
  padding: .8rem 1rem;
  border-radius: 1rem;
  border: 2px dashed var(--panel-edge);
  font-size: 1.1rem;
  line-height: 1.4;
  text-align: left;
}
.tip .icon { color: var(--accent); margin-top: .15rem; }
.win-stars { display: flex; justify-content: center; align-items: flex-end; gap: .2rem; margin: .2rem 0 .4rem; }
.win-star { color: rgba(0, 0, 0, .1); }
.win-star .icon svg { width: 4.4rem; height: 4.4rem; }
.win-star:nth-child(2) { transform: translateY(-.7rem); }
.win-star:nth-child(2) .icon svg { width: 5.4rem; height: 5.4rem; }
.win-star.lit { color: var(--star); filter: drop-shadow(0 3px 0 rgba(0, 0, 0, .18)); }
.win-star.lit .icon { animation: star-pop .55s cubic-bezier(.2, 1.7, .5, 1); }
.win-score { font-size: 2.4rem; font-weight: 700; line-height: 1; }
.win-sub { margin-top: .3rem; font-size: 1.1rem; color: var(--text-soft); font-weight: 600; }
.settings-modal { width: min(34rem, 100%); text-align: left; }
.settings-modal .modal-title { text-align: center; }

/* ---- settings ----------------------------------------------------------------- */

.settings-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 1rem 2.5rem; }
.settings { width: min(34rem, 100%); margin: 0 auto; }
.settings-section { margin: 1.2rem .4rem .55rem; font-size: .9rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--on-bg-soft); }
.modal .settings-section { color: var(--text-soft); }
.settings > .settings-section:first-child { margin-top: .4rem; }
.setting {
  display: flex;
  align-items: center;
  gap: .9rem;
  margin-bottom: .6rem;
  padding: .85rem 1rem;
  border-radius: 1.1rem;
  background: var(--panel);
  box-shadow: 0 3px 0 var(--panel-edge);
  cursor: pointer;
}
.setting.choice { flex-wrap: wrap; cursor: default; }
.setting-text { flex: 1; min-width: 9rem; }
.setting-label { font-size: 1.15rem; font-weight: 600; }
.setting-help { font-size: .92rem; color: var(--text-soft); }
.switch {
  position: relative;
  flex-shrink: 0;
  width: 3.7rem;
  height: 2.2rem;
  border: 0;
  border-radius: 999px;
  background: #d9d0d5;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, .12);
  transition: background .2s;
  pointer-events: none;
}
.switch::after {
  content: '';
  position: absolute;
  top: .22rem;
  left: .22rem;
  width: 1.76rem;
  height: 1.76rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, .22);
  transition: transform .22s cubic-bezier(.3, 1.4, .6, 1);
}
.switch[aria-checked="true"] { background: var(--accent2); }
.switch[aria-checked="true"]::after { transform: translateX(1.5rem); }
.chips { display: flex; gap: .25rem; padding: .25rem; border-radius: 999px; background: rgba(0, 0, 0, .06); }
.chip-btn {
  padding: .5rem .85rem;
  border: 0;
  border-radius: 999px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  background: transparent;
  cursor: pointer;
}
.chip-btn.on { color: var(--accent-dark); background: #fff; box-shadow: 0 2px 5px rgba(0, 0, 0, .12); }
.theme-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: .7rem; margin-bottom: .7rem; }
.theme-card {
  padding: .6rem;
  border: 0;
  border-radius: 1.1rem;
  font-family: inherit;
  text-align: left;
  color: var(--text);
  background: var(--panel);
  box-shadow: 0 3px 0 var(--panel-edge), inset 0 0 0 3px transparent;
  cursor: pointer;
}
.theme-card.on { box-shadow: 0 3px 0 var(--panel-edge), inset 0 0 0 3px var(--accent); }
.theme-swatch { display: flex; justify-content: center; gap: .1rem; padding: .5rem .3rem; border-radius: .8rem; }
.theme-piece { width: 1.9rem; height: 1.9rem; background-size: contain; background-repeat: no-repeat; }
.theme-name { margin-top: .45rem; font-size: 1.05rem; font-weight: 700; }
.theme-desc { font-size: .85rem; color: var(--text-soft); }
.about { padding: .9rem 1.1rem; margin-bottom: 1rem; border-radius: 1.1rem; background: var(--panel); box-shadow: 0 3px 0 var(--panel-edge); line-height: 1.45; }
.about p { margin: .3rem 0; }
.about-love { display: flex; align-items: center; gap: .4rem; font-weight: 600; }
.settings .btn.danger { width: 100%; }

/* ---- animations ------------------------------------------------------------ */

@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.7); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes wave { 0%, 100% { transform: translateY(0) rotate(0); } 25% { transform: translateY(-5px) rotate(-3deg); } 75% { transform: translateY(2px) rotate(2deg); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes node-pulse { 0%, 100% { transform: translate(-50%, -50%) scale(1); } 50% { transform: translate(-50%, -50%) scale(1.09); } }
@keyframes throb { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@keyframes star-pop { 0% { transform: scale(.2); } 100% { transform: scale(1); } }
@keyframes selected { 0%, 100% { transform: scale(1.08); } 50% { transform: scale(.94); } }
@keyframes hint {
  0%, 60%, 100% { transform: translate(0, 0) scale(1); }
  20% { transform: translate(calc(var(--hx) * 16%), calc(var(--hy) * 16%)) scale(1.1); }
  40% { transform: translate(0, 0) scale(1); }
}
@keyframes shimmer { 0%, 100% { filter: brightness(1) drop-shadow(0 0 0 transparent); } 50% { filter: brightness(1.15) drop-shadow(0 0 6px rgba(255, 255, 255, .95)); } }
@keyframes fuse { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.2) drop-shadow(0 0 5px rgba(255, 210, 80, .9)); } }
@keyframes nudge { 0%, 100% { translate: 0 0; } 50% { translate: 0 3px; } }
@keyframes flicker { from { transform: scale(1, 1) rotate(-3deg); } to { transform: scale(.9, 1.12) rotate(3deg); } }
@keyframes shimmer-bg { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
@keyframes wobble { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }

@media (prefers-reduced-motion: reduce) {
  .logo-piece, .logo-title span, .map-decor, .level-node.current, .level-node.current::before { animation: none; }
}
