[
  {
    "path": ".gitignore",
    "content": ".sass-cache/\n"
  },
  {
    "path": ".jshintrc",
    "content": "{\n    \"esnext\": true,\n    \"indent\": 2,\n    \"maxlen\": 80,\n    \"freeze\": true,\n    \"camelcase\": true,\n    \"unused\": true,\n    \"eqnull\": true,\n    \"proto\": true,\n    \"supernew\": true,\n    \"noyield\": true,\n    \"evil\": true,\n    \"node\": true,\n    \"boss\": true,\n    \"expr\": true,\n    \"loopfunc\": true,\n    \"white\": true,\n    \"maxdepth\": 4\n}\n"
  },
  {
    "path": "CONTRIBUTING.md",
    "content": "# Contributing\nChanges and improvements are more than welcome! Feel free to fork and open a pull request.\n\nPlease follow the house rules to have a bigger chance of your contribution being merged.\n\n## House rules\n\n### How to make changes\n - To make changes, create a new branch based on `master` (do not create one from `gh-pages` unless strictly necessary) and make them there, then create a Pull Request to master.  \n `gh-pages` is different from master in that it contains sharing features, analytics and other things that have no direct bearing with the game. `master` is the \"pure\" version of the game.\n - If you want to modify the CSS, please edit the SCSS files present in `style/`: `main.scss` and others. Don't edit the `main.css`, because it's supposed to be generated.  \n In order to compile your SCSS modifications, you need to use the `sass` gem (install it by running `gem install sass` once Ruby is installed).  \n To run SASS, simply use the following command:  \n `sass --unix-newlines --watch style/main.scss`  \n SASS will automatically recompile your css when changed.\n - `Rakefile` contains some tasks that help during development. Feel free to add useful tasks if needed.\n - Please use 2-space indentation when editing the JavaScript. A `.jshintrc` file is present, which will help your code to follow the guidelines if you install and run `jshint`.\n - Please test your modification thoroughly before submitting your Pull Request.\n\n### Changes that might not be accepted\nWe have to be conservative with the core game. This means that some modifications won't be merged, or will have to be evaluated carefully before being merged:\n\n - Undo/redo features\n - Save/reload features\n - Changes to how the tiles look or their contents\n - Changes to the layout\n - Changes to the grid size\n\n### Changes that are welcome\n - Bug fixes\n - Compatibility improvements\n - \"Under the hood\" enhancements\n - Small changes that don't have an impact on the core gameplay\n"
  },
  {
    "path": "LICENSE.txt",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2014 Gabriele Cirulli\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# 2048\nA small clone of [1024](https://play.google.com/store/apps/details?id=com.veewo.a1024), based on [Saming's 2048](http://saming.fr/p/2048/) (also a clone). 2048 was indirectly inspired by [Threes](https://asherv.com/threes/).\n\nMade just for fun. [Play it here!](http://gabrielecirulli.github.io/2048/)\n\nThe official app can also be found on the [Play Store](https://play.google.com/store/apps/details?id=com.gabrielecirulli.app2048) and [App Store!](https://itunes.apple.com/us/app/2048-by-gabriele-cirulli/id868076805)\n\n### Contributions\n\n[Anna Harren](https://github.com/iirelu/) and [sigod](https://github.com/sigod) are maintainers for this repository.\n\nOther notable contributors:\n\n - [TimPetricola](https://github.com/TimPetricola) added best score storage\n - [chrisprice](https://github.com/chrisprice) added custom code for swipe handling on mobile\n - [marcingajda](https://github.com/marcingajda) made swipes work on Windows Phone\n - [mgarciaisaia](https://github.com/mgarciaisaia) added support for Android 2.3\n\nMany thanks to [rayhaanj](https://github.com/rayhaanj), [Mechazawa](https://github.com/Mechazawa), [grant](https://github.com/grant), [remram44](https://github.com/remram44) and [ghoullier](https://github.com/ghoullier) for the many other good contributions.\n\n### Screenshot\n\n<p align=\"center\">\n  <img src=\"https://cloud.githubusercontent.com/assets/1175750/8614312/280e5dc2-26f1-11e5-9f1f-5891c3ca8b26.png\" alt=\"Screenshot\"/>\n</p>\n\nThat screenshot is fake, by the way. I never reached 2048 :smile:\n\n## Contributing\nChanges and improvements are more than welcome! Feel free to fork and open a pull request. Please make your changes in a specific branch and request to pull into `master`! If you can, please make sure the game fully works before sending the PR, as that will help speed up the process.\n\nYou can find the same information in the [contributing guide.](https://github.com/gabrielecirulli/2048/blob/master/CONTRIBUTING.md)\n\n## License\n2048 is licensed under the [MIT license.](https://github.com/gabrielecirulli/2048/blob/master/LICENSE.txt)\n\n## Donations\nI made this in my spare time, and it's hosted on GitHub (which means I don't have any hosting costs), but if you enjoyed the game and feel like buying me coffee, you can donate at my BTC address: `1Ec6onfsQmoP9kkL3zkpB6c5sA4PVcXU2i`. Thank you very much!\n"
  },
  {
    "path": "Rakefile",
    "content": "require \"date\"\n\nnamespace :appcache do\n  desc \"update the date in the appcache file (in the gh-pages branch)\"\n  task :update do\n    appcache = File.read(\"cache.appcache\")\n    updated  = \"# Updated: #{DateTime.now}\"\n\n    File.write(\"cache.appcache\", appcache.sub(/^# Updated:.*$/, updated))\n  end\nend\n"
  },
  {
    "path": "index.html",
    "content": "<!DOCTYPE html>\n<html>\n<head>\n  <meta charset=\"utf-8\">\n  <title>2048</title>\n\n  <link href=\"style/main.css\" rel=\"stylesheet\" type=\"text/css\">\n  <link rel=\"shortcut icon\" href=\"favicon.ico\">\n  <link rel=\"apple-touch-icon\" href=\"meta/apple-touch-icon.png\">\n  <link rel=\"apple-touch-startup-image\" href=\"meta/apple-touch-startup-image-640x1096.png\" media=\"(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2)\"> <!-- iPhone 5+ -->\n  <link rel=\"apple-touch-startup-image\" href=\"meta/apple-touch-startup-image-640x920.png\"  media=\"(device-width: 320px) and (device-height: 480px) and (-webkit-device-pixel-ratio: 2)\"> <!-- iPhone, retina -->\n  <meta name=\"apple-mobile-web-app-capable\" content=\"yes\">\n  <meta name=\"apple-mobile-web-app-status-bar-style\" content=\"black\">\n\n  <meta name=\"HandheldFriendly\" content=\"True\">\n  <meta name=\"MobileOptimized\" content=\"320\">\n  <meta name=\"viewport\" content=\"width=device-width, target-densitydpi=160dpi, initial-scale=1.0, maximum-scale=1, user-scalable=no, minimal-ui\">\n</head>\n<body>\n  <div class=\"container\">\n    <div class=\"heading\">\n      <h1 class=\"title\">2048</h1>\n      <div class=\"scores-container\">\n        <div class=\"score-container\">0</div>\n        <div class=\"best-container\">0</div>\n      </div>\n    </div>\n\n    <div class=\"above-game\">\n      <p class=\"game-intro\">Join the numbers and get to the <strong>2048 tile!</strong></p>\n      <a class=\"restart-button\">New Game</a>\n    </div>\n\n    <div class=\"game-container\">\n      <div class=\"game-message\">\n        <p></p>\n        <div class=\"lower\">\n\t        <a class=\"keep-playing-button\">Keep going</a>\n          <a class=\"retry-button\">Try again</a>\n        </div>\n      </div>\n\n      <div class=\"grid-container\">\n        <div class=\"grid-row\">\n          <div class=\"grid-cell\"></div>\n          <div class=\"grid-cell\"></div>\n          <div class=\"grid-cell\"></div>\n          <div class=\"grid-cell\"></div>\n        </div>\n        <div class=\"grid-row\">\n          <div class=\"grid-cell\"></div>\n          <div class=\"grid-cell\"></div>\n          <div class=\"grid-cell\"></div>\n          <div class=\"grid-cell\"></div>\n        </div>\n        <div class=\"grid-row\">\n          <div class=\"grid-cell\"></div>\n          <div class=\"grid-cell\"></div>\n          <div class=\"grid-cell\"></div>\n          <div class=\"grid-cell\"></div>\n        </div>\n        <div class=\"grid-row\">\n          <div class=\"grid-cell\"></div>\n          <div class=\"grid-cell\"></div>\n          <div class=\"grid-cell\"></div>\n          <div class=\"grid-cell\"></div>\n        </div>\n      </div>\n\n      <div class=\"tile-container\">\n\n      </div>\n    </div>\n\n    <p class=\"game-explanation\">\n      <strong class=\"important\">How to play:</strong> Use your <strong>arrow keys</strong> to move the tiles. When two tiles with the same number touch, they <strong>merge into one!</strong>\n    </p>\n    <hr>\n    <p>\n    <strong class=\"important\">Note:</strong> This site is the official version of 2048. You can play it on your phone via <a href=\"http://git.io/2048\">http://git.io/2048.</a> All other apps or sites are derivatives or fakes, and should be used with caution.\n    </p>\n    <hr>\n    <p>\n    Created by <a href=\"http://gabrielecirulli.com\" target=\"_blank\">Gabriele Cirulli.</a> Based on <a href=\"https://itunes.apple.com/us/app/1024!/id823499224\" target=\"_blank\">1024 by Veewo Studio</a> and conceptually similar to <a href=\"http://asherv.com/threes/\" target=\"_blank\">Threes by Asher Vollmer.</a>\n    </p>\n  </div>\n\n  <script src=\"js/bind_polyfill.js\"></script>\n  <script src=\"js/classlist_polyfill.js\"></script>\n  <script src=\"js/animframe_polyfill.js\"></script>\n  <script src=\"js/keyboard_input_manager.js\"></script>\n  <script src=\"js/html_actuator.js\"></script>\n  <script src=\"js/grid.js\"></script>\n  <script src=\"js/tile.js\"></script>\n  <script src=\"js/local_storage_manager.js\"></script>\n  <script src=\"js/game_manager.js\"></script>\n  <script src=\"js/application.js\"></script>\n</body>\n</html>\n"
  },
  {
    "path": "js/animframe_polyfill.js",
    "content": "(function () {\n  var lastTime = 0;\n  var vendors = ['webkit', 'moz'];\n  for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {\n    window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];\n    window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] ||\n      window[vendors[x] + 'CancelRequestAnimationFrame'];\n  }\n\n  if (!window.requestAnimationFrame) {\n    window.requestAnimationFrame = function (callback) {\n      var currTime = new Date().getTime();\n      var timeToCall = Math.max(0, 16 - (currTime - lastTime));\n      var id = window.setTimeout(function () {\n        callback(currTime + timeToCall);\n      },\n      timeToCall);\n      lastTime = currTime + timeToCall;\n      return id;\n    };\n  }\n\n  if (!window.cancelAnimationFrame) {\n    window.cancelAnimationFrame = function (id) {\n      clearTimeout(id);\n    };\n  }\n}());\n"
  },
  {
    "path": "js/application.js",
    "content": "// Wait till the browser is ready to render the game (avoids glitches)\nwindow.requestAnimationFrame(function () {\n  new GameManager(4, KeyboardInputManager, HTMLActuator, LocalStorageManager);\n});\n"
  },
  {
    "path": "js/bind_polyfill.js",
    "content": "Function.prototype.bind = Function.prototype.bind || function (target) {\n  var self = this;\n  return function (args) {\n    if (!(args instanceof Array)) {\n      args = [args];\n    }\n    self.apply(target, args);\n  };\n};\n"
  },
  {
    "path": "js/classlist_polyfill.js",
    "content": "(function () {\n  if (typeof window.Element === \"undefined\" ||\n      \"classList\" in document.documentElement) {\n    return;\n  }\n\n  var prototype = Array.prototype,\n      push = prototype.push,\n      splice = prototype.splice,\n      join = prototype.join;\n\n  function DOMTokenList(el) {\n    this.el = el;\n    // The className needs to be trimmed and split on whitespace\n    // to retrieve a list of classes.\n    var classes = el.className.replace(/^\\s+|\\s+$/g, '').split(/\\s+/);\n    for (var i = 0; i < classes.length; i++) {\n      push.call(this, classes[i]);\n    }\n  }\n\n  DOMTokenList.prototype = {\n    add: function (token) {\n      if (this.contains(token)) return;\n      push.call(this, token);\n      this.el.className = this.toString();\n    },\n    contains: function (token) {\n      return this.el.className.indexOf(token) != -1;\n    },\n    item: function (index) {\n      return this[index] || null;\n    },\n    remove: function (token) {\n      if (!this.contains(token)) return;\n      for (var i = 0; i < this.length; i++) {\n        if (this[i] == token) break;\n      }\n      splice.call(this, i, 1);\n      this.el.className = this.toString();\n    },\n    toString: function () {\n      return join.call(this, ' ');\n    },\n    toggle: function (token) {\n      if (!this.contains(token)) {\n        this.add(token);\n      } else {\n        this.remove(token);\n      }\n\n      return this.contains(token);\n    }\n  };\n\n  window.DOMTokenList = DOMTokenList;\n\n  function defineElementGetter(obj, prop, getter) {\n    if (Object.defineProperty) {\n      Object.defineProperty(obj, prop, {\n        get: getter\n      });\n    } else {\n      obj.__defineGetter__(prop, getter);\n    }\n  }\n\n  defineElementGetter(HTMLElement.prototype, 'classList', function () {\n    return new DOMTokenList(this);\n  });\n})();\n"
  },
  {
    "path": "js/game_manager.js",
    "content": "function GameManager(size, InputManager, Actuator, StorageManager) {\n  this.size           = size; // Size of the grid\n  this.inputManager   = new InputManager;\n  this.storageManager = new StorageManager;\n  this.actuator       = new Actuator;\n\n  this.startTiles     = 2;\n\n  this.inputManager.on(\"move\", this.move.bind(this));\n  this.inputManager.on(\"restart\", this.restart.bind(this));\n  this.inputManager.on(\"keepPlaying\", this.keepPlaying.bind(this));\n\n  this.setup();\n}\n\n// Restart the game\nGameManager.prototype.restart = function () {\n  this.storageManager.clearGameState();\n  this.actuator.continueGame(); // Clear the game won/lost message\n  this.setup();\n};\n\n// Keep playing after winning (allows going over 2048)\nGameManager.prototype.keepPlaying = function () {\n  this.keepPlaying = true;\n  this.actuator.continueGame(); // Clear the game won/lost message\n};\n\n// Return true if the game is lost, or has won and the user hasn't kept playing\nGameManager.prototype.isGameTerminated = function () {\n  return this.over || (this.won && !this.keepPlaying);\n};\n\n// Set up the game\nGameManager.prototype.setup = function () {\n  var previousState = this.storageManager.getGameState();\n\n  // Reload the game from a previous game if present\n  if (previousState) {\n    this.grid        = new Grid(previousState.grid.size,\n                                previousState.grid.cells); // Reload grid\n    this.score       = previousState.score;\n    this.over        = previousState.over;\n    this.won         = previousState.won;\n    this.keepPlaying = previousState.keepPlaying;\n  } else {\n    this.grid        = new Grid(this.size);\n    this.score       = 0;\n    this.over        = false;\n    this.won         = false;\n    this.keepPlaying = false;\n\n    // Add the initial tiles\n    this.addStartTiles();\n  }\n\n  // Update the actuator\n  this.actuate();\n};\n\n// Set up the initial tiles to start the game with\nGameManager.prototype.addStartTiles = function () {\n  for (var i = 0; i < this.startTiles; i++) {\n    this.addRandomTile();\n  }\n};\n\n// Adds a tile in a random position\nGameManager.prototype.addRandomTile = function () {\n  if (this.grid.cellsAvailable()) {\n    var value = Math.random() < 0.9 ? 2 : 4;\n    var tile = new Tile(this.grid.randomAvailableCell(), value);\n\n    this.grid.insertTile(tile);\n  }\n};\n\n// Sends the updated grid to the actuator\nGameManager.prototype.actuate = function () {\n  if (this.storageManager.getBestScore() < this.score) {\n    this.storageManager.setBestScore(this.score);\n  }\n\n  // Clear the state when the game is over (game over only, not win)\n  if (this.over) {\n    this.storageManager.clearGameState();\n  } else {\n    this.storageManager.setGameState(this.serialize());\n  }\n\n  this.actuator.actuate(this.grid, {\n    score:      this.score,\n    over:       this.over,\n    won:        this.won,\n    bestScore:  this.storageManager.getBestScore(),\n    terminated: this.isGameTerminated()\n  });\n\n};\n\n// Represent the current game as an object\nGameManager.prototype.serialize = function () {\n  return {\n    grid:        this.grid.serialize(),\n    score:       this.score,\n    over:        this.over,\n    won:         this.won,\n    keepPlaying: this.keepPlaying\n  };\n};\n\n// Save all tile positions and remove merger info\nGameManager.prototype.prepareTiles = function () {\n  this.grid.eachCell(function (x, y, tile) {\n    if (tile) {\n      tile.mergedFrom = null;\n      tile.savePosition();\n    }\n  });\n};\n\n// Move a tile and its representation\nGameManager.prototype.moveTile = function (tile, cell) {\n  this.grid.cells[tile.x][tile.y] = null;\n  this.grid.cells[cell.x][cell.y] = tile;\n  tile.updatePosition(cell);\n};\n\n// Move tiles on the grid in the specified direction\nGameManager.prototype.move = function (direction) {\n  // 0: up, 1: right, 2: down, 3: left\n  var self = this;\n\n  if (this.isGameTerminated()) return; // Don't do anything if the game's over\n\n  var cell, tile;\n\n  var vector     = this.getVector(direction);\n  var traversals = this.buildTraversals(vector);\n  var moved      = false;\n\n  // Save the current tile positions and remove merger information\n  this.prepareTiles();\n\n  // Traverse the grid in the right direction and move tiles\n  traversals.x.forEach(function (x) {\n    traversals.y.forEach(function (y) {\n      cell = { x: x, y: y };\n      tile = self.grid.cellContent(cell);\n\n      if (tile) {\n        var positions = self.findFarthestPosition(cell, vector);\n        var next      = self.grid.cellContent(positions.next);\n\n        // Only one merger per row traversal?\n        if (next && next.value === tile.value && !next.mergedFrom) {\n          var merged = new Tile(positions.next, tile.value * 2);\n          merged.mergedFrom = [tile, next];\n\n          self.grid.insertTile(merged);\n          self.grid.removeTile(tile);\n\n          // Converge the two tiles' positions\n          tile.updatePosition(positions.next);\n\n          // Update the score\n          self.score += merged.value;\n\n          // The mighty 2048 tile\n          if (merged.value === 2048) self.won = true;\n        } else {\n          self.moveTile(tile, positions.farthest);\n        }\n\n        if (!self.positionsEqual(cell, tile)) {\n          moved = true; // The tile moved from its original cell!\n        }\n      }\n    });\n  });\n\n  if (moved) {\n    this.addRandomTile();\n\n    if (!this.movesAvailable()) {\n      this.over = true; // Game over!\n    }\n\n    this.actuate();\n  }\n};\n\n// Get the vector representing the chosen direction\nGameManager.prototype.getVector = function (direction) {\n  // Vectors representing tile movement\n  var map = {\n    0: { x: 0,  y: -1 }, // Up\n    1: { x: 1,  y: 0 },  // Right\n    2: { x: 0,  y: 1 },  // Down\n    3: { x: -1, y: 0 }   // Left\n  };\n\n  return map[direction];\n};\n\n// Build a list of positions to traverse in the right order\nGameManager.prototype.buildTraversals = function (vector) {\n  var traversals = { x: [], y: [] };\n\n  for (var pos = 0; pos < this.size; pos++) {\n    traversals.x.push(pos);\n    traversals.y.push(pos);\n  }\n\n  // Always traverse from the farthest cell in the chosen direction\n  if (vector.x === 1) traversals.x = traversals.x.reverse();\n  if (vector.y === 1) traversals.y = traversals.y.reverse();\n\n  return traversals;\n};\n\nGameManager.prototype.findFarthestPosition = function (cell, vector) {\n  var previous;\n\n  // Progress towards the vector direction until an obstacle is found\n  do {\n    previous = cell;\n    cell     = { x: previous.x + vector.x, y: previous.y + vector.y };\n  } while (this.grid.withinBounds(cell) &&\n           this.grid.cellAvailable(cell));\n\n  return {\n    farthest: previous,\n    next: cell // Used to check if a merge is required\n  };\n};\n\nGameManager.prototype.movesAvailable = function () {\n  return this.grid.cellsAvailable() || this.tileMatchesAvailable();\n};\n\n// Check for available matches between tiles (more expensive check)\nGameManager.prototype.tileMatchesAvailable = function () {\n  var self = this;\n\n  var tile;\n\n  for (var x = 0; x < this.size; x++) {\n    for (var y = 0; y < this.size; y++) {\n      tile = this.grid.cellContent({ x: x, y: y });\n\n      if (tile) {\n        for (var direction = 0; direction < 4; direction++) {\n          var vector = self.getVector(direction);\n          var cell   = { x: x + vector.x, y: y + vector.y };\n\n          var other  = self.grid.cellContent(cell);\n\n          if (other && other.value === tile.value) {\n            return true; // These two tiles can be merged\n          }\n        }\n      }\n    }\n  }\n\n  return false;\n};\n\nGameManager.prototype.positionsEqual = function (first, second) {\n  return first.x === second.x && first.y === second.y;\n};\n"
  },
  {
    "path": "js/grid.js",
    "content": "function Grid(size, previousState) {\n  this.size = size;\n  this.cells = previousState ? this.fromState(previousState) : this.empty();\n}\n\n// Build a grid of the specified size\nGrid.prototype.empty = function () {\n  var cells = [];\n\n  for (var x = 0; x < this.size; x++) {\n    var row = cells[x] = [];\n\n    for (var y = 0; y < this.size; y++) {\n      row.push(null);\n    }\n  }\n\n  return cells;\n};\n\nGrid.prototype.fromState = function (state) {\n  var cells = [];\n\n  for (var x = 0; x < this.size; x++) {\n    var row = cells[x] = [];\n\n    for (var y = 0; y < this.size; y++) {\n      var tile = state[x][y];\n      row.push(tile ? new Tile(tile.position, tile.value) : null);\n    }\n  }\n\n  return cells;\n};\n\n// Find the first available random position\nGrid.prototype.randomAvailableCell = function () {\n  var cells = this.availableCells();\n\n  if (cells.length) {\n    return cells[Math.floor(Math.random() * cells.length)];\n  }\n};\n\nGrid.prototype.availableCells = function () {\n  var cells = [];\n\n  this.eachCell(function (x, y, tile) {\n    if (!tile) {\n      cells.push({ x: x, y: y });\n    }\n  });\n\n  return cells;\n};\n\n// Call callback for every cell\nGrid.prototype.eachCell = function (callback) {\n  for (var x = 0; x < this.size; x++) {\n    for (var y = 0; y < this.size; y++) {\n      callback(x, y, this.cells[x][y]);\n    }\n  }\n};\n\n// Check if there are any cells available\nGrid.prototype.cellsAvailable = function () {\n  return !!this.availableCells().length;\n};\n\n// Check if the specified cell is taken\nGrid.prototype.cellAvailable = function (cell) {\n  return !this.cellOccupied(cell);\n};\n\nGrid.prototype.cellOccupied = function (cell) {\n  return !!this.cellContent(cell);\n};\n\nGrid.prototype.cellContent = function (cell) {\n  if (this.withinBounds(cell)) {\n    return this.cells[cell.x][cell.y];\n  } else {\n    return null;\n  }\n};\n\n// Inserts a tile at its position\nGrid.prototype.insertTile = function (tile) {\n  this.cells[tile.x][tile.y] = tile;\n};\n\nGrid.prototype.removeTile = function (tile) {\n  this.cells[tile.x][tile.y] = null;\n};\n\nGrid.prototype.withinBounds = function (position) {\n  return position.x >= 0 && position.x < this.size &&\n         position.y >= 0 && position.y < this.size;\n};\n\nGrid.prototype.serialize = function () {\n  var cellState = [];\n\n  for (var x = 0; x < this.size; x++) {\n    var row = cellState[x] = [];\n\n    for (var y = 0; y < this.size; y++) {\n      row.push(this.cells[x][y] ? this.cells[x][y].serialize() : null);\n    }\n  }\n\n  return {\n    size: this.size,\n    cells: cellState\n  };\n};\n"
  },
  {
    "path": "js/html_actuator.js",
    "content": "function HTMLActuator() {\n  this.tileContainer    = document.querySelector(\".tile-container\");\n  this.scoreContainer   = document.querySelector(\".score-container\");\n  this.bestContainer    = document.querySelector(\".best-container\");\n  this.messageContainer = document.querySelector(\".game-message\");\n\n  this.score = 0;\n}\n\nHTMLActuator.prototype.actuate = function (grid, metadata) {\n  var self = this;\n\n  window.requestAnimationFrame(function () {\n    self.clearContainer(self.tileContainer);\n\n    grid.cells.forEach(function (column) {\n      column.forEach(function (cell) {\n        if (cell) {\n          self.addTile(cell);\n        }\n      });\n    });\n\n    self.updateScore(metadata.score);\n    self.updateBestScore(metadata.bestScore);\n\n    if (metadata.terminated) {\n      if (metadata.over) {\n        self.message(false); // You lose\n      } else if (metadata.won) {\n        self.message(true); // You win!\n      }\n    }\n\n  });\n};\n\n// Continues the game (both restart and keep playing)\nHTMLActuator.prototype.continueGame = function () {\n  this.clearMessage();\n};\n\nHTMLActuator.prototype.clearContainer = function (container) {\n  while (container.firstChild) {\n    container.removeChild(container.firstChild);\n  }\n};\n\nHTMLActuator.prototype.addTile = function (tile) {\n  var self = this;\n\n  var wrapper   = document.createElement(\"div\");\n  var inner     = document.createElement(\"div\");\n  var position  = tile.previousPosition || { x: tile.x, y: tile.y };\n  var positionClass = this.positionClass(position);\n\n  // We can't use classlist because it somehow glitches when replacing classes\n  var classes = [\"tile\", \"tile-\" + tile.value, positionClass];\n\n  if (tile.value > 2048) classes.push(\"tile-super\");\n\n  this.applyClasses(wrapper, classes);\n\n  inner.classList.add(\"tile-inner\");\n  inner.textContent = tile.value;\n\n  if (tile.previousPosition) {\n    // Make sure that the tile gets rendered in the previous position first\n    window.requestAnimationFrame(function () {\n      classes[2] = self.positionClass({ x: tile.x, y: tile.y });\n      self.applyClasses(wrapper, classes); // Update the position\n    });\n  } else if (tile.mergedFrom) {\n    classes.push(\"tile-merged\");\n    this.applyClasses(wrapper, classes);\n\n    // Render the tiles that merged\n    tile.mergedFrom.forEach(function (merged) {\n      self.addTile(merged);\n    });\n  } else {\n    classes.push(\"tile-new\");\n    this.applyClasses(wrapper, classes);\n  }\n\n  // Add the inner part of the tile to the wrapper\n  wrapper.appendChild(inner);\n\n  // Put the tile on the board\n  this.tileContainer.appendChild(wrapper);\n};\n\nHTMLActuator.prototype.applyClasses = function (element, classes) {\n  element.setAttribute(\"class\", classes.join(\" \"));\n};\n\nHTMLActuator.prototype.normalizePosition = function (position) {\n  return { x: position.x + 1, y: position.y + 1 };\n};\n\nHTMLActuator.prototype.positionClass = function (position) {\n  position = this.normalizePosition(position);\n  return \"tile-position-\" + position.x + \"-\" + position.y;\n};\n\nHTMLActuator.prototype.updateScore = function (score) {\n  this.clearContainer(this.scoreContainer);\n\n  var difference = score - this.score;\n  this.score = score;\n\n  this.scoreContainer.textContent = this.score;\n\n  if (difference > 0) {\n    var addition = document.createElement(\"div\");\n    addition.classList.add(\"score-addition\");\n    addition.textContent = \"+\" + difference;\n\n    this.scoreContainer.appendChild(addition);\n  }\n};\n\nHTMLActuator.prototype.updateBestScore = function (bestScore) {\n  this.bestContainer.textContent = bestScore;\n};\n\nHTMLActuator.prototype.message = function (won) {\n  var type    = won ? \"game-won\" : \"game-over\";\n  var message = won ? \"You win!\" : \"Game over!\";\n\n  this.messageContainer.classList.add(type);\n  this.messageContainer.getElementsByTagName(\"p\")[0].textContent = message;\n};\n\nHTMLActuator.prototype.clearMessage = function () {\n  // IE only takes one value to remove at a time.\n  this.messageContainer.classList.remove(\"game-won\");\n  this.messageContainer.classList.remove(\"game-over\");\n};\n"
  },
  {
    "path": "js/keyboard_input_manager.js",
    "content": "function KeyboardInputManager() {\n  this.events = {};\n\n  if (window.navigator.msPointerEnabled) {\n    //Internet Explorer 10 style\n    this.eventTouchstart    = \"MSPointerDown\";\n    this.eventTouchmove     = \"MSPointerMove\";\n    this.eventTouchend      = \"MSPointerUp\";\n  } else {\n    this.eventTouchstart    = \"touchstart\";\n    this.eventTouchmove     = \"touchmove\";\n    this.eventTouchend      = \"touchend\";\n  }\n\n  this.listen();\n}\n\nKeyboardInputManager.prototype.on = function (event, callback) {\n  if (!this.events[event]) {\n    this.events[event] = [];\n  }\n  this.events[event].push(callback);\n};\n\nKeyboardInputManager.prototype.emit = function (event, data) {\n  var callbacks = this.events[event];\n  if (callbacks) {\n    callbacks.forEach(function (callback) {\n      callback(data);\n    });\n  }\n};\n\nKeyboardInputManager.prototype.listen = function () {\n  var self = this;\n\n  var map = {\n    38: 0, // Up\n    39: 1, // Right\n    40: 2, // Down\n    37: 3, // Left\n    75: 0, // Vim up\n    76: 1, // Vim right\n    74: 2, // Vim down\n    72: 3, // Vim left\n    87: 0, // W\n    68: 1, // D\n    83: 2, // S\n    65: 3  // A\n  };\n\n  // Respond to direction keys\n  document.addEventListener(\"keydown\", function (event) {\n    var modifiers = event.altKey || event.ctrlKey || event.metaKey ||\n                    event.shiftKey;\n    var mapped    = map[event.which];\n\n    if (!modifiers) {\n      if (mapped !== undefined) {\n        event.preventDefault();\n        self.emit(\"move\", mapped);\n      }\n    }\n\n    // R key restarts the game\n    if (!modifiers && event.which === 82) {\n      self.restart.call(self, event);\n    }\n  });\n\n  // Respond to button presses\n  this.bindButtonPress(\".retry-button\", this.restart);\n  this.bindButtonPress(\".restart-button\", this.restart);\n  this.bindButtonPress(\".keep-playing-button\", this.keepPlaying);\n\n  // Respond to swipe events\n  var touchStartClientX, touchStartClientY;\n  var gameContainer = document.getElementsByClassName(\"game-container\")[0];\n\n  gameContainer.addEventListener(this.eventTouchstart, function (event) {\n    if ((!window.navigator.msPointerEnabled && event.touches.length > 1) ||\n        event.targetTouches.length > 1) {\n      return; // Ignore if touching with more than 1 finger\n    }\n\n    if (window.navigator.msPointerEnabled) {\n      touchStartClientX = event.pageX;\n      touchStartClientY = event.pageY;\n    } else {\n      touchStartClientX = event.touches[0].clientX;\n      touchStartClientY = event.touches[0].clientY;\n    }\n\n    event.preventDefault();\n  });\n\n  gameContainer.addEventListener(this.eventTouchmove, function (event) {\n    event.preventDefault();\n  });\n\n  gameContainer.addEventListener(this.eventTouchend, function (event) {\n    if ((!window.navigator.msPointerEnabled && event.touches.length > 0) ||\n        event.targetTouches.length > 0) {\n      return; // Ignore if still touching with one or more fingers\n    }\n\n    var touchEndClientX, touchEndClientY;\n\n    if (window.navigator.msPointerEnabled) {\n      touchEndClientX = event.pageX;\n      touchEndClientY = event.pageY;\n    } else {\n      touchEndClientX = event.changedTouches[0].clientX;\n      touchEndClientY = event.changedTouches[0].clientY;\n    }\n\n    var dx = touchEndClientX - touchStartClientX;\n    var absDx = Math.abs(dx);\n\n    var dy = touchEndClientY - touchStartClientY;\n    var absDy = Math.abs(dy);\n\n    if (Math.max(absDx, absDy) > 10) {\n      // (right : left) : (down : up)\n      self.emit(\"move\", absDx > absDy ? (dx > 0 ? 1 : 3) : (dy > 0 ? 2 : 0));\n    }\n  });\n};\n\nKeyboardInputManager.prototype.restart = function (event) {\n  event.preventDefault();\n  this.emit(\"restart\");\n};\n\nKeyboardInputManager.prototype.keepPlaying = function (event) {\n  event.preventDefault();\n  this.emit(\"keepPlaying\");\n};\n\nKeyboardInputManager.prototype.bindButtonPress = function (selector, fn) {\n  var button = document.querySelector(selector);\n  button.addEventListener(\"click\", fn.bind(this));\n  button.addEventListener(this.eventTouchend, fn.bind(this));\n};\n"
  },
  {
    "path": "js/local_storage_manager.js",
    "content": "window.fakeStorage = {\n  _data: {},\n\n  setItem: function (id, val) {\n    return this._data[id] = String(val);\n  },\n\n  getItem: function (id) {\n    return this._data.hasOwnProperty(id) ? this._data[id] : undefined;\n  },\n\n  removeItem: function (id) {\n    return delete this._data[id];\n  },\n\n  clear: function () {\n    return this._data = {};\n  }\n};\n\nfunction LocalStorageManager() {\n  this.bestScoreKey     = \"bestScore\";\n  this.gameStateKey     = \"gameState\";\n\n  var supported = this.localStorageSupported();\n  this.storage = supported ? window.localStorage : window.fakeStorage;\n}\n\nLocalStorageManager.prototype.localStorageSupported = function () {\n  var testKey = \"test\";\n\n  try {\n    var storage = window.localStorage;\n    storage.setItem(testKey, \"1\");\n    storage.removeItem(testKey);\n    return true;\n  } catch (error) {\n    return false;\n  }\n};\n\n// Best score getters/setters\nLocalStorageManager.prototype.getBestScore = function () {\n  return this.storage.getItem(this.bestScoreKey) || 0;\n};\n\nLocalStorageManager.prototype.setBestScore = function (score) {\n  this.storage.setItem(this.bestScoreKey, score);\n};\n\n// Game state getters/setters and clearing\nLocalStorageManager.prototype.getGameState = function () {\n  var stateJSON = this.storage.getItem(this.gameStateKey);\n  return stateJSON ? JSON.parse(stateJSON) : null;\n};\n\nLocalStorageManager.prototype.setGameState = function (gameState) {\n  this.storage.setItem(this.gameStateKey, JSON.stringify(gameState));\n};\n\nLocalStorageManager.prototype.clearGameState = function () {\n  this.storage.removeItem(this.gameStateKey);\n};\n"
  },
  {
    "path": "js/tile.js",
    "content": "function Tile(position, value) {\n  this.x                = position.x;\n  this.y                = position.y;\n  this.value            = value || 2;\n\n  this.previousPosition = null;\n  this.mergedFrom       = null; // Tracks tiles that merged together\n}\n\nTile.prototype.savePosition = function () {\n  this.previousPosition = { x: this.x, y: this.y };\n};\n\nTile.prototype.updatePosition = function (position) {\n  this.x = position.x;\n  this.y = position.y;\n};\n\nTile.prototype.serialize = function () {\n  return {\n    position: {\n      x: this.x,\n      y: this.y\n    },\n    value: this.value\n  };\n};\n"
  },
  {
    "path": "style/fonts/clear-sans.css",
    "content": "@font-face {\n    font-family: \"Clear Sans\";\n    src: url(\"ClearSans-Light-webfont.eot\");\n    src: url(\"ClearSans-Light-webfont.eot?#iefix\") format(\"embedded-opentype\"),\n         url(\"ClearSans-Light-webfont.svg#clear_sans_lightregular\") format(\"svg\"),\n         url(\"ClearSans-Light-webfont.woff\") format(\"woff\");\n    font-weight: 200;\n    font-style: normal;\n}\n\n@font-face {\n    font-family: \"Clear Sans\";\n    src: url(\"ClearSans-Regular-webfont.eot\");\n    src: url(\"ClearSans-Regular-webfont.eot?#iefix\") format(\"embedded-opentype\"),\n         url(\"ClearSans-Regular-webfont.svg#clear_sansregular\") format(\"svg\"),\n         url(\"ClearSans-Regular-webfont.woff\") format(\"woff\");\n    font-weight: normal;\n    font-style: normal;\n}\n\n@font-face {\n    font-family: \"Clear Sans\";\n    src: url(\"ClearSans-Bold-webfont.eot\");\n    src: url(\"ClearSans-Bold-webfont.eot?#iefix\") format(\"embedded-opentype\"),\n         url(\"ClearSans-Bold-webfont.svg#clear_sansbold\") format(\"svg\"),\n         url(\"ClearSans-Bold-webfont.woff\") format(\"woff\");\n    font-weight: 700;\n    font-style: normal;\n}\n\n"
  },
  {
    "path": "style/helpers.scss",
    "content": "// Exponent\n// From: https://github.com/Team-Sass/Sassy-math/blob/master/sass/math.scss#L36\n\n@function exponent($base, $exponent) {\n  // reset value\n  $value: $base;\n  // positive intergers get multiplied\n  @if $exponent > 1 {\n    @for $i from 2 through $exponent {\n      $value: $value * $base; } }\n  // negitive intergers get divided. A number divided by itself is 1\n  @if $exponent < 1 {\n    @for $i from 0 through -$exponent {\n      $value: $value / $base; } }\n  // return the last value written\n  @return $value;\n}\n\n@function pow($base, $exponent) {\n  @return exponent($base, $exponent);\n}\n\n// Transition mixins\n@mixin transition($args...) {\n  -webkit-transition: $args;\n  -moz-transition: $args;\n  transition: $args;\n}\n\n@mixin transition-property($args...) {\n  -webkit-transition-property: $args;\n  -moz-transition-property: $args;\n  transition-property: $args;\n}\n\n@mixin animation($args...) {\n  -webkit-animation: $args;\n  -moz-animation: $args;\n  animation: $args;\n}\n\n@mixin animation-fill-mode($args...) {\n  -webkit-animation-fill-mode: $args;\n  -moz-animation-fill-mode: $args;\n  animation-fill-mode: $args;\n}\n\n@mixin transform($args...) {\n  -webkit-transform: $args;\n  -moz-transform: $args;\n  -ms-transform: $args;\n  transform: $args;\n}\n\n// Keyframe animations\n@mixin keyframes($animation-name) {\n  @-webkit-keyframes $animation-name {\n    @content;\n  }\n  @-moz-keyframes $animation-name {\n    @content;\n  }\n  @keyframes $animation-name {\n    @content;\n  }\n}\n\n// Media queries\n@mixin smaller($width) {\n  @media screen and (max-width: $width) {\n    @content;\n  }\n}\n\n// Clearfix\n@mixin clearfix {\n  &:after {\n    content: \"\";\n    display: block;\n    clear: both;\n  }\n}\n"
  },
  {
    "path": "style/main.css",
    "content": "@import url(fonts/clear-sans.css);\nhtml, body {\n  margin: 0;\n  padding: 0;\n  background: #faf8ef;\n  color: #776e65;\n  font-family: \"Clear Sans\", \"Helvetica Neue\", Arial, sans-serif;\n  font-size: 18px; }\n\nbody {\n  margin: 80px 0; }\n\n.heading:after {\n  content: \"\";\n  display: block;\n  clear: both; }\n\nh1.title {\n  font-size: 80px;\n  font-weight: bold;\n  margin: 0;\n  display: block;\n  float: left; }\n\n@-webkit-keyframes move-up {\n  0% {\n    top: 25px;\n    opacity: 1; }\n\n  100% {\n    top: -50px;\n    opacity: 0; } }\n@-moz-keyframes move-up {\n  0% {\n    top: 25px;\n    opacity: 1; }\n\n  100% {\n    top: -50px;\n    opacity: 0; } }\n@keyframes move-up {\n  0% {\n    top: 25px;\n    opacity: 1; }\n\n  100% {\n    top: -50px;\n    opacity: 0; } }\n.scores-container {\n  float: right;\n  text-align: right; }\n\n.score-container, .best-container {\n  position: relative;\n  display: inline-block;\n  background: #bbada0;\n  padding: 15px 25px;\n  font-size: 25px;\n  height: 25px;\n  line-height: 47px;\n  font-weight: bold;\n  border-radius: 3px;\n  color: white;\n  margin-top: 8px;\n  text-align: center; }\n  .score-container:after, .best-container:after {\n    position: absolute;\n    width: 100%;\n    top: 10px;\n    left: 0;\n    text-transform: uppercase;\n    font-size: 13px;\n    line-height: 13px;\n    text-align: center;\n    color: #eee4da; }\n  .score-container .score-addition, .best-container .score-addition {\n    position: absolute;\n    right: 30px;\n    color: red;\n    font-size: 25px;\n    line-height: 25px;\n    font-weight: bold;\n    color: rgba(119, 110, 101, 0.9);\n    z-index: 100;\n    -webkit-animation: move-up 600ms ease-in;\n    -moz-animation: move-up 600ms ease-in;\n    animation: move-up 600ms ease-in;\n    -webkit-animation-fill-mode: both;\n    -moz-animation-fill-mode: both;\n    animation-fill-mode: both; }\n\n.score-container:after {\n  content: \"Score\"; }\n\n.best-container:after {\n  content: \"Best\"; }\n\np {\n  margin-top: 0;\n  margin-bottom: 10px;\n  line-height: 1.65; }\n\na {\n  color: #776e65;\n  font-weight: bold;\n  text-decoration: underline;\n  cursor: pointer; }\n\nstrong.important {\n  text-transform: uppercase; }\n\nhr {\n  border: none;\n  border-bottom: 1px solid #d8d4d0;\n  margin-top: 20px;\n  margin-bottom: 30px; }\n\n.container {\n  width: 500px;\n  margin: 0 auto; }\n\n@-webkit-keyframes fade-in {\n  0% {\n    opacity: 0; }\n\n  100% {\n    opacity: 1; } }\n@-moz-keyframes fade-in {\n  0% {\n    opacity: 0; }\n\n  100% {\n    opacity: 1; } }\n@keyframes fade-in {\n  0% {\n    opacity: 0; }\n\n  100% {\n    opacity: 1; } }\n.game-container {\n  margin-top: 40px;\n  position: relative;\n  padding: 15px;\n  cursor: default;\n  -webkit-touch-callout: none;\n  -ms-touch-callout: none;\n  -webkit-user-select: none;\n  -moz-user-select: none;\n  -ms-user-select: none;\n  -ms-touch-action: none;\n  touch-action: none;\n  background: #bbada0;\n  border-radius: 6px;\n  width: 500px;\n  height: 500px;\n  -webkit-box-sizing: border-box;\n  -moz-box-sizing: border-box;\n  box-sizing: border-box; }\n  .game-container .game-message {\n    display: none;\n    position: absolute;\n    top: 0;\n    right: 0;\n    bottom: 0;\n    left: 0;\n    background: rgba(238, 228, 218, 0.5);\n    z-index: 100;\n    text-align: center;\n    -webkit-animation: fade-in 800ms ease 1200ms;\n    -moz-animation: fade-in 800ms ease 1200ms;\n    animation: fade-in 800ms ease 1200ms;\n    -webkit-animation-fill-mode: both;\n    -moz-animation-fill-mode: both;\n    animation-fill-mode: both; }\n    .game-container .game-message p {\n      font-size: 60px;\n      font-weight: bold;\n      height: 60px;\n      line-height: 60px;\n      margin-top: 222px; }\n    .game-container .game-message .lower {\n      display: block;\n      margin-top: 59px; }\n    .game-container .game-message a {\n      display: inline-block;\n      background: #8f7a66;\n      border-radius: 3px;\n      padding: 0 20px;\n      text-decoration: none;\n      color: #f9f6f2;\n      height: 40px;\n      line-height: 42px;\n      margin-left: 9px; }\n      .game-container .game-message a.keep-playing-button {\n        display: none; }\n    .game-container .game-message.game-won {\n      background: rgba(237, 194, 46, 0.5);\n      color: #f9f6f2; }\n      .game-container .game-message.game-won a.keep-playing-button {\n        display: inline-block; }\n    .game-container .game-message.game-won, .game-container .game-message.game-over {\n      display: block; }\n\n.grid-container {\n  position: absolute;\n  z-index: 1; }\n\n.grid-row {\n  margin-bottom: 15px; }\n  .grid-row:last-child {\n    margin-bottom: 0; }\n  .grid-row:after {\n    content: \"\";\n    display: block;\n    clear: both; }\n\n.grid-cell {\n  width: 106.25px;\n  height: 106.25px;\n  margin-right: 15px;\n  float: left;\n  border-radius: 3px;\n  background: rgba(238, 228, 218, 0.35); }\n  .grid-cell:last-child {\n    margin-right: 0; }\n\n.tile-container {\n  position: absolute;\n  z-index: 2; }\n\n.tile, .tile .tile-inner {\n  width: 107px;\n  height: 107px;\n  line-height: 107px; }\n.tile.tile-position-1-1 {\n  -webkit-transform: translate(0px, 0px);\n  -moz-transform: translate(0px, 0px);\n  -ms-transform: translate(0px, 0px);\n  transform: translate(0px, 0px); }\n.tile.tile-position-1-2 {\n  -webkit-transform: translate(0px, 121px);\n  -moz-transform: translate(0px, 121px);\n  -ms-transform: translate(0px, 121px);\n  transform: translate(0px, 121px); }\n.tile.tile-position-1-3 {\n  -webkit-transform: translate(0px, 242px);\n  -moz-transform: translate(0px, 242px);\n  -ms-transform: translate(0px, 242px);\n  transform: translate(0px, 242px); }\n.tile.tile-position-1-4 {\n  -webkit-transform: translate(0px, 363px);\n  -moz-transform: translate(0px, 363px);\n  -ms-transform: translate(0px, 363px);\n  transform: translate(0px, 363px); }\n.tile.tile-position-2-1 {\n  -webkit-transform: translate(121px, 0px);\n  -moz-transform: translate(121px, 0px);\n  -ms-transform: translate(121px, 0px);\n  transform: translate(121px, 0px); }\n.tile.tile-position-2-2 {\n  -webkit-transform: translate(121px, 121px);\n  -moz-transform: translate(121px, 121px);\n  -ms-transform: translate(121px, 121px);\n  transform: translate(121px, 121px); }\n.tile.tile-position-2-3 {\n  -webkit-transform: translate(121px, 242px);\n  -moz-transform: translate(121px, 242px);\n  -ms-transform: translate(121px, 242px);\n  transform: translate(121px, 242px); }\n.tile.tile-position-2-4 {\n  -webkit-transform: translate(121px, 363px);\n  -moz-transform: translate(121px, 363px);\n  -ms-transform: translate(121px, 363px);\n  transform: translate(121px, 363px); }\n.tile.tile-position-3-1 {\n  -webkit-transform: translate(242px, 0px);\n  -moz-transform: translate(242px, 0px);\n  -ms-transform: translate(242px, 0px);\n  transform: translate(242px, 0px); }\n.tile.tile-position-3-2 {\n  -webkit-transform: translate(242px, 121px);\n  -moz-transform: translate(242px, 121px);\n  -ms-transform: translate(242px, 121px);\n  transform: translate(242px, 121px); }\n.tile.tile-position-3-3 {\n  -webkit-transform: translate(242px, 242px);\n  -moz-transform: translate(242px, 242px);\n  -ms-transform: translate(242px, 242px);\n  transform: translate(242px, 242px); }\n.tile.tile-position-3-4 {\n  -webkit-transform: translate(242px, 363px);\n  -moz-transform: translate(242px, 363px);\n  -ms-transform: translate(242px, 363px);\n  transform: translate(242px, 363px); }\n.tile.tile-position-4-1 {\n  -webkit-transform: translate(363px, 0px);\n  -moz-transform: translate(363px, 0px);\n  -ms-transform: translate(363px, 0px);\n  transform: translate(363px, 0px); }\n.tile.tile-position-4-2 {\n  -webkit-transform: translate(363px, 121px);\n  -moz-transform: translate(363px, 121px);\n  -ms-transform: translate(363px, 121px);\n  transform: translate(363px, 121px); }\n.tile.tile-position-4-3 {\n  -webkit-transform: translate(363px, 242px);\n  -moz-transform: translate(363px, 242px);\n  -ms-transform: translate(363px, 242px);\n  transform: translate(363px, 242px); }\n.tile.tile-position-4-4 {\n  -webkit-transform: translate(363px, 363px);\n  -moz-transform: translate(363px, 363px);\n  -ms-transform: translate(363px, 363px);\n  transform: translate(363px, 363px); }\n\n.tile {\n  position: absolute;\n  -webkit-transition: 100ms ease-in-out;\n  -moz-transition: 100ms ease-in-out;\n  transition: 100ms ease-in-out;\n  -webkit-transition-property: -webkit-transform;\n  -moz-transition-property: -moz-transform;\n  transition-property: transform; }\n  .tile .tile-inner {\n    border-radius: 3px;\n    background: #eee4da;\n    text-align: center;\n    font-weight: bold;\n    z-index: 10;\n    font-size: 55px; }\n  .tile.tile-2 .tile-inner {\n    background: #eee4da;\n    box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0), inset 0 0 0 1px rgba(255, 255, 255, 0); }\n  .tile.tile-4 .tile-inner {\n    background: #ede0c8;\n    box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0), inset 0 0 0 1px rgba(255, 255, 255, 0); }\n  .tile.tile-8 .tile-inner {\n    color: #f9f6f2;\n    background: #f2b179; }\n  .tile.tile-16 .tile-inner {\n    color: #f9f6f2;\n    background: #f59563; }\n  .tile.tile-32 .tile-inner {\n    color: #f9f6f2;\n    background: #f67c5f; }\n  .tile.tile-64 .tile-inner {\n    color: #f9f6f2;\n    background: #f65e3b; }\n  .tile.tile-128 .tile-inner {\n    color: #f9f6f2;\n    background: #edcf72;\n    box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.2381), inset 0 0 0 1px rgba(255, 255, 255, 0.14286);\n    font-size: 45px; }\n    @media screen and (max-width: 520px) {\n      .tile.tile-128 .tile-inner {\n        font-size: 25px; } }\n  .tile.tile-256 .tile-inner {\n    color: #f9f6f2;\n    background: #edcc61;\n    box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.31746), inset 0 0 0 1px rgba(255, 255, 255, 0.19048);\n    font-size: 45px; }\n    @media screen and (max-width: 520px) {\n      .tile.tile-256 .tile-inner {\n        font-size: 25px; } }\n  .tile.tile-512 .tile-inner {\n    color: #f9f6f2;\n    background: #edc850;\n    box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.39683), inset 0 0 0 1px rgba(255, 255, 255, 0.2381);\n    font-size: 45px; }\n    @media screen and (max-width: 520px) {\n      .tile.tile-512 .tile-inner {\n        font-size: 25px; } }\n  .tile.tile-1024 .tile-inner {\n    color: #f9f6f2;\n    background: #edc53f;\n    box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.47619), inset 0 0 0 1px rgba(255, 255, 255, 0.28571);\n    font-size: 35px; }\n    @media screen and (max-width: 520px) {\n      .tile.tile-1024 .tile-inner {\n        font-size: 15px; } }\n  .tile.tile-2048 .tile-inner {\n    color: #f9f6f2;\n    background: #edc22e;\n    box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.55556), inset 0 0 0 1px rgba(255, 255, 255, 0.33333);\n    font-size: 35px; }\n    @media screen and (max-width: 520px) {\n      .tile.tile-2048 .tile-inner {\n        font-size: 15px; } }\n  .tile.tile-super .tile-inner {\n    color: #f9f6f2;\n    background: #3c3a32;\n    font-size: 30px; }\n    @media screen and (max-width: 520px) {\n      .tile.tile-super .tile-inner {\n        font-size: 10px; } }\n\n@-webkit-keyframes appear {\n  0% {\n    opacity: 0;\n    -webkit-transform: scale(0);\n    -moz-transform: scale(0);\n    -ms-transform: scale(0);\n    transform: scale(0); }\n\n  100% {\n    opacity: 1;\n    -webkit-transform: scale(1);\n    -moz-transform: scale(1);\n    -ms-transform: scale(1);\n    transform: scale(1); } }\n@-moz-keyframes appear {\n  0% {\n    opacity: 0;\n    -webkit-transform: scale(0);\n    -moz-transform: scale(0);\n    -ms-transform: scale(0);\n    transform: scale(0); }\n\n  100% {\n    opacity: 1;\n    -webkit-transform: scale(1);\n    -moz-transform: scale(1);\n    -ms-transform: scale(1);\n    transform: scale(1); } }\n@keyframes appear {\n  0% {\n    opacity: 0;\n    -webkit-transform: scale(0);\n    -moz-transform: scale(0);\n    -ms-transform: scale(0);\n    transform: scale(0); }\n\n  100% {\n    opacity: 1;\n    -webkit-transform: scale(1);\n    -moz-transform: scale(1);\n    -ms-transform: scale(1);\n    transform: scale(1); } }\n.tile-new .tile-inner {\n  -webkit-animation: appear 200ms ease 100ms;\n  -moz-animation: appear 200ms ease 100ms;\n  animation: appear 200ms ease 100ms;\n  -webkit-animation-fill-mode: backwards;\n  -moz-animation-fill-mode: backwards;\n  animation-fill-mode: backwards; }\n\n@-webkit-keyframes pop {\n  0% {\n    -webkit-transform: scale(0);\n    -moz-transform: scale(0);\n    -ms-transform: scale(0);\n    transform: scale(0); }\n\n  50% {\n    -webkit-transform: scale(1.2);\n    -moz-transform: scale(1.2);\n    -ms-transform: scale(1.2);\n    transform: scale(1.2); }\n\n  100% {\n    -webkit-transform: scale(1);\n    -moz-transform: scale(1);\n    -ms-transform: scale(1);\n    transform: scale(1); } }\n@-moz-keyframes pop {\n  0% {\n    -webkit-transform: scale(0);\n    -moz-transform: scale(0);\n    -ms-transform: scale(0);\n    transform: scale(0); }\n\n  50% {\n    -webkit-transform: scale(1.2);\n    -moz-transform: scale(1.2);\n    -ms-transform: scale(1.2);\n    transform: scale(1.2); }\n\n  100% {\n    -webkit-transform: scale(1);\n    -moz-transform: scale(1);\n    -ms-transform: scale(1);\n    transform: scale(1); } }\n@keyframes pop {\n  0% {\n    -webkit-transform: scale(0);\n    -moz-transform: scale(0);\n    -ms-transform: scale(0);\n    transform: scale(0); }\n\n  50% {\n    -webkit-transform: scale(1.2);\n    -moz-transform: scale(1.2);\n    -ms-transform: scale(1.2);\n    transform: scale(1.2); }\n\n  100% {\n    -webkit-transform: scale(1);\n    -moz-transform: scale(1);\n    -ms-transform: scale(1);\n    transform: scale(1); } }\n.tile-merged .tile-inner {\n  z-index: 20;\n  -webkit-animation: pop 200ms ease 100ms;\n  -moz-animation: pop 200ms ease 100ms;\n  animation: pop 200ms ease 100ms;\n  -webkit-animation-fill-mode: backwards;\n  -moz-animation-fill-mode: backwards;\n  animation-fill-mode: backwards; }\n\n.above-game:after {\n  content: \"\";\n  display: block;\n  clear: both; }\n\n.game-intro {\n  float: left;\n  line-height: 42px;\n  margin-bottom: 0; }\n\n.restart-button {\n  display: inline-block;\n  background: #8f7a66;\n  border-radius: 3px;\n  padding: 0 20px;\n  text-decoration: none;\n  color: #f9f6f2;\n  height: 40px;\n  line-height: 42px;\n  display: block;\n  text-align: center;\n  float: right; }\n\n.game-explanation {\n  margin-top: 50px; }\n\n@media screen and (max-width: 520px) {\n  html, body {\n    font-size: 15px; }\n\n  body {\n    margin: 20px 0;\n    padding: 0 20px; }\n\n  h1.title {\n    font-size: 27px;\n    margin-top: 15px; }\n\n  .container {\n    width: 280px;\n    margin: 0 auto; }\n\n  .score-container, .best-container {\n    margin-top: 0;\n    padding: 15px 10px;\n    min-width: 40px; }\n\n  .heading {\n    margin-bottom: 10px; }\n\n  .game-intro {\n    width: 55%;\n    display: block;\n    box-sizing: border-box;\n    line-height: 1.65; }\n\n  .restart-button {\n    width: 42%;\n    padding: 0;\n    display: block;\n    box-sizing: border-box;\n    margin-top: 2px; }\n\n  .game-container {\n    margin-top: 17px;\n    position: relative;\n    padding: 10px;\n    cursor: default;\n    -webkit-touch-callout: none;\n    -ms-touch-callout: none;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    -ms-touch-action: none;\n    touch-action: none;\n    background: #bbada0;\n    border-radius: 6px;\n    width: 280px;\n    height: 280px;\n    -webkit-box-sizing: border-box;\n    -moz-box-sizing: border-box;\n    box-sizing: border-box; }\n    .game-container .game-message {\n      display: none;\n      position: absolute;\n      top: 0;\n      right: 0;\n      bottom: 0;\n      left: 0;\n      background: rgba(238, 228, 218, 0.5);\n      z-index: 100;\n      text-align: center;\n      -webkit-animation: fade-in 800ms ease 1200ms;\n      -moz-animation: fade-in 800ms ease 1200ms;\n      animation: fade-in 800ms ease 1200ms;\n      -webkit-animation-fill-mode: both;\n      -moz-animation-fill-mode: both;\n      animation-fill-mode: both; }\n      .game-container .game-message p {\n        font-size: 60px;\n        font-weight: bold;\n        height: 60px;\n        line-height: 60px;\n        margin-top: 222px; }\n      .game-container .game-message .lower {\n        display: block;\n        margin-top: 59px; }\n      .game-container .game-message a {\n        display: inline-block;\n        background: #8f7a66;\n        border-radius: 3px;\n        padding: 0 20px;\n        text-decoration: none;\n        color: #f9f6f2;\n        height: 40px;\n        line-height: 42px;\n        margin-left: 9px; }\n        .game-container .game-message a.keep-playing-button {\n          display: none; }\n      .game-container .game-message.game-won {\n        background: rgba(237, 194, 46, 0.5);\n        color: #f9f6f2; }\n        .game-container .game-message.game-won a.keep-playing-button {\n          display: inline-block; }\n      .game-container .game-message.game-won, .game-container .game-message.game-over {\n        display: block; }\n\n  .grid-container {\n    position: absolute;\n    z-index: 1; }\n\n  .grid-row {\n    margin-bottom: 10px; }\n    .grid-row:last-child {\n      margin-bottom: 0; }\n    .grid-row:after {\n      content: \"\";\n      display: block;\n      clear: both; }\n\n  .grid-cell {\n    width: 57.5px;\n    height: 57.5px;\n    margin-right: 10px;\n    float: left;\n    border-radius: 3px;\n    background: rgba(238, 228, 218, 0.35); }\n    .grid-cell:last-child {\n      margin-right: 0; }\n\n  .tile-container {\n    position: absolute;\n    z-index: 2; }\n\n  .tile, .tile .tile-inner {\n    width: 58px;\n    height: 58px;\n    line-height: 58px; }\n  .tile.tile-position-1-1 {\n    -webkit-transform: translate(0px, 0px);\n    -moz-transform: translate(0px, 0px);\n    -ms-transform: translate(0px, 0px);\n    transform: translate(0px, 0px); }\n  .tile.tile-position-1-2 {\n    -webkit-transform: translate(0px, 67px);\n    -moz-transform: translate(0px, 67px);\n    -ms-transform: translate(0px, 67px);\n    transform: translate(0px, 67px); }\n  .tile.tile-position-1-3 {\n    -webkit-transform: translate(0px, 135px);\n    -moz-transform: translate(0px, 135px);\n    -ms-transform: translate(0px, 135px);\n    transform: translate(0px, 135px); }\n  .tile.tile-position-1-4 {\n    -webkit-transform: translate(0px, 202px);\n    -moz-transform: translate(0px, 202px);\n    -ms-transform: translate(0px, 202px);\n    transform: translate(0px, 202px); }\n  .tile.tile-position-2-1 {\n    -webkit-transform: translate(67px, 0px);\n    -moz-transform: translate(67px, 0px);\n    -ms-transform: translate(67px, 0px);\n    transform: translate(67px, 0px); }\n  .tile.tile-position-2-2 {\n    -webkit-transform: translate(67px, 67px);\n    -moz-transform: translate(67px, 67px);\n    -ms-transform: translate(67px, 67px);\n    transform: translate(67px, 67px); }\n  .tile.tile-position-2-3 {\n    -webkit-transform: translate(67px, 135px);\n    -moz-transform: translate(67px, 135px);\n    -ms-transform: translate(67px, 135px);\n    transform: translate(67px, 135px); }\n  .tile.tile-position-2-4 {\n    -webkit-transform: translate(67px, 202px);\n    -moz-transform: translate(67px, 202px);\n    -ms-transform: translate(67px, 202px);\n    transform: translate(67px, 202px); }\n  .tile.tile-position-3-1 {\n    -webkit-transform: translate(135px, 0px);\n    -moz-transform: translate(135px, 0px);\n    -ms-transform: translate(135px, 0px);\n    transform: translate(135px, 0px); }\n  .tile.tile-position-3-2 {\n    -webkit-transform: translate(135px, 67px);\n    -moz-transform: translate(135px, 67px);\n    -ms-transform: translate(135px, 67px);\n    transform: translate(135px, 67px); }\n  .tile.tile-position-3-3 {\n    -webkit-transform: translate(135px, 135px);\n    -moz-transform: translate(135px, 135px);\n    -ms-transform: translate(135px, 135px);\n    transform: translate(135px, 135px); }\n  .tile.tile-position-3-4 {\n    -webkit-transform: translate(135px, 202px);\n    -moz-transform: translate(135px, 202px);\n    -ms-transform: translate(135px, 202px);\n    transform: translate(135px, 202px); }\n  .tile.tile-position-4-1 {\n    -webkit-transform: translate(202px, 0px);\n    -moz-transform: translate(202px, 0px);\n    -ms-transform: translate(202px, 0px);\n    transform: translate(202px, 0px); }\n  .tile.tile-position-4-2 {\n    -webkit-transform: translate(202px, 67px);\n    -moz-transform: translate(202px, 67px);\n    -ms-transform: translate(202px, 67px);\n    transform: translate(202px, 67px); }\n  .tile.tile-position-4-3 {\n    -webkit-transform: translate(202px, 135px);\n    -moz-transform: translate(202px, 135px);\n    -ms-transform: translate(202px, 135px);\n    transform: translate(202px, 135px); }\n  .tile.tile-position-4-4 {\n    -webkit-transform: translate(202px, 202px);\n    -moz-transform: translate(202px, 202px);\n    -ms-transform: translate(202px, 202px);\n    transform: translate(202px, 202px); }\n\n  .tile .tile-inner {\n    font-size: 35px; }\n\n  .game-message p {\n    font-size: 30px !important;\n    height: 30px !important;\n    line-height: 30px !important;\n    margin-top: 90px !important; }\n  .game-message .lower {\n    margin-top: 30px !important; } }\n"
  },
  {
    "path": "style/main.scss",
    "content": "@import \"helpers\";\n@import \"fonts/clear-sans.css\";\n\n$field-width: 500px;\n$grid-spacing: 15px;\n$grid-row-cells: 4;\n$tile-size: ($field-width - $grid-spacing * ($grid-row-cells + 1)) / $grid-row-cells;\n$tile-border-radius: 3px;\n\n$mobile-threshold: $field-width + 20px;\n\n$text-color: #776E65;\n$bright-text-color: #f9f6f2;\n\n$tile-color: #eee4da;\n$tile-gold-color: #edc22e;\n$tile-gold-glow-color: lighten($tile-gold-color, 15%);\n\n$game-container-margin-top: 40px;\n$game-container-background: #bbada0;\n\n$transition-speed: 100ms;\n\nhtml, body {\n  margin: 0;\n  padding: 0;\n\n  background: #faf8ef;\n  color: $text-color;\n  font-family: \"Clear Sans\", \"Helvetica Neue\", Arial, sans-serif;\n  font-size: 18px;\n}\n\nbody {\n  margin: 80px 0;\n}\n\n.heading {\n  @include clearfix;\n}\n\nh1.title {\n  font-size: 80px;\n  font-weight: bold;\n  margin: 0;\n  display: block;\n  float: left;\n}\n\n@include keyframes(move-up) {\n  0% {\n    top: 25px;\n    opacity: 1;\n  }\n\n  100% {\n    top: -50px;\n    opacity: 0;\n  }\n}\n\n.scores-container {\n  float: right;\n  text-align: right;\n}\n\n.score-container, .best-container {\n  $height: 25px;\n\n  position: relative;\n  display: inline-block;\n  background: $game-container-background;\n  padding: 15px 25px;\n  font-size: $height;\n  height: $height;\n  line-height: $height + 22px;\n  font-weight: bold;\n  border-radius: 3px;\n  color: white;\n  margin-top: 8px;\n  text-align: center;\n\n  &:after {\n    position: absolute;\n    width: 100%;\n    top: 10px;\n    left: 0;\n    text-transform: uppercase;\n    font-size: 13px;\n    line-height: 13px;\n    text-align: center;\n    color: $tile-color;\n  }\n\n  .score-addition {\n    position: absolute;\n    right: 30px;\n    color: red;\n    font-size: $height;\n    line-height: $height;\n    font-weight: bold;\n    color: rgba($text-color, .9);\n    z-index: 100;\n    @include animation(move-up 600ms ease-in);\n    @include animation-fill-mode(both);\n  }\n}\n\n.score-container:after {\n  content: \"Score\";\n}\n\n.best-container:after {\n  content: \"Best\";\n}\n\np {\n  margin-top: 0;\n  margin-bottom: 10px;\n  line-height: 1.65;\n}\n\na {\n  color: $text-color;\n  font-weight: bold;\n  text-decoration: underline;\n  cursor: pointer;\n}\n\nstrong {\n  &.important {\n    text-transform: uppercase;\n  }\n}\n\nhr {\n  border: none;\n  border-bottom: 1px solid lighten($text-color, 40%);\n  margin-top: 20px;\n  margin-bottom: 30px;\n}\n\n.container {\n  width: $field-width;\n  margin: 0 auto;\n}\n\n@include keyframes(fade-in) {\n  0% {\n    opacity: 0;\n  }\n\n  100% {\n    opacity: 1;\n  }\n}\n\n// Styles for buttons\n@mixin button {\n  display: inline-block;\n  background: darken($game-container-background, 20%);\n  border-radius: 3px;\n  padding: 0 20px;\n  text-decoration: none;\n  color: $bright-text-color;\n  height: 40px;\n  line-height: 42px;\n}\n\n// Game field mixin used to render CSS at different width\n@mixin game-field {\n  .game-container {\n    margin-top: $game-container-margin-top;\n    position: relative;\n    padding: $grid-spacing;\n\n    cursor: default;\n    -webkit-touch-callout: none;\n    -ms-touch-callout: none;\n\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n\n    -ms-touch-action: none;\n    touch-action: none;\n\n    background: $game-container-background;\n    border-radius: $tile-border-radius * 2;\n    width: $field-width;\n    height: $field-width;\n    -webkit-box-sizing: border-box;\n    -moz-box-sizing: border-box;\n    box-sizing: border-box;\n\n    .game-message {\n      display: none;\n\n      position: absolute;\n      top: 0;\n      right: 0;\n      bottom: 0;\n      left: 0;\n      background: rgba($tile-color, .5);\n      z-index: 100;\n\n      text-align: center;\n\n      p {\n        font-size: 60px;\n        font-weight: bold;\n        height: 60px;\n        line-height: 60px;\n        margin-top: 222px;\n        // height: $field-width;\n        // line-height: $field-width;\n      }\n\n      .lower {\n        display: block;\n        margin-top: 59px;\n      }\n\n      a {\n        @include button;\n        margin-left: 9px;\n        // margin-top: 59px;\n\n\t&.keep-playing-button {\n\t  display: none;\n\t}\n      }\n\n      @include animation(fade-in 800ms ease $transition-speed * 12);\n      @include animation-fill-mode(both);\n\n      &.game-won {\n        background: rgba($tile-gold-color, .5);\n        color: $bright-text-color;\n\n\ta.keep-playing-button {\n\t  display: inline-block;\n\t}\n      }\n\n      &.game-won, &.game-over {\n        display: block;\n      }\n    }\n  }\n\n  .grid-container {\n    position: absolute;\n    z-index: 1;\n  }\n\n  .grid-row {\n    margin-bottom: $grid-spacing;\n\n    &:last-child {\n      margin-bottom: 0;\n    }\n\n    &:after {\n      content: \"\";\n      display: block;\n      clear: both;\n    }\n  }\n\n  .grid-cell {\n    width: $tile-size;\n    height: $tile-size;\n    margin-right: $grid-spacing;\n    float: left;\n\n    border-radius: $tile-border-radius;\n\n    background: rgba($tile-color, .35);\n\n    &:last-child {\n      margin-right: 0;\n    }\n  }\n\n  .tile-container {\n    position: absolute;\n    z-index: 2;\n  }\n\n  .tile {\n    &, .tile-inner {\n      width: ceil($tile-size);\n      height: ceil($tile-size);\n      line-height: ceil($tile-size);\n    }\n\n    // Build position classes\n    @for $x from 1 through $grid-row-cells {\n      @for $y from 1 through $grid-row-cells {\n        &.tile-position-#{$x}-#{$y} {\n          $xPos: floor(($tile-size + $grid-spacing) * ($x - 1));\n          $yPos: floor(($tile-size + $grid-spacing) * ($y - 1));\n          @include transform(translate($xPos, $yPos));\n        }\n      }\n    }\n  }\n}\n\n// End of game-field mixin\n@include game-field;\n\n.tile {\n  position: absolute; // Makes transforms relative to the top-left corner\n\n  .tile-inner {\n    border-radius: $tile-border-radius;\n\n    background: $tile-color;\n    text-align: center;\n    font-weight: bold;\n    z-index: 10;\n\n    font-size: 55px;\n  }\n\n  // Movement transition\n  @include transition($transition-speed ease-in-out);\n  -webkit-transition-property: -webkit-transform;\n  -moz-transition-property: -moz-transform;\n  transition-property: transform;\n\n  $base: 2;\n  $exponent: 1;\n  $limit: 11;\n\n  // Colors for all 11 states, false = no special color\n  $special-colors: false false, // 2\n                   false false, // 4\n                   #f78e48 true, // 8\n                   #fc5e2e true, // 16\n                   #ff3333 true, // 32\n                   #ff0000 true, // 64\n                   false true, // 128\n                   false true, // 256\n                   false true, // 512\n                   false true, // 1024\n                   false true; // 2048\n\n  // Build tile colors\n  @while $exponent <= $limit {\n    $power: pow($base, $exponent);\n\n    &.tile-#{$power} .tile-inner {\n      // Calculate base background color\n      $gold-percent: ($exponent - 1) / ($limit - 1) * 100;\n      $mixed-background: mix($tile-gold-color, $tile-color, $gold-percent);\n\n      $nth-color: nth($special-colors, $exponent);\n\n      $special-background: nth($nth-color, 1);\n      $bright-color: nth($nth-color, 2);\n\n      @if $special-background {\n        $mixed-background: mix($special-background, $mixed-background, 55%);\n      }\n\n      @if $bright-color {\n        color: $bright-text-color;\n      }\n\n      // Set background\n      background: $mixed-background;\n\n      // Add glow\n      $glow-opacity: max($exponent - 4, 0) / ($limit - 4);\n\n      @if not $special-background {\n        box-shadow: 0 0 30px 10px rgba($tile-gold-glow-color, $glow-opacity / 1.8),\n                    inset 0 0 0 1px rgba(white, $glow-opacity / 3);\n      }\n\n      // Adjust font size for bigger numbers\n      @if $power >= 100 and $power < 1000 {\n        font-size: 45px;\n\n        // Media queries placed here to avoid carrying over the rest of the logic\n        @include smaller($mobile-threshold) {\n          font-size: 25px;\n        }\n      } @else if $power >= 1000 {\n        font-size: 35px;\n\n        @include smaller($mobile-threshold) {\n          font-size: 15px;\n        }\n      }\n    }\n\n    $exponent: $exponent + 1;\n  }\n\n  // Super tiles (above 2048)\n  &.tile-super .tile-inner {\n    color: $bright-text-color;\n    background: mix(#333, $tile-gold-color, 95%);\n\n    font-size: 30px;\n\n    @include smaller($mobile-threshold) {\n      font-size: 10px;\n    }\n  }\n}\n\n@include keyframes(appear) {\n  0% {\n    opacity: 0;\n    @include transform(scale(0));\n  }\n\n  100% {\n    opacity: 1;\n    @include transform(scale(1));\n  }\n}\n\n.tile-new .tile-inner {\n  @include animation(appear 200ms ease $transition-speed);\n  @include animation-fill-mode(backwards);\n}\n\n@include keyframes(pop) {\n  0% {\n    @include transform(scale(0));\n  }\n\n  50% {\n    @include transform(scale(1.2));\n  }\n\n  100% {\n    @include transform(scale(1));\n  }\n}\n\n.tile-merged .tile-inner {\n  z-index: 20;\n  @include animation(pop 200ms ease $transition-speed);\n  @include animation-fill-mode(backwards);\n}\n\n.above-game {\n  @include clearfix;\n}\n\n.game-intro {\n  float: left;\n  line-height: 42px;\n  margin-bottom: 0;\n}\n\n.restart-button {\n  @include button;\n  display: block;\n  text-align: center;\n  float: right;\n}\n\n.game-explanation {\n  margin-top: 50px;\n}\n\n@include smaller($mobile-threshold) {\n  // Redefine variables for smaller screens\n  $field-width: 280px;\n  $grid-spacing: 10px;\n  $grid-row-cells: 4;\n  $tile-size: ($field-width - $grid-spacing * ($grid-row-cells + 1)) / $grid-row-cells;\n  $tile-border-radius: 3px;\n  $game-container-margin-top: 17px;\n\n  html, body {\n    font-size: 15px;\n  }\n\n  body {\n    margin: 20px 0;\n    padding: 0 20px;\n  }\n\n  h1.title {\n    font-size: 27px;\n    margin-top: 15px;\n  }\n\n  .container {\n    width: $field-width;\n    margin: 0 auto;\n  }\n\n  .score-container, .best-container {\n    margin-top: 0;\n    padding: 15px 10px;\n    min-width: 40px;\n  }\n\n  .heading {\n    margin-bottom: 10px;\n  }\n\n  // Show intro and restart button side by side\n  .game-intro {\n    width: 55%;\n    display: block;\n    box-sizing: border-box;\n    line-height: 1.65;\n  }\n\n  .restart-button {\n    width: 42%;\n    padding: 0;\n    display: block;\n    box-sizing: border-box;\n    margin-top: 2px;\n  }\n\n  // Render the game field at the right width\n  @include game-field;\n\n  // Rest of the font-size adjustments in the tile class\n  .tile .tile-inner {\n    font-size: 35px;\n  }\n\n  .game-message {\n    p {\n      font-size: 30px !important;\n      height: 30px !important;\n      line-height: 30px !important;\n      margin-top: 90px !important;\n    }\n\n    .lower {\n      margin-top: 30px !important;\n    }\n  }\n}\n"
  }
]