@import url(fonts/clear-sans.css);

html, body {
  margin: 0;
  padding: 0;
  background: #faf8ef url('../images/background.jpg') no-repeat center center fixed;
  background-size: cover;
  color: #00ffe0;
  font-family: "Clear Sans", "Helvetica Neue", Arial, sans-serif;
  font-size: 18px;
}

body {
  margin: 40px 0;
}

.container {
  width: 575px; /* Alkuperäinen 500px * 1.15 */
  margin: 0 auto;
}

.heading {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 20px;
}

h1.title {
  font-size: 80px;
  font-weight: bold;
  margin: 0 0 20px 0;
}

.score-board {
  display: flex;
  gap: 15px;
  margin-bottom: 25px;
}

.score-container, .best-container {
  position: relative;
  background: #000000;
  padding: 15px 25px;
  font-size: 25px;
  height: 25px;
  line-height: 47px;
  font-weight: bold;
  border-radius: 3px;
  color: #ff0000;
  text-align: center;
  min-width: 120px;
}

.score-container:after, .best-container:after {
  position: absolute;
  width: 100%;
  top: 10px;
  left: 0;
  text-transform: uppercase;
  font-size: 13px;
  line-height: 13px;
  text-align: center;
  color: #ffffff;
}

.score-container:after {
  content: "Pisteet";
}

.best-container:after {
  content: "Paras";
}

.score-addition {
  position: absolute;
  right: 30px;
  font-size: 25px;
  line-height: 25px;
  font-weight: bold;
  color: #ff0000;
  z-index: 100;
  animation: move-up 600ms ease-in both;
}

@keyframes move-up {
  0% { top: 25px; opacity: 1; }
  100% { top: -50px; opacity: 0; }
}

.game-actions {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-bottom: 25px;
}

.game-container {
  margin-top: 0;
  position: relative;
  padding: 17.25px; /* 15px * 1.15 */
  cursor: default;
  background: #000000;
  border-radius: 6px;
  width: 575px; /* 500px * 1.15 */
  height: 575px; /* 500px * 1.15 */
  box-sizing: border-box;
}

.grid-container {
  position: absolute;
  z-index: 1;
}

.grid-row {
  margin-bottom: 17.25px; /* 15px * 1.15 */
}

.grid-row:last-child {
  margin-bottom: 0;
}

.grid-row:after {
  content: "";
  display: block;
  clear: both;
}

.grid-cell {
  width: 122.19px; /* 106.25px * 1.15 */
  height: 122.19px; /* 106.25px * 1.15 */
  margin-right: 17.25px; /* 15px * 1.15 */
  float: left;
  border-radius: 3px;
  background: rgb(255, 255, 255);
}

.grid-cell:last-child {
  margin-right: 0;
}

.tile-container {
  position: absolute;
  z-index: 2;
}

.tile {
  position: absolute;
  width: 123.05px; /* 107px * 1.15 */
  height: 123.05px; /* 107px * 1.15 */
  line-height: 123.05px; /* 107px * 1.15 */
  font-weight: bold;
  text-align: center;
  border-radius: 3px;
  transition: transform 100ms ease-in-out;
  z-index: 10;
}

.tile .tile-inner {
  width: 100%;
  height: 100%;
  border-radius: 3px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.tile-position-1-1 { transform: translate(0, 0); }
.tile-position-1-2 { transform: translate(0, 139.15px); /* 121px * 1.15 */ }
.tile-position-1-3 { transform: translate(0, 278.3px); /* 242px * 1.15 */ }
.tile-position-1-4 { transform: translate(0, 417.45px); /* 363px * 1.15 */ }
.tile-position-2-1 { transform: translate(139.15px, 0); }
.tile-position-2-2 { transform: translate(139.15px, 139.15px); }
.tile-position-2-3 { transform: translate(139.15px, 278.3px); }
.tile-position-2-4 { transform: translate(139.15px, 417.45px); }
.tile-position-3-1 { transform: translate(278.3px, 0); }
.tile-position-3-2 { transform: translate(278.3px, 139.15px); }
.tile-position-3-3 { transform: translate(278.3px, 278.3px); }
.tile-position-3-4 { transform: translate(278.3px, 417.45px); }
.tile-position-4-1 { transform: translate(417.45px, 0); }
.tile-position-4-2 { transform: translate(417.45px, 139.15px); }
.tile-position-4-3 { transform: translate(417.45px, 278.3px); }
.tile-position-4-4 { transform: translate(417.45px, 417.45px); }

.tile.tile-2 .tile-inner { background-image: url('../images/tile2.png'); }
.tile.tile-4 .tile-inner { background-image: url('../images/tile4.png'); }
.tile.tile-8 .tile-inner { background-image: url('../images/tile8.png'); }
.tile.tile-16 .tile-inner { background-image: url('../images/tile16.png'); }
.tile.tile-32 .tile-inner { background-image: url('../images/tile32.png'); }
.tile.tile-64 .tile-inner { background-image: url('../images/tile64.png'); }
.tile.tile-128 .tile-inner { background-image: url('../images/tile128.png'); font-size: 51.75px; /* 45px * 1.15 */ }
.tile.tile-256 .tile-inner { background-image: url('../images/tile256.png'); font-size: 51.75px; }
.tile.tile-512 .tile-inner { background-image: url('../images/tile512.png'); font-size: 51.75px; }
.tile.tile-1024 .tile-inner { background-image: url('../images/tile1024.png'); font-size: 40.25px; /* 35px * 1.15 */ }
.tile.tile-2048 .tile-inner { background-image: url('../images/tile2048.png'); font-size: 40.25px; }

.tile-new .tile-inner {
  animation: appear 200ms ease 100ms both;
}

.tile-merged .tile-inner {
  z-index: 20;
  animation: pop 200ms ease 100ms both;
}

@keyframes appear {
  0% { opacity: 0; transform: scale(0.5); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.game-over {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 100;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.game-over h1 {
  font-size: 60px;
  font-weight: bold;
  color: #ff0000;
  margin-bottom: 30px;
}

.game-message {
  display: none;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(238, 228, 218, 0.73);
  z-index: 100;
  text-align: center;
  animation: fade-in 800ms ease 1200ms both;
}

.game-message.game-won {
  background: rgba(0, 0, 0, 0.5);
  color: white;
}

.game-message p {
  font-size: 60px;
  font-weight: bold;
  height: 60px;
  line-height: 60px;
  margin-top: 255px; /* 222px * 1.15 */
}

.game-message .lower {
  display: block;
  margin-top: 67.85px; /* 59px * 1.15 */
}

.game-message a {
  display: inline-block;
  background: #ffdada;
  border-radius: 3px;
  padding: 0 20px;
  text-decoration: none;
  color: white;
  height: 40px;
  line-height: 42px;
  margin-left: 9px;
  cursor: default !important;
}

@keyframes fade-in {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

.restart-button, .keep-playing-button {
  display: inline-block;
  background: #000000;
  border-radius: 3px;
  padding: 0 20px;
  text-decoration: none;
  color: white;
  height: 40px;
  line-height: 42px;
  cursor: default !important;
}

.trade-up-button {
  display: inline-block;
  background: #f44336;
  border-radius: 3px;
  padding: 0 20px;
  margin-left: 0;
  text-decoration: none;
  color: white;
  height: 40px;
  line-height: 42px;
  border: none;
  cursor: default !important;
  font-family: "Clear Sans", "Helvetica Neue", Arial, sans-serif;
}

.trade-up-button:not(:disabled) {
  background: #4CAF50;
}

.trade-up-button:disabled {
  background: #bbada0;
  color: #eee4da;
}

.info-box {
  background: rgb(22 22 22 / 90%);
  border-radius: 10px;
  padding: 20px;
  margin: 30px auto;
  max-width: 575px; /* 500px * 1.15 */
  box-shadow: 0 0 20px rgba(0,0,0,0.2);
  border: 2px solid #bbada0;
}

.info-box h3 {
  color: #FF0000;
  font-size: 24px;
  margin-top: 0;
  border-bottom: 1px solid #000000;
  padding-bottom: 10px;
}

.game-over .retry-button {
  display: inline-block;
  background: #000000;
  border-radius: 5px;
  padding: 15px 30px;
  text-decoration: none;
  color: white;
  font-size: 25px;
  font-weight: bold;
  border: none;
  cursor: pointer;
  margin-top: 20px;
  transition: all 0.2s;
}

.game-over .retry-button:hover {
  background: #333333;
  transform: scale(1.05);
}

.info-button {
  display: inline-block;
  background: #000000;
  border-radius: 5px;
  padding: 15px 30px;
  text-decoration: none;
  color: white;
  font-size: 25px;
  font-weight: bold;
  border: none;
  cursor: pointer;
  margin-top: 20px;
  transition: all 0.2s;
  text-align: center;
  width: calc(100% - 60px);
}

.info-button:hover {
  background: #333333;
  transform: scale(1.05);
}

@media screen and (max-width: 620px) {
  html, body {
    font-size: 15px;
  }

  body {
    margin: 20px 0;
    padding: 0 20px;
  }

  .container {
    width: 322px; /* 280px * 1.15 */
  }

  h1.title {
    font-size: 27px;
    margin-top: 15px;
  }

  .score-board {
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }

  .score-container, .best-container {
    margin-top: 0;
    padding: 15px 10px;
    min-width: 100px;
  }

  .game-container {
    width: 322px; /* 280px * 1.15 */
    height: 322px; /* 280px * 1.15 */
    padding: 11.5px; /* 10px * 1.15 */
    margin-top: 20px;
    margin-bottom: 20px;
  }

  .grid-cell {
    width: 66.13px; /* 57.5px * 1.15 */
    height: 66.13px; /* 57.5px * 1.15 */
    margin-right: 11.5px; /* 10px * 1.15 */
  }

  .tile, .tile .tile-inner {
    width: 66.7px; /* 58px * 1.15 */
    height: 66.7px; /* 58px * 1.15 */
    line-height: 66.7px; /* 58px * 1.15 */
  }

  .tile .tile-inner {
    font-size: 40.25px; /* 35px * 1.15 */
  }

  .tile-position-1-1 { transform: translate(0, 0); }
  .tile-position-1-2 { transform: translate(0, 77.05px); /* 67px * 1.15 */ }
  .tile-position-1-3 { transform: translate(0, 154.1px); /* 135px * 1.15 */ }
  .tile-position-1-4 { transform: translate(0, 231.15px); /* 202px * 1.15 */ }
  .tile-position-2-1 { transform: translate(77.05px, 0); }
  .tile-position-2-2 { transform: translate(77.05px, 77.05px); }
  .tile-position-2-3 { transform: translate(77.05px, 154.1px); }
  .tile-position-2-4 { transform: translate(77.05px, 231.15px); }
  .tile-position-3-1 { transform: translate(154.1px, 0); }
  .tile-position-3-2 { transform: translate(154.1px, 77.05px); }
  .tile-position-3-3 { transform: translate(154.1px, 154.1px); }
  .tile-position-3-4 { transform: translate(154.1px, 231.15px); }
  .tile-position-4-1 { transform: translate(231.15px, 0); }
  .tile-position-4-2 { transform: translate(231.15px, 77.05px); }
  .tile-position-4-3 { transform: translate(231.15px, 154.1px); }
  .tile-position-4-4 { transform: translate(231.15px, 231.15px); }

  .game-over h1 {
    font-size: 30px;
    margin-bottom: 15px;
  }

  .game-message p {
    font-size: 30px !important;
    height: 30px !important;
    line-height: 30px !important;
    margin-top: 103.5px !important; /* 90px * 1.15 */
  }

  .game-message .lower {
    margin-top: 34.5px !important; /* 30px * 1.15 */
  }

  .restart-button, .keep-playing-button, .trade-up-button {
    padding: 0 15px;
    height: 35px;
    line-height: 37px;
    font-size: 14px;
    margin-top: 5px;
  }

  .info-box {
    max-width: 322px; /* 280px * 1.15 */
    padding: 15px;
    font-size: 14px;
  }
  
  .game-over .retry-button {
    padding: 12px 24px;
    font-size: 20px;
    margin-top: 15px;
  }
}

/* UUDET ASETUKSET */
.heading {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 10px;
}

.scores-container {
  display: flex;
  gap: 20px;
  margin: 15px 0;
}

.above-game {
  text-align: center;
  margin-bottom: 20px;
}

.game-intro {
  background: rgba(255, 255, 255, 0.5);
  padding: 15px;
  border-radius: 5px;
  max-width: 500px;
  margin: 0 auto 15px;
}

.game-actions {
  display: flex;
  justify-content: center;
  gap: 15px;
}

.info-box {
  margin-top: 30px;
  padding: 20px;
  background: rgba(28, 28, 28, 0,8);
  border-radius: 10px;
}

/* ---------- NUMEROT (VALKOISET KAIIKILLE TIILEILLE) ---------- */
.tile-number {
  position: absolute;
  bottom: 8px;
  left: 8px;
  font-size: 30px;
  font-weight: 900;
  color: white !important; /* Pakottaa valkoisen värin */
  text-shadow: 
    0 0 10px rgba(119, 110, 101, 0.8), /* Harmaa hehku (näkyy hyvin kuvien päällä) */
    0 0 4px rgba(0, 0, 0, 0.5);         /* Lisäsyvyys */
  z-index: 10;
  pointer-events: none;
  user-select: none;
  font-family: 'Clear Sans', sans-serif;
}

/* Vahvempi kontrasti */
.tile-number {
  text-shadow: 
    0 0 12px black, 
    0 0 5px rgba(0, 0, 0, 0.7);
}

/* Varmista, että grid-container ei leikkaa tiiliä */
.grid-container {
  overflow: visible !important;
}





