/* Rainbow Merge — a magical rainbow & unicorn puzzle */
@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;600;700;800&family=Bricolage+Grotesque:wght@200;800&display=swap');

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --ink: #5a4a7a;
  --pink: #ffb6d9;
  --lav: #c9b6ff;
  --blue: #a8d4ff;
}

html, body { height: 100%; }

body {
  font-family: 'Baloo 2', sans-serif;
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink);
  overflow-x: hidden;
  padding: 12px;
  position: relative;
  background:
    radial-gradient(ellipse at 15% 8%, rgba(255,182,217,.85), transparent 42%),
    radial-gradient(ellipse at 85% 15%, rgba(168,212,255,.8), transparent 45%),
    radial-gradient(ellipse at 50% 105%, rgba(201,182,255,.9), transparent 55%),
    linear-gradient(170deg, #fff0fb 0%, #f3ecff 45%, #e9f4ff 100%);
}

/* -------- magical sky background -------- */
#sky { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.cloud {
  position: absolute;
  background: radial-gradient(circle, rgba(255,255,255,.9), rgba(255,255,255,.5) 60%, transparent 72%);
  border-radius: 50%;
  filter: blur(2px);
  opacity: .8;
  animation: drift linear infinite;
}
.cloud::before, .cloud::after {
  content: ''; position: absolute; background: inherit; border-radius: 50%;
}
.c1 { width: 160px; height: 70px; top: 12%; left: -180px; animation-duration: 46s; }
.c1::before { width: 90px; height: 90px; top: -28px; left: 30px; }
.c1::after { width: 70px; height: 70px; top: -14px; left: 90px; }
.c2 { width: 120px; height: 55px; top: 42%; left: -160px; animation-duration: 62s; animation-delay: -20s; opacity: .6; }
.c2::before { width: 70px; height: 70px; top: -22px; left: 22px; }
.c3 { width: 200px; height: 84px; top: 74%; left: -220px; animation-duration: 74s; animation-delay: -40s; opacity: .5; }
.c3::before { width: 110px; height: 110px; top: -36px; left: 36px; }
.c3::after { width: 84px; height: 84px; top: -18px; left: 110px; }
@keyframes drift { to { transform: translateX(115vw); } }

/* faint giant rainbow arc up top */
.bigbow {
  position: absolute; top: -46vw; left: 50%; transform: translateX(-50%);
  width: 130vw; height: 130vw; border-radius: 50%;
  background: conic-gradient(from 180deg,
    transparent 0deg,
    rgba(255,120,120,.18) 44deg,
    rgba(255,190,110,.18) 46deg,
    rgba(255,240,130,.18) 48deg,
    rgba(150,230,150,.18) 50deg,
    rgba(130,200,255,.18) 52deg,
    rgba(180,150,255,.18) 54deg,
    transparent 56deg);
  filter: blur(6px);
  opacity: .6;
}

#wrap { width: 100%; max-width: 480px; position: relative; z-index: 1; }

/* -------- header -------- */
#hd {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; flex-wrap: wrap; gap: 8px;
}
#title {
  font-weight: 800; font-size: clamp(20px, 6vw, 30px); letter-spacing: -.5px;
  background: linear-gradient(90deg,#ff6ba8,#ffa94d,#ffe14d,#5fd67a,#4dbcff,#a56bff);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  text-shadow: 0 2px 0 rgba(255,255,255,.5);
  filter: drop-shadow(0 2px 3px rgba(180,120,220,.25));
}
#title .uni { -webkit-text-fill-color: initial; display: inline-block; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4px) rotate(-6deg); } }

#scores { display: flex; gap: 8px; }
.sc {
  background: rgba(255,255,255,.75);
  border: 2px solid rgba(255,255,255,.9);
  border-radius: 16px; padding: 6px 14px;
  display: flex; flex-direction: column; align-items: center;
  box-shadow: 0 6px 16px rgba(180,120,220,.18);
  backdrop-filter: blur(6px);
}
.sc span { font-size: 10px; font-weight: 800; letter-spacing: 1px; opacity: .5; }
.sc b { font-size: 20px; font-variant-numeric: tabular-nums; color: #a05bd6; }

/* -------- rainbow journey -------- */
#journey {
  background: rgba(255,255,255,.55);
  border: 2px solid rgba(255,255,255,.8);
  border-radius: 18px; padding: 10px 12px 12px; margin-bottom: 14px;
  box-shadow: 0 6px 18px rgba(180,120,220,.14);
  backdrop-filter: blur(6px);
}
.jlabel { font-size: 12px; font-weight: 800; letter-spacing: .5px; opacity: .7; text-align: center; margin-bottom: 8px; }
#journey-track { display: flex; gap: 4px; align-items: flex-end; }
.jstep {
  flex: 1; position: relative; border-radius: 10px; height: 22px;
  box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.5), 0 2px 4px rgba(120,80,160,.12);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; transition: transform .25s ease, height .25s ease, box-shadow .25s ease;
  opacity: .55; filter: saturate(.7);
}
.jstep::after {
  content: ''; position: absolute; top: 3px; left: 12%; right: 40%; height: 30%;
  border-radius: 8px; background: linear-gradient(180deg, rgba(255,255,255,.55), transparent);
}
.jstep.active {
  opacity: 1; filter: saturate(1.2) brightness(1.05);
  height: 30px; transform: translateY(-4px) scale(1.06);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.7), 0 6px 14px rgba(120,80,160,.3), 0 0 14px currentColor;
  z-index: 2;
}
.jstep.reached { opacity: .95; filter: saturate(1); }
.jstep.uni { font-size: 15px; background: conic-gradient(from 0deg,#ff6b6b,#ffa94d,#ffe14d,#5fd67a,#4dbcff,#a56bff,#ff6b6b) !important; }
.jstep.uni.active { animation: unipulse 1.4s ease-in-out infinite; }
@keyframes unipulse { 50% { box-shadow: inset 0 0 0 2px rgba(255,255,255,.8), 0 0 22px rgba(255,150,220,.9), 0 6px 16px rgba(150,80,200,.5); } }

/* -------- board -------- */
#boardwrap { position: relative; }
canvas { display: block; width: 100%; height: auto; border-radius: 24px; touch-action: none; }

/* floating combo text */
#combo {
  position: absolute; top: 40%; left: 50%; transform: translate(-50%,-50%) scale(.6);
  font-weight: 800; font-size: clamp(22px,7vw,40px);
  pointer-events: none; opacity: 0; z-index: 5;
  text-shadow: 0 3px 0 rgba(255,255,255,.7), 0 6px 14px rgba(150,80,200,.4);
  white-space: nowrap;
}
#combo.show { animation: comboPop .95s cubic-bezier(.2,1.5,.4,1) forwards; }
@keyframes comboPop {
  0% { opacity: 0; transform: translate(-50%,-50%) scale(.4) rotate(-6deg); }
  25% { opacity: 1; transform: translate(-50%,-56%) scale(1.15) rotate(3deg); }
  60% { opacity: 1; transform: translate(-50%,-58%) scale(1) rotate(0); }
  100% { opacity: 0; transform: translate(-50%,-80%) scale(.9); }
}
#combo.rainbow {
  background: linear-gradient(90deg,#ff6b6b,#ffa94d,#ffe14d,#5fd67a,#4dbcff,#a56bff);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}

/* -------- controls -------- */
#controls { margin-top: 16px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
#hint { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 200; font-size: 14px; opacity: .75; text-align: center; }

button {
  font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 15px;
  border: 2px solid rgba(255,255,255,.85); cursor: pointer;
  padding: 11px 24px; border-radius: 18px;
  color: #fff;
  background: linear-gradient(135deg, #ff7ec0, #b57cff 55%, #7cb8ff);
  box-shadow: 0 8px 18px rgba(165,107,255,.35), inset 0 2px 6px rgba(255,255,255,.4);
  transition: transform .12s ease, box-shadow .12s ease;
}
button:hover { transform: translateY(-2px); box-shadow: 0 12px 24px rgba(165,107,255,.45), inset 0 2px 6px rgba(255,255,255,.4); }
button:active { transform: translateY(0) scale(.97); }

#footer { margin-top: 18px; text-align: center; font-size: 12px; font-family: 'Bricolage Grotesque'; font-weight: 200; }
#footer a { color: #a56bff; text-decoration: none; font-weight: 800; }
#footer a:hover { text-decoration: underline; }

/* -------- overlay -------- */
#overlay {
  position: fixed; inset: 0;
  background: radial-gradient(circle at center, rgba(120,80,160,.35), rgba(58,43,82,.6));
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 30; padding: 20px;
  transition: opacity .3s ease;
}
#overlay.hidden { opacity: 0; pointer-events: none; }
#ov-card {
  position: relative;
  background: linear-gradient(160deg, #fff, #fbeeff);
  border: 3px solid rgba(255,255,255,.9);
  border-radius: 28px; padding: 34px 28px 30px; text-align: center;
  box-shadow: 0 24px 70px rgba(80,40,120,.5);
  max-width: 340px; width: 100%;
  animation: pop .4s cubic-bezier(.2,1.5,.4,1);
}
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
#ov-emoji { font-size: 62px; line-height: 1; margin-bottom: 6px; animation: bob 2s ease-in-out infinite; }
#ov-msg {
  font-weight: 800; font-size: 26px; margin-bottom: 8px;
  background: linear-gradient(90deg,#ff6ba8,#ffa94d,#5fd67a,#4dbcff,#a56bff);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
#ov-sub { font-family: 'Bricolage Grotesque'; font-weight: 200; font-size: 15px; opacity: .8; margin-bottom: 22px; }
#ov-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.hidden { display: none; }
#overlay.hidden { display: flex; }