/* Direction: Candy Wonderland — cream sugar paper, bubblegum pink, grape ink,
   puffy rounded game panels and glossy candy pieces. */
/* Completed by the platform from the short form: both modes, every
   palette token, each text-on-ground pair at its floor. To restyle, write the
   short form again (the decisions in one :root) and it is completed again. */

:root {
  --canvas: #fff8ef;
  --surface: #ffffff;
  --surface-2: #fbebf4;
  --border: #f0dae8;
  --border-strong: #bdb4af;
  --ink: #3f2b56;
  --muted: #74608b;
  --accent: #ff8db5;
  --accent-hover: #d9789a;
  --accent-ink: #241419;
  --accent-text: #be2f68;
  --accent-strong: #ac2659;
  --accent-soft: #ffe4ef;
  --accent-border: #ffc8d5;
  --success: #1c8e74;
  --success-ink: #ffffff;
  --success-soft: #e4ebe0;
  --success-strong: #166f5a;
  --warning: #a8690a;
  --warning-ink: #ffffff;
  --warning-soft: #f5e7d4;
  --warning-strong: #8f5908;
  --danger: #d7405b;
  --danger-ink: #ffffff;
  --danger-soft: #fae2dd;
  --danger-strong: #b6364d;
  --chart-1: #d56890;
  --chart-2: #d17925;
  --chart-3: #72830c;
  --chart-4: #1da28d;
  --chart-5: #157fb5;
  --chart-6: #9e7cdd;

  --font-display: "Baloo 2", "Trebuchet MS", sans-serif;
  --font-body: "Nunito", system-ui, sans-serif;
  --display-weight: 800;
  --display-tracking: -0.01em;
  --radius-card: 26px;
  --radius-btn: 999px;
  --radius-input: 16px;
  --card-pad: 1.25rem;
  --shadow-card: 0 8px 0 rgba(89, 65, 111, 0.07), 0 18px 38px rgba(89, 65, 111, 0.13);
  --x-c-pink: #FF7FAE;
  --x-c-lemon: #FFC63D;
  --x-c-blue: #4FA2FF;
  --x-c-mint: #3FCDB1;
  --x-c-grape: #A98BFA;
  --x-c-orange: #FF854A;
  --x-tile: rgba(255, 255, 255, 0.5);
  --x-tile-alt: rgba(169, 139, 250, 0.12);
  --x-gloss: rgba(255, 255, 255, 0.75);
  --x-stripe: rgba(255, 255, 255, 0.9);
  --x-gold: #D99400;
  --x-shadow-candy: rgba(60, 30, 70, 0.22);
  --x-shadow-inner: rgba(60, 30, 70, 0.3);
  --x-on-photo: #FFFFFF;
  --gradient-sky: linear-gradient(185deg, #FFE7F1 0%, #F3E9FF 46%, #E4FAF3 100%);
  --gradient-rainbow: conic-gradient(from 0deg, #FF7FAE, #FFC63D, #3FCDB1, #4FA2FF, #A98BFA, #FF7FAE);
  --gradient-candy: linear-gradient(180deg, #FFA3C8 0%, #FF6FA3 100%);
  --font-mono: "JetBrains Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-sans: "Nunito", system-ui, sans-serif;
  --eyebrow-tracking: 0.08em;
}

html[data-theme="dark"] {
  --canvas: #1f1115;
  --surface: #35292c;
  --surface-2: #2a1d21;
  --border: #3e3236;
  --border-strong: #62585b;
  --ink: #fff8ef;
  --muted: #a59c98;
  --accent: #ff8db5;
  --accent-hover: #ff9ec0;
  --accent-ink: #241419;
  --accent-text: #ff8db5;
  --accent-strong: #ff8db5;
  --accent-soft: #502c38;
  --accent-border: #84495d;
  --success: #1c8e74;
  --success-ink: #ffffff;
  --success-soft: #1e2d2a;
  --success-strong: #4ea792;
  --warning: #a8690a;
  --warning-ink: #ffffff;
  --warning-soft: #3d2413;
  --warning-strong: #bb8a41;
  --danger: #d7405b;
  --danger-ink: #ffffff;
  --danger-soft: #471b24;
  --danger-strong: #e06a7f;
  --chart-1: #ff8db5;
  --chart-2: #fda762;
  --chart-3: #95a931;
  --chart-4: #18dbbf;
  --chart-5: #25a5e9;
  --chart-6: #c7aefc;
}

/* SweetSwap — board, candies and celebration effects */

.sugar-bg {
  background-image: var(--gradient-sky);
  background-attachment: fixed;
}

.panel {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

/* ---------- board ---------- */
.board {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 2px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  padding: 6px;
  border-radius: 22px;
  background:
    repeating-conic-gradient(var(--x-tile-alt) 0% 25%, transparent 0% 50%) 0 0 / 26px 26px,
    var(--surface-2);
}

.tile {
  position: relative;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 14px;
  background: transparent;
  padding: 0;
  cursor: pointer;
}
.tile:focus-visible {
  outline: 3px solid var(--accent-strong);
  outline-offset: -3px;
}
.tile.sel::before {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 14px;
  background: var(--x-tile);
  box-shadow: inset 0 0 0 3px var(--accent-strong);
  animation: selpulse 0.9s ease-in-out infinite;
}
.tile.hint::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 14px;
  box-shadow: inset 0 0 0 3px var(--x-c-lemon);
  animation: selpulse 1.1s ease-in-out infinite;
}

.candy {
  width: 88%;
  height: 88%;
  position: relative;
  filter: drop-shadow(0 2px 0 var(--x-shadow-candy));
  transform-origin: 50% 50%;
}
.candy-ico {
  filter: drop-shadow(0 2px 0 var(--x-shadow-candy));
}
.candy-ico svg,
.candy svg {
  width: 100%;
  height: 100%;
  display: block;
}
.cbody {
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 9;
  stroke-linejoin: round;
}
.gloss { fill: var(--x-gloss); }

.c0 { color: var(--x-c-pink); }
.c1 { color: var(--x-c-lemon); }
.c2 { color: var(--x-c-blue); }
.c3 { color: var(--x-c-mint); }
.c4 { color: var(--x-c-grape); }
.c5 { color: var(--x-c-orange); }

/* special candy skins */
.sp-row .candy::after,
.sp-col .candy::after {
  content: "";
  position: absolute;
  inset: 24% 8%;
  border-radius: 6px;
  background: repeating-linear-gradient(90deg, var(--x-stripe) 0 4px, transparent 4px 9px);
  pointer-events: none;
}
.sp-col .candy::after {
  inset: 8% 24%;
  background: repeating-linear-gradient(0deg, var(--x-stripe) 0 4px, transparent 4px 9px);
}
.sp-wrap .candy::after {
  content: "";
  position: absolute;
  inset: 10%;
  border-radius: 10px;
  box-shadow: inset 0 0 0 4px var(--x-stripe);
  transform: rotate(45deg);
  pointer-events: none;
}
.sp-rb .candy svg { opacity: 0; }
.sp-rb .candy::after {
  content: "";
  position: absolute;
  inset: 4%;
  border-radius: 999px;
  background: var(--gradient-rainbow);
  box-shadow: inset 0 -5px 10px var(--x-shadow-inner), inset 0 6px 10px var(--x-gloss);
  animation: spin 3.4s linear infinite;
}

/* ---------- animations ---------- */
.falling .candy { animation: drop 0.28s cubic-bezier(0.25, 0.9, 0.35, 1.25); }
.pop .candy { animation: pop 0.3s ease-in forwards; }
.shake .candy { animation: shake 0.34s ease-in-out; }
.swapped .candy { animation: bump 0.2s ease-out; }

@keyframes drop {
  from { transform: translateY(calc(var(--fall, 1) * -112%)); }
  to { transform: translateY(0); }
}
@keyframes pop {
  0% { transform: scale(1) rotate(0deg); }
  45% { transform: scale(1.3) rotate(8deg); }
  100% { transform: scale(0.1) rotate(-20deg); opacity: 0; }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-16%) rotate(-6deg); }
  75% { transform: translateX(16%) rotate(6deg); }
}
@keyframes bump {
  from { transform: scale(0.8); }
  to { transform: scale(1); }
}
@keyframes selpulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes floatup {
  0% { transform: translate(-50%, 0) scale(0.7); opacity: 0; }
  25% { opacity: 1; }
  100% { transform: translate(-50%, -150%) scale(1.1); opacity: 0; }
}
@keyframes bokeh {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx, 0px), var(--dy, -60px)) scale(0.2); opacity: 0; }
}
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-10px) rotate(3deg); }
}
@keyframes starpop {
  0% { transform: scale(0.2) rotate(-40deg); }
  70% { transform: scale(1.2) rotate(6deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.score-pop {
  position: absolute;
  left: 50%;
  bottom: 40%;
  transform: translate(-50%, 0);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(0.7rem, 2.1vw, 1rem);
  color: var(--ink);
  text-shadow: 0 1px 0 var(--x-gloss);
  pointer-events: none;
  animation: floatup 0.85s ease-out forwards;
  z-index: 4;
}
.spark {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  pointer-events: none;
  animation: bokeh 0.7s ease-out forwards;
  z-index: 5;
}
.bobbing { animation: bob 4.5s ease-in-out infinite; }
.star-burst { animation: starpop 0.55s cubic-bezier(0.2, 1.3, 0.4, 1) both; }

html.reduced-motion .bobbing,
html.reduced-motion .candy,
html.reduced-motion .sp-rb .candy::after,
html.reduced-motion .star-burst,
html.reduced-motion .tile.sel::before {
  animation: none !important;
}

/* ---------- small pieces ---------- */
.stat-chip {
  @apply rounded-2xl border-2 border-border bg-surface px-3 py-2 text-center;
}
.booster-btn {
  @apply relative flex min-w-[4.5rem] flex-col items-center gap-1 rounded-2xl border-2 border-border bg-surface px-3 py-2 text-xs font-bold transition hover:-translate-y-0.5 hover:border-accent focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent-strong disabled:opacity-40;
}
.booster-btn.armed {
  @apply border-accent-strong bg-accent-soft;
}
.level-node {
  @apply relative flex aspect-square w-full flex-col items-center justify-center rounded-3xl border-2 font-display text-2xl transition;
}
