:root{
  --bg-1:#fff8fc;
  --bg-2:#f6f4ff;
  --card:rgba(255,255,255,.9);
  --text:#2f2440;
  --muted:#786d8a;
  --pink:#ff78b2;
  --pink-dark:#e05597;
  --purple:#9f7dff;
  --gold:#ffc85f;
  --board:#bbada0;
  --tile-empty:#cdc1b4;
  --shadow:0 18px 46px rgba(86,53,116,.14);
  --shadow-soft:0 10px 24px rgba(86,53,116,.10);
}

*{box-sizing:border-box}

html{direction:rtl}

body{
  margin:0;
  min-height:100vh;
  font-family:Tahoma, Arial, sans-serif;
  color:var(--text);
  background:
    radial-gradient(circle at top right, rgba(255,203,227,.55), transparent 28%),
    radial-gradient(circle at bottom left, rgba(215,223,255,.72), transparent 34%),
    linear-gradient(135deg, var(--bg-1), var(--bg-2));
}

a{
  color:inherit;
  text-decoration:none;
}

.game-page{
  min-height:100vh;
  padding:20px 14px;
  display:flex;
  align-items:center;
  justify-content:center;
}

.game-shell{
  width:min(100%, 680px);
}

.game-topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:14px;
}

.back-link,
.brand-badge{
  min-height:44px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:0 16px;
  border-radius:999px;
  background:rgba(255,255,255,.85);
  box-shadow:var(--shadow-soft);
  font-weight:700;
}

.back-link{color:var(--muted)}
.brand-badge{
  background:linear-gradient(135deg,var(--pink),var(--purple));
  color:#fff;
}

.game-card{
  background:var(--card);
  box-shadow:var(--shadow);
  border-radius:32px;
  padding:22px;
}

.game-header{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
  margin-bottom:14px;
}

.game-kicker{
  margin:0 0 8px;
  color:var(--pink-dark);
  font-size:14px;
  font-weight:800;
}

h1{
  margin:0;
  font-size:clamp(34px, 7vw, 64px);
  line-height:1.05;
}

.score-container{
  min-width:104px;
  padding:10px 12px;
  text-align:center;
  border-radius:20px;
  background:linear-gradient(135deg,#8f7a66,#6f5e4f);
  color:#fff;
  box-shadow:0 12px 24px rgba(111,94,79,.28);
}

.score-title{
  font-size:14px;
  font-weight:700;
  margin-bottom:4px;
}

#score{
  display:block;
  font-size:30px;
  font-weight:800;
}

.game-instructions{
  margin:0 0 18px;
  color:var(--muted);
  line-height:1.9;
  font-size:15px;
}

.game-instructions strong{
  color:var(--pink-dark);
}

.game-grid-wrap{
  background:rgba(255,255,255,.46);
  border-radius:26px;
  padding:14px;
  overflow:hidden;
}

.grid{
  width:min(100%, 456px);
  margin-inline:auto;
  background:var(--board);
  border:7px solid var(--board);
  border-radius:22px;
  display:grid;
  grid-template-columns:repeat(4, 1fr);
  gap:7px;
  padding:7px;
  aspect-ratio:1 / 1;
}

.grid div{
  width:100%;
  aspect-ratio:1 / 1;
  margin:0;
  border-radius:16px;
  background:var(--tile-empty);
  color:#8a7d70;
  font-weight:800;
  display:flex;
  align-items:center;
  justify-content:center;
  text-align:center;
  font-size:clamp(26px, 4vw, 44px);
  line-height:1;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.35);
}

.grid div[data-value="0"]{background:#cdc1b4;color:#9f9488}
.grid div[data-value="2"]{background:#eee4da;color:#776e65}
.grid div[data-value="4"]{background:#ede0c8;color:#776e65}
.grid div[data-value="8"]{background:#f2b179;color:#fff}
.grid div[data-value="16"]{background:#f59563;color:#fff}
.grid div[data-value="32"]{background:#f67c5f;color:#fff}
.grid div[data-value="64"]{background:#f65e3b;color:#fff}
.grid div[data-value="128"]{background:#edcf72;color:#fff;font-size:clamp(22px,3.4vw,36px)}
.grid div[data-value="256"]{background:#edcc61;color:#fff;font-size:clamp(22px,3.4vw,36px)}
.grid div[data-value="512"]{background:#edc850;color:#fff;font-size:clamp(22px,3.4vw,36px)}
.grid div[data-value="1024"]{background:#edc53f;color:#fff;font-size:clamp(16px,2.6vw,26px)}
.grid div[data-value="2048"]{background:linear-gradient(135deg,var(--gold),#ffae42);color:#fff;font-size:clamp(16px,2.6vw,26px)}

@media (max-width:560px){
  .game-page{
    padding:14px 10px;
    align-items:flex-start;
  }

  .game-card{
    padding:16px;
    border-radius:24px;
  }

  .game-header{
    flex-direction:column;
    align-items:stretch;
  }

  .score-container{
    min-width:100%;
  }

  .game-grid-wrap{
    padding:10px;
    border-radius:22px;
  }

  .grid{
    width:100%;
    border-width:6px;
    gap:6px;
    padding:6px;
    border-radius:18px;
  }

  .grid div{
    border-radius:14px;
    font-size:clamp(22px,7vw,34px);
  }
}