/* ================================================================
   Cupcake 2048 — Modern Redesign
   All selectors scoped to .cupcake2048-game
   ================================================================ */

/* ── Font face ────────────────────────────────────────────────── */
@font-face {
  font-family: "Clear Sans";
  src: url("fonts/ClearSans-Light-webfont.eot");
  src: url("fonts/ClearSans-Light-webfont.eot?#iefix") format("embedded-opentype"),
       url("fonts/ClearSans-Light-webfont.svg#clear_sans_lightregular") format("svg"),
       url("fonts/ClearSans-Light-webfont.woff") format("woff");
  font-weight: 200;
  font-style: normal;
}
@font-face {
  font-family: "Clear Sans";
  src: url("fonts/ClearSans-Regular-webfont.eot");
  src: url("fonts/ClearSans-Regular-webfont.eot?#iefix") format("embedded-opentype"),
       url("fonts/ClearSans-Regular-webfont.svg#clear_sansregular") format("svg"),
       url("fonts/ClearSans-Regular-webfont.woff") format("woff");
  font-weight: normal;
  font-style: normal;
}
@font-face {
  font-family: "Clear Sans";
  src: url("fonts/ClearSans-Bold-webfont.eot");
  src: url("fonts/ClearSans-Bold-webfont.eot?#iefix") format("embedded-opentype"),
       url("fonts/ClearSans-Bold-webfont.svg#clear_sansbold") format("svg"),
       url("fonts/ClearSans-Bold-webfont.woff") format("woff");
  font-weight: 700;
  font-style: normal;
}

/* ── Root ──────────────────────────────────────────────────────── */
.cupcake2048-game {
  font-family: "Clear Sans", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  color: #3d2130;
  width: 520px;
  max-width: 100%;
  margin: 0 auto;
  padding: 24px;
  box-sizing: border-box;
  outline: none;
  background: linear-gradient(145deg, #fff5f8, #ffeaf0);
  border-radius: 20px;
  border: 1px solid rgba(244, 114, 152, .15);
  box-shadow: 0 8px 32px rgba(214, 51, 108, .08);
}
.cupcake2048-game *,
.cupcake2048-game *::before,
.cupcake2048-game *::after {
  box-sizing: border-box;
}
.cupcake2048-game p {
  margin-top: 0;
  margin-bottom: 10px;
  line-height: 1.65;
}
.cupcake2048-game a {
  color: #c2255c;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.cupcake2048-game strong.important {
  text-transform: uppercase;
  color: #c2255c;
}
.cupcake2048-game hr {
  border: none;
  border-bottom: 1px solid rgba(244, 114, 152, .18);
  margin: 20px 0;
}

/* ── Scores ───────────────────────────────────────────────────── */
@keyframes cupcake-move-up {
  0%   { top: 25px; opacity: 1; }
  100% { top: -50px; opacity: 0; }
}

.cupcake2048-game .scores-container {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.cupcake2048-game .score-card {
  background: linear-gradient(135deg, #ff6b9d 0%, #ee4f8a 100%);
  border-radius: 12px;
  padding: 10px 8px 8px;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(238, 79, 138, .2);
}

.cupcake2048-game .score-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, .85);
  margin-bottom: 2px;
}

.cupcake2048-game .score-container,
.cupcake2048-game .best-container,
.cupcake2048-game .score-points,
.cupcake2048-game .best-points {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
  min-height: 21px;
  position: relative;
  overflow: hidden;
  text-transform: capitalize;
}

.cupcake2048-game .score-container .score-addition,
.cupcake2048-game .best-container .score-addition,
.cupcake2048-game .score-points .score-addition,
.cupcake2048-game .best-points .score-addition {
  position: absolute;
  width: 100%;
  left: 0;
  text-align: center;
  font-size: 14px;
  line-height: 14px;
  font-weight: 700;
  color: #fff;
  z-index: 100;
  animation: cupcake-move-up 600ms ease-in both;
}

/* ── Above game ───────────────────────────────────────────────── */
.cupcake2048-game .above-game {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.cupcake2048-game .above-game::after {
  display: none;
}
.cupcake2048-game .game-intro {
  font-size: 15px;
  line-height: 1.4;
  margin: 0;
  color: #6b3a56;
}
.cupcake2048-game .restart-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ff6b9d 0%, #ee4f8a 100%);
  border: none;
  border-radius: 10px;
  padding: 10px 22px;
  text-decoration: none;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
  box-shadow: 0 3px 12px rgba(238, 79, 138, .3);
  white-space: nowrap;
  flex-shrink: 0;
}
.cupcake2048-game .restart-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(238, 79, 138, .4);
  color: #fff;
}
.cupcake2048-game .restart-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(238, 79, 138, .25);
}

/* ── Game container ───────────────────────────────────────────── */
@keyframes cupcake-fade-in {
  0%   { opacity: 0; }
  100% { opacity: 1; }
}

.cupcake2048-game .game-container {
  position: relative;
  padding: 12px;
  cursor: default;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
  background: linear-gradient(145deg, #f472a0, #e8508c);
  border-radius: 14px;
  width: 472px;
  height: 472px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,.08), 0 4px 16px rgba(228, 80, 140, .2);
}

/* ── Game message overlay ─────────────────────────────────────── */
.cupcake2048-game .game-container .game-message {
  display: none;
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  background: rgba(255, 245, 248, .82);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  text-align: center;
  border-radius: 14px;
  animation: cupcake-fade-in 600ms ease 800ms both;
}
.cupcake2048-game .game-container .game-message p {
  font-size: 48px;
  font-weight: 700;
  height: 48px;
  line-height: 48px;
  margin-top: 180px;
  color: #c2255c;
}
.cupcake2048-game .game-container .game-message .lower {
  display: block;
  margin-top: 40px;
}
.cupcake2048-game .game-container .game-message a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ff6b9d 0%, #ee4f8a 100%);
  border-radius: 10px;
  padding: 10px 22px;
  text-decoration: none;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  margin: 0 6px;
  transition: transform .15s ease, box-shadow .15s ease;
  box-shadow: 0 3px 12px rgba(238, 79, 138, .3);
}
.cupcake2048-game .game-container .game-message a:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(238, 79, 138, .4);
  color: #fff;
}
.cupcake2048-game .game-container .game-message a.keep-playing-button {
  display: none;
  background: transparent;
  border: 2px solid #ee4f8a;
  color: #c2255c;
  box-shadow: none;
}
.cupcake2048-game .game-container .game-message a.keep-playing-button:hover {
  background: rgba(238, 79, 138, .08);
  box-shadow: none;
}
.cupcake2048-game .game-container .game-message .score-sharing {
  display: inline-block;
  vertical-align: middle;
  margin-left: 10px;
}
.cupcake2048-game .game-container .game-message.game-won {
  background: rgba(88, 46, 116, .6);
  backdrop-filter: blur(6px);
}
.cupcake2048-game .game-container .game-message.game-won p {
  color: #fff;
}
.cupcake2048-game .game-container .game-message.game-won a.keep-playing-button {
  display: inline-flex;
  border-color: rgba(255,255,255,.5);
  color: #fff;
}
.cupcake2048-game .game-container .game-message.game-won a.keep-playing-button:hover {
  background: rgba(255,255,255,.15);
}
.cupcake2048-game .game-container .game-message.game-won,
.cupcake2048-game .game-container .game-message.game-over {
  display: block;
}

/* ── Grid ─────────────────────────────────────────────────────── */
.cupcake2048-game .grid-container {
  position: absolute;
  z-index: 1;
}
.cupcake2048-game .grid-row {
  margin-bottom: 8px;
}
.cupcake2048-game .grid-row:last-child {
  margin-bottom: 0;
}
.cupcake2048-game .grid-row::after {
  content: "";
  display: block;
  clear: both;
}
.cupcake2048-game .grid-cell {
  width: 106px;
  height: 106px;
  margin-right: 8px;
  float: left;
  border-radius: 10px;
  background: rgba(255, 255, 255, .25);
}
.cupcake2048-game .grid-cell:last-child {
  margin-right: 0;
}

/* ── Tile base ────────────────────────────────────────────────── */
.cupcake2048-game .tile-container {
  position: absolute;
  z-index: 2;
}
.cupcake2048-game .tile,
.cupcake2048-game .tile .tile-inner {
  width: 106px;
  height: 106px;
  line-height: 106px;
}
.cupcake2048-game .tile {
  position: absolute;
  transition: transform 100ms ease-in-out;
}
.cupcake2048-game .tile .tile-inner {
  border-radius: 10px;
  background: #fff;
  text-align: center;
  font-weight: 700;
  z-index: 10;
  font-size: 55px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,.06);
}
.cupcake2048-game .tile .tile-inner img {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  display: block;
}

/* ── Tile positions (desktop 472px board, 12px padding, 106px tiles, 8px gap) ── */
/* Step = 106 + 8 = 114px */
.cupcake2048-game .tile.tile-position-1-1 { transform: translate(0px, 0px); }
.cupcake2048-game .tile.tile-position-1-2 { transform: translate(0px, 114px); }
.cupcake2048-game .tile.tile-position-1-3 { transform: translate(0px, 228px); }
.cupcake2048-game .tile.tile-position-1-4 { transform: translate(0px, 342px); }
.cupcake2048-game .tile.tile-position-2-1 { transform: translate(114px, 0px); }
.cupcake2048-game .tile.tile-position-2-2 { transform: translate(114px, 114px); }
.cupcake2048-game .tile.tile-position-2-3 { transform: translate(114px, 228px); }
.cupcake2048-game .tile.tile-position-2-4 { transform: translate(114px, 342px); }
.cupcake2048-game .tile.tile-position-3-1 { transform: translate(228px, 0px); }
.cupcake2048-game .tile.tile-position-3-2 { transform: translate(228px, 114px); }
.cupcake2048-game .tile.tile-position-3-3 { transform: translate(228px, 228px); }
.cupcake2048-game .tile.tile-position-3-4 { transform: translate(228px, 342px); }
.cupcake2048-game .tile.tile-position-4-1 { transform: translate(342px, 0px); }
.cupcake2048-game .tile.tile-position-4-2 { transform: translate(342px, 114px); }
.cupcake2048-game .tile.tile-position-4-3 { transform: translate(342px, 228px); }
.cupcake2048-game .tile.tile-position-4-4 { transform: translate(342px, 342px); }

/* ── Tile value backgrounds ───────────────────────────────────── */
.cupcake2048-game .tile.tile-2 .tile-inner { background: #fff; }
.cupcake2048-game .tile.tile-4 .tile-inner { background: #fef0f5; }
.cupcake2048-game .tile.tile-8 .tile-inner { background: #fde2eb; }
.cupcake2048-game .tile.tile-16 .tile-inner { background: #fbd4e1; }
.cupcake2048-game .tile.tile-32 .tile-inner { background: #f9c6d7; box-shadow: 0 0 20px 6px rgba(238,79,138,.08); }
.cupcake2048-game .tile.tile-64 .tile-inner { background: #f6b8cd; box-shadow: 0 0 20px 6px rgba(238,79,138,.14); }
.cupcake2048-game .tile.tile-128 .tile-inner { background: #f3aac3; box-shadow: 0 0 24px 8px rgba(238,79,138,.2); }
.cupcake2048-game .tile.tile-256 .tile-inner { background: #f09cb9; box-shadow: 0 0 24px 8px rgba(238,79,138,.26); }
.cupcake2048-game .tile.tile-512 .tile-inner { background: #ec8eaf; box-shadow: 0 0 28px 10px rgba(200,40,120,.3); }
.cupcake2048-game .tile.tile-1024 .tile-inner { background: #e880a5; box-shadow: 0 0 28px 10px rgba(200,40,120,.36); }
.cupcake2048-game .tile.tile-2048 .tile-inner { background: #e4729b; box-shadow: 0 0 32px 12px rgba(200,40,120,.42); }
.cupcake2048-game .tile.tile-super .tile-inner { color: white; background: #8b2252; }

/* ── Tile animations ──────────────────────────────────────────── */
@keyframes cupcake-appear {
  0%   { opacity: 0; transform: scale(0); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes cupcake-pop {
  0%   { transform: scale(0); }
  50%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}
.cupcake2048-game .tile-new .tile-inner {
  animation: cupcake-appear 200ms ease 100ms backwards;
}
.cupcake2048-game .tile-merged .tile-inner {
  z-index: 20;
  animation: cupcake-pop 200ms ease 100ms backwards;
}

/* ── Game explanation ─────────────────────────────────────────── */
.cupcake2048-game .game-explanation {
  margin-top: 24px;
  font-size: 14px;
  color: #6b3a56;
}

/* ── Legend ────────────────────────────────────────────────────── */
.cupcake2048-game .legend-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 0;
}
.cupcake2048-game .legend-row::after {
  display: none;
}
.cupcake2048-game .legend-row p {
  margin: 0;
  text-transform: capitalize;
  font-size: 14px;
  color: #6b3a56;
}
.cupcake2048-game .legend-grid {
  position: relative;
  padding: 6px;
  cursor: default;
  background: linear-gradient(145deg, #f472a0, #e8508c);
  border-radius: 10px;
  width: 64px;
  height: 64px;
  flex-shrink: 0;
}
.cupcake2048-game .legend-cell {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .25);
  overflow: hidden;
}
.cupcake2048-game .legend-cell img {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  display: block;
}

/* Legend cell backgrounds */
.cupcake2048-game .cell-2 { background: #fff; }
.cupcake2048-game .cell-4 { background: #fef0f5; }
.cupcake2048-game .cell-8 { background: #fde2eb; }
.cupcake2048-game .cell-16 { background: #fbd4e1; }
.cupcake2048-game .cell-32 { background: #f9c6d7; }
.cupcake2048-game .cell-64 { background: #f6b8cd; }
.cupcake2048-game .cell-128 { background: #f3aac3; }
.cupcake2048-game .cell-256 { background: #f09cb9; }
.cupcake2048-game .cell-512 { background: #ec8eaf; }
.cupcake2048-game .cell-1024 { background: #e880a5; }
.cupcake2048-game .cell-2048 { background: #e4729b; }
.cupcake2048-game .cell-4096 { background: #c2255c; }
.cupcake2048-game .cell-8192 { background: #8b2252; }

/* ================================================================
   MOBILE — max-width: 520px
   ================================================================ */
@media screen and (max-width: 520px) {
  .cupcake2048-game {
    font-size: 14px;
    width: 100%;
    max-width: 320px;
    padding: 16px;
    border-radius: 16px;
  }

  .cupcake2048-game .scores-container {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
  }

  .cupcake2048-game .score-card {
    padding: 8px 6px 6px;
    border-radius: 10px;
  }

  .cupcake2048-game .score-label {
    font-size: 9px;
  }

  .cupcake2048-game .score-container,
  .cupcake2048-game .best-container,
  .cupcake2048-game .score-points,
  .cupcake2048-game .best-points {
    font-size: 13px;
    min-height: 17px;
  }

  .cupcake2048-game .game-intro {
    font-size: 13px;
  }

  .cupcake2048-game .restart-button {
    padding: 8px 16px;
    font-size: 13px;
    border-radius: 8px;
  }

  .cupcake2048-game .game-container {
    margin-top: 12px;
    padding: 8px;
    border-radius: 12px;
    width: 288px;
    height: 288px;
  }

  .cupcake2048-game .game-container .game-message p {
    font-size: 28px;
    height: 28px;
    line-height: 28px;
    margin-top: 100px;
  }
  .cupcake2048-game .game-container .game-message .lower {
    margin-top: 24px;
  }
  .cupcake2048-game .game-container .game-message a {
    padding: 8px 16px;
    font-size: 12px;
    border-radius: 8px;
  }

  .cupcake2048-game .grid-row {
    margin-bottom: 8px;
  }
  .cupcake2048-game .grid-cell {
    width: 62px;
    height: 62px;
    margin-right: 8px;
    border-radius: 8px;
  }

  .cupcake2048-game .tile,
  .cupcake2048-game .tile .tile-inner {
    width: 62px;
    height: 62px;
    line-height: 62px;
  }
  .cupcake2048-game .tile .tile-inner {
    border-radius: 8px;
    font-size: 28px;
  }
  .cupcake2048-game .tile .tile-inner img {
    border-radius: 8px;
  }

  /* Mobile tile positions (288px board, 8px pad, 62px tiles, 8px gap = 62*4+8*3+8*2 = 288) */
  .cupcake2048-game .tile.tile-position-1-1 { transform: translate(0px, 0px); }
  .cupcake2048-game .tile.tile-position-1-2 { transform: translate(0px, 70px); }
  .cupcake2048-game .tile.tile-position-1-3 { transform: translate(0px, 140px); }
  .cupcake2048-game .tile.tile-position-1-4 { transform: translate(0px, 210px); }
  .cupcake2048-game .tile.tile-position-2-1 { transform: translate(70px, 0px); }
  .cupcake2048-game .tile.tile-position-2-2 { transform: translate(70px, 70px); }
  .cupcake2048-game .tile.tile-position-2-3 { transform: translate(70px, 140px); }
  .cupcake2048-game .tile.tile-position-2-4 { transform: translate(70px, 210px); }
  .cupcake2048-game .tile.tile-position-3-1 { transform: translate(140px, 0px); }
  .cupcake2048-game .tile.tile-position-3-2 { transform: translate(140px, 70px); }
  .cupcake2048-game .tile.tile-position-3-3 { transform: translate(140px, 140px); }
  .cupcake2048-game .tile.tile-position-3-4 { transform: translate(140px, 210px); }
  .cupcake2048-game .tile.tile-position-4-1 { transform: translate(210px, 0px); }
  .cupcake2048-game .tile.tile-position-4-2 { transform: translate(210px, 70px); }
  .cupcake2048-game .tile.tile-position-4-3 { transform: translate(210px, 140px); }
  .cupcake2048-game .tile.tile-position-4-4 { transform: translate(210px, 210px); }

  .cupcake2048-game .tile.tile-128 .tile-inner,
  .cupcake2048-game .tile.tile-256 .tile-inner,
  .cupcake2048-game .tile.tile-512 .tile-inner { font-size: 20px; }
  .cupcake2048-game .tile.tile-1024 .tile-inner,
  .cupcake2048-game .tile.tile-2048 .tile-inner { font-size: 14px; }
  .cupcake2048-game .tile.tile-super .tile-inner { font-size: 10px; }

  .cupcake2048-game .legend-grid {
    width: 52px;
    height: 52px;
    padding: 5px;
    border-radius: 8px;
  }
  .cupcake2048-game .legend-cell {
    width: 42px;
    height: 42px;
    border-radius: 6px;
  }
  .cupcake2048-game .legend-cell img {
    border-radius: 6px;
  }
  .cupcake2048-game .legend-row p {
    font-size: 13px;
  }
}
