/* ================================================================
   Pokémon 2048 — Modern Redesign
   All selectors scoped to .pokemon2048-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 ──────────────────────────────────────────────────────── */
.pokemon2048-game {
  font-family: "Clear Sans", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  color: #1a2744;
  width: 520px;
  max-width: 100%;
  margin: 0 auto;
  padding: 24px;
  box-sizing: border-box;
  outline: none;
  background: linear-gradient(145deg, #e8f4ff, #dbeeff);
  border-radius: 20px;
  border: 1px solid rgba(59, 130, 246, .15);
  box-shadow: 0 8px 32px rgba(37, 99, 235, .08);
}
.pokemon2048-game *,
.pokemon2048-game *::before,
.pokemon2048-game *::after {
  box-sizing: border-box;
}
.pokemon2048-game p {
  margin-top: 0;
  margin-bottom: 10px;
  line-height: 1.65;
}
.pokemon2048-game a {
  color: #dc2626;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.pokemon2048-game strong.important {
  text-transform: uppercase;
  color: #dc2626;
}
.pokemon2048-game hr {
  border: none;
  border-bottom: 1px solid rgba(59, 130, 246, .18);
  margin: 20px 0;
}

/* ── Scores ───────────────────────────────────────────────────── */
@keyframes pokemon-move-up {
  0%   { top: 25px; opacity: 1; }
  100% { top: -50px; opacity: 0; }
}

.pokemon2048-game .scores-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.pokemon2048-game .score-card {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  border-radius: 12px;
  padding: 10px 8px 8px;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(37, 99, 235, .25);
}

.pokemon2048-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;
}

.pokemon2048-game .score-container,
.pokemon2048-game .best-container {
  display: block;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
  min-height: 23px;
  position: relative;
  overflow: hidden;
}

.pokemon2048-game .score-container .score-addition,
.pokemon2048-game .best-container .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: pokemon-move-up 600ms ease-in both;
}

/* ── Above game ───────────────────────────────────────────────── */
.pokemon2048-game .above-game {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.pokemon2048-game .above-game::after {
  display: none;
}
.pokemon2048-game .game-intro {
  font-size: 15px;
  line-height: 1.4;
  margin: 0;
  color: #374a6d;
}
.pokemon2048-game .restart-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 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(220, 38, 38, .3);
  white-space: nowrap;
  flex-shrink: 0;
}
.pokemon2048-game .restart-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(220, 38, 38, .4);
  color: #fff;
}
.pokemon2048-game .restart-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(220, 38, 38, .25);
}

/* ── Game container ───────────────────────────────────────────── */
@keyframes pokemon-fade-in {
  0%   { opacity: 0; }
  100% { opacity: 1; }
}

.pokemon2048-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, #3b82f6, #1d4ed8);
  border-radius: 14px;
  width: 472px;
  height: 472px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,.1), 0 4px 16px rgba(29, 78, 216, .25);
}

/* ── Game message overlay ─────────────────────────────────────── */
.pokemon2048-game .game-container .game-message {
  display: none;
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  background: rgba(232, 244, 255, .85);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  text-align: center;
  border-radius: 14px;
  animation: pokemon-fade-in 600ms ease 800ms both;
}
.pokemon2048-game .game-container .game-message p {
  font-size: 48px;
  font-weight: 700;
  height: 48px;
  line-height: 48px;
  margin-top: 180px;
  color: #dc2626;
}
.pokemon2048-game .game-container .game-message .lower {
  display: block;
  margin-top: 40px;
}
.pokemon2048-game .game-container .game-message a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 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(220, 38, 38, .3);
}
.pokemon2048-game .game-container .game-message a:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(220, 38, 38, .4);
  color: #fff;
}
.pokemon2048-game .game-container .game-message a.keep-playing-button {
  display: none;
  background: transparent;
  border: 2px solid #dc2626;
  color: #dc2626;
  box-shadow: none;
}
.pokemon2048-game .game-container .game-message a.keep-playing-button:hover {
  background: rgba(220, 38, 38, .08);
  box-shadow: none;
}
.pokemon2048-game .game-container .game-message .score-sharing {
  display: inline-block;
  vertical-align: middle;
  margin-left: 10px;
}
.pokemon2048-game .game-container .game-message.game-won {
  background: rgba(29, 78, 216, .65);
  backdrop-filter: blur(6px);
}
.pokemon2048-game .game-container .game-message.game-won p {
  color: #fbbf24;
}
.pokemon2048-game .game-container .game-message.game-won a.keep-playing-button {
  display: inline-flex;
  border-color: rgba(255,255,255,.5);
  color: #fff;
}
.pokemon2048-game .game-container .game-message.game-won a.keep-playing-button:hover {
  background: rgba(255,255,255,.15);
}
.pokemon2048-game .game-container .game-message.game-won,
.pokemon2048-game .game-container .game-message.game-over {
  display: block;
}

/* ── Grid ─────────────────────────────────────────────────────── */
.pokemon2048-game .grid-container {
  position: absolute;
  z-index: 1;
}
.pokemon2048-game .grid-row {
  margin-bottom: 8px;
}
.pokemon2048-game .grid-row:last-child {
  margin-bottom: 0;
}
.pokemon2048-game .grid-row::after {
  content: "";
  display: block;
  clear: both;
}
.pokemon2048-game .grid-cell {
  width: 106px;
  height: 106px;
  margin-right: 8px;
  float: left;
  border-radius: 10px;
  background: rgba(255, 255, 255, .18);
}
.pokemon2048-game .grid-cell:last-child {
  margin-right: 0;
}

/* ── Tile base ────────────────────────────────────────────────── */
.pokemon2048-game .tile-container {
  position: absolute;
  z-index: 2;
}
.pokemon2048-game .tile,
.pokemon2048-game .tile .tile-inner {
  width: 106px;
  height: 106px;
  line-height: 106px;
}
.pokemon2048-game .tile {
  position: absolute;
  transition: transform 100ms ease-in-out;
}
.pokemon2048-game .tile .tile-inner {
  border-radius: 10px;
  background: #fff;
  text-align: center;
  font-weight: 700;
  z-index: 10;
  font-size: 0;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* ── Tile positions (desktop 472px board, 12px padding, 106px tiles, 8px gap) ── */
.pokemon2048-game .tile.tile-position-1-1 { transform: translate(0px, 0px); }
.pokemon2048-game .tile.tile-position-1-2 { transform: translate(0px, 114px); }
.pokemon2048-game .tile.tile-position-1-3 { transform: translate(0px, 228px); }
.pokemon2048-game .tile.tile-position-1-4 { transform: translate(0px, 342px); }
.pokemon2048-game .tile.tile-position-2-1 { transform: translate(114px, 0px); }
.pokemon2048-game .tile.tile-position-2-2 { transform: translate(114px, 114px); }
.pokemon2048-game .tile.tile-position-2-3 { transform: translate(114px, 228px); }
.pokemon2048-game .tile.tile-position-2-4 { transform: translate(114px, 342px); }
.pokemon2048-game .tile.tile-position-3-1 { transform: translate(228px, 0px); }
.pokemon2048-game .tile.tile-position-3-2 { transform: translate(228px, 114px); }
.pokemon2048-game .tile.tile-position-3-3 { transform: translate(228px, 228px); }
.pokemon2048-game .tile.tile-position-3-4 { transform: translate(228px, 342px); }
.pokemon2048-game .tile.tile-position-4-1 { transform: translate(342px, 0px); }
.pokemon2048-game .tile.tile-position-4-2 { transform: translate(342px, 114px); }
.pokemon2048-game .tile.tile-position-4-3 { transform: translate(342px, 228px); }
.pokemon2048-game .tile.tile-position-4-4 { transform: translate(342px, 342px); }

/* ── Pokémon tile backgrounds ─────────────────────────────────── */
/* Tile value → Pokémon: 2=Bulbasaur(2), 4=Charmander(4), 8=Squirtle(8),
   16=Pikachu(16), 32=Jigglypuff(32), 64=Gengar(64), 128=Eevee(128),
   256=Snorlax(256), 512=Dragonite(512), 1024=Mew(151), 2048=Mewtwo(150),
   4096=Magikarp(129) */
.pokemon2048-game .tile-2 .tile-inner {
  background-image: url(../img/pokemon/2.png);
  background-color: #e8f5e9;
}
.pokemon2048-game .tile-4 .tile-inner {
  background-image: url(../img/pokemon/4.png);
  background-color: #fff3e0;
}
.pokemon2048-game .tile-8 .tile-inner {
  background-image: url(../img/pokemon/8.png);
  background-color: #e3f2fd;
}
.pokemon2048-game .tile-16 .tile-inner {
  background-image: url(../img/pokemon/16.png);
  background-color: #fffde7;
}
.pokemon2048-game .tile-32 .tile-inner {
  background-image: url(../img/pokemon/32.png);
  background-color: #fce4ec;
  box-shadow: 0 0 20px 6px rgba(233, 30, 99, .08);
}
.pokemon2048-game .tile-64 .tile-inner {
  background-image: url(../img/pokemon/64.png);
  background-color: #ede7f6;
  box-shadow: 0 0 20px 6px rgba(103, 58, 183, .12);
}
.pokemon2048-game .tile-128 .tile-inner {
  background-image: url(../img/pokemon/128.png);
  background-color: #f3e5f5;
  box-shadow: 0 0 24px 8px rgba(156, 39, 176, .16);
}
.pokemon2048-game .tile-256 .tile-inner {
  background-image: url(../img/pokemon/256.png);
  background-color: #e0f2f1;
  box-shadow: 0 0 24px 8px rgba(0, 150, 136, .18);
}
.pokemon2048-game .tile-512 .tile-inner {
  background-image: url(../img/pokemon/512.png);
  background-color: #e8eaf6;
  box-shadow: 0 0 28px 10px rgba(63, 81, 181, .22);
}
.pokemon2048-game .tile-1024 .tile-inner {
  background-image: url(../img/pokemon/151.png);
  background-color: #fce4ec;
  box-shadow: 0 0 28px 10px rgba(244, 67, 54, .25);
}
.pokemon2048-game .tile-2048 .tile-inner {
  background-image: url(../img/pokemon/150.png);
  background-color: #ede7f6;
  box-shadow: 0 0 32px 12px rgba(103, 58, 183, .3);
}
.pokemon2048-game .tile-4096 .tile-inner {
  background-image: url(../img/pokemon/129.png);
  background-color: #fff8e1;
  box-shadow: 0 0 32px 12px rgba(255, 152, 0, .3);
}
.pokemon2048-game .tile-super .tile-inner {
  background-color: #1a2744;
  color: white;
  font-size: 14px;
}

/* ── Tile animations ──────────────────────────────────────────── */
@keyframes pokemon-appear {
  0%   { opacity: 0; transform: scale(0); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes pokemon-pop {
  0%   { transform: scale(0); }
  50%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}
.pokemon2048-game .tile-new .tile-inner {
  animation: pokemon-appear 200ms ease 100ms backwards;
}
.pokemon2048-game .tile-merged .tile-inner {
  z-index: 20;
  animation: pokemon-pop 200ms ease 100ms backwards;
}

/* ── Game explanation ─────────────────────────────────────────── */
.pokemon2048-game .game-explanation {
  margin-top: 24px;
  font-size: 14px;
  color: #374a6d;
}

/* ── Legend ────────────────────────────────────────────────────── */
.pokemon2048-game .legend-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 0;
}
.pokemon2048-game .legend-row::after {
  display: none;
}
.pokemon2048-game .legend-row p {
  margin: 0;
  font-size: 14px;
  color: #374a6d;
}
.pokemon2048-game .legend-grid {
  position: relative;
  padding: 6px;
  cursor: default;
  background: linear-gradient(145deg, #3b82f6, #1d4ed8);
  border-radius: 10px;
  width: 64px;
  height: 64px;
  flex-shrink: 0;
}
.pokemon2048-game .legend-cell {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .18);
  overflow: hidden;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* Legend cell backgrounds */
.pokemon2048-game .cell-2    { background-image: url(../img/pokemon/2.png);   background-color: #e8f5e9; }
.pokemon2048-game .cell-4    { background-image: url(../img/pokemon/4.png);   background-color: #fff3e0; }
.pokemon2048-game .cell-8    { background-image: url(../img/pokemon/8.png);   background-color: #e3f2fd; }
.pokemon2048-game .cell-16   { background-image: url(../img/pokemon/16.png);  background-color: #fffde7; }
.pokemon2048-game .cell-32   { background-image: url(../img/pokemon/32.png);  background-color: #fce4ec; }
.pokemon2048-game .cell-64   { background-image: url(../img/pokemon/64.png);  background-color: #ede7f6; }
.pokemon2048-game .cell-128  { background-image: url(../img/pokemon/128.png); background-color: #f3e5f5; }
.pokemon2048-game .cell-256  { background-image: url(../img/pokemon/256.png); background-color: #e0f2f1; }
.pokemon2048-game .cell-512  { background-image: url(../img/pokemon/512.png); background-color: #e8eaf6; }
.pokemon2048-game .cell-1024 { background-image: url(../img/pokemon/151.png); background-color: #fce4ec; }
.pokemon2048-game .cell-2048 { background-image: url(../img/pokemon/150.png); background-color: #ede7f6; }
.pokemon2048-game .cell-4096 { background-image: url(../img/pokemon/129.png); background-color: #fff8e1; }

/* ================================================================
   MOBILE — max-width: 520px
   ================================================================ */
@media screen and (max-width: 520px) {
  .pokemon2048-game {
    font-size: 14px;
    width: 100%;
    max-width: 320px;
    padding: 16px;
    border-radius: 16px;
  }

  .pokemon2048-game .scores-container {
    gap: 8px;
    margin-bottom: 12px;
  }

  .pokemon2048-game .score-card {
    padding: 8px 6px 6px;
    border-radius: 10px;
  }

  .pokemon2048-game .score-label {
    font-size: 9px;
  }

  .pokemon2048-game .score-container,
  .pokemon2048-game .best-container {
    font-size: 14px;
    min-height: 18px;
  }

  .pokemon2048-game .game-intro {
    font-size: 13px;
  }

  .pokemon2048-game .restart-button {
    padding: 8px 16px;
    font-size: 13px;
    border-radius: 8px;
  }

  .pokemon2048-game .game-container {
    margin-top: 12px;
    padding: 8px;
    border-radius: 12px;
    width: 288px;
    height: 288px;
  }

  .pokemon2048-game .game-container .game-message p {
    font-size: 28px;
    height: 28px;
    line-height: 28px;
    margin-top: 100px;
  }
  .pokemon2048-game .game-container .game-message .lower {
    margin-top: 24px;
  }
  .pokemon2048-game .game-container .game-message a {
    padding: 8px 16px;
    font-size: 12px;
    border-radius: 8px;
  }

  .pokemon2048-game .grid-row {
    margin-bottom: 8px;
  }
  .pokemon2048-game .grid-cell {
    width: 62px;
    height: 62px;
    margin-right: 8px;
    border-radius: 8px;
  }

  .pokemon2048-game .tile,
  .pokemon2048-game .tile .tile-inner {
    width: 62px;
    height: 62px;
    line-height: 62px;
  }
  .pokemon2048-game .tile .tile-inner {
    border-radius: 8px;
  }

  /* Mobile tile positions (288px board, 8px pad, 62px tiles, 8px gap) */
  .pokemon2048-game .tile.tile-position-1-1 { transform: translate(0px, 0px); }
  .pokemon2048-game .tile.tile-position-1-2 { transform: translate(0px, 70px); }
  .pokemon2048-game .tile.tile-position-1-3 { transform: translate(0px, 140px); }
  .pokemon2048-game .tile.tile-position-1-4 { transform: translate(0px, 210px); }
  .pokemon2048-game .tile.tile-position-2-1 { transform: translate(70px, 0px); }
  .pokemon2048-game .tile.tile-position-2-2 { transform: translate(70px, 70px); }
  .pokemon2048-game .tile.tile-position-2-3 { transform: translate(70px, 140px); }
  .pokemon2048-game .tile.tile-position-2-4 { transform: translate(70px, 210px); }
  .pokemon2048-game .tile.tile-position-3-1 { transform: translate(140px, 0px); }
  .pokemon2048-game .tile.tile-position-3-2 { transform: translate(140px, 70px); }
  .pokemon2048-game .tile.tile-position-3-3 { transform: translate(140px, 140px); }
  .pokemon2048-game .tile.tile-position-3-4 { transform: translate(140px, 210px); }
  .pokemon2048-game .tile.tile-position-4-1 { transform: translate(210px, 0px); }
  .pokemon2048-game .tile.tile-position-4-2 { transform: translate(210px, 70px); }
  .pokemon2048-game .tile.tile-position-4-3 { transform: translate(210px, 140px); }
  .pokemon2048-game .tile.tile-position-4-4 { transform: translate(210px, 210px); }

  .pokemon2048-game .legend-grid {
    width: 52px;
    height: 52px;
    padding: 5px;
    border-radius: 8px;
  }
  .pokemon2048-game .legend-cell {
    width: 42px;
    height: 42px;
    border-radius: 6px;
  }
  .pokemon2048-game .legend-row p {
    font-size: 13px;
  }
}
