/* Cat Merge Town — Meowverse cosmic reskin over the original 2048 stylesheet */

:root {
  --deep: #0b0420; --mid: #1b0b3d; --violet: #4a2391; --glow: #a682ff;
  --cream: #fff4dc; --peach: #ffd2a8; --paw: #ff6b9d;
}

html, body {
  background: linear-gradient(180deg, #0b0420 0%, #1b0b3d 40%, #31165f 82%, #6b3a7e 96%, #8a4a72 100%) fixed;
  color: var(--cream);
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  min-height: 100vh;
}

/* ---- meow chrome ---- */
#meow-top {
  max-width: 500px; margin: 0 auto;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 6px; padding: 10px 12px 0; font-family: Fredoka, sans-serif;
}
#meow-top a { color: var(--cream); text-decoration: none; }
.hud { display: flex; gap: 6px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.15);
  border-radius: 999px; padding: 3px 10px; font-size: 12.5px; font-weight: 600;
  color: var(--cream); white-space: nowrap;
}
.chip b { color: var(--peach); }
.switch { display: inline-flex; border: 1px solid rgba(255,255,255,.18); border-radius: 999px; overflow: hidden; }
.switch a { padding: 4px 10px; font-size: 12px; font-weight: 600; color: rgba(255,244,220,.75); }
.switch a.on { background: var(--paw); color: #fff; }

#meow-title { text-align: center; margin-top: 10px; font-family: Fredoka, sans-serif; }
#meow-title small { color: rgba(255,244,220,.55); font-size: 10.5px; font-weight: 600; letter-spacing: .18em; }
#meow-title h1 {
  font-size: 30px; font-weight: 700; letter-spacing: .03em; margin: 0;
  background: linear-gradient(135deg, #a682ff, #ff6b9d 55%, #ffd2a8);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

#meow-evo {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  max-width: 500px; margin: 10px auto 0; padding: 6px 12px;
  width: fit-content;
  background: rgba(11,4,32,.55); border: 1px solid rgba(255,255,255,.16);
  border-radius: 999px;
}
#meow-evo img { height: 24px; transition: filter .4s; }
#meow-evo img.lock { filter: brightness(.25) saturate(.2); }
#meow-evo span { color: rgba(255,244,220,.45); font-size: 11px; }

#meow-banner {
  position: fixed; top: 18%; left: 50%; transform: translateX(-50%);
  font-family: Fredoka, sans-serif; font-weight: 700; font-size: 18px;
  padding: 7px 16px; border-radius: 999px; background: rgba(11,4,32,.85);
  border: 1px solid var(--peach); color: var(--peach); white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 50;
}
#meow-banner.show { opacity: 1; }

#meow-goal {
  display: flex; align-items: center; gap: 12px; width: fit-content;
  margin: 18px auto 0;
  background: rgba(11,4,32,.6); border: 1px solid rgba(255,210,168,.4);
  border-radius: 18px; padding: 9px 18px; font-family: Fredoka, sans-serif;
}
#meow-goal img { height: 42px; }
#meow-goal b { color: var(--peach); font-size: 13px; display: block; }
#meow-goal span { color: rgba(255,244,220,.6); font-size: 11px; }

.meow-credit { text-align: center; font-size: 11px; color: rgba(255,244,220,.4); margin-top: 16px; }
.meow-credit a { color: rgba(255,244,220,.6); }

/* ---- restyle original 2048 chrome ---- */
.container { margin-top: 4px; }
.heading { margin-top: 6px; }
h1.title { display: none; }
.scores-container { float: none !important; text-align: center; }
.score-container, .best-container {
  background: rgba(11,4,32,.6) !important;
  border: 1px solid rgba(255,255,255,.2);
  font-family: Fredoka, sans-serif;
  color: var(--peach) !important;
  border-radius: 999px;
}
.score-container:after, .best-container:after { color: rgba(255,244,220,.55) !important; }
.game-intro { color: rgba(255,244,220,.75); font-family: Fredoka, sans-serif; font-weight: 600; }
.restart-button, .retry-button, .keep-playing-button {
  background: var(--paw) !important; color: #fff !important;
  font-family: Fredoka, sans-serif; border-radius: 999px !important;
}

/* board */
.game-container {
  background: rgba(11,4,32,.55) !important;
  border: 2px solid rgba(166,130,255,.4);
  border-radius: 22px !important;
  box-shadow: 0 18px 50px -18px rgba(0,0,0,.8), inset 0 0 40px rgba(74,35,145,.5);
}
.grid-cell {
  background: rgba(255,255,255,.06) !important;
  border-radius: 14px !important;
}

/* tiles → cats */
.tile .tile-inner {
  border-radius: 14px !important;
  background-color: #2c1b56 !important;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  color: transparent !important;
  font-size: 0 !important;
}
.tile .lv-badge {
  position: absolute; bottom: 2px; right: 6px;
  font-family: Fredoka, sans-serif; font-size: 11px; font-weight: 700;
  color: rgba(255,244,220,.85);
  text-shadow: 0 1px 4px rgba(11,4,32,.9);
}
.tile.tile-2 .tile-inner { background-image: url(../img/s1.png) !important; background-size: contain !important; background-position: center !important; background-repeat: no-repeat !important; background-color: #2c1b56 !important; }
.tile.tile-4 .tile-inner { background-image: url(../img/s2.png) !important; background-size: contain !important; background-position: center !important; background-repeat: no-repeat !important; background-color: #2c1b56 !important; }
.tile.tile-8 .tile-inner { background-image: url(../img/s3.png) !important; background-size: contain !important; background-position: center !important; background-repeat: no-repeat !important; background-color: #2c1b56 !important; }
.tile.tile-16 .tile-inner { background-image: url(../img/s4.png) !important; background-size: contain !important; background-position: center !important; background-repeat: no-repeat !important; background-color: #2c1b56 !important; }
.tile.tile-32 .tile-inner { background-image: url(../img/s5.png) !important; background-size: contain !important; background-position: center !important; background-repeat: no-repeat !important; background-color: #2c1b56 !important; }
.tile.tile-64 .tile-inner { background-image: url(../img/s6.png) !important; background-size: contain !important; background-position: center !important; background-repeat: no-repeat !important; background-color: #2c1b56 !important; }
.tile.tile-128 .tile-inner { background-image: url(../img/s7.png) !important; background-size: contain !important; background-position: center !important; background-repeat: no-repeat !important; background-color: #2c1b56 !important; }
.tile.tile-256 .tile-inner { background-image: url(../img/s8.png) !important; background-size: contain !important; background-position: center !important; background-repeat: no-repeat !important; background-color: #2c1b56 !important; }
.tile.tile-512 .tile-inner,
.tile.tile-1024 .tile-inner,
.tile.tile-2048 .tile-inner,
.tile.tile-super .tile-inner {
  background-image: url(../img/s8.png) !important;
  background-size: contain !important; background-position: center !important;
  background-repeat: no-repeat !important; background-color: #2c1b56 !important;
  box-shadow: 0 0 18px rgba(255,210,168,.75), inset 0 0 12px rgba(255,210,168,.35) !important;
}
.tile.tile-64 .tile-inner, .tile.tile-128 .tile-inner, .tile.tile-256 .tile-inner {
  box-shadow: 0 0 12px rgba(166,130,255,.55) !important;
}

/* score popup */
.score-container .score-addition {
  color: var(--peach) !important;
  font-family: Fredoka, sans-serif;
}

/* game over / win overlay */
.game-message {
  background: rgba(11,4,32,.85) !important;
  border-radius: 22px;
}
.game-message p {
  color: var(--cream) !important;
  font-family: Fredoka, sans-serif;
}
.game-message.game-won { background: rgba(74,35,145,.85) !important; }


/* ---- juice pass (GameDesigner/Animator spec) ---- */

/* 1. merge pop: stronger, earlier, with expanding ring */
@keyframes pop {
  0% { transform: scale(0); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}
@keyframes popStrong {
  0% { transform: scale(0); }
  50% { transform: scale(1.32) rotate(-3deg); }
  100% { transform: scale(1) rotate(0); }
}
@keyframes popEpic {
  0% { transform: scale(0); }
  45% { transform: scale(1.45); }
  70% { transform: scale(.92); }
  100% { transform: scale(1); }
}
.tile-merged .tile-inner {
  animation: pop 260ms cubic-bezier(.2,1.5,.4,1) 30ms !important;
  animation-fill-mode: backwards !important;
}
.tile-merged.tile-32 .tile-inner, .tile-merged.tile-64 .tile-inner {
  animation-name: popStrong !important;
}
.tile-merged.tile-128 .tile-inner, .tile-merged.tile-256 .tile-inner,
.tile-merged.tile-512 .tile-inner, .tile-merged.tile-1024 .tile-inner,
.tile-merged.tile-2048 .tile-inner, .tile-merged.tile-super .tile-inner {
  animation-name: popEpic !important;
}
.tile-merged .tile-inner::after {
  content: ""; position: absolute; inset: 0; border-radius: 14px;
  animation: mergeRing 320ms ease-out 30ms backwards;
  pointer-events: none;
}
@keyframes mergeRing {
  0% { box-shadow: 0 0 0 0 rgba(255,210,168,.7); }
  100% { box-shadow: 0 0 0 14px rgba(255,210,168,0); }
}

/* 3. board lean on input */
.game-container { transition: transform 140ms cubic-bezier(.2,1.3,.4,1); }
.game-container.lean-up { transform: translateY(-4px); }
.game-container.lean-down { transform: translateY(4px); }
.game-container.lean-left { transform: translateX(-4px); }
.game-container.lean-right { transform: translateX(4px); }
#tile-drag-wrap { transition: none; }

/* 5. fx layer for merge particles */
#fx-layer {
  position: absolute; inset: 0; pointer-events: none; z-index: 30;
  overflow: hidden; border-radius: 22px;
}
.fx-p {
  position: absolute; font-size: 15px; will-change: transform, opacity;
  transition: transform 420ms cubic-bezier(.15,.8,.3,1), opacity 420ms ease-out;
}

/* 6. stardust chip pulse + floater */
@keyframes chipPulse { 0% { transform: scale(1); } 45% { transform: scale(1.18); } 100% { transform: scale(1); } }
.chip.pulse { animation: chipPulse 200ms ease-out; }
.dust-float {
  position: fixed; z-index: 60; pointer-events: none;
  font-family: Fredoka, sans-serif; font-weight: 700; font-size: 14px; color: var(--peach);
  text-shadow: 0 1px 6px rgba(11,4,32,.9);
  transition: transform 720ms ease-out, opacity 720ms ease-out;
}
.chip.capped b { color: rgba(255,244,220,.4); }

/* 7. evolution celebration */
@keyframes bannerPop {
  0% { transform: translateX(-50%) scale(.8); opacity: 0; }
  55% { transform: translateX(-50%) scale(1.08); opacity: 1; }
  100% { transform: translateX(-50%) scale(1); opacity: 1; }
}
#meow-banner.show { animation: bannerPop 340ms cubic-bezier(.2,1.4,.4,1); }
#evo-flash {
  position: fixed; inset: 0; pointer-events: none; z-index: 40; opacity: 0;
  background: radial-gradient(circle at 50% 35%, rgba(255,210,168,.55), transparent 60%);
}
#evo-flash.on { animation: evoFlash 500ms ease-out; }
@keyframes evoFlash { 0% { opacity: 0; } 35% { opacity: .55; } 100% { opacity: 0; } }
@keyframes evoPulse {
  0% { transform: scale(1); filter: brightness(1); }
  40% { transform: scale(1.45); filter: brightness(1.6) drop-shadow(0 0 8px rgba(255,210,168,.9)); }
  100% { transform: scale(1); filter: brightness(1); }
}
#meow-evo img.pulse { animation: evoPulse 600ms cubic-bezier(.2,1.4,.4,1); }
#goal-img { transition: filter .5s ease; }

/* 8a. drifting starfield */
body::before {
  content: ""; position: fixed; inset: -50vh 0 0 0; pointer-events: none; z-index: -1;
  background-image:
    radial-gradient(1.4px 1.4px at 22% 18%, rgba(255,244,220,.8), transparent 55%),
    radial-gradient(1px 1px at 68% 42%, rgba(255,244,220,.55), transparent 55%),
    radial-gradient(1.8px 1.8px at 84% 12%, rgba(166,130,255,.7), transparent 55%),
    radial-gradient(1.2px 1.2px at 40% 68%, rgba(255,210,168,.5), transparent 55%),
    radial-gradient(1px 1px at 8% 52%, rgba(255,244,220,.45), transparent 55%),
    radial-gradient(1.5px 1.5px at 55% 88%, rgba(166,130,255,.5), transparent 55%);
  background-size: 420px 420px;
  animation: starDrift 40s linear infinite;
}
@keyframes starDrift { to { background-position: 420px 420px; } }

/* 8b. game-over shake */
@keyframes boardShake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-6px); }
  35% { transform: translateX(5px); }
  55% { transform: translateX(-4px); }
  75% { transform: translateX(3px); }
}
.game-container.shake { animation: boardShake 380ms ease-in-out; }

/* blocked-move cushion shake (softer than game-over) */
@keyframes boardShakeSoft {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px) rotate(-.3deg); }
  40% { transform: translateX(4px) rotate(.2deg); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}
.game-container.shake-soft { animation: boardShakeSoft 220ms ease-out; }

/* stardust flight from merge tile to wallet chip */
#fly-layer { position: fixed; inset: 0; pointer-events: none; z-index: 80; }
.dust-fly {
  position: fixed; font-size: 16px; color: var(--peach);
  text-shadow: 0 0 6px rgba(255,210,168,.8);
  will-change: transform, opacity;
  transition: transform 480ms cubic-bezier(.2,.7,.3,1), opacity 480ms ease-in;
}

/* game-over score rollup + new-record celebration */
.game-message .go-score {
  font-family: Fredoka, sans-serif; font-weight: 700; font-size: 30px;
  color: var(--peach); margin-top: 4px;
}
.game-message .record-badge {
  font-family: Fredoka, sans-serif; font-weight: 700; font-size: 17px;
  color: #fff; background: var(--paw); border-radius: 999px;
  padding: 5px 18px; margin-top: 10px; display: inline-block;
  animation: recordPop 420ms cubic-bezier(.34,1.56,.64,1);
}
@keyframes recordPop {
  0% { transform: scale(0); }
  70% { transform: scale(1.15); }
  100% { transform: scale(1); }
}
.game-message .confetti {
  position: absolute; top: -20px; font-size: 15px; pointer-events: none;
  animation: confettiFall 1600ms ease-in forwards;
}
@keyframes confettiFall {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  100% { transform: translate(var(--drift), 360px) rotate(var(--spin)); opacity: 0; }
}

/* ---- game shell: title / pause / how-to ---- */
.shell {
  position: fixed; inset: 0; z-index: 120; display: none;
  align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, rgba(42,18,88,.96), rgba(11,4,32,.98));
  font-family: Fredoka, sans-serif;
}
.shell.on { display: flex; animation: shellIn 240ms ease-out; }
@keyframes shellIn { from { opacity: 0; } to { opacity: 1; } }
.shell-card {
  text-align: center; max-width: 380px; width: calc(100% - 48px);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.shell-card small { color: rgba(255,244,220,.5); letter-spacing: .24em; font-size: 10.5px; font-weight: 600; }
.shell-hero { height: 110px; filter: drop-shadow(0 10px 30px rgba(166,130,255,.45)); animation: heroFloat 4s ease-in-out infinite; }
@keyframes heroFloat { 50% { transform: translateY(-8px); } }
.shell-logo {
  font-size: 44px; font-weight: 700; letter-spacing: .04em; margin: 0;
  background: linear-gradient(135deg, #a682ff, #ff6b9d 55%, #ffd2a8);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.shell-tag { color: rgba(255,244,220,.8); font-size: 14px; font-family: "Plus Jakarta Sans", sans-serif; }
.shell-primary {
  border: 0; cursor: pointer; margin-top: 6px;
  background: var(--paw); color: #fff; font-family: Fredoka, sans-serif;
  font-weight: 700; font-size: 19px; border-radius: 999px; padding: 14px 52px;
  box-shadow: 0 14px 40px -12px rgba(255,107,157,.65);
  transition: transform .15s;
}
.shell-primary:hover { transform: translateY(-2px); }
.shell-row { display: flex; gap: 8px; margin-top: 2px; }
.shell-ghost {
  border: 1px solid rgba(255,255,255,.22); cursor: pointer;
  background: rgba(255,255,255,.06); color: var(--cream);
  font-family: Fredoka, sans-serif; font-weight: 600; font-size: 13px;
  border-radius: 999px; padding: 9px 16px;
}
.shell-ghost:hover { background: rgba(255,255,255,.12); }
.shell-wide { width: 100%; }
.shell-ver { margin-top: 10px; color: rgba(255,244,220,.35); font-size: 11px; }
.shell-h2 { font-size: 26px; font-weight: 700; color: var(--peach); margin: 0 0 4px; }
.shell-left { text-align: left; align-items: stretch; }
.shell-left p { color: rgba(255,244,220,.85); font-size: 14px; line-height: 1.55; font-family: "Plus Jakarta Sans", sans-serif; margin: 0; }
.shell-left .shell-primary { align-self: center; margin-top: 10px; }
.shell-pausebtn {
  position: absolute; top: 0; right: -2px;
  border: 1px solid rgba(255,255,255,.2); background: rgba(11,4,32,.6);
  color: var(--cream); border-radius: 10px; padding: 4px 10px; cursor: pointer; font-size: 14px;
}
.heading { position: relative; }
body.shell-open #meow-banner { display: none; }

/* ---- combo chip, run-goal bar, daily order ---- */
.combo-chip {
  position: absolute; top: 2px; left: 0;
  font-family: Fredoka, sans-serif; font-weight: 700; font-size: 12.5px;
  color: #fff; background: linear-gradient(135deg, #a682ff, #ff6b9d);
  border-radius: 999px; padding: 4px 12px;
  box-shadow: 0 6px 18px -6px rgba(255,107,157,.7);
}
.combo-chip.pop { animation: chipPulse 220ms ease-out; }
.combo-chip.broken { background: rgba(255,255,255,.18); color: rgba(255,244,220,.5); animation: boardShakeSoft 300ms ease-out; }
#meow-goal .goal-main { display: flex; flex-direction: column; gap: 6px; min-width: 210px; }
.order-bar {
  height: 7px; border-radius: 999px; background: rgba(255,255,255,.12); overflow: hidden;
}
.order-bar i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, #a682ff, #ffd2a8);
  border-radius: 999px; transition: width .45s cubic-bezier(.2,1,.3,1);
}
#meow-order {
  width: fit-content; min-width: 300px; max-width: 92vw;
  margin: 10px auto 0; padding: 10px 18px;
  background: rgba(11,4,32,.6); border: 1px solid rgba(166,130,255,.35);
  border-radius: 16px; font-family: Fredoka, sans-serif;
  display: flex; flex-direction: column; gap: 7px;
}
#meow-order .order-text { color: rgba(255,244,220,.85); font-size: 12.5px; font-weight: 600; }
#meow-order .order-text b { color: var(--peach); }
#meow-order.done { border-color: rgba(255,210,168,.6); }
#meow-order.done .order-bar i { background: linear-gradient(90deg, #ffd2a8, #ff6b9d); }
#goal-img.cosmic-star { filter: none; box-shadow: 0 0 14px rgba(255,210,168,.8); border-radius: 50%; }

/* ---- stardust undo (game over panel) ---- */
.game-message .undo-button {
  display: inline-block;
  background: linear-gradient(135deg, #ffcf6e, #ff9a3d) !important;
  color: #2c1b56 !important;
  font-family: Fredoka, sans-serif;
  font-weight: 700;
  border-radius: 999px !important;
  padding: 0 18px;
  height: 40px;
  line-height: 42px;
  cursor: pointer;
  margin: 0 6px 10px 6px;
  box-shadow: 0 6px 18px rgba(255, 154, 61, 0.45);
}
.game-message .undo-button:hover { filter: brightness(1.07); }
.game-message .undo-button b { font-weight: 800; }
.game-message.game-won .undo-button,
.game-message .undo-button.gone { display: none !important; }

/* trademark superscript on the shell logo */
.shell-logo .shell-tm { font-size: .32em; vertical-align: super; letter-spacing: 0; -webkit-text-fill-color: #fff4dc; opacity: .75; }
